From 807c6931fe683fd844ceec1b023232181e6aae03 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 28 Dec 2010 16:10:20 +0000 Subject: xserver and mesa git update 28-12-2010 --- mesalib/src/mesa/main/APIspec.xml | 8673 ++++++------ mesalib/src/mesa/main/accum.c | 244 +- mesalib/src/mesa/main/accum.h | 147 +- mesalib/src/mesa/main/api_arrayelt.c | 3040 +++-- mesalib/src/mesa/main/api_arrayelt.h | 166 +- mesalib/src/mesa/main/api_exec.c | 1449 +- mesalib/src/mesa/main/api_loopback.c | 3563 +++-- mesalib/src/mesa/main/api_loopback.h | 93 +- mesalib/src/mesa/main/api_noop.c | 2156 +-- mesalib/src/mesa/main/api_validate.c | 863 +- mesalib/src/mesa/main/api_validate.h | 133 +- mesalib/src/mesa/main/arrayobj.c | 1152 +- mesalib/src/mesa/main/arrayobj.h | 168 +- mesalib/src/mesa/main/atifragshader.c | 1589 +-- mesalib/src/mesa/main/atifragshader.h | 303 +- mesalib/src/mesa/main/attrib.c | 3121 +++-- mesalib/src/mesa/main/attrib.h | 158 +- mesalib/src/mesa/main/blend.c | 1260 +- mesalib/src/mesa/main/blend.h | 176 +- mesalib/src/mesa/main/bufferobj.c | 4285 +++--- mesalib/src/mesa/main/bufferobj.h | 378 +- mesalib/src/mesa/main/buffers.c | 1050 +- mesalib/src/mesa/main/buffers.h | 113 +- mesalib/src/mesa/main/clear.c | 1070 +- mesalib/src/mesa/main/clear.h | 121 +- mesalib/src/mesa/main/clip.c | 275 +- mesalib/src/mesa/main/clip.h | 91 +- mesalib/src/mesa/main/colormac.h | 463 +- mesalib/src/mesa/main/colortab.c | 2065 ++- mesalib/src/mesa/main/colortab.h | 172 +- mesalib/src/mesa/main/compiler.h | 1028 +- mesalib/src/mesa/main/condrender.c | 294 +- mesalib/src/mesa/main/condrender.h | 90 +- mesalib/src/mesa/main/config.h | 696 +- mesalib/src/mesa/main/context.c | 3667 ++--- mesalib/src/mesa/main/context.h | 652 +- mesalib/src/mesa/main/convolve.c | 1642 +-- mesalib/src/mesa/main/convolve.h | 171 +- mesalib/src/mesa/main/core.h | 130 +- mesalib/src/mesa/main/dd.h | 2370 ++-- mesalib/src/mesa/main/debug.c | 1269 +- mesalib/src/mesa/main/debug.h | 171 +- mesalib/src/mesa/main/depth.c | 324 +- mesalib/src/mesa/main/depth.h | 127 +- mesalib/src/mesa/main/depthstencil.c | 1664 +-- mesalib/src/mesa/main/depthstencil.h | 114 +- mesalib/src/mesa/main/dispatch.h | 74 +- mesalib/src/mesa/main/dlist.c | 20204 ++++++++++++++-------------- mesalib/src/mesa/main/dlist.h | 206 +- mesalib/src/mesa/main/drawpix.c | 596 +- mesalib/src/mesa/main/drawpix.h | 97 +- mesalib/src/mesa/main/drawtex.c | 262 +- mesalib/src/mesa/main/drawtex.h | 121 +- mesalib/src/mesa/main/enable.c | 3058 ++--- mesalib/src/mesa/main/enable.h | 140 +- mesalib/src/mesa/main/enums.c | 11974 +++++++++-------- mesalib/src/mesa/main/enums.h | 123 +- mesalib/src/mesa/main/es_generator.py | 1503 ++- mesalib/src/mesa/main/eval.c | 2002 +-- mesalib/src/mesa/main/eval.h | 220 +- mesalib/src/mesa/main/extensions.c | 1976 ++- mesalib/src/mesa/main/extensions.h | 189 +- mesalib/src/mesa/main/fbobject.c | 4735 +++---- mesalib/src/mesa/main/fbobject.h | 333 +- mesalib/src/mesa/main/feedback.c | 1082 +- mesalib/src/mesa/main/feedback.h | 196 +- mesalib/src/mesa/main/ffvertex_prog.c | 3358 ++--- mesalib/src/mesa/main/ffvertex_prog.h | 80 +- mesalib/src/mesa/main/fog.c | 388 +- mesalib/src/mesa/main/fog.h | 135 +- mesalib/src/mesa/main/formats.c | 2888 ++-- mesalib/src/mesa/main/formats.h | 444 +- mesalib/src/mesa/main/framebuffer.c | 2147 +-- mesalib/src/mesa/main/framebuffer.h | 199 +- mesalib/src/mesa/main/get.c | 4936 ++++--- mesalib/src/mesa/main/getstring.c | 502 +- mesalib/src/mesa/main/glapidispatch.h | 4548 +++++++ mesalib/src/mesa/main/glheader.h | 308 +- mesalib/src/mesa/main/hash.c | 1094 +- mesalib/src/mesa/main/hint.c | 294 +- mesalib/src/mesa/main/hint.h | 116 +- mesalib/src/mesa/main/histogram.c | 1255 +- mesalib/src/mesa/main/histogram.h | 115 +- mesalib/src/mesa/main/image.c | 7947 +++-------- mesalib/src/mesa/main/image.h | 512 +- mesalib/src/mesa/main/imports.c | 2063 +-- mesalib/src/mesa/main/imports.h | 1196 +- mesalib/src/mesa/main/light.c | 2860 ++-- mesalib/src/mesa/main/light.h | 297 +- mesalib/src/mesa/main/lines.c | 227 +- mesalib/src/mesa/main/lines.h | 97 +- mesalib/src/mesa/main/matrix.c | 1580 ++- mesalib/src/mesa/main/matrix.h | 225 +- mesalib/src/mesa/main/mfeatures.h | 294 +- mesalib/src/mesa/main/mipmap.c | 3766 +++--- mesalib/src/mesa/main/mipmap.h | 128 +- mesalib/src/mesa/main/mtypes.h | 6673 +++++---- mesalib/src/mesa/main/multisample.c | 122 +- mesalib/src/mesa/main/multisample.h | 80 +- mesalib/src/mesa/main/nvprogram.c | 1838 +-- mesalib/src/mesa/main/nvprogram.h | 234 +- mesalib/src/mesa/main/pack.c | 5063 +++++++ mesalib/src/mesa/main/pack.h | 147 + mesalib/src/mesa/main/pixel.c | 1570 +-- mesalib/src/mesa/main/pixel.h | 139 +- mesalib/src/mesa/main/pixelstore.c | 566 +- mesalib/src/mesa/main/pixelstore.h | 103 +- mesalib/src/mesa/main/pixeltransfer.c | 566 + mesalib/src/mesa/main/pixeltransfer.h | 90 + mesalib/src/mesa/main/points.c | 544 +- mesalib/src/mesa/main/points.h | 116 +- mesalib/src/mesa/main/polygon.c | 643 +- mesalib/src/mesa/main/polygon.h | 133 +- mesalib/src/mesa/main/querymatrix.c | 428 +- mesalib/src/mesa/main/queryobj.c | 1149 +- mesalib/src/mesa/main/queryobj.h | 190 +- mesalib/src/mesa/main/rastpos.c | 1128 +- mesalib/src/mesa/main/rastpos.h | 117 +- mesalib/src/mesa/main/readpix.c | 442 +- mesalib/src/mesa/main/readpix.h | 85 +- mesalib/src/mesa/main/remap.c | 416 +- mesalib/src/mesa/main/remap.h | 240 +- mesalib/src/mesa/main/remap_helper.h | 12640 ++++++++--------- mesalib/src/mesa/main/renderbuffer.c | 4015 +++--- mesalib/src/mesa/main/renderbuffer.h | 222 +- mesalib/src/mesa/main/scissor.c | 198 +- mesalib/src/mesa/main/scissor.h | 93 +- mesalib/src/mesa/main/shaderapi.c | 3528 ++--- mesalib/src/mesa/main/shaderapi.h | 362 +- mesalib/src/mesa/main/shaderobj.c | 819 +- mesalib/src/mesa/main/shaderobj.h | 271 +- mesalib/src/mesa/main/shared.c | 780 +- mesalib/src/mesa/main/shared.h | 76 +- mesalib/src/mesa/main/state.c | 1466 +- mesalib/src/mesa/main/state.h | 98 +- mesalib/src/mesa/main/stencil.c | 1180 +- mesalib/src/mesa/main/stencil.h | 161 +- mesalib/src/mesa/main/syncobj.c | 848 +- mesalib/src/mesa/main/syncobj.h | 234 +- mesalib/src/mesa/main/texcompress.c | 494 +- mesalib/src/mesa/main/texcompress.h | 115 +- mesalib/src/mesa/main/texcompress_fxt1.c | 3303 +++-- mesalib/src/mesa/main/texcompress_s3tc.c | 1149 +- mesalib/src/mesa/main/texcompress_s3tc.h | 216 +- mesalib/src/mesa/main/texenv.c | 2072 +-- mesalib/src/mesa/main/texenvprogram.c | 3233 ++--- mesalib/src/mesa/main/texenvprogram.h | 70 +- mesalib/src/mesa/main/texfetch.c | 1667 +-- mesalib/src/mesa/main/texfetch_tmp.h | 3808 +++--- mesalib/src/mesa/main/texformat.c | 903 +- mesalib/src/mesa/main/texformat.h | 78 +- mesalib/src/mesa/main/texgetimage.c | 1798 +-- mesalib/src/mesa/main/texgetimage.h | 116 +- mesalib/src/mesa/main/teximage.c | 7369 +++++----- mesalib/src/mesa/main/teximage.h | 547 +- mesalib/src/mesa/main/texobj.c | 2494 ++-- mesalib/src/mesa/main/texobj.h | 240 +- mesalib/src/mesa/main/texparam.c | 2839 ++-- mesalib/src/mesa/main/texrender.c | 1270 +- mesalib/src/mesa/main/texrender.h | 34 +- mesalib/src/mesa/main/texstate.c | 1677 +-- mesalib/src/mesa/main/texstate.h | 184 +- mesalib/src/mesa/main/texstore.c | 9311 ++++++------- mesalib/src/mesa/main/texstore.h | 436 +- mesalib/src/mesa/main/transformfeedback.c | 1888 +-- mesalib/src/mesa/main/transformfeedback.h | 269 +- mesalib/src/mesa/main/uniforms.c | 3044 +++-- mesalib/src/mesa/main/uniforms.h | 368 +- mesalib/src/mesa/main/varray.c | 2614 ++-- mesalib/src/mesa/main/varray.h | 485 +- mesalib/src/mesa/main/version.c | 568 +- mesalib/src/mesa/main/version.h | 120 +- mesalib/src/mesa/main/viewport.c | 360 +- mesalib/src/mesa/main/viewport.h | 109 +- mesalib/src/mesa/main/vtxfmt.c | 374 +- mesalib/src/mesa/main/vtxfmt.h | 130 +- mesalib/src/mesa/main/vtxfmt_tmp.h | 603 - 177 files changed, 128750 insertions(+), 123454 deletions(-) create mode 100644 mesalib/src/mesa/main/glapidispatch.h create mode 100644 mesalib/src/mesa/main/pack.c create mode 100644 mesalib/src/mesa/main/pack.h create mode 100644 mesalib/src/mesa/main/pixeltransfer.c create mode 100644 mesalib/src/mesa/main/pixeltransfer.h delete mode 100644 mesalib/src/mesa/main/vtxfmt_tmp.h (limited to 'mesalib/src/mesa/main') diff --git a/mesalib/src/mesa/main/APIspec.xml b/mesalib/src/mesa/main/APIspec.xml index 4c5fd59d4..280e93a90 100644 --- a/mesalib/src/mesa/main/APIspec.xml +++ b/mesalib/src/mesa/main/APIspec.xml @@ -1,4332 +1,4341 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mesalib/src/mesa/main/accum.c b/mesalib/src/mesa/main/accum.c index 2012d00fd..1e001ab42 100644 --- a/mesalib/src/mesa/main/accum.c +++ b/mesalib/src/mesa/main/accum.c @@ -1,122 +1,122 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "accum.h" -#include "context.h" -#include "imports.h" -#include "macros.h" -#include "state.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_accum - - -void GLAPIENTRY -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = CLAMP( red, -1.0F, 1.0F ); - tmp[1] = CLAMP( green, -1.0F, 1.0F ); - tmp[2] = CLAMP( blue, -1.0F, 1.0F ); - tmp[3] = CLAMP( alpha, -1.0F, 1.0F ); - - if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor)) - return; - - FLUSH_VERTICES(ctx, _NEW_ACCUM); - COPY_4FV( ctx->Accum.ClearColor, tmp ); -} - - -static void GLAPIENTRY -_mesa_Accum( GLenum op, GLfloat value ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (op) { - case GL_ADD: - case GL_MULT: - case GL_ACCUM: - case GL_LOAD: - case GL_RETURN: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)"); - return; - } - - if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)"); - return; - } - - if (ctx->DrawBuffer != ctx->ReadBuffer) { - /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read, - * or GL_EXT_framebuffer_blit. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glAccum(different read/draw buffers)"); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glAccum(incomplete framebuffer)"); - return; - } - - if (ctx->RenderMode == GL_RENDER) { - ctx->Driver.Accum(ctx, op, value); - } -} - - -void -_mesa_init_accum_dispatch(struct _glapi_table *disp) -{ - SET_Accum(disp, _mesa_Accum); - SET_ClearAccum(disp, _mesa_ClearAccum); -} - - -#endif /* FEATURE_accum */ - - -void -_mesa_init_accum( GLcontext *ctx ) -{ - /* Accumulate buffer group */ - ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "accum.h" +#include "context.h" +#include "imports.h" +#include "macros.h" +#include "state.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_accum + + +void GLAPIENTRY +_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = CLAMP( red, -1.0F, 1.0F ); + tmp[1] = CLAMP( green, -1.0F, 1.0F ); + tmp[2] = CLAMP( blue, -1.0F, 1.0F ); + tmp[3] = CLAMP( alpha, -1.0F, 1.0F ); + + if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor)) + return; + + FLUSH_VERTICES(ctx, _NEW_ACCUM); + COPY_4FV( ctx->Accum.ClearColor, tmp ); +} + + +static void GLAPIENTRY +_mesa_Accum( GLenum op, GLfloat value ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + switch (op) { + case GL_ADD: + case GL_MULT: + case GL_ACCUM: + case GL_LOAD: + case GL_RETURN: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)"); + return; + } + + if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)"); + return; + } + + if (ctx->DrawBuffer != ctx->ReadBuffer) { + /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read, + * or GL_EXT_framebuffer_blit. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glAccum(different read/draw buffers)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glAccum(incomplete framebuffer)"); + return; + } + + if (ctx->RenderMode == GL_RENDER) { + ctx->Driver.Accum(ctx, op, value); + } +} + + +void +_mesa_init_accum_dispatch(struct _glapi_table *disp) +{ + SET_Accum(disp, _mesa_Accum); + SET_ClearAccum(disp, _mesa_ClearAccum); +} + + +#endif /* FEATURE_accum */ + + +void +_mesa_init_accum( struct gl_context *ctx ) +{ + /* Accumulate buffer group */ + ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); +} diff --git a/mesalib/src/mesa/main/accum.h b/mesalib/src/mesa/main/accum.h index 4b628bafa..bcd91bd53 100644 --- a/mesalib/src/mesa/main/accum.h +++ b/mesalib/src/mesa/main/accum.h @@ -1,72 +1,75 @@ -/** - * \file accum.h - * Accumulation buffer operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef ACCUM_H -#define ACCUM_H - - -#include "main/mtypes.h" - -#if FEATURE_accum - -extern void GLAPIENTRY -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); - -extern void -_mesa_init_accum_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_accum */ - -#include "main/compiler.h" - -static INLINE void -_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - /* this is used in _mesa_PopAttrib */ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_init_accum_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_accum */ - -extern void -_mesa_init_accum( GLcontext *ctx ); - -#endif /* ACCUM_H */ +/** + * \file accum.h + * Accumulation buffer operations. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef ACCUM_H +#define ACCUM_H + +#include "main/glheader.h" +#include "main/mfeatures.h" + +struct _glapi_table; +struct gl_context; + +#if FEATURE_accum + +extern void GLAPIENTRY +_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +extern void +_mesa_init_accum_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_accum */ + +#include "main/compiler.h" + +static INLINE void +_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + /* this is used in _mesa_PopAttrib */ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_init_accum_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_accum */ + +extern void +_mesa_init_accum( struct gl_context *ctx ); + +#endif /* ACCUM_H */ diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c index ffcd19424..98ae3cff7 100644 --- a/mesalib/src/mesa/main/api_arrayelt.c +++ b/mesalib/src/mesa/main/api_arrayelt.c @@ -1,1332 +1,1708 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Author: - * Keith Whitwell - */ - -#include "glheader.h" -#include "api_arrayelt.h" -#include "bufferobj.h" -#include "context.h" -#include "imports.h" -#include "macros.h" -#include "main/dispatch.h" - -typedef void (GLAPIENTRY *array_func)( const void * ); - -typedef struct { - const struct gl_client_array *array; - int offset; -} AEarray; - -typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); - -typedef struct { - const struct gl_client_array *array; - attrib_func func; - GLuint index; -} AEattrib; - -typedef struct { - AEarray arrays[32]; - AEattrib attribs[VERT_ATTRIB_MAX + 1]; - GLuint NewState; - - struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; - GLuint nr_vbos; - GLboolean mapped_vbos; - -} AEcontext; - -#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) - - -/* - * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer - * in the range [0, 7]. Luckily these type tokens are sequentially - * numbered in gl.h, except for GL_DOUBLE. - */ -#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) - - -#if FEATURE_arrayelt - - -static const int ColorFuncs[2][8] = { - { - _gloffset_Color3bv, - _gloffset_Color3ubv, - _gloffset_Color3sv, - _gloffset_Color3usv, - _gloffset_Color3iv, - _gloffset_Color3uiv, - _gloffset_Color3fv, - _gloffset_Color3dv, - }, - { - _gloffset_Color4bv, - _gloffset_Color4ubv, - _gloffset_Color4sv, - _gloffset_Color4usv, - _gloffset_Color4iv, - _gloffset_Color4uiv, - _gloffset_Color4fv, - _gloffset_Color4dv, - }, -}; - -static const int VertexFuncs[3][8] = { - { - -1, - -1, - _gloffset_Vertex2sv, - -1, - _gloffset_Vertex2iv, - -1, - _gloffset_Vertex2fv, - _gloffset_Vertex2dv, - }, - { - -1, - -1, - _gloffset_Vertex3sv, - -1, - _gloffset_Vertex3iv, - -1, - _gloffset_Vertex3fv, - _gloffset_Vertex3dv, - }, - { - -1, - -1, - _gloffset_Vertex4sv, - -1, - _gloffset_Vertex4iv, - -1, - _gloffset_Vertex4fv, - _gloffset_Vertex4dv, - }, -}; - -static const int IndexFuncs[8] = { - -1, - _gloffset_Indexubv, - _gloffset_Indexsv, - -1, - _gloffset_Indexiv, - -1, - _gloffset_Indexfv, - _gloffset_Indexdv, -}; - -static const int NormalFuncs[8] = { - _gloffset_Normal3bv, - -1, - _gloffset_Normal3sv, - -1, - _gloffset_Normal3iv, - -1, - _gloffset_Normal3fv, - _gloffset_Normal3dv, -}; - -/* Note: _gloffset_* for these may not be a compile-time constant. */ -static int SecondaryColorFuncs[8]; -static int FogCoordFuncs[8]; - - -/** - ** GL_NV_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); -} - - -/* - * Array [size][type] of VertexAttrib functions - */ -static attrib_func AttribFuncsNV[2][4][8] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvNV, - (attrib_func) VertexAttrib1ubvNV, - (attrib_func) VertexAttrib1svNV, - (attrib_func) VertexAttrib1usvNV, - (attrib_func) VertexAttrib1ivNV, - (attrib_func) VertexAttrib1uivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvNV, - (attrib_func) VertexAttrib2ubvNV, - (attrib_func) VertexAttrib2svNV, - (attrib_func) VertexAttrib2usvNV, - (attrib_func) VertexAttrib2ivNV, - (attrib_func) VertexAttrib2uivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvNV, - (attrib_func) VertexAttrib3ubvNV, - (attrib_func) VertexAttrib3svNV, - (attrib_func) VertexAttrib3usvNV, - (attrib_func) VertexAttrib3ivNV, - (attrib_func) VertexAttrib3uivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvNV, - (attrib_func) VertexAttrib4ubvNV, - (attrib_func) VertexAttrib4svNV, - (attrib_func) VertexAttrib4usvNV, - (attrib_func) VertexAttrib4ivNV, - (attrib_func) VertexAttrib4uivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvNV, - (attrib_func) VertexAttrib1NubvNV, - (attrib_func) VertexAttrib1NsvNV, - (attrib_func) VertexAttrib1NusvNV, - (attrib_func) VertexAttrib1NivNV, - (attrib_func) VertexAttrib1NuivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvNV, - (attrib_func) VertexAttrib2NubvNV, - (attrib_func) VertexAttrib2NsvNV, - (attrib_func) VertexAttrib2NusvNV, - (attrib_func) VertexAttrib2NivNV, - (attrib_func) VertexAttrib2NuivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvNV, - (attrib_func) VertexAttrib3NubvNV, - (attrib_func) VertexAttrib3NsvNV, - (attrib_func) VertexAttrib3NusvNV, - (attrib_func) VertexAttrib3NivNV, - (attrib_func) VertexAttrib3NuivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvNV, - (attrib_func) VertexAttrib4NubvNV, - (attrib_func) VertexAttrib4NsvNV, - (attrib_func) VertexAttrib4NusvNV, - (attrib_func) VertexAttrib4NivNV, - (attrib_func) VertexAttrib4NuivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - } -}; - - -/** - ** GL_ARB_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY VertexAttrib1NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY VertexAttrib1NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY VertexAttrib3ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY VertexAttrib1NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY VertexAttrib1NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY VertexAttrib1NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY VertexAttrib1NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY VertexAttrib1uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY VertexAttrib2uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY VertexAttrib3uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY VertexAttrib4uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY VertexAttrib1fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib2fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib3fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib4fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY VertexAttrib1dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib2dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib3dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY VertexAttrib4dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v)); -} - - -/* - * Array [size][type] of VertexAttrib functions - */ -static attrib_func AttribFuncsARB[2][4][8] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvARB, - (attrib_func) VertexAttrib1ubvARB, - (attrib_func) VertexAttrib1svARB, - (attrib_func) VertexAttrib1usvARB, - (attrib_func) VertexAttrib1ivARB, - (attrib_func) VertexAttrib1uivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvARB, - (attrib_func) VertexAttrib2ubvARB, - (attrib_func) VertexAttrib2svARB, - (attrib_func) VertexAttrib2usvARB, - (attrib_func) VertexAttrib2ivARB, - (attrib_func) VertexAttrib2uivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvARB, - (attrib_func) VertexAttrib3ubvARB, - (attrib_func) VertexAttrib3svARB, - (attrib_func) VertexAttrib3usvARB, - (attrib_func) VertexAttrib3ivARB, - (attrib_func) VertexAttrib3uivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvARB, - (attrib_func) VertexAttrib4ubvARB, - (attrib_func) VertexAttrib4svARB, - (attrib_func) VertexAttrib4usvARB, - (attrib_func) VertexAttrib4ivARB, - (attrib_func) VertexAttrib4uivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvARB, - (attrib_func) VertexAttrib1NubvARB, - (attrib_func) VertexAttrib1NsvARB, - (attrib_func) VertexAttrib1NusvARB, - (attrib_func) VertexAttrib1NivARB, - (attrib_func) VertexAttrib1NuivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvARB, - (attrib_func) VertexAttrib2NubvARB, - (attrib_func) VertexAttrib2NsvARB, - (attrib_func) VertexAttrib2NusvARB, - (attrib_func) VertexAttrib2NivARB, - (attrib_func) VertexAttrib2NuivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvARB, - (attrib_func) VertexAttrib3NubvARB, - (attrib_func) VertexAttrib3NsvARB, - (attrib_func) VertexAttrib3NusvARB, - (attrib_func) VertexAttrib3NivARB, - (attrib_func) VertexAttrib3NuivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvARB, - (attrib_func) VertexAttrib4NubvARB, - (attrib_func) VertexAttrib4NsvARB, - (attrib_func) VertexAttrib4NusvARB, - (attrib_func) VertexAttrib4NivARB, - (attrib_func) VertexAttrib4NuivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - } -}; - -/**********************************************************************/ - - -GLboolean _ae_create_context( GLcontext *ctx ) -{ - if (ctx->aelt_context) - return GL_TRUE; - - /* These _gloffset_* values may not be compile-time constants */ - SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT; - SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT; - SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT; - SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT; - SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT; - SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT; - SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT; - SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT; - - FogCoordFuncs[0] = -1; - FogCoordFuncs[1] = -1; - FogCoordFuncs[2] = -1; - FogCoordFuncs[3] = -1; - FogCoordFuncs[4] = -1; - FogCoordFuncs[5] = -1; - FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; - FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; - - ctx->aelt_context = CALLOC( sizeof(AEcontext) ); - if (!ctx->aelt_context) - return GL_FALSE; - - AE_CONTEXT(ctx)->NewState = ~0; - return GL_TRUE; -} - - -void _ae_destroy_context( GLcontext *ctx ) -{ - if ( AE_CONTEXT( ctx ) ) { - FREE( ctx->aelt_context ); - ctx->aelt_context = NULL; - } -} - -static void check_vbo( AEcontext *actx, - struct gl_buffer_object *vbo ) -{ - if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { - GLuint i; - for (i = 0; i < actx->nr_vbos; i++) - if (actx->vbo[i] == vbo) - return; - assert(actx->nr_vbos < VERT_ATTRIB_MAX); - actx->vbo[actx->nr_vbos++] = vbo; - } -} - - -/** - * Make a list of per-vertex functions to call for each glArrayElement call. - * These functions access the array data (i.e. glVertex, glColor, glNormal, - * etc). - * Note: this may be called during display list construction. - */ -static void _ae_update_state( GLcontext *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - AEarray *aa = actx->arrays; - AEattrib *at = actx->attribs; - GLuint i; - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - - actx->nr_vbos = 0; - - /* conventional vertex arrays */ - if (arrayObj->Index.Enabled) { - aa->array = &arrayObj->Index; - aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->EdgeFlag.Enabled) { - aa->array = &arrayObj->EdgeFlag; - aa->offset = _gloffset_EdgeFlagv; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->Normal.Enabled) { - aa->array = &arrayObj->Normal; - aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->Color.Enabled) { - aa->array = &arrayObj->Color; - aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->SecondaryColor.Enabled) { - aa->array = &arrayObj->SecondaryColor; - aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->FogCoord.Enabled) { - aa->array = &arrayObj->FogCoord; - aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - struct gl_client_array *attribArray = &arrayObj->TexCoord[i]; - if (attribArray->Enabled) { - /* NOTE: we use generic glVertexAttribNV functions here. - * If we ever remove GL_NV_vertex_program this will have to change. - */ - at->array = attribArray; - ASSERT(!at->array->Normalized); - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - at->index = VERT_ATTRIB_TEX0 + i; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* generic vertex attribute arrays */ - for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */ - struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i]; - if (attribArray->Enabled) { - at->array = attribArray; - /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV - * function pointer here (for float arrays) since the pointer may - * change from one execution of _ae_ArrayElement() to - * the next. Doing so caused UT to break. - */ - if (ctx->VertexProgram._Enabled - && ctx->VertexProgram.Current->IsNVProgram) { - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - else { - at->func = AttribFuncsARB[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - at->index = i; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* finally, vertex position */ - if (arrayObj->VertexAttrib[0].Enabled) { - /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's - * issued as the last (provoking) attribute). - */ - aa->array = &arrayObj->VertexAttrib[0]; - assert(aa->array->Size >= 2); /* XXX fix someday? */ - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - else if (arrayObj->Vertex.Enabled) { - aa->array = &arrayObj->Vertex; - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - - check_vbo(actx, ctx->Array.ElementArrayBufferObj); - - ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); - ASSERT(aa - actx->arrays < 32); - at->func = NULL; /* terminate the list */ - aa->offset = -1; /* terminate the list */ - - actx->NewState = 0; -} - -void _ae_map_vbos( GLcontext *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (actx->mapped_vbos) - return; - - if (actx->NewState) - _ae_update_state(ctx); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.MapBuffer(ctx, - GL_ARRAY_BUFFER_ARB, - GL_DYNAMIC_DRAW_ARB, - actx->vbo[i]); - - if (actx->nr_vbos) - actx->mapped_vbos = GL_TRUE; -} - -void _ae_unmap_vbos( GLcontext *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (!actx->mapped_vbos) - return; - - assert (!actx->NewState); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.UnmapBuffer(ctx, - GL_ARRAY_BUFFER_ARB, - actx->vbo[i]); - - actx->mapped_vbos = GL_FALSE; -} - - -/** - * Called via glArrayElement() and glDrawArrays(). - * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions - * for all enabled vertex arrays (for elt-th element). - * Note: this may be called during display list construction. - */ -void GLAPIENTRY _ae_ArrayElement( GLint elt ) -{ - GET_CURRENT_CONTEXT(ctx); - const AEcontext *actx = AE_CONTEXT(ctx); - const AEarray *aa; - const AEattrib *at; - const struct _glapi_table * const disp = GET_DISPATCH(); - GLboolean do_map; - - if (actx->NewState) { - assert(!actx->mapped_vbos); - _ae_update_state( ctx ); - } - - do_map = actx->nr_vbos && !actx->mapped_vbos; - - /* - */ - if (do_map) - _ae_map_vbos(ctx); - - /* generic attributes */ - for (at = actx->attribs; at->func; at++) { - const GLubyte *src - = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) - + elt * at->array->StrideB; - at->func( at->index, src ); - } - - /* conventional arrays */ - for (aa = actx->arrays; aa->offset != -1 ; aa++) { - const GLubyte *src - = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr) - + elt * aa->array->StrideB; - CALL_by_offset( disp, (array_func), aa->offset, - ((const void *) src) ); - } - - if (do_map) - _ae_unmap_vbos(ctx); -} - - -void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - - - /* Only interested in this subset of mesa state. Need to prune - * this down as both tnl/ and the drivers can raise statechanges - * for arcane reasons in the middle of seemingly atomic operations - * like DrawElements, over which we'd like to keep a known set of - * arrays and vbo's mapped. - * - * Luckily, neither the drivers nor tnl muck with the state that - * concerns us here: - */ - new_state &= _NEW_ARRAY | _NEW_PROGRAM; - if (new_state) { - assert(!actx->mapped_vbos); - actx->NewState |= new_state; - } -} - - -void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_ArrayElement(disp, vfmt->ArrayElement); -} - - -#endif /* FEATURE_arrayelt */ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * This file implements the glArrayElement() function. + * It involves looking at the format/type of all the enabled vertex arrays + * and emitting a list of pointers to functions which set the per-vertex + * state for the element/index. + */ + + +/* Author: + * Keith Whitwell + */ + +#include "glheader.h" +#include "api_arrayelt.h" +#include "bufferobj.h" +#include "context.h" +#include "imports.h" +#include "macros.h" +#include "main/dispatch.h" + +typedef void (GLAPIENTRY *array_func)( const void * ); + +typedef struct { + const struct gl_client_array *array; + int offset; +} AEarray; + +typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); + +typedef struct { + const struct gl_client_array *array; + attrib_func func; + GLuint index; +} AEattrib; + +typedef struct { + AEarray arrays[32]; + AEattrib attribs[VERT_ATTRIB_MAX + 1]; + GLuint NewState; + + struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; + GLuint nr_vbos; + GLboolean mapped_vbos; + +} AEcontext; + +#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) + + +/* + * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer + * in the range [0, 7]. Luckily these type tokens are sequentially + * numbered in gl.h, except for GL_DOUBLE. + */ +#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) + +#define NUM_TYPES 8 + + +#if FEATURE_arrayelt + + +static const int ColorFuncs[2][NUM_TYPES] = { + { + _gloffset_Color3bv, + _gloffset_Color3ubv, + _gloffset_Color3sv, + _gloffset_Color3usv, + _gloffset_Color3iv, + _gloffset_Color3uiv, + _gloffset_Color3fv, + _gloffset_Color3dv, + }, + { + _gloffset_Color4bv, + _gloffset_Color4ubv, + _gloffset_Color4sv, + _gloffset_Color4usv, + _gloffset_Color4iv, + _gloffset_Color4uiv, + _gloffset_Color4fv, + _gloffset_Color4dv, + }, +}; + +static const int VertexFuncs[3][NUM_TYPES] = { + { + -1, + -1, + _gloffset_Vertex2sv, + -1, + _gloffset_Vertex2iv, + -1, + _gloffset_Vertex2fv, + _gloffset_Vertex2dv, + }, + { + -1, + -1, + _gloffset_Vertex3sv, + -1, + _gloffset_Vertex3iv, + -1, + _gloffset_Vertex3fv, + _gloffset_Vertex3dv, + }, + { + -1, + -1, + _gloffset_Vertex4sv, + -1, + _gloffset_Vertex4iv, + -1, + _gloffset_Vertex4fv, + _gloffset_Vertex4dv, + }, +}; + +static const int IndexFuncs[NUM_TYPES] = { + -1, + _gloffset_Indexubv, + _gloffset_Indexsv, + -1, + _gloffset_Indexiv, + -1, + _gloffset_Indexfv, + _gloffset_Indexdv, +}; + +static const int NormalFuncs[NUM_TYPES] = { + _gloffset_Normal3bv, + -1, + _gloffset_Normal3sv, + -1, + _gloffset_Normal3iv, + -1, + _gloffset_Normal3fv, + _gloffset_Normal3dv, +}; + +/* Note: _gloffset_* for these may not be a compile-time constant. */ +static int SecondaryColorFuncs[NUM_TYPES]; +static int FogCoordFuncs[NUM_TYPES]; + + +/** + ** GL_NV_vertex_program + **/ + +/* GL_BYTE attributes */ + +static void +VertexAttrib1NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), + BYTE_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_BYTE attributes */ + +static void +VertexAttrib1NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]))); +} +static void +VertexAttrib3ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + UBYTE_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2], + (GLfloat)v[3])); +} + +/* GL_SHORT attributes */ + +static void +VertexAttrib1NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void +VertexAttrib4NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), + SHORT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_SHORT attributes */ + +static void +VertexAttrib1NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void +VertexAttrib3NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void +VertexAttrib4NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), + USHORT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_INT attributes */ + +static void +VertexAttrib1NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void +VertexAttrib4NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), + INT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_INT attributes */ + +static void +VertexAttrib1NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void +VertexAttrib3NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void +VertexAttrib4NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), + UINT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_FLOAT attributes */ + +static void +VertexAttrib1fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib2fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib3fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib4fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); +} + +/* GL_DOUBLE attributes */ + +static void +VertexAttrib1dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib2dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib3dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib4dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); +} + + +/* + * Array [size][type] of VertexAttrib functions + */ +static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = { + { + /* non-normalized */ + { + /* size 1 */ + (attrib_func) VertexAttrib1bvNV, + (attrib_func) VertexAttrib1ubvNV, + (attrib_func) VertexAttrib1svNV, + (attrib_func) VertexAttrib1usvNV, + (attrib_func) VertexAttrib1ivNV, + (attrib_func) VertexAttrib1uivNV, + (attrib_func) VertexAttrib1fvNV, + (attrib_func) VertexAttrib1dvNV + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2bvNV, + (attrib_func) VertexAttrib2ubvNV, + (attrib_func) VertexAttrib2svNV, + (attrib_func) VertexAttrib2usvNV, + (attrib_func) VertexAttrib2ivNV, + (attrib_func) VertexAttrib2uivNV, + (attrib_func) VertexAttrib2fvNV, + (attrib_func) VertexAttrib2dvNV + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3bvNV, + (attrib_func) VertexAttrib3ubvNV, + (attrib_func) VertexAttrib3svNV, + (attrib_func) VertexAttrib3usvNV, + (attrib_func) VertexAttrib3ivNV, + (attrib_func) VertexAttrib3uivNV, + (attrib_func) VertexAttrib3fvNV, + (attrib_func) VertexAttrib3dvNV + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4bvNV, + (attrib_func) VertexAttrib4ubvNV, + (attrib_func) VertexAttrib4svNV, + (attrib_func) VertexAttrib4usvNV, + (attrib_func) VertexAttrib4ivNV, + (attrib_func) VertexAttrib4uivNV, + (attrib_func) VertexAttrib4fvNV, + (attrib_func) VertexAttrib4dvNV + } + }, + { + /* normalized (except for float/double) */ + { + /* size 1 */ + (attrib_func) VertexAttrib1NbvNV, + (attrib_func) VertexAttrib1NubvNV, + (attrib_func) VertexAttrib1NsvNV, + (attrib_func) VertexAttrib1NusvNV, + (attrib_func) VertexAttrib1NivNV, + (attrib_func) VertexAttrib1NuivNV, + (attrib_func) VertexAttrib1fvNV, + (attrib_func) VertexAttrib1dvNV + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2NbvNV, + (attrib_func) VertexAttrib2NubvNV, + (attrib_func) VertexAttrib2NsvNV, + (attrib_func) VertexAttrib2NusvNV, + (attrib_func) VertexAttrib2NivNV, + (attrib_func) VertexAttrib2NuivNV, + (attrib_func) VertexAttrib2fvNV, + (attrib_func) VertexAttrib2dvNV + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3NbvNV, + (attrib_func) VertexAttrib3NubvNV, + (attrib_func) VertexAttrib3NsvNV, + (attrib_func) VertexAttrib3NusvNV, + (attrib_func) VertexAttrib3NivNV, + (attrib_func) VertexAttrib3NuivNV, + (attrib_func) VertexAttrib3fvNV, + (attrib_func) VertexAttrib3dvNV + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4NbvNV, + (attrib_func) VertexAttrib4NubvNV, + (attrib_func) VertexAttrib4NsvNV, + (attrib_func) VertexAttrib4NusvNV, + (attrib_func) VertexAttrib4NivNV, + (attrib_func) VertexAttrib4NuivNV, + (attrib_func) VertexAttrib4fvNV, + (attrib_func) VertexAttrib4dvNV + } + } +}; + + +/** + ** GL_ARB_vertex_program + **/ + +/* GL_BYTE attributes */ + +static void +VertexAttrib1NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), + BYTE_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_BYTE attributes */ + +static void +VertexAttrib1NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, + (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]))); +} +static void +VertexAttrib3ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, + (GLfloat)v[0], + (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void +VertexAttrib4NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + UBYTE_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_SHORT attributes */ + +static void +VertexAttrib1NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), + (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), + (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void +VertexAttrib3NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), + (index, + SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), + (index, + (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), + SHORT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_SHORT attributes */ + +static void +VertexAttrib1NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void +VertexAttrib3NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), + USHORT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_INT attributes */ + +static void +VertexAttrib1NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void +VertexAttrib3NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), + INT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_INT attributes */ + +static void +VertexAttrib1NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); +} + +static void +VertexAttrib1uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void +VertexAttrib2NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]))); +} + +static void +VertexAttrib2uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void +VertexAttrib3NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]))); +} + +static void +VertexAttrib3uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void +VertexAttrib4NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), + UINT_TO_FLOAT(v[3]))); +} + +static void +VertexAttrib4uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_FLOAT attributes */ + +static void +VertexAttrib1fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib2fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib3fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib4fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v)); +} + +/* GL_DOUBLE attributes */ + +static void +VertexAttrib1dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib2dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib3dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v)); +} + +static void +VertexAttrib4dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v)); +} + + +/** + * Integer-valued attributes + */ +static void +VertexAttribI1bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index, v)); +} + + +static void +VertexAttribI1ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index, v)); +} + + + +static void +VertexAttribI1sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index, v)); +} + + +static void +VertexAttribI1usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index, v)); +} + + + +static void +VertexAttribI1iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v)); +} + + +static void +VertexAttribI1uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void +VertexAttribI2uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void +VertexAttribI3uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void +VertexAttribI4uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v)); +} + + + + +/* + * Array [unnormalized/normalized/integer][size][type] of VertexAttrib + * functions + */ +static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = { + { + /* non-normalized */ + { + /* size 1 */ + (attrib_func) VertexAttrib1bvARB, + (attrib_func) VertexAttrib1ubvARB, + (attrib_func) VertexAttrib1svARB, + (attrib_func) VertexAttrib1usvARB, + (attrib_func) VertexAttrib1ivARB, + (attrib_func) VertexAttrib1uivARB, + (attrib_func) VertexAttrib1fvARB, + (attrib_func) VertexAttrib1dvARB + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2bvARB, + (attrib_func) VertexAttrib2ubvARB, + (attrib_func) VertexAttrib2svARB, + (attrib_func) VertexAttrib2usvARB, + (attrib_func) VertexAttrib2ivARB, + (attrib_func) VertexAttrib2uivARB, + (attrib_func) VertexAttrib2fvARB, + (attrib_func) VertexAttrib2dvARB + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3bvARB, + (attrib_func) VertexAttrib3ubvARB, + (attrib_func) VertexAttrib3svARB, + (attrib_func) VertexAttrib3usvARB, + (attrib_func) VertexAttrib3ivARB, + (attrib_func) VertexAttrib3uivARB, + (attrib_func) VertexAttrib3fvARB, + (attrib_func) VertexAttrib3dvARB + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4bvARB, + (attrib_func) VertexAttrib4ubvARB, + (attrib_func) VertexAttrib4svARB, + (attrib_func) VertexAttrib4usvARB, + (attrib_func) VertexAttrib4ivARB, + (attrib_func) VertexAttrib4uivARB, + (attrib_func) VertexAttrib4fvARB, + (attrib_func) VertexAttrib4dvARB + } + }, + { + /* normalized (except for float/double) */ + { + /* size 1 */ + (attrib_func) VertexAttrib1NbvARB, + (attrib_func) VertexAttrib1NubvARB, + (attrib_func) VertexAttrib1NsvARB, + (attrib_func) VertexAttrib1NusvARB, + (attrib_func) VertexAttrib1NivARB, + (attrib_func) VertexAttrib1NuivARB, + (attrib_func) VertexAttrib1fvARB, + (attrib_func) VertexAttrib1dvARB + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2NbvARB, + (attrib_func) VertexAttrib2NubvARB, + (attrib_func) VertexAttrib2NsvARB, + (attrib_func) VertexAttrib2NusvARB, + (attrib_func) VertexAttrib2NivARB, + (attrib_func) VertexAttrib2NuivARB, + (attrib_func) VertexAttrib2fvARB, + (attrib_func) VertexAttrib2dvARB + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3NbvARB, + (attrib_func) VertexAttrib3NubvARB, + (attrib_func) VertexAttrib3NsvARB, + (attrib_func) VertexAttrib3NusvARB, + (attrib_func) VertexAttrib3NivARB, + (attrib_func) VertexAttrib3NuivARB, + (attrib_func) VertexAttrib3fvARB, + (attrib_func) VertexAttrib3dvARB + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4NbvARB, + (attrib_func) VertexAttrib4NubvARB, + (attrib_func) VertexAttrib4NsvARB, + (attrib_func) VertexAttrib4NusvARB, + (attrib_func) VertexAttrib4NivARB, + (attrib_func) VertexAttrib4NuivARB, + (attrib_func) VertexAttrib4fvARB, + (attrib_func) VertexAttrib4dvARB + } + }, + + { + /* integer-valued */ + { + /* size 1 */ + (attrib_func) VertexAttribI1bv, + (attrib_func) VertexAttribI1ubv, + (attrib_func) VertexAttribI1sv, + (attrib_func) VertexAttribI1usv, + (attrib_func) VertexAttribI1iv, + (attrib_func) VertexAttribI1uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 2 */ + (attrib_func) VertexAttribI2bv, + (attrib_func) VertexAttribI2ubv, + (attrib_func) VertexAttribI2sv, + (attrib_func) VertexAttribI2usv, + (attrib_func) VertexAttribI2iv, + (attrib_func) VertexAttribI2uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 3 */ + (attrib_func) VertexAttribI3bv, + (attrib_func) VertexAttribI3ubv, + (attrib_func) VertexAttribI3sv, + (attrib_func) VertexAttribI3usv, + (attrib_func) VertexAttribI3iv, + (attrib_func) VertexAttribI3uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 4 */ + (attrib_func) VertexAttribI4bv, + (attrib_func) VertexAttribI4ubv, + (attrib_func) VertexAttribI4sv, + (attrib_func) VertexAttribI4usv, + (attrib_func) VertexAttribI4iv, + (attrib_func) VertexAttribI4uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + } + } +}; + +/**********************************************************************/ + + +GLboolean _ae_create_context( struct gl_context *ctx ) +{ + if (ctx->aelt_context) + return GL_TRUE; + + /* These _gloffset_* values may not be compile-time constants */ + SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT; + SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT; + SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT; + SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT; + SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT; + SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT; + SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT; + SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT; + + FogCoordFuncs[0] = -1; + FogCoordFuncs[1] = -1; + FogCoordFuncs[2] = -1; + FogCoordFuncs[3] = -1; + FogCoordFuncs[4] = -1; + FogCoordFuncs[5] = -1; + FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; + FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; + + ctx->aelt_context = CALLOC( sizeof(AEcontext) ); + if (!ctx->aelt_context) + return GL_FALSE; + + AE_CONTEXT(ctx)->NewState = ~0; + return GL_TRUE; +} + + +void _ae_destroy_context( struct gl_context *ctx ) +{ + if ( AE_CONTEXT( ctx ) ) { + FREE( ctx->aelt_context ); + ctx->aelt_context = NULL; + } +} + +static void check_vbo( AEcontext *actx, + struct gl_buffer_object *vbo ) +{ + if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { + GLuint i; + for (i = 0; i < actx->nr_vbos; i++) + if (actx->vbo[i] == vbo) + return; + assert(actx->nr_vbos < VERT_ATTRIB_MAX); + actx->vbo[actx->nr_vbos++] = vbo; + } +} + + +/** + * Make a list of per-vertex functions to call for each glArrayElement call. + * These functions access the array data (i.e. glVertex, glColor, glNormal, + * etc). + * Note: this may be called during display list construction. + */ +static void _ae_update_state( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + AEarray *aa = actx->arrays; + AEattrib *at = actx->attribs; + GLuint i; + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + + actx->nr_vbos = 0; + + /* conventional vertex arrays */ + if (arrayObj->Index.Enabled) { + aa->array = &arrayObj->Index; + aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->EdgeFlag.Enabled) { + aa->array = &arrayObj->EdgeFlag; + aa->offset = _gloffset_EdgeFlagv; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->Normal.Enabled) { + aa->array = &arrayObj->Normal; + aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->Color.Enabled) { + aa->array = &arrayObj->Color; + aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->SecondaryColor.Enabled) { + aa->array = &arrayObj->SecondaryColor; + aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->FogCoord.Enabled) { + aa->array = &arrayObj->FogCoord; + aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + struct gl_client_array *attribArray = &arrayObj->TexCoord[i]; + if (attribArray->Enabled) { + /* NOTE: we use generic glVertexAttribNV functions here. + * If we ever remove GL_NV_vertex_program this will have to change. + */ + at->array = attribArray; + ASSERT(!at->array->Normalized); + at->func = AttribFuncsNV[at->array->Normalized] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + at->index = VERT_ATTRIB_TEX0 + i; + check_vbo(actx, at->array->BufferObj); + at++; + } + } + + /* generic vertex attribute arrays */ + for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */ + struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i]; + if (attribArray->Enabled) { + at->array = attribArray; + /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV + * function pointer here (for float arrays) since the pointer may + * change from one execution of _ae_ArrayElement() to + * the next. Doing so caused UT to break. + */ + if (ctx->VertexProgram._Enabled + && ctx->VertexProgram.Current->IsNVProgram) { + at->func = AttribFuncsNV[at->array->Normalized] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + } + else { + GLint intOrNorm; + if (at->array->Integer) + intOrNorm = 2; + else if (at->array->Normalized) + intOrNorm = 1; + else + intOrNorm = 0; + + at->func = AttribFuncsARB[intOrNorm] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + } + at->index = i; + check_vbo(actx, at->array->BufferObj); + at++; + } + } + + /* finally, vertex position */ + if (arrayObj->VertexAttrib[0].Enabled) { + /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's + * issued as the last (provoking) attribute). + */ + aa->array = &arrayObj->VertexAttrib[0]; + assert(aa->array->Size >= 2); /* XXX fix someday? */ + aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + else if (arrayObj->Vertex.Enabled) { + aa->array = &arrayObj->Vertex; + aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + + check_vbo(actx, ctx->Array.ElementArrayBufferObj); + + ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); + ASSERT(aa - actx->arrays < 32); + at->func = NULL; /* terminate the list */ + aa->offset = -1; /* terminate the list */ + + actx->NewState = 0; +} + +void _ae_map_vbos( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + GLuint i; + + if (actx->mapped_vbos) + return; + + if (actx->NewState) + _ae_update_state(ctx); + + for (i = 0; i < actx->nr_vbos; i++) + ctx->Driver.MapBuffer(ctx, + GL_ARRAY_BUFFER_ARB, + GL_DYNAMIC_DRAW_ARB, + actx->vbo[i]); + + if (actx->nr_vbos) + actx->mapped_vbos = GL_TRUE; +} + +void _ae_unmap_vbos( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + GLuint i; + + if (!actx->mapped_vbos) + return; + + assert (!actx->NewState); + + for (i = 0; i < actx->nr_vbos; i++) + ctx->Driver.UnmapBuffer(ctx, + GL_ARRAY_BUFFER_ARB, + actx->vbo[i]); + + actx->mapped_vbos = GL_FALSE; +} + + +/** + * Called via glArrayElement() and glDrawArrays(). + * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions + * for all enabled vertex arrays (for elt-th element). + * Note: this may be called during display list construction. + */ +void GLAPIENTRY _ae_ArrayElement( GLint elt ) +{ + GET_CURRENT_CONTEXT(ctx); + const AEcontext *actx = AE_CONTEXT(ctx); + const AEarray *aa; + const AEattrib *at; + const struct _glapi_table * const disp = GET_DISPATCH(); + GLboolean do_map; + + if (actx->NewState) { + assert(!actx->mapped_vbos); + _ae_update_state( ctx ); + } + + /* Determine if w need to map/unmap VBOs */ + do_map = actx->nr_vbos && !actx->mapped_vbos; + + if (do_map) + _ae_map_vbos(ctx); + + /* emit generic attribute elements */ + for (at = actx->attribs; at->func; at++) { + const GLubyte *src + = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) + + elt * at->array->StrideB; + at->func( at->index, src ); + } + + /* emit conventional arrays elements */ + for (aa = actx->arrays; aa->offset != -1 ; aa++) { + const GLubyte *src + = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr) + + elt * aa->array->StrideB; + CALL_by_offset( disp, (array_func), aa->offset, + ((const void *) src) ); + } + + if (do_map) + _ae_unmap_vbos(ctx); +} + + +void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + + + /* Only interested in this subset of mesa state. Need to prune + * this down as both tnl/ and the drivers can raise statechanges + * for arcane reasons in the middle of seemingly atomic operations + * like DrawElements, over which we'd like to keep a known set of + * arrays and vbo's mapped. + * + * Luckily, neither the drivers nor tnl muck with the state that + * concerns us here: + */ + new_state &= _NEW_ARRAY | _NEW_PROGRAM; + if (new_state) { + assert(!actx->mapped_vbos); + actx->NewState |= new_state; + } +} + + +void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_ArrayElement(disp, vfmt->ArrayElement); +} + + +#endif /* FEATURE_arrayelt */ diff --git a/mesalib/src/mesa/main/api_arrayelt.h b/mesalib/src/mesa/main/api_arrayelt.h index d18c0792c..1e5c6dee0 100644 --- a/mesalib/src/mesa/main/api_arrayelt.h +++ b/mesalib/src/mesa/main/api_arrayelt.h @@ -1,83 +1,83 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef API_ARRAYELT_H -#define API_ARRAYELT_H - - -#include "main/mtypes.h" - -#if FEATURE_arrayelt - -#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->ArrayElement = impl ## ArrayElement; \ - } while (0) - -extern GLboolean _ae_create_context( GLcontext *ctx ); -extern void _ae_destroy_context( GLcontext *ctx ); -extern void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ); -extern void GLAPIENTRY _ae_ArrayElement( GLint elt ); - -/* May optionally be called before a batch of element calls: - */ -extern void _ae_map_vbos( GLcontext *ctx ); -extern void _ae_unmap_vbos( GLcontext *ctx ); - -extern void -_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -#else /* FEATURE_arrayelt */ - -#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) do { } while (0) - -static INLINE GLboolean -_ae_create_context( GLcontext *ctx ) -{ - return GL_TRUE; -} - -static INLINE void -_ae_destroy_context( GLcontext *ctx ) -{ -} - -static INLINE void -_ae_invalidate_state( GLcontext *ctx, GLuint new_state ) -{ -} - -static INLINE void -_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -#endif /* FEATURE_arrayelt */ - - -#endif /* API_ARRAYELT_H */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef API_ARRAYELT_H +#define API_ARRAYELT_H + + +#include "main/mtypes.h" + +#if FEATURE_arrayelt + +#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->ArrayElement = impl ## ArrayElement; \ + } while (0) + +extern GLboolean _ae_create_context( struct gl_context *ctx ); +extern void _ae_destroy_context( struct gl_context *ctx ); +extern void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ); +extern void GLAPIENTRY _ae_ArrayElement( GLint elt ); + +/* May optionally be called before a batch of element calls: + */ +extern void _ae_map_vbos( struct gl_context *ctx ); +extern void _ae_unmap_vbos( struct gl_context *ctx ); + +extern void +_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); + +#else /* FEATURE_arrayelt */ + +#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) do { } while (0) + +static INLINE GLboolean +_ae_create_context( struct gl_context *ctx ) +{ + return GL_TRUE; +} + +static INLINE void +_ae_destroy_context( struct gl_context *ctx ) +{ +} + +static INLINE void +_ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) +{ +} + +static INLINE void +_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} + +#endif /* FEATURE_arrayelt */ + + +#endif /* API_ARRAYELT_H */ diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c index c3c710f5e..af8383b6a 100644 --- a/mesalib/src/mesa/main/api_exec.c +++ b/mesalib/src/mesa/main/api_exec.c @@ -1,735 +1,714 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file api_exec.c - * Initialize dispatch table with the immidiate mode functions. - */ - - -#include "mfeatures.h" -#include "accum.h" -#include "api_loopback.h" -#include "api_exec.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#include "atifragshader.h" -#include "attrib.h" -#include "blend.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#if FEATURE_draw_read_buffer -#include "buffers.h" -#endif -#include "clear.h" -#include "clip.h" -#include "colortab.h" -#include "condrender.h" -#include "context.h" -#include "convolve.h" -#include "depth.h" -#include "dlist.h" -#include "drawpix.h" -#include "rastpos.h" -#include "enable.h" -#include "eval.h" -#include "get.h" -#include "feedback.h" -#include "fog.h" -#if FEATURE_EXT_framebuffer_object -#include "fbobject.h" -#endif -#include "framebuffer.h" -#include "hint.h" -#include "histogram.h" -#include "imports.h" -#include "light.h" -#include "lines.h" -#include "matrix.h" -#include "multisample.h" -#include "pixel.h" -#include "pixelstore.h" -#include "points.h" -#include "polygon.h" -#include "queryobj.h" -#include "readpix.h" -#include "scissor.h" -#include "stencil.h" -#include "texenv.h" -#include "texgetimage.h" -#include "teximage.h" -#include "texgen.h" -#include "texobj.h" -#include "texparam.h" -#include "texstate.h" -#include "transformfeedback.h" -#include "mtypes.h" -#include "varray.h" -#include "viewport.h" -#if FEATURE_NV_vertex_program -#include "nvprogram.h" -#endif -#if FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif -#if FEATURE_ARB_shader_objects -#include "shaderapi.h" -#include "uniforms.h" -#endif -#include "syncobj.h" -#include "main/dispatch.h" - - -#if FEATURE_GL - - -#ifdef _GLAPI_USE_REMAP_TABLE - -#define need_MESA_remap_table -#include "main/remap.h" -#include "main/remap_helper.h" - -/* This is shared across all APIs but We define this here since - * desktop GL has the biggest remap table. */ -int driDispatchRemapTable[driDispatchRemapTable_size]; - -/** - * Map the functions which are already static. - * - * When a extension function are incorporated into the ABI, the - * extension suffix is usually stripped. Mapping such functions - * makes sure the alternative names are available. - * - * Note that functions mapped by _mesa_init_remap_table() are - * excluded. - */ -void -_mesa_map_static_functions(void) -{ - /* Remap static functions which have alternative names and are in the ABI. - * This is to be on the safe side. glapi should have defined those names. - */ - _mesa_map_function_array(MESA_alt_functions); -} - -void -_mesa_init_remap_table(void) -{ - _mesa_do_init_remap_table(_mesa_function_pool, - driDispatchRemapTable_size, - MESA_remap_table_functions); -} - -#endif /* _GLAPI_USE_REMAP_TABLE */ - - -/** - * Initialize a dispatch table with pointers to Mesa's immediate-mode - * commands. - * - * Pointers to glBegin()/glEnd() object commands and a few others - * are provided via the GLvertexformat interface. - * - * \param ctx GL context to which \c exec belongs. - * \param exec dispatch table. - */ -struct _glapi_table * -_mesa_create_exec_table(void) -{ - struct _glapi_table *exec; - - exec = _mesa_alloc_dispatch_table(sizeof *exec); - if (exec == NULL) - return NULL; - -#if _HAVE_FULL_GL - _mesa_loopback_init_api_table( exec ); -#endif - - /* load the dispatch slots we understand */ - SET_AlphaFunc(exec, _mesa_AlphaFunc); - SET_BlendFunc(exec, _mesa_BlendFunc); - SET_Clear(exec, _mesa_Clear); - SET_ClearColor(exec, _mesa_ClearColor); - SET_ClearStencil(exec, _mesa_ClearStencil); - SET_ColorMask(exec, _mesa_ColorMask); - SET_CullFace(exec, _mesa_CullFace); - SET_Disable(exec, _mesa_Disable); -#if FEATURE_draw_read_buffer - SET_DrawBuffer(exec, _mesa_DrawBuffer); - SET_ReadBuffer(exec, _mesa_ReadBuffer); -#endif - SET_Enable(exec, _mesa_Enable); - SET_Finish(exec, _mesa_Finish); - SET_Flush(exec, _mesa_Flush); - SET_FrontFace(exec, _mesa_FrontFace); - SET_Frustum(exec, _mesa_Frustum); - SET_GetError(exec, _mesa_GetError); - SET_GetFloatv(exec, _mesa_GetFloatv); - SET_GetString(exec, _mesa_GetString); - SET_LineStipple(exec, _mesa_LineStipple); - SET_LineWidth(exec, _mesa_LineWidth); - SET_LoadIdentity(exec, _mesa_LoadIdentity); - SET_LoadMatrixf(exec, _mesa_LoadMatrixf); - SET_LogicOp(exec, _mesa_LogicOp); - SET_MatrixMode(exec, _mesa_MatrixMode); - SET_MultMatrixf(exec, _mesa_MultMatrixf); - SET_Ortho(exec, _mesa_Ortho); - SET_PixelStorei(exec, _mesa_PixelStorei); - SET_PopMatrix(exec, _mesa_PopMatrix); - SET_PushMatrix(exec, _mesa_PushMatrix); - SET_Rotatef(exec, _mesa_Rotatef); - SET_Scalef(exec, _mesa_Scalef); - SET_Scissor(exec, _mesa_Scissor); - SET_ShadeModel(exec, _mesa_ShadeModel); - SET_StencilFunc(exec, _mesa_StencilFunc); - SET_StencilMask(exec, _mesa_StencilMask); - SET_StencilOp(exec, _mesa_StencilOp); - SET_TexEnvfv(exec, _mesa_TexEnvfv); - SET_TexEnvi(exec, _mesa_TexEnvi); - SET_TexImage2D(exec, _mesa_TexImage2D); - SET_TexParameteri(exec, _mesa_TexParameteri); - SET_Translatef(exec, _mesa_Translatef); - SET_Viewport(exec, _mesa_Viewport); - - _mesa_init_accum_dispatch(exec); - _mesa_init_dlist_dispatch(exec); - - SET_ClearDepth(exec, _mesa_ClearDepth); - SET_ClearIndex(exec, _mesa_ClearIndex); - SET_ClipPlane(exec, _mesa_ClipPlane); - SET_ColorMaterial(exec, _mesa_ColorMaterial); - SET_CullParameterfvEXT(exec, _mesa_CullParameterfvEXT); - SET_CullParameterdvEXT(exec, _mesa_CullParameterdvEXT); - SET_DepthFunc(exec, _mesa_DepthFunc); - SET_DepthMask(exec, _mesa_DepthMask); - SET_DepthRange(exec, _mesa_DepthRange); - - _mesa_init_drawpix_dispatch(exec); - _mesa_init_feedback_dispatch(exec); - - SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); - SET_Fogf(exec, _mesa_Fogf); - SET_Fogfv(exec, _mesa_Fogfv); - SET_Fogi(exec, _mesa_Fogi); - SET_Fogiv(exec, _mesa_Fogiv); - SET_GetClipPlane(exec, _mesa_GetClipPlane); - SET_GetBooleanv(exec, _mesa_GetBooleanv); - SET_GetDoublev(exec, _mesa_GetDoublev); - SET_GetIntegerv(exec, _mesa_GetIntegerv); - SET_GetLightfv(exec, _mesa_GetLightfv); - SET_GetLightiv(exec, _mesa_GetLightiv); - SET_GetMaterialfv(exec, _mesa_GetMaterialfv); - SET_GetMaterialiv(exec, _mesa_GetMaterialiv); - SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); - SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); - SET_GetTexEnviv(exec, _mesa_GetTexEnviv); - SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); - SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); - SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); - SET_GetTexImage(exec, _mesa_GetTexImage); - SET_Hint(exec, _mesa_Hint); - SET_IndexMask(exec, _mesa_IndexMask); - SET_IsEnabled(exec, _mesa_IsEnabled); - SET_LightModelf(exec, _mesa_LightModelf); - SET_LightModelfv(exec, _mesa_LightModelfv); - SET_LightModeli(exec, _mesa_LightModeli); - SET_LightModeliv(exec, _mesa_LightModeliv); - SET_Lightf(exec, _mesa_Lightf); - SET_Lightfv(exec, _mesa_Lightfv); - SET_Lighti(exec, _mesa_Lighti); - SET_Lightiv(exec, _mesa_Lightiv); - SET_LoadMatrixd(exec, _mesa_LoadMatrixd); - - _mesa_init_eval_dispatch(exec); - - SET_MultMatrixd(exec, _mesa_MultMatrixd); - - _mesa_init_pixel_dispatch(exec); - - SET_PixelStoref(exec, _mesa_PixelStoref); - SET_PointSize(exec, _mesa_PointSize); - SET_PolygonMode(exec, _mesa_PolygonMode); - SET_PolygonOffset(exec, _mesa_PolygonOffset); - SET_PolygonStipple(exec, _mesa_PolygonStipple); - - _mesa_init_attrib_dispatch(exec); - _mesa_init_rastpos_dispatch(exec); - - SET_ReadPixels(exec, _mesa_ReadPixels); - SET_Rotated(exec, _mesa_Rotated); - SET_Scaled(exec, _mesa_Scaled); - SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT); - SET_TexEnvf(exec, _mesa_TexEnvf); - SET_TexEnviv(exec, _mesa_TexEnviv); - - _mesa_init_texgen_dispatch(exec); - - SET_TexImage1D(exec, _mesa_TexImage1D); - SET_TexParameterf(exec, _mesa_TexParameterf); - SET_TexParameterfv(exec, _mesa_TexParameterfv); - SET_TexParameteriv(exec, _mesa_TexParameteriv); - SET_Translated(exec, _mesa_Translated); - - /* 1.1 */ - SET_BindTexture(exec, _mesa_BindTexture); - SET_DeleteTextures(exec, _mesa_DeleteTextures); - SET_GenTextures(exec, _mesa_GenTextures); -#if _HAVE_FULL_GL - SET_AreTexturesResident(exec, _mesa_AreTexturesResident); - SET_ColorPointer(exec, _mesa_ColorPointer); - SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D); - SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D); - SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D); - SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D); - SET_DisableClientState(exec, _mesa_DisableClientState); - SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer); - SET_EnableClientState(exec, _mesa_EnableClientState); - SET_GetPointerv(exec, _mesa_GetPointerv); - SET_IndexPointer(exec, _mesa_IndexPointer); - SET_InterleavedArrays(exec, _mesa_InterleavedArrays); - SET_IsTexture(exec, _mesa_IsTexture); - SET_NormalPointer(exec, _mesa_NormalPointer); - SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); - SET_TexCoordPointer(exec, _mesa_TexCoordPointer); - SET_TexSubImage1D(exec, _mesa_TexSubImage1D); - SET_TexSubImage2D(exec, _mesa_TexSubImage2D); - SET_VertexPointer(exec, _mesa_VertexPointer); -#endif - - /* 1.2 */ -#if _HAVE_FULL_GL - SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D); - SET_TexImage3D(exec, _mesa_TexImage3D); - SET_TexSubImage3D(exec, _mesa_TexSubImage3D); -#endif - - /* OpenGL 1.2 GL_ARB_imaging */ - SET_BlendColor(exec, _mesa_BlendColor); - SET_BlendEquation(exec, _mesa_BlendEquation); - SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); - - _mesa_init_colortable_dispatch(exec); - _mesa_init_convolve_dispatch(exec); - _mesa_init_histogram_dispatch(exec); - - /* OpenGL 2.0 */ - SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate); - SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); - SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); - -#if FEATURE_ARB_shader_objects - _mesa_init_shader_dispatch(exec); - _mesa_init_shader_uniform_dispatch(exec); -#endif - - /* 2. GL_EXT_blend_color */ -#if 0 -/* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */ -#endif - - /* 3. GL_EXT_polygon_offset */ -#if _HAVE_FULL_GL - SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); -#endif - - /* 6. GL_EXT_texture3d */ -#if 0 -/* SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */ -/* SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */ -/* SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */ -#endif - - /* 11. GL_EXT_histogram */ -#if 0 - SET_GetHistogramEXT(exec, _mesa_GetHistogram); - SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv); - SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv); - SET_GetMinmaxEXT(exec, _mesa_GetMinmax); - SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv); - SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv); -#endif - - /* 14. SGI_color_table */ -#if 0 - SET_ColorTableSGI(exec, _mesa_ColorTable); - SET_ColorSubTableSGI(exec, _mesa_ColorSubTable); - SET_GetColorTableSGI(exec, _mesa_GetColorTable); - SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv); - SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv); -#endif - - /* 30. GL_EXT_vertex_array */ -#if _HAVE_FULL_GL - SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); - SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); - SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); - SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT); - SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT); - SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT); -#endif - - /* 37. GL_EXT_blend_minmax */ -#if 0 - SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT); -#endif - - /* 54. GL_EXT_point_parameters */ -#if _HAVE_FULL_GL - SET_PointParameterfEXT(exec, _mesa_PointParameterf); - SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); -#endif - - /* 97. GL_EXT_compiled_vertex_array */ -#if _HAVE_FULL_GL - SET_LockArraysEXT(exec, _mesa_LockArraysEXT); - SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); -#endif - - /* 148. GL_EXT_multi_draw_arrays */ -#if _HAVE_FULL_GL - SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT); -#endif - - /* 173. GL_INGR_blend_func_separate */ -#if _HAVE_FULL_GL - SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT); -#endif - - /* 196. GL_MESA_resize_buffers */ -#if _HAVE_FULL_GL - SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); -#endif - - /* 197. GL_MESA_window_pos */ - /* part of _mesa_init_rastpos_dispatch(exec); */ - - /* 200. GL_IBM_multimode_draw_arrays */ -#if _HAVE_FULL_GL - SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM); -#endif - - /* 233. GL_NV_vertex_program */ -#if FEATURE_NV_vertex_program - SET_BindProgramNV(exec, _mesa_BindProgram); - SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); - SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); - SET_GenProgramsNV(exec, _mesa_GenPrograms); - SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(exec, _mesa_GetProgramivNV); - SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(exec, _mesa_IsProgramARB); - SET_LoadProgramNV(exec, _mesa_LoadProgramNV); - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ - SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); - SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); - SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); - /* glVertexAttrib*NV functions handled in api_loopback.c */ -#endif - - /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); - SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); - SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE); - - /* 282. GL_NV_fragment_program */ -#if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); -#endif - - /* 262. GL_NV_point_sprite */ -#if _HAVE_FULL_GL - SET_PointParameteriNV(exec, _mesa_PointParameteri); - SET_PointParameterivNV(exec, _mesa_PointParameteriv); -#endif - - /* 268. GL_EXT_stencil_two_side */ -#if _HAVE_FULL_GL - SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); -#endif - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); - - /* 352. GL_EXT_transform_feedback */ - _mesa_init_transform_feedback_dispatch(exec); - - /* 364. GL_EXT_provoking_vertex */ - SET_ProvokingVertexEXT(exec, _mesa_ProvokingVertexEXT); - - /* ARB 1. GL_ARB_multitexture */ -#if _HAVE_FULL_GL - SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB); - SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB); -#endif - - /* ARB 3. GL_ARB_transpose_matrix */ -#if _HAVE_FULL_GL - SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB); -#endif - - /* ARB 5. GL_ARB_multisample */ -#if _HAVE_FULL_GL - SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB); -#endif - - /* ARB 12. GL_ARB_texture_compression */ -#if _HAVE_FULL_GL - SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB); - SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB); - SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB); - SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB); - SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB); - SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB); - SET_GetCompressedTexImageARB(exec, _mesa_GetCompressedTexImageARB); -#endif - - /* ARB 14. GL_ARB_point_parameters */ - /* reuse EXT_point_parameters functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */ - /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */ - /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */ - /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */ - /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */ - /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */ - /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */ - /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */ - /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */ - /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */ - /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */ - /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */ - /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */ - /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */ - /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */ - /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */ - /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */ - /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */ - /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */ - /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */ - /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */ - /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */ - /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */ - /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */ - /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */ - /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */ - /* glVertexAttrib4bvARB handled in api_loopback.c */ - /* glVertexAttrib4ivARB handled in api_loopback.c */ - /* glVertexAttrib4ubvARB handled in api_loopback.c */ - /* glVertexAttrib4usvARB handled in api_loopback.c */ - /* glVertexAttrib4uivARB handled in api_loopback.c */ - /* glVertexAttrib4NbvARB handled in api_loopback.c */ - /* glVertexAttrib4NsvARB handled in api_loopback.c */ - /* glVertexAttrib4NivARB handled in api_loopback.c */ - /* glVertexAttrib4NusvARB handled in api_loopback.c */ - /* glVertexAttrib4NuivARB handled in api_loopback.c */ - SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(exec, _mesa_ProgramStringARB); - /* glBindProgramARB aliases glBindProgramNV */ - /* glDeleteProgramsARB aliases glDeleteProgramsNV */ - /* glGenProgramsARB aliases glGenProgramsNV */ - /* glIsProgramARB aliases glIsProgramNV */ - SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB); - SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); - SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); - /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(exec, _mesa_GetProgramivARB); - SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); -#endif - - /* ARB 28. GL_ARB_vertex_buffer_object */ -#if FEATURE_ARB_vertex_buffer_object - SET_BindBufferARB(exec, _mesa_BindBufferARB); - SET_BufferDataARB(exec, _mesa_BufferDataARB); - SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(exec, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(exec, _mesa_IsBufferARB); - SET_MapBufferARB(exec, _mesa_MapBufferARB); - SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB); -#endif - - /* ARB 29. GL_ARB_occlusion_query */ - _mesa_init_queryobj_dispatch(exec); - - /* ARB 37. GL_ARB_draw_buffers */ -#if FEATURE_draw_read_buffer - SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB); -#endif - - /* GL_ARB_sync */ - _mesa_init_sync_dispatch(exec); - - /* GL_ATI_fragment_shader */ - _mesa_init_ati_fragment_shader_dispatch(exec); - - /* GL_ATI_envmap_bumpmap */ - SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); - SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); - SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); - -#if FEATURE_EXT_framebuffer_object - SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT); - SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT); - SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT); - SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT); - SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT); - SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT); - SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT); - SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT); - SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT); - SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT); - SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT); - SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT); - SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT); - SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT); - SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT); - SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT); - SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT); -#endif - -#if FEATURE_EXT_framebuffer_blit - SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT); -#endif - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); -#endif - - /* GL_MESA_texture_array / GL_EXT_texture_array */ -#if FEATURE_EXT_framebuffer_object - SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT); -#endif - - /* GL_ATI_separate_stencil */ - SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); - -#if FEATURE_ARB_framebuffer_object - /* The ARB_fbo functions are the union of - * GL_EXT_fbo, GL_EXT_framebuffer_blit, GL_EXT_texture_array - */ - SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample); -#endif - -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(exec, _mesa_MapBufferRange); - SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange); -#endif - - /* GL_ARB_copy_buffer */ - SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData); - - /* GL_ARB_vertex_array_object */ - SET_BindVertexArray(exec, _mesa_BindVertexArray); - SET_GenVertexArrays(exec, _mesa_GenVertexArrays); - - /* GL_EXT_draw_buffers2 */ - SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed); - SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv); - SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv); - SET_EnableIndexedEXT(exec, _mesa_EnableIndexed); - SET_DisableIndexedEXT(exec, _mesa_DisableIndexed); - SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed); - - /* GL_NV_conditional_render */ - SET_BeginConditionalRenderNV(exec, _mesa_BeginConditionalRender); - SET_EndConditionalRenderNV(exec, _mesa_EndConditionalRender); - -#if FEATURE_OES_EGL_image - SET_EGLImageTargetTexture2DOES(exec, _mesa_EGLImageTargetTexture2DOES); - SET_EGLImageTargetRenderbufferStorageOES(exec, _mesa_EGLImageTargetRenderbufferStorageOES); -#endif - -#if FEATURE_APPLE_object_purgeable - SET_ObjectPurgeableAPPLE(exec, _mesa_ObjectPurgeableAPPLE); - SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE); - SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE); -#endif - -#if FEATURE_ARB_geometry_shader4 - SET_FramebufferTextureARB(exec, _mesa_FramebufferTextureARB); - SET_FramebufferTextureFaceARB(exec, _mesa_FramebufferTextureFaceARB); -#endif - - - return exec; -} - -#endif /* FEATURE_GL */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file api_exec.c + * Initialize dispatch table with the immidiate mode functions. + */ + + +#include "mfeatures.h" +#include "accum.h" +#include "api_loopback.h" +#include "api_exec.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "arbprogram.h" +#endif +#include "atifragshader.h" +#include "attrib.h" +#include "blend.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#if FEATURE_draw_read_buffer +#include "buffers.h" +#endif +#include "clear.h" +#include "clip.h" +#include "colortab.h" +#include "condrender.h" +#include "context.h" +#include "convolve.h" +#include "depth.h" +#include "dlist.h" +#include "drawpix.h" +#include "rastpos.h" +#include "enable.h" +#include "eval.h" +#include "get.h" +#include "feedback.h" +#include "fog.h" +#if FEATURE_EXT_framebuffer_object +#include "fbobject.h" +#endif +#include "framebuffer.h" +#include "hint.h" +#include "histogram.h" +#include "imports.h" +#include "light.h" +#include "lines.h" +#include "matrix.h" +#include "multisample.h" +#include "pixel.h" +#include "pixelstore.h" +#include "points.h" +#include "polygon.h" +#include "queryobj.h" +#include "readpix.h" +#include "scissor.h" +#include "stencil.h" +#include "texenv.h" +#include "texgetimage.h" +#include "teximage.h" +#include "texgen.h" +#include "texobj.h" +#include "texparam.h" +#include "texstate.h" +#include "transformfeedback.h" +#include "mtypes.h" +#include "varray.h" +#include "viewport.h" +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "nvprogram.h" +#endif +#if FEATURE_ARB_shader_objects +#include "shaderapi.h" +#include "uniforms.h" +#endif +#include "syncobj.h" +#include "main/dispatch.h" + + +#if FEATURE_GL + + +/** + * Initialize a dispatch table with pointers to Mesa's immediate-mode + * commands. + * + * Pointers to glBegin()/glEnd() object commands and a few others + * are provided via the GLvertexformat interface. + * + * \param ctx GL context to which \c exec belongs. + * \param exec dispatch table. + */ +struct _glapi_table * +_mesa_create_exec_table(void) +{ + struct _glapi_table *exec; + + exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (exec == NULL) + return NULL; + +#if _HAVE_FULL_GL + _mesa_loopback_init_api_table( exec ); +#endif + + /* load the dispatch slots we understand */ + SET_AlphaFunc(exec, _mesa_AlphaFunc); + SET_BlendFunc(exec, _mesa_BlendFunc); + SET_Clear(exec, _mesa_Clear); + SET_ClearColor(exec, _mesa_ClearColor); + SET_ClearStencil(exec, _mesa_ClearStencil); + SET_ColorMask(exec, _mesa_ColorMask); + SET_CullFace(exec, _mesa_CullFace); + SET_Disable(exec, _mesa_Disable); +#if FEATURE_draw_read_buffer + SET_DrawBuffer(exec, _mesa_DrawBuffer); + SET_ReadBuffer(exec, _mesa_ReadBuffer); +#endif + SET_Enable(exec, _mesa_Enable); + SET_Finish(exec, _mesa_Finish); + SET_Flush(exec, _mesa_Flush); + SET_FrontFace(exec, _mesa_FrontFace); + SET_Frustum(exec, _mesa_Frustum); + SET_GetError(exec, _mesa_GetError); + SET_GetFloatv(exec, _mesa_GetFloatv); + SET_GetString(exec, _mesa_GetString); + SET_LineStipple(exec, _mesa_LineStipple); + SET_LineWidth(exec, _mesa_LineWidth); + SET_LoadIdentity(exec, _mesa_LoadIdentity); + SET_LoadMatrixf(exec, _mesa_LoadMatrixf); + SET_LogicOp(exec, _mesa_LogicOp); + SET_MatrixMode(exec, _mesa_MatrixMode); + SET_MultMatrixf(exec, _mesa_MultMatrixf); + SET_Ortho(exec, _mesa_Ortho); + SET_PixelStorei(exec, _mesa_PixelStorei); + SET_PopMatrix(exec, _mesa_PopMatrix); + SET_PushMatrix(exec, _mesa_PushMatrix); + SET_Rotatef(exec, _mesa_Rotatef); + SET_Scalef(exec, _mesa_Scalef); + SET_Scissor(exec, _mesa_Scissor); + SET_ShadeModel(exec, _mesa_ShadeModel); + SET_StencilFunc(exec, _mesa_StencilFunc); + SET_StencilMask(exec, _mesa_StencilMask); + SET_StencilOp(exec, _mesa_StencilOp); + SET_TexEnvfv(exec, _mesa_TexEnvfv); + SET_TexEnvi(exec, _mesa_TexEnvi); + SET_TexImage2D(exec, _mesa_TexImage2D); + SET_TexParameteri(exec, _mesa_TexParameteri); + SET_Translatef(exec, _mesa_Translatef); + SET_Viewport(exec, _mesa_Viewport); + + _mesa_init_accum_dispatch(exec); + _mesa_init_dlist_dispatch(exec); + + SET_ClearDepth(exec, _mesa_ClearDepth); + SET_ClearIndex(exec, _mesa_ClearIndex); + SET_ClipPlane(exec, _mesa_ClipPlane); + SET_ColorMaterial(exec, _mesa_ColorMaterial); + SET_DepthFunc(exec, _mesa_DepthFunc); + SET_DepthMask(exec, _mesa_DepthMask); + SET_DepthRange(exec, _mesa_DepthRange); + + _mesa_init_drawpix_dispatch(exec); + _mesa_init_feedback_dispatch(exec); + + SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); + SET_Fogf(exec, _mesa_Fogf); + SET_Fogfv(exec, _mesa_Fogfv); + SET_Fogi(exec, _mesa_Fogi); + SET_Fogiv(exec, _mesa_Fogiv); + SET_GetClipPlane(exec, _mesa_GetClipPlane); + SET_GetBooleanv(exec, _mesa_GetBooleanv); + SET_GetDoublev(exec, _mesa_GetDoublev); + SET_GetIntegerv(exec, _mesa_GetIntegerv); + SET_GetLightfv(exec, _mesa_GetLightfv); + SET_GetLightiv(exec, _mesa_GetLightiv); + SET_GetMaterialfv(exec, _mesa_GetMaterialfv); + SET_GetMaterialiv(exec, _mesa_GetMaterialiv); + SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); + SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); + SET_GetTexEnviv(exec, _mesa_GetTexEnviv); + SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv); + SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); + SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); + SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); + SET_GetTexImage(exec, _mesa_GetTexImage); + SET_Hint(exec, _mesa_Hint); + SET_IndexMask(exec, _mesa_IndexMask); + SET_IsEnabled(exec, _mesa_IsEnabled); + SET_LightModelf(exec, _mesa_LightModelf); + SET_LightModelfv(exec, _mesa_LightModelfv); + SET_LightModeli(exec, _mesa_LightModeli); + SET_LightModeliv(exec, _mesa_LightModeliv); + SET_Lightf(exec, _mesa_Lightf); + SET_Lightfv(exec, _mesa_Lightfv); + SET_Lighti(exec, _mesa_Lighti); + SET_Lightiv(exec, _mesa_Lightiv); + SET_LoadMatrixd(exec, _mesa_LoadMatrixd); + + _mesa_init_eval_dispatch(exec); + + SET_MultMatrixd(exec, _mesa_MultMatrixd); + + _mesa_init_pixel_dispatch(exec); + + SET_PixelStoref(exec, _mesa_PixelStoref); + SET_PointSize(exec, _mesa_PointSize); + SET_PolygonMode(exec, _mesa_PolygonMode); + SET_PolygonOffset(exec, _mesa_PolygonOffset); + SET_PolygonStipple(exec, _mesa_PolygonStipple); + + _mesa_init_attrib_dispatch(exec); + _mesa_init_rastpos_dispatch(exec); + + SET_ReadPixels(exec, _mesa_ReadPixels); + SET_Rotated(exec, _mesa_Rotated); + SET_Scaled(exec, _mesa_Scaled); + SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT); + SET_TexEnvf(exec, _mesa_TexEnvf); + SET_TexEnviv(exec, _mesa_TexEnviv); + + _mesa_init_texgen_dispatch(exec); + + SET_TexImage1D(exec, _mesa_TexImage1D); + SET_TexParameterf(exec, _mesa_TexParameterf); + SET_TexParameterfv(exec, _mesa_TexParameterfv); + SET_TexParameteriv(exec, _mesa_TexParameteriv); + SET_Translated(exec, _mesa_Translated); + + /* 1.1 */ + SET_BindTexture(exec, _mesa_BindTexture); + SET_DeleteTextures(exec, _mesa_DeleteTextures); + SET_GenTextures(exec, _mesa_GenTextures); +#if _HAVE_FULL_GL + SET_AreTexturesResident(exec, _mesa_AreTexturesResident); + SET_ColorPointer(exec, _mesa_ColorPointer); + SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D); + SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D); + SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D); + SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D); + SET_DisableClientState(exec, _mesa_DisableClientState); + SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer); + SET_EnableClientState(exec, _mesa_EnableClientState); + SET_GetPointerv(exec, _mesa_GetPointerv); + SET_IndexPointer(exec, _mesa_IndexPointer); + SET_InterleavedArrays(exec, _mesa_InterleavedArrays); + SET_IsTexture(exec, _mesa_IsTexture); + SET_NormalPointer(exec, _mesa_NormalPointer); + SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); + SET_TexCoordPointer(exec, _mesa_TexCoordPointer); + SET_TexSubImage1D(exec, _mesa_TexSubImage1D); + SET_TexSubImage2D(exec, _mesa_TexSubImage2D); + SET_VertexPointer(exec, _mesa_VertexPointer); +#endif + + /* 1.2 */ +#if _HAVE_FULL_GL + SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D); + SET_TexImage3D(exec, _mesa_TexImage3D); + SET_TexSubImage3D(exec, _mesa_TexSubImage3D); +#endif + + /* OpenGL 1.2 GL_ARB_imaging */ + SET_BlendColor(exec, _mesa_BlendColor); + SET_BlendEquation(exec, _mesa_BlendEquation); + SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); + + _mesa_init_colortable_dispatch(exec); + _mesa_init_convolve_dispatch(exec); + _mesa_init_histogram_dispatch(exec); + + /* OpenGL 2.0 */ + SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate); + SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); + SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); + +#if FEATURE_ARB_shader_objects + _mesa_init_shader_dispatch(exec); + _mesa_init_shader_uniform_dispatch(exec); +#endif + + /* 2. GL_EXT_blend_color */ +#if 0 +/* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */ +#endif + + /* 3. GL_EXT_polygon_offset */ +#if _HAVE_FULL_GL + SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); +#endif + + /* 6. GL_EXT_texture3d */ +#if 0 +/* SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */ +/* SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */ +/* SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */ +#endif + + /* 11. GL_EXT_histogram */ +#if 0 + SET_GetHistogramEXT(exec, _mesa_GetHistogram); + SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv); + SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv); + SET_GetMinmaxEXT(exec, _mesa_GetMinmax); + SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv); + SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv); +#endif + + /* 14. SGI_color_table */ +#if 0 + SET_ColorTableSGI(exec, _mesa_ColorTable); + SET_ColorSubTableSGI(exec, _mesa_ColorSubTable); + SET_GetColorTableSGI(exec, _mesa_GetColorTable); + SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv); + SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv); +#endif + + /* 30. GL_EXT_vertex_array */ +#if _HAVE_FULL_GL + SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); + SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); + SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); + SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT); + SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT); + SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT); +#endif + + /* 37. GL_EXT_blend_minmax */ +#if 0 + SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT); +#endif + + /* 54. GL_EXT_point_parameters */ +#if _HAVE_FULL_GL + SET_PointParameterfEXT(exec, _mesa_PointParameterf); + SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); +#endif + + /* 97. GL_EXT_compiled_vertex_array */ +#if _HAVE_FULL_GL + SET_LockArraysEXT(exec, _mesa_LockArraysEXT); + SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); +#endif + + /* 148. GL_EXT_multi_draw_arrays */ +#if _HAVE_FULL_GL + SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT); +#endif + + /* 173. GL_INGR_blend_func_separate */ +#if _HAVE_FULL_GL + SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT); +#endif + + /* 196. GL_MESA_resize_buffers */ +#if _HAVE_FULL_GL + SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); +#endif + + /* 197. GL_MESA_window_pos */ + /* part of _mesa_init_rastpos_dispatch(exec); */ + + /* 200. GL_IBM_multimode_draw_arrays */ +#if _HAVE_FULL_GL + SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM); +#endif + + /* 233. GL_NV_vertex_program */ +#if FEATURE_NV_vertex_program + SET_BindProgramNV(exec, _mesa_BindProgram); + SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); + SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); + SET_GenProgramsNV(exec, _mesa_GenPrograms); + SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(exec, _mesa_GetProgramivNV); + SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(exec, _mesa_IsProgramARB); + SET_LoadProgramNV(exec, _mesa_LoadProgramNV); + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ + SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); + SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); + SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); + /* glVertexAttrib*NV functions handled in api_loopback.c */ +#endif + + /* 273. GL_APPLE_vertex_array_object */ + SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE); + + /* 282. GL_NV_fragment_program */ +#if FEATURE_NV_fragment_program + SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); +#endif + + /* 262. GL_NV_point_sprite */ +#if _HAVE_FULL_GL + SET_PointParameteriNV(exec, _mesa_PointParameteri); + SET_PointParameterivNV(exec, _mesa_PointParameteriv); +#endif + + /* 268. GL_EXT_stencil_two_side */ +#if _HAVE_FULL_GL + SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); +#endif + + /* 285. GL_NV_primitive_restart */ + SET_PrimitiveRestartIndexNV(exec, _mesa_PrimitiveRestartIndex); + + /* ???. GL_EXT_depth_bounds_test */ + SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); + + /* 352. GL_EXT_transform_feedback */ + _mesa_init_transform_feedback_dispatch(exec); + + /* 364. GL_EXT_provoking_vertex */ + SET_ProvokingVertexEXT(exec, _mesa_ProvokingVertexEXT); + + /* ARB 1. GL_ARB_multitexture */ +#if _HAVE_FULL_GL + SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB); + SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB); +#endif + + /* ARB 3. GL_ARB_transpose_matrix */ +#if _HAVE_FULL_GL + SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB); +#endif + + /* ARB 5. GL_ARB_multisample */ +#if _HAVE_FULL_GL + SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB); +#endif + + /* ARB 12. GL_ARB_texture_compression */ +#if _HAVE_FULL_GL + SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB); + SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB); + SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(exec, _mesa_GetCompressedTexImageARB); +#endif + + /* ARB 14. GL_ARB_point_parameters */ + /* reuse EXT_point_parameters functions */ + + /* ARB 26. GL_ARB_vertex_program */ + /* ARB 27. GL_ARB_fragment_program */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */ + /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */ + /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */ + /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */ + /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */ + /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */ + /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */ + /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */ + /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */ + /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */ + /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */ + /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */ + /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */ + /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */ + /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */ + /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */ + /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */ + /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */ + /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */ + /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */ + /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */ + /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */ + /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */ + /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */ + /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */ + /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */ + /* glVertexAttrib4bvARB handled in api_loopback.c */ + /* glVertexAttrib4ivARB handled in api_loopback.c */ + /* glVertexAttrib4ubvARB handled in api_loopback.c */ + /* glVertexAttrib4usvARB handled in api_loopback.c */ + /* glVertexAttrib4uivARB handled in api_loopback.c */ + /* glVertexAttrib4NbvARB handled in api_loopback.c */ + /* glVertexAttrib4NsvARB handled in api_loopback.c */ + /* glVertexAttrib4NivARB handled in api_loopback.c */ + /* glVertexAttrib4NusvARB handled in api_loopback.c */ + /* glVertexAttrib4NuivARB handled in api_loopback.c */ + SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB); + SET_ProgramStringARB(exec, _mesa_ProgramStringARB); + /* glBindProgramARB aliases glBindProgramNV */ + /* glDeleteProgramsARB aliases glDeleteProgramsNV */ + /* glGenProgramsARB aliases glGenProgramsNV */ + /* glIsProgramARB aliases glIsProgramNV */ + SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB); + SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); + SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); + /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramivARB(exec, _mesa_GetProgramivARB); + SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); +#endif + + /* ARB 28. GL_ARB_vertex_buffer_object */ +#if FEATURE_ARB_vertex_buffer_object + SET_BindBufferARB(exec, _mesa_BindBufferARB); + SET_BufferDataARB(exec, _mesa_BufferDataARB); + SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB); + SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB); + SET_GenBuffersARB(exec, _mesa_GenBuffersARB); + SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB); + SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB); + SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB); + SET_IsBufferARB(exec, _mesa_IsBufferARB); + SET_MapBufferARB(exec, _mesa_MapBufferARB); + SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB); +#endif + + /* ARB 29. GL_ARB_occlusion_query */ + _mesa_init_queryobj_dispatch(exec); + + /* ARB 37. GL_ARB_draw_buffers */ +#if FEATURE_draw_read_buffer + SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB); +#endif + + /* GL_ARB_sync */ + _mesa_init_sync_dispatch(exec); + + /* GL_ATI_fragment_shader */ + _mesa_init_ati_fragment_shader_dispatch(exec); + + /* GL_ATI_envmap_bumpmap */ + SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); + SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); + SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); + +#if FEATURE_EXT_framebuffer_object + SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT); + SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT); + SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT); + SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT); + SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT); + SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT); + SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT); + SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT); + SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT); + SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT); + SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT); + SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT); + SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT); + SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT); + SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT); +#endif + +#if FEATURE_EXT_framebuffer_blit + SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT); +#endif + + /* GL_EXT_gpu_program_parameters */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); +#endif + + /* GL_MESA_texture_array / GL_EXT_texture_array */ +#if FEATURE_EXT_framebuffer_object + SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT); +#endif + + /* GL_ATI_separate_stencil */ + SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); + +#if FEATURE_ARB_framebuffer_object + /* The ARB_fbo functions are the union of + * GL_EXT_fbo, GL_EXT_framebuffer_blit, GL_EXT_texture_array + */ + SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample); +#endif + +#if FEATURE_ARB_map_buffer_range + SET_MapBufferRange(exec, _mesa_MapBufferRange); + SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange); +#endif + + /* GL_ARB_copy_buffer */ + SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData); + + /* GL_ARB_vertex_array_object */ + SET_BindVertexArray(exec, _mesa_BindVertexArray); + SET_GenVertexArrays(exec, _mesa_GenVertexArrays); + + /* GL_EXT_draw_buffers2 */ + SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed); + SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv); + SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv); + SET_EnableIndexedEXT(exec, _mesa_EnableIndexed); + SET_DisableIndexedEXT(exec, _mesa_DisableIndexed); + SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed); + + /* GL_NV_conditional_render */ + SET_BeginConditionalRenderNV(exec, _mesa_BeginConditionalRender); + SET_EndConditionalRenderNV(exec, _mesa_EndConditionalRender); + +#if FEATURE_OES_EGL_image + SET_EGLImageTargetTexture2DOES(exec, _mesa_EGLImageTargetTexture2DOES); + SET_EGLImageTargetRenderbufferStorageOES(exec, _mesa_EGLImageTargetRenderbufferStorageOES); +#endif + +#if FEATURE_APPLE_object_purgeable + SET_ObjectPurgeableAPPLE(exec, _mesa_ObjectPurgeableAPPLE); + SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE); + SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE); +#endif + +#if FEATURE_ARB_geometry_shader4 + SET_FramebufferTextureARB(exec, _mesa_FramebufferTextureARB); + SET_FramebufferTextureFaceARB(exec, _mesa_FramebufferTextureFaceARB); +#endif + + /* GL_EXT_texture_integer */ + SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT); + SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT); + SET_GetTexParameterIivEXT(exec, _mesa_GetTexParameterIiv); + SET_GetTexParameterIuivEXT(exec, _mesa_GetTexParameterIuiv); + SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv); + SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv); + + /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ + SET_GetVertexAttribIivEXT(exec, _mesa_GetVertexAttribIiv); + SET_GetVertexAttribIuivEXT(exec, _mesa_GetVertexAttribIuiv); + SET_VertexAttribIPointerEXT(exec, _mesa_VertexAttribIPointer); + + /* GL 3.0 (functions not covered by other extensions) */ + SET_ClearBufferiv(exec, _mesa_ClearBufferiv); + SET_ClearBufferuiv(exec, _mesa_ClearBufferuiv); + SET_ClearBufferfv(exec, _mesa_ClearBufferfv); + SET_ClearBufferfi(exec, _mesa_ClearBufferfi); + SET_GetStringi(exec, _mesa_GetStringi); + SET_ClampColor(exec, _mesa_ClampColorARB); + + + return exec; +} + +#endif /* FEATURE_GL */ diff --git a/mesalib/src/mesa/main/api_loopback.c b/mesalib/src/mesa/main/api_loopback.c index d1789069c..fb9d781f7 100644 --- a/mesalib/src/mesa/main/api_loopback.c +++ b/mesalib/src/mesa/main/api_loopback.c @@ -1,1838 +1,1725 @@ -/** - * \file api_loopback.c - * - * \author Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "macros.h" -#include "api_loopback.h" -#include "mtypes.h" -#include "glapi/glapi.h" -#include "glapi/glapitable.h" -#include "glapi/glthread.h" -#include "main/dispatch.h" - -/* KW: A set of functions to convert unusual Color/Normal/Vertex/etc - * calls to a smaller set of driver-provided formats. Currently just - * go back to dispatch to find these (eg. call glNormal3f directly), - * hence 'loopback'. - * - * The driver must supply all of the remaining entry points, which are - * listed in dd.h. The easiest way for a driver to do this is to - * install the supplied software t&l module. - */ -#define COLORF(r,g,b,a) CALL_Color4f(GET_DISPATCH(), (r,g,b,a)) -#define VERTEX2(x,y) CALL_Vertex2f(GET_DISPATCH(), (x,y)) -#define VERTEX3(x,y,z) CALL_Vertex3f(GET_DISPATCH(), (x,y,z)) -#define VERTEX4(x,y,z,w) CALL_Vertex4f(GET_DISPATCH(), (x,y,z,w)) -#define NORMAL(x,y,z) CALL_Normal3f(GET_DISPATCH(), (x,y,z)) -#define TEXCOORD1(s) CALL_TexCoord1f(GET_DISPATCH(), (s)) -#define TEXCOORD2(s,t) CALL_TexCoord2f(GET_DISPATCH(), (s,t)) -#define TEXCOORD3(s,t,u) CALL_TexCoord3f(GET_DISPATCH(), (s,t,u)) -#define TEXCOORD4(s,t,u,v) CALL_TexCoord4f(GET_DISPATCH(), (s,t,u,v)) -#define INDEX(c) CALL_Indexf(GET_DISPATCH(), (c)) -#define MULTI_TEXCOORD1(z,s) CALL_MultiTexCoord1fARB(GET_DISPATCH(), (z,s)) -#define MULTI_TEXCOORD2(z,s,t) CALL_MultiTexCoord2fARB(GET_DISPATCH(), (z,s,t)) -#define MULTI_TEXCOORD3(z,s,t,u) CALL_MultiTexCoord3fARB(GET_DISPATCH(), (z,s,t,u)) -#define MULTI_TEXCOORD4(z,s,t,u,v) CALL_MultiTexCoord4fARB(GET_DISPATCH(), (z,s,t,u,v)) -#define EVALCOORD1(x) CALL_EvalCoord1f(GET_DISPATCH(), (x)) -#define EVALCOORD2(x,y) CALL_EvalCoord2f(GET_DISPATCH(), (x,y)) -#define MATERIALFV(a,b,c) CALL_Materialfv(GET_DISPATCH(), (a,b,c)) -#define RECTF(a,b,c,d) CALL_Rectf(GET_DISPATCH(), (a,b,c,d)) - -#define ATTRIB1NV(index,x) CALL_VertexAttrib1fNV(GET_DISPATCH(), (index,x)) -#define ATTRIB2NV(index,x,y) CALL_VertexAttrib2fNV(GET_DISPATCH(), (index,x,y)) -#define ATTRIB3NV(index,x,y,z) CALL_VertexAttrib3fNV(GET_DISPATCH(), (index,x,y,z)) -#define ATTRIB4NV(index,x,y,z,w) CALL_VertexAttrib4fNV(GET_DISPATCH(), (index,x,y,z,w)) -#define ATTRIB1ARB(index,x) CALL_VertexAttrib1fARB(GET_DISPATCH(), (index,x)) -#define ATTRIB2ARB(index,x,y) CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,x,y)) -#define ATTRIB3ARB(index,x,y,z) CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,x,y,z)) -#define ATTRIB4ARB(index,x,y,z,w) CALL_VertexAttrib4fARB(GET_DISPATCH(), (index,x,y,z,w)) -#define FOGCOORDF(x) CALL_FogCoordfEXT(GET_DISPATCH(), (x)) -#define SECONDARYCOLORF(a,b,c) CALL_SecondaryColor3fEXT(GET_DISPATCH(), (a,b,c)) - - -#if FEATURE_beginend - - -static void GLAPIENTRY -loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue ) -{ - COLORF( BYTE_TO_FLOAT(red), - BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue), - 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3d_f( GLdouble red, GLdouble green, GLdouble blue ) -{ - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3i_f( GLint red, GLint green, GLint blue ) -{ - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), - INT_TO_FLOAT(blue), 1.0); -} - -static void GLAPIENTRY -loopback_Color3s_f( GLshort red, GLshort green, GLshort blue ) -{ - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue), 1.0); -} - -static void GLAPIENTRY -loopback_Color3ui_f( GLuint red, GLuint green, GLuint blue ) -{ - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3us_f( GLushort red, GLushort green, GLushort blue ) -{ - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3ub_f( GLubyte red, GLubyte green, GLubyte blue ) -{ - COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue), 1.0 ); -} - - -static void GLAPIENTRY -loopback_Color3bv_f( const GLbyte *v ) -{ - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3dv_f( const GLdouble *v ) -{ - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3iv_f( const GLint *v ) -{ - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3sv_f( const GLshort *v ) -{ - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3uiv_f( const GLuint *v ) -{ - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3usv_f( const GLushort *v ) -{ - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), 1.0 ); -} - -static void GLAPIENTRY -loopback_Color3ubv_f( const GLubyte *v ) -{ - COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), 1.0 ); -} - - -static void GLAPIENTRY -loopback_Color4b_f( GLbyte red, GLbyte green, GLbyte blue, - GLbyte alpha ) -{ - COLORF( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4d_f( GLdouble red, GLdouble green, GLdouble blue, - GLdouble alpha ) -{ - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha ); -} - -static void GLAPIENTRY -loopback_Color4i_f( GLint red, GLint green, GLint blue, GLint alpha ) -{ - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), - INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4s_f( GLshort red, GLshort green, GLshort blue, - GLshort alpha ) -{ - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4ui_f( GLuint red, GLuint green, GLuint blue, GLuint alpha ) -{ - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha ) -{ - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) ); -} - -static void GLAPIENTRY -loopback_Color4ub_f( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) -{ - COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha) ); -} - - -static void GLAPIENTRY -loopback_Color4iv_f( const GLint *v ) -{ - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_Color4bv_f( const GLbyte *v ) -{ - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4dv_f( const GLdouble *v ) -{ - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] ); -} - - -static void GLAPIENTRY -loopback_Color4sv_f( const GLshort *v) -{ - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_Color4uiv_f( const GLuint *v) -{ - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4usv_f( const GLushort *v) -{ - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) ); -} - -static void GLAPIENTRY -loopback_Color4ubv_f( const GLubyte *v) -{ - COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]) ); -} - - -static void GLAPIENTRY -loopback_FogCoorddEXT( GLdouble d ) -{ - FOGCOORDF( (GLfloat) d ); -} - -static void GLAPIENTRY -loopback_FogCoorddvEXT( const GLdouble *v ) -{ - FOGCOORDF( (GLfloat) *v ); -} - - -static void GLAPIENTRY -loopback_Indexd( GLdouble c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexi( GLint c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexs( GLshort c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexub( GLubyte c ) -{ - INDEX( (GLfloat) c ); -} - -static void GLAPIENTRY -loopback_Indexdv( const GLdouble *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexiv( const GLint *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexsv( const GLshort *c ) -{ - INDEX( (GLfloat) *c ); -} - -static void GLAPIENTRY -loopback_Indexubv( const GLubyte *c ) -{ - INDEX( (GLfloat) *c ); -} - - -static void GLAPIENTRY -loopback_EdgeFlagv(const GLboolean *flag) -{ - CALL_EdgeFlag(GET_DISPATCH(), (*flag)); -} - - -static void GLAPIENTRY -loopback_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz ) -{ - NORMAL( BYTE_TO_FLOAT(nx), BYTE_TO_FLOAT(ny), BYTE_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz ) -{ - NORMAL((GLfloat) nx, (GLfloat) ny, (GLfloat) nz); -} - -static void GLAPIENTRY -loopback_Normal3i( GLint nx, GLint ny, GLint nz ) -{ - NORMAL( INT_TO_FLOAT(nx), INT_TO_FLOAT(ny), INT_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3s( GLshort nx, GLshort ny, GLshort nz ) -{ - NORMAL( SHORT_TO_FLOAT(nx), SHORT_TO_FLOAT(ny), SHORT_TO_FLOAT(nz) ); -} - -static void GLAPIENTRY -loopback_Normal3bv( const GLbyte *v ) -{ - NORMAL( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_Normal3dv( const GLdouble *v ) -{ - NORMAL( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Normal3iv( const GLint *v ) -{ - NORMAL( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_Normal3sv( const GLshort *v ) -{ - NORMAL( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]) ); -} - -static void GLAPIENTRY -loopback_TexCoord1d( GLdouble s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord1i( GLint s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord1s( GLshort s ) -{ - TEXCOORD1((GLfloat) s); -} - -static void GLAPIENTRY -loopback_TexCoord2d( GLdouble s, GLdouble t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord2s( GLshort s, GLshort t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord2i( GLint s, GLint t ) -{ - TEXCOORD2((GLfloat) s,(GLfloat) t); -} - -static void GLAPIENTRY -loopback_TexCoord3d( GLdouble s, GLdouble t, GLdouble r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord3i( GLint s, GLint t, GLint r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord3s( GLshort s, GLshort t, GLshort r ) -{ - TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); -} - -static void GLAPIENTRY -loopback_TexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord4i( GLint s, GLint t, GLint r, GLint q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) -{ - TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); -} - -static void GLAPIENTRY -loopback_TexCoord1dv( const GLdouble *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord1iv( const GLint *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord1sv( const GLshort *v ) -{ - TEXCOORD1((GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_TexCoord2dv( const GLdouble *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord2iv( const GLint *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord2sv( const GLshort *v ) -{ - TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_TexCoord3dv( const GLdouble *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord3iv( const GLint *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord3sv( const GLshort *v ) -{ - TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_TexCoord4dv( const GLdouble *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_TexCoord4iv( const GLint *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_TexCoord4sv( const GLshort *v ) -{ - TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_Vertex2d( GLdouble x, GLdouble y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex2i( GLint x, GLint y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex2s( GLshort x, GLshort y ) -{ - VERTEX2( (GLfloat) x, (GLfloat) y ); -} - -static void GLAPIENTRY -loopback_Vertex3d( GLdouble x, GLdouble y, GLdouble z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex3i( GLint x, GLint y, GLint z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex3s( GLshort x, GLshort y, GLshort z ) -{ - VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); -} - -static void GLAPIENTRY -loopback_Vertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex4i( GLint x, GLint y, GLint z, GLint w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) -{ - VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); -} - -static void GLAPIENTRY -loopback_Vertex2dv( const GLdouble *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex2iv( const GLint *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex2sv( const GLshort *v ) -{ - VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_Vertex3dv( const GLdouble *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex3iv( const GLint *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex3sv( const GLshort *v ) -{ - VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_Vertex4dv( const GLdouble *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_Vertex4iv( const GLint *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_Vertex4sv( const GLshort *v ) -{ - VERTEX4( (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1dARB(GLenum target, GLdouble s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1iARB(GLenum target, GLint s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1sARB(GLenum target, GLshort s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2iARB(GLenum target, GLint s, GLint t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2sARB(GLenum target, GLshort s, GLshort t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2dv( const GLdouble *u ) -{ - EVALCOORD2( (GLfloat) u[0], (GLfloat) u[1] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2fv( const GLfloat *u ) -{ - EVALCOORD2( u[0], u[1] ); -} - -static void GLAPIENTRY -loopback_EvalCoord2d( GLdouble u, GLdouble v ) -{ - EVALCOORD2( (GLfloat) u, (GLfloat) v ); -} - -static void GLAPIENTRY -loopback_EvalCoord1dv( const GLdouble *u ) -{ - EVALCOORD1( (GLfloat) *u ); -} - -static void GLAPIENTRY -loopback_EvalCoord1fv( const GLfloat *u ) -{ - EVALCOORD1( (GLfloat) *u ); -} - -static void GLAPIENTRY -loopback_EvalCoord1d( GLdouble u ) -{ - EVALCOORD1( (GLfloat) u ); -} - -static void GLAPIENTRY -loopback_Materialf( GLenum face, GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - MATERIALFV( face, pname, fparam ); -} - -static void GLAPIENTRY -loopback_Materiali(GLenum face, GLenum pname, GLint param ) -{ - GLfloat p = (GLfloat) param; - MATERIALFV(face, pname, &p); -} - -static void GLAPIENTRY -loopback_Materialiv(GLenum face, GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: - case GL_AMBIENT_AND_DIFFUSE: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_SHININESS: - fparam[0] = (GLfloat) params[0]; - break; - case GL_COLOR_INDEXES: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - default: - ; - } - MATERIALFV(face, pname, fparam); -} - - -static void GLAPIENTRY -loopback_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectdv(const GLdouble *v1, const GLdouble *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - -static void GLAPIENTRY -loopback_Rectfv(const GLfloat *v1, const GLfloat *v2) -{ - RECTF(v1[0], v1[1], v2[0], v2[1]); -} - -static void GLAPIENTRY -loopback_Recti(GLint x1, GLint y1, GLint x2, GLint y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectiv(const GLint *v1, const GLint *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - -static void GLAPIENTRY -loopback_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) -{ - RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); -} - -static void GLAPIENTRY -loopback_Rectsv(const GLshort *v1, const GLshort *v2) -{ - RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); -} - -static void GLAPIENTRY -loopback_SecondaryColor3bEXT_f( GLbyte red, GLbyte green, GLbyte blue ) -{ - SECONDARYCOLORF( BYTE_TO_FLOAT(red), - BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue) ); -} - -static void GLAPIENTRY -loopback_SecondaryColor3dEXT_f( GLdouble red, GLdouble green, GLdouble blue ) -{ - SECONDARYCOLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue ); -} - -static void GLAPIENTRY -loopback_SecondaryColor3iEXT_f( GLint red, GLint green, GLint blue ) -{ - SECONDARYCOLORF( INT_TO_FLOAT(red), - INT_TO_FLOAT(green), - INT_TO_FLOAT(blue)); -} - -static void GLAPIENTRY -loopback_SecondaryColor3sEXT_f( GLshort red, GLshort green, GLshort blue ) -{ - SECONDARYCOLORF(SHORT_TO_FLOAT(red), - SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue)); -} - -static void GLAPIENTRY -loopback_SecondaryColor3uiEXT_f( GLuint red, GLuint green, GLuint blue ) -{ - SECONDARYCOLORF(UINT_TO_FLOAT(red), - UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue)); -} - -static void GLAPIENTRY -loopback_SecondaryColor3usEXT_f( GLushort red, GLushort green, GLushort blue ) -{ - SECONDARYCOLORF(USHORT_TO_FLOAT(red), - USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue)); -} - -static void GLAPIENTRY -loopback_SecondaryColor3ubEXT_f( GLubyte red, GLubyte green, GLubyte blue ) -{ - SECONDARYCOLORF(UBYTE_TO_FLOAT(red), - UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue)); -} - -static void GLAPIENTRY -loopback_SecondaryColor3bvEXT_f( const GLbyte *v ) -{ - SECONDARYCOLORF(BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2])); -} - -static void GLAPIENTRY -loopback_SecondaryColor3dvEXT_f( const GLdouble *v ) -{ - SECONDARYCOLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} -static void GLAPIENTRY -loopback_SecondaryColor3ivEXT_f( const GLint *v ) -{ - SECONDARYCOLORF(INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2])); -} - -static void GLAPIENTRY -loopback_SecondaryColor3svEXT_f( const GLshort *v ) -{ - SECONDARYCOLORF(SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2])); -} - -static void GLAPIENTRY -loopback_SecondaryColor3uivEXT_f( const GLuint *v ) -{ - SECONDARYCOLORF(UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2])); -} - -static void GLAPIENTRY -loopback_SecondaryColor3usvEXT_f( const GLushort *v ) -{ - SECONDARYCOLORF(USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2])); -} - -static void GLAPIENTRY -loopback_SecondaryColor3ubvEXT_f( const GLubyte *v ) -{ - SECONDARYCOLORF(UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2])); -} - - -/* - * GL_NV_vertex_program: - * Always loop-back to one of the VertexAttrib[1234]f[v]NV functions. - */ - -static void GLAPIENTRY -loopback_VertexAttrib1sNV(GLuint index, GLshort x) -{ - ATTRIB1NV(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dNV(GLuint index, GLdouble x) -{ - ATTRIB1NV(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib2sNV(GLuint index, GLshort x, GLshort y) -{ - ATTRIB2NV(index, (GLfloat) x, y); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y) -{ - ATTRIB2NV(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z) -{ - ATTRIB3NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -loopback_VertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) -{ - ATTRIB4NV(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), - UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); -} - -static void GLAPIENTRY -loopback_VertexAttrib1svNV(GLuint index, const GLshort *v) -{ - ATTRIB1NV(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB1NV(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2svNV(GLuint index, const GLshort *v) -{ - ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3svNV(GLuint index, const GLshort *v) -{ - ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4svNV(GLuint index, const GLshort *v) -{ - ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], - (GLfloat)v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dvNV(GLuint index, const GLdouble *v) -{ - ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - ATTRIB4NV(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); -} - - -static void GLAPIENTRY -loopback_VertexAttribs1svNV(GLuint index, GLsizei n, const GLshort *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib1svNV(index + i, v + i); -} - -static void GLAPIENTRY -loopback_VertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - ATTRIB1NV(index + i, v[i]); -} - -static void GLAPIENTRY -loopback_VertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib1dvNV(index + i, v + i); -} - -static void GLAPIENTRY -loopback_VertexAttribs2svNV(GLuint index, GLsizei n, const GLshort *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib2svNV(index + i, v + 2 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - ATTRIB2NV(index + i, v[2 * i], v[2 * i + 1]); -} - -static void GLAPIENTRY -loopback_VertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib2dvNV(index + i, v + 2 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs3svNV(GLuint index, GLsizei n, const GLshort *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib3svNV(index + i, v + 3 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - ATTRIB3NV(index + i, v[3 * i], v[3 * i + 1], v[3 * i + 2]); -} - -static void GLAPIENTRY -loopback_VertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib3dvNV(index + i, v + 3 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs4svNV(GLuint index, GLsizei n, const GLshort *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib4svNV(index + i, v + 4 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - ATTRIB4NV(index + i, v[4 * i], v[4 * i + 1], v[4 * i + 2], v[4 * i + 3]); -} - -static void GLAPIENTRY -loopback_VertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib4dvNV(index + i, v + 4 * i); -} - -static void GLAPIENTRY -loopback_VertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) -{ - GLint i; - for (i = n - 1; i >= 0; i--) - loopback_VertexAttrib4ubvNV(index + i, v + 4 * i); -} - - -/* - * GL_ARB_vertex_program - * Always loop-back to one of the VertexAttrib[1234]f[v]ARB functions. - */ - -static void GLAPIENTRY -loopback_VertexAttrib1sARB(GLuint index, GLshort x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dARB(GLuint index, GLdouble x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y) -{ - ATTRIB2ARB(index, (GLfloat) x, y); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) -{ - ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) -{ - ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -loopback_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib1svARB(GLuint index, const GLshort *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2svARB(GLuint index, const GLshort *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3svARB(GLuint index, const GLshort *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4svARB(GLuint index, const GLshort *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], - (GLfloat)v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4bvARB(GLuint index, const GLbyte * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ivARB(GLuint index, const GLint * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubvARB(GLuint index, const GLubyte * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4usvARB(GLuint index, const GLushort * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4uivARB(GLuint index, const GLuint * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NbvARB(GLuint index, const GLbyte * v) -{ - ATTRIB4ARB(index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NsvARB(GLuint index, const GLshort * v) -{ - ATTRIB4ARB(index, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NivARB(GLuint index, const GLint * v) -{ - ATTRIB4ARB(index, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) -{ - ATTRIB4ARB(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), - UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NubvARB(GLuint index, const GLubyte * v) -{ - ATTRIB4ARB(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NusvARB(GLuint index, const GLushort * v) -{ - ATTRIB4ARB(index, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NuivARB(GLuint index, const GLuint * v) -{ - ATTRIB4ARB(index, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3])); -} - - - -/** GL 3.0 Integer-valued attributes **/ - -static void GLAPIENTRY -loopback_VertexAttribI1i(GLuint index, GLint x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttribI2i(GLuint index, GLint x, GLint y) -{ - ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttribI3i(GLuint index, GLint x, GLint y, GLint z) -{ - ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttribI1ui(GLuint index, GLuint x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttribI2ui(GLuint index, GLuint x, GLuint y) -{ - ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttribI3ui(GLuint index, GLuint x, GLuint y, GLuint z) -{ - ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttribI1iv(GLuint index, const GLint *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttribI2iv (GLuint index, const GLint *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttribI3iv(GLuint index, const GLint *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4iv(GLuint index, const GLint *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI1uiv(GLuint index, const GLuint *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttribI2uiv(GLuint index, const GLuint *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttribI3uiv(GLuint index, const GLuint *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4uiv(GLuint index, const GLuint *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4bv(GLuint index, const GLbyte *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4sv(GLuint index, const GLshort *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4ubv(GLuint index, const GLubyte *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4usv(GLuint index, const GLushort *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - - - -/* - * This code never registers handlers for any of the entry points - * listed in vtxfmt.h. - */ -void -_mesa_loopback_init_api_table( struct _glapi_table *dest ) -{ - SET_Color3b(dest, loopback_Color3b_f); - SET_Color3d(dest, loopback_Color3d_f); - SET_Color3i(dest, loopback_Color3i_f); - SET_Color3s(dest, loopback_Color3s_f); - SET_Color3ui(dest, loopback_Color3ui_f); - SET_Color3us(dest, loopback_Color3us_f); - SET_Color3ub(dest, loopback_Color3ub_f); - SET_Color4b(dest, loopback_Color4b_f); - SET_Color4d(dest, loopback_Color4d_f); - SET_Color4i(dest, loopback_Color4i_f); - SET_Color4s(dest, loopback_Color4s_f); - SET_Color4ui(dest, loopback_Color4ui_f); - SET_Color4us(dest, loopback_Color4us_f); - SET_Color4ub(dest, loopback_Color4ub_f); - SET_Color3bv(dest, loopback_Color3bv_f); - SET_Color3dv(dest, loopback_Color3dv_f); - SET_Color3iv(dest, loopback_Color3iv_f); - SET_Color3sv(dest, loopback_Color3sv_f); - SET_Color3uiv(dest, loopback_Color3uiv_f); - SET_Color3usv(dest, loopback_Color3usv_f); - SET_Color3ubv(dest, loopback_Color3ubv_f); - SET_Color4bv(dest, loopback_Color4bv_f); - SET_Color4dv(dest, loopback_Color4dv_f); - SET_Color4iv(dest, loopback_Color4iv_f); - SET_Color4sv(dest, loopback_Color4sv_f); - SET_Color4uiv(dest, loopback_Color4uiv_f); - SET_Color4usv(dest, loopback_Color4usv_f); - SET_Color4ubv(dest, loopback_Color4ubv_f); - - SET_SecondaryColor3bEXT(dest, loopback_SecondaryColor3bEXT_f); - SET_SecondaryColor3dEXT(dest, loopback_SecondaryColor3dEXT_f); - SET_SecondaryColor3iEXT(dest, loopback_SecondaryColor3iEXT_f); - SET_SecondaryColor3sEXT(dest, loopback_SecondaryColor3sEXT_f); - SET_SecondaryColor3uiEXT(dest, loopback_SecondaryColor3uiEXT_f); - SET_SecondaryColor3usEXT(dest, loopback_SecondaryColor3usEXT_f); - SET_SecondaryColor3ubEXT(dest, loopback_SecondaryColor3ubEXT_f); - SET_SecondaryColor3bvEXT(dest, loopback_SecondaryColor3bvEXT_f); - SET_SecondaryColor3dvEXT(dest, loopback_SecondaryColor3dvEXT_f); - SET_SecondaryColor3ivEXT(dest, loopback_SecondaryColor3ivEXT_f); - SET_SecondaryColor3svEXT(dest, loopback_SecondaryColor3svEXT_f); - SET_SecondaryColor3uivEXT(dest, loopback_SecondaryColor3uivEXT_f); - SET_SecondaryColor3usvEXT(dest, loopback_SecondaryColor3usvEXT_f); - SET_SecondaryColor3ubvEXT(dest, loopback_SecondaryColor3ubvEXT_f); - - SET_EdgeFlagv(dest, loopback_EdgeFlagv); - - SET_Indexd(dest, loopback_Indexd); - SET_Indexi(dest, loopback_Indexi); - SET_Indexs(dest, loopback_Indexs); - SET_Indexub(dest, loopback_Indexub); - SET_Indexdv(dest, loopback_Indexdv); - SET_Indexiv(dest, loopback_Indexiv); - SET_Indexsv(dest, loopback_Indexsv); - SET_Indexubv(dest, loopback_Indexubv); - SET_Normal3b(dest, loopback_Normal3b); - SET_Normal3d(dest, loopback_Normal3d); - SET_Normal3i(dest, loopback_Normal3i); - SET_Normal3s(dest, loopback_Normal3s); - SET_Normal3bv(dest, loopback_Normal3bv); - SET_Normal3dv(dest, loopback_Normal3dv); - SET_Normal3iv(dest, loopback_Normal3iv); - SET_Normal3sv(dest, loopback_Normal3sv); - SET_TexCoord1d(dest, loopback_TexCoord1d); - SET_TexCoord1i(dest, loopback_TexCoord1i); - SET_TexCoord1s(dest, loopback_TexCoord1s); - SET_TexCoord2d(dest, loopback_TexCoord2d); - SET_TexCoord2s(dest, loopback_TexCoord2s); - SET_TexCoord2i(dest, loopback_TexCoord2i); - SET_TexCoord3d(dest, loopback_TexCoord3d); - SET_TexCoord3i(dest, loopback_TexCoord3i); - SET_TexCoord3s(dest, loopback_TexCoord3s); - SET_TexCoord4d(dest, loopback_TexCoord4d); - SET_TexCoord4i(dest, loopback_TexCoord4i); - SET_TexCoord4s(dest, loopback_TexCoord4s); - SET_TexCoord1dv(dest, loopback_TexCoord1dv); - SET_TexCoord1iv(dest, loopback_TexCoord1iv); - SET_TexCoord1sv(dest, loopback_TexCoord1sv); - SET_TexCoord2dv(dest, loopback_TexCoord2dv); - SET_TexCoord2iv(dest, loopback_TexCoord2iv); - SET_TexCoord2sv(dest, loopback_TexCoord2sv); - SET_TexCoord3dv(dest, loopback_TexCoord3dv); - SET_TexCoord3iv(dest, loopback_TexCoord3iv); - SET_TexCoord3sv(dest, loopback_TexCoord3sv); - SET_TexCoord4dv(dest, loopback_TexCoord4dv); - SET_TexCoord4iv(dest, loopback_TexCoord4iv); - SET_TexCoord4sv(dest, loopback_TexCoord4sv); - SET_Vertex2d(dest, loopback_Vertex2d); - SET_Vertex2i(dest, loopback_Vertex2i); - SET_Vertex2s(dest, loopback_Vertex2s); - SET_Vertex3d(dest, loopback_Vertex3d); - SET_Vertex3i(dest, loopback_Vertex3i); - SET_Vertex3s(dest, loopback_Vertex3s); - SET_Vertex4d(dest, loopback_Vertex4d); - SET_Vertex4i(dest, loopback_Vertex4i); - SET_Vertex4s(dest, loopback_Vertex4s); - SET_Vertex2dv(dest, loopback_Vertex2dv); - SET_Vertex2iv(dest, loopback_Vertex2iv); - SET_Vertex2sv(dest, loopback_Vertex2sv); - SET_Vertex3dv(dest, loopback_Vertex3dv); - SET_Vertex3iv(dest, loopback_Vertex3iv); - SET_Vertex3sv(dest, loopback_Vertex3sv); - SET_Vertex4dv(dest, loopback_Vertex4dv); - SET_Vertex4iv(dest, loopback_Vertex4iv); - SET_Vertex4sv(dest, loopback_Vertex4sv); - SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB); - SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB); - SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB); - SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB); - SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB); - SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB); - SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB); - SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB); - SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB); - SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB); - SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB); - SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB); - SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB); - SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB); - SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB); - SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB); - SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB); - SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB); - SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB); - SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB); - SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB); - SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB); - SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB); - SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB); - SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); - SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); - SET_EvalCoord2d(dest, loopback_EvalCoord2d); - SET_EvalCoord1dv(dest, loopback_EvalCoord1dv); - SET_EvalCoord1fv(dest, loopback_EvalCoord1fv); - SET_EvalCoord1d(dest, loopback_EvalCoord1d); - SET_Materialf(dest, loopback_Materialf); - SET_Materiali(dest, loopback_Materiali); - SET_Materialiv(dest, loopback_Materialiv); - SET_Rectd(dest, loopback_Rectd); - SET_Rectdv(dest, loopback_Rectdv); - SET_Rectfv(dest, loopback_Rectfv); - SET_Recti(dest, loopback_Recti); - SET_Rectiv(dest, loopback_Rectiv); - SET_Rects(dest, loopback_Rects); - SET_Rectsv(dest, loopback_Rectsv); - SET_FogCoorddEXT(dest, loopback_FogCoorddEXT); - SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT); - - SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV); - SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV); - SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV); - SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV); - SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV); - SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV); - SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV); - SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV); - SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV); - SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV); - SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV); - SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV); - SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV); - SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV); - SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV); - SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV); - SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV); - SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV); - SET_VertexAttribs1svNV(dest, loopback_VertexAttribs1svNV); - SET_VertexAttribs1fvNV(dest, loopback_VertexAttribs1fvNV); - SET_VertexAttribs1dvNV(dest, loopback_VertexAttribs1dvNV); - SET_VertexAttribs2svNV(dest, loopback_VertexAttribs2svNV); - SET_VertexAttribs2fvNV(dest, loopback_VertexAttribs2fvNV); - SET_VertexAttribs2dvNV(dest, loopback_VertexAttribs2dvNV); - SET_VertexAttribs3svNV(dest, loopback_VertexAttribs3svNV); - SET_VertexAttribs3fvNV(dest, loopback_VertexAttribs3fvNV); - SET_VertexAttribs3dvNV(dest, loopback_VertexAttribs3dvNV); - SET_VertexAttribs4svNV(dest, loopback_VertexAttribs4svNV); - SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV); - SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV); - SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV); - - SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB); - SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB); - SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB); - SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB); - SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB); - SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB); - SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB); - SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB); - SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB); - SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB); - SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB); - SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB); - SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB); - SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB); - SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB); - SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB); - SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB); - SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB); - SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB); - SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB); - SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB); - SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB); - SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB); - SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB); - SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB); - SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB); - SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); - SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); - - /* GL 3.0 */ -#if 0 - SET_VertexAttribI1i(dest, loopback_VertexAttribI1i); - SET_VertexAttribI2i(dest, loopback_VertexAttribI2i); - SET_VertexAttribI3i(dest, loopback_VertexAttribI3i); - SET_VertexAttribI4i(dest, loopback_VertexAttribI4i); - SET_VertexAttribI1ui(dest, loopback_VertexAttribI1ui); - SET_VertexAttribI2ui(dest, loopback_VertexAttribI2ui); - SET_VertexAttribI3ui(dest, loopback_VertexAttribI3ui); - SET_VertexAttribI4ui(dest, loopback_VertexAttribI4ui); - SET_VertexAttribI1iv(dest, loopback_VertexAttribI1iv); - SET_VertexAttribI2iv(dest, loopback_VertexAttribI2iv); - SET_VertexAttribI3iv(dest, loopback_VertexAttribI3iv); - SET_VertexAttribI4iv(dest, loopback_VertexAttribI4iv); - SET_VertexAttribI1uiv(dest, loopback_VertexAttribI1uiv); - SET_VertexAttribI2uiv(dest, loopback_VertexAttribI2uiv); - SET_VertexAttribI3uiv(dest, loopback_VertexAttribI3uiv); - SET_VertexAttribI4uiv(dest, loopback_VertexAttribI4uiv); - SET_VertexAttribI4bv(dest, loopback_VertexAttribI4bv); - SET_VertexAttribI4sv(dest, loopback_VertexAttribI4sv); - SET_VertexAttribI4ubv(dest, loopback_VertexAttribI4ubv); - SET_VertexAttribI4usv(dest, loopback_VertexAttribI4usv); -#else - (void) loopback_VertexAttribI1i; - (void) loopback_VertexAttribI2i; - (void) loopback_VertexAttribI3i; - (void) loopback_VertexAttribI4i; - (void) loopback_VertexAttribI1ui; - (void) loopback_VertexAttribI2ui; - (void) loopback_VertexAttribI3ui; - (void) loopback_VertexAttribI4ui; - (void) loopback_VertexAttribI1iv; - (void) loopback_VertexAttribI2iv; - (void) loopback_VertexAttribI3iv; - (void) loopback_VertexAttribI4iv; - (void) loopback_VertexAttribI1uiv; - (void) loopback_VertexAttribI2uiv; - (void) loopback_VertexAttribI3uiv; - (void) loopback_VertexAttribI4uiv; - (void) loopback_VertexAttribI4bv; - (void) loopback_VertexAttribI4sv; - (void) loopback_VertexAttribI4ubv; - (void) loopback_VertexAttribI4usv; -#endif -} - - -#endif /* FEATURE_beginend */ +/** + * \file api_loopback.c + * + * \author Keith Whitwell + */ + +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "macros.h" +#include "api_loopback.h" +#include "mtypes.h" +#include "glapi/glapi.h" +#include "glapi/glthread.h" +#include "main/dispatch.h" +#include "mfeatures.h" + +/* KW: A set of functions to convert unusual Color/Normal/Vertex/etc + * calls to a smaller set of driver-provided formats. Currently just + * go back to dispatch to find these (eg. call glNormal3f directly), + * hence 'loopback'. + * + * The driver must supply all of the remaining entry points, which are + * listed in dd.h. The easiest way for a driver to do this is to + * install the supplied software t&l module. + */ +#define COLORF(r,g,b,a) CALL_Color4f(GET_DISPATCH(), (r,g,b,a)) +#define VERTEX2(x,y) CALL_Vertex2f(GET_DISPATCH(), (x,y)) +#define VERTEX3(x,y,z) CALL_Vertex3f(GET_DISPATCH(), (x,y,z)) +#define VERTEX4(x,y,z,w) CALL_Vertex4f(GET_DISPATCH(), (x,y,z,w)) +#define NORMAL(x,y,z) CALL_Normal3f(GET_DISPATCH(), (x,y,z)) +#define TEXCOORD1(s) CALL_TexCoord1f(GET_DISPATCH(), (s)) +#define TEXCOORD2(s,t) CALL_TexCoord2f(GET_DISPATCH(), (s,t)) +#define TEXCOORD3(s,t,u) CALL_TexCoord3f(GET_DISPATCH(), (s,t,u)) +#define TEXCOORD4(s,t,u,v) CALL_TexCoord4f(GET_DISPATCH(), (s,t,u,v)) +#define INDEX(c) CALL_Indexf(GET_DISPATCH(), (c)) +#define MULTI_TEXCOORD1(z,s) CALL_MultiTexCoord1fARB(GET_DISPATCH(), (z,s)) +#define MULTI_TEXCOORD2(z,s,t) CALL_MultiTexCoord2fARB(GET_DISPATCH(), (z,s,t)) +#define MULTI_TEXCOORD3(z,s,t,u) CALL_MultiTexCoord3fARB(GET_DISPATCH(), (z,s,t,u)) +#define MULTI_TEXCOORD4(z,s,t,u,v) CALL_MultiTexCoord4fARB(GET_DISPATCH(), (z,s,t,u,v)) +#define EVALCOORD1(x) CALL_EvalCoord1f(GET_DISPATCH(), (x)) +#define EVALCOORD2(x,y) CALL_EvalCoord2f(GET_DISPATCH(), (x,y)) +#define MATERIALFV(a,b,c) CALL_Materialfv(GET_DISPATCH(), (a,b,c)) +#define RECTF(a,b,c,d) CALL_Rectf(GET_DISPATCH(), (a,b,c,d)) + +#define FOGCOORDF(x) CALL_FogCoordfEXT(GET_DISPATCH(), (x)) +#define SECONDARYCOLORF(a,b,c) CALL_SecondaryColor3fEXT(GET_DISPATCH(), (a,b,c)) + +#define ATTRIB1NV(index,x) CALL_VertexAttrib1fNV(GET_DISPATCH(), (index,x)) +#define ATTRIB2NV(index,x,y) CALL_VertexAttrib2fNV(GET_DISPATCH(), (index,x,y)) +#define ATTRIB3NV(index,x,y,z) CALL_VertexAttrib3fNV(GET_DISPATCH(), (index,x,y,z)) +#define ATTRIB4NV(index,x,y,z,w) CALL_VertexAttrib4fNV(GET_DISPATCH(), (index,x,y,z,w)) + +#define ATTRIB1ARB(index,x) CALL_VertexAttrib1fARB(GET_DISPATCH(), (index,x)) +#define ATTRIB2ARB(index,x,y) CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,x,y)) +#define ATTRIB3ARB(index,x,y,z) CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,x,y,z)) +#define ATTRIB4ARB(index,x,y,z,w) CALL_VertexAttrib4fARB(GET_DISPATCH(), (index,x,y,z,w)) + +#define ATTRIBI_1I(index,x) CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index,x)) +#define ATTRIBI_1UI(index,x) CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index,x)) +#define ATTRIBI_4I(index,x,y,z,w) CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index,x,y,z,w)) + +#define ATTRIBI_4UI(index,x,y,z,w) CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index,x,y,z,w)) + + +#if FEATURE_beginend + + +static void GLAPIENTRY +loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue ) +{ + COLORF( BYTE_TO_FLOAT(red), + BYTE_TO_FLOAT(green), + BYTE_TO_FLOAT(blue), + 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3d_f( GLdouble red, GLdouble green, GLdouble blue ) +{ + COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3i_f( GLint red, GLint green, GLint blue ) +{ + COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), + INT_TO_FLOAT(blue), 1.0); +} + +static void GLAPIENTRY +loopback_Color3s_f( GLshort red, GLshort green, GLshort blue ) +{ + COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue), 1.0); +} + +static void GLAPIENTRY +loopback_Color3ui_f( GLuint red, GLuint green, GLuint blue ) +{ + COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3us_f( GLushort red, GLushort green, GLushort blue ) +{ + COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3ub_f( GLubyte red, GLubyte green, GLubyte blue ) +{ + COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue), 1.0 ); +} + + +static void GLAPIENTRY +loopback_Color3bv_f( const GLbyte *v ) +{ + COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3dv_f( const GLdouble *v ) +{ + COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3iv_f( const GLint *v ) +{ + COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3sv_f( const GLshort *v ) +{ + COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3uiv_f( const GLuint *v ) +{ + COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3usv_f( const GLushort *v ) +{ + COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), 1.0 ); +} + +static void GLAPIENTRY +loopback_Color3ubv_f( const GLubyte *v ) +{ + COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), 1.0 ); +} + + +static void GLAPIENTRY +loopback_Color4b_f( GLbyte red, GLbyte green, GLbyte blue, + GLbyte alpha ) +{ + COLORF( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), + BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) ); +} + +static void GLAPIENTRY +loopback_Color4d_f( GLdouble red, GLdouble green, GLdouble blue, + GLdouble alpha ) +{ + COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha ); +} + +static void GLAPIENTRY +loopback_Color4i_f( GLint red, GLint green, GLint blue, GLint alpha ) +{ + COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), + INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) ); +} + +static void GLAPIENTRY +loopback_Color4s_f( GLshort red, GLshort green, GLshort blue, + GLshort alpha ) +{ + COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) ); +} + +static void GLAPIENTRY +loopback_Color4ui_f( GLuint red, GLuint green, GLuint blue, GLuint alpha ) +{ + COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) ); +} + +static void GLAPIENTRY +loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha ) +{ + COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) ); +} + +static void GLAPIENTRY +loopback_Color4ub_f( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha) ); +} + + +static void GLAPIENTRY +loopback_Color4iv_f( const GLint *v ) +{ + COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); +} + + +static void GLAPIENTRY +loopback_Color4bv_f( const GLbyte *v ) +{ + COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) ); +} + +static void GLAPIENTRY +loopback_Color4dv_f( const GLdouble *v ) +{ + COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] ); +} + + +static void GLAPIENTRY +loopback_Color4sv_f( const GLshort *v) +{ + COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) ); +} + + +static void GLAPIENTRY +loopback_Color4uiv_f( const GLuint *v) +{ + COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) ); +} + +static void GLAPIENTRY +loopback_Color4usv_f( const GLushort *v) +{ + COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) ); +} + +static void GLAPIENTRY +loopback_Color4ubv_f( const GLubyte *v) +{ + COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]) ); +} + + +static void GLAPIENTRY +loopback_FogCoorddEXT( GLdouble d ) +{ + FOGCOORDF( (GLfloat) d ); +} + +static void GLAPIENTRY +loopback_FogCoorddvEXT( const GLdouble *v ) +{ + FOGCOORDF( (GLfloat) *v ); +} + + +static void GLAPIENTRY +loopback_Indexd( GLdouble c ) +{ + INDEX( (GLfloat) c ); +} + +static void GLAPIENTRY +loopback_Indexi( GLint c ) +{ + INDEX( (GLfloat) c ); +} + +static void GLAPIENTRY +loopback_Indexs( GLshort c ) +{ + INDEX( (GLfloat) c ); +} + +static void GLAPIENTRY +loopback_Indexub( GLubyte c ) +{ + INDEX( (GLfloat) c ); +} + +static void GLAPIENTRY +loopback_Indexdv( const GLdouble *c ) +{ + INDEX( (GLfloat) *c ); +} + +static void GLAPIENTRY +loopback_Indexiv( const GLint *c ) +{ + INDEX( (GLfloat) *c ); +} + +static void GLAPIENTRY +loopback_Indexsv( const GLshort *c ) +{ + INDEX( (GLfloat) *c ); +} + +static void GLAPIENTRY +loopback_Indexubv( const GLubyte *c ) +{ + INDEX( (GLfloat) *c ); +} + + +static void GLAPIENTRY +loopback_EdgeFlagv(const GLboolean *flag) +{ + CALL_EdgeFlag(GET_DISPATCH(), (*flag)); +} + + +static void GLAPIENTRY +loopback_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz ) +{ + NORMAL( BYTE_TO_FLOAT(nx), BYTE_TO_FLOAT(ny), BYTE_TO_FLOAT(nz) ); +} + +static void GLAPIENTRY +loopback_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz ) +{ + NORMAL((GLfloat) nx, (GLfloat) ny, (GLfloat) nz); +} + +static void GLAPIENTRY +loopback_Normal3i( GLint nx, GLint ny, GLint nz ) +{ + NORMAL( INT_TO_FLOAT(nx), INT_TO_FLOAT(ny), INT_TO_FLOAT(nz) ); +} + +static void GLAPIENTRY +loopback_Normal3s( GLshort nx, GLshort ny, GLshort nz ) +{ + NORMAL( SHORT_TO_FLOAT(nx), SHORT_TO_FLOAT(ny), SHORT_TO_FLOAT(nz) ); +} + +static void GLAPIENTRY +loopback_Normal3bv( const GLbyte *v ) +{ + NORMAL( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]) ); +} + +static void GLAPIENTRY +loopback_Normal3dv( const GLdouble *v ) +{ + NORMAL( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_Normal3iv( const GLint *v ) +{ + NORMAL( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]) ); +} + +static void GLAPIENTRY +loopback_Normal3sv( const GLshort *v ) +{ + NORMAL( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]) ); +} + +static void GLAPIENTRY +loopback_TexCoord1d( GLdouble s ) +{ + TEXCOORD1((GLfloat) s); +} + +static void GLAPIENTRY +loopback_TexCoord1i( GLint s ) +{ + TEXCOORD1((GLfloat) s); +} + +static void GLAPIENTRY +loopback_TexCoord1s( GLshort s ) +{ + TEXCOORD1((GLfloat) s); +} + +static void GLAPIENTRY +loopback_TexCoord2d( GLdouble s, GLdouble t ) +{ + TEXCOORD2((GLfloat) s,(GLfloat) t); +} + +static void GLAPIENTRY +loopback_TexCoord2s( GLshort s, GLshort t ) +{ + TEXCOORD2((GLfloat) s,(GLfloat) t); +} + +static void GLAPIENTRY +loopback_TexCoord2i( GLint s, GLint t ) +{ + TEXCOORD2((GLfloat) s,(GLfloat) t); +} + +static void GLAPIENTRY +loopback_TexCoord3d( GLdouble s, GLdouble t, GLdouble r ) +{ + TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); +} + +static void GLAPIENTRY +loopback_TexCoord3i( GLint s, GLint t, GLint r ) +{ + TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); +} + +static void GLAPIENTRY +loopback_TexCoord3s( GLshort s, GLshort t, GLshort r ) +{ + TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r); +} + +static void GLAPIENTRY +loopback_TexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) +{ + TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); +} + +static void GLAPIENTRY +loopback_TexCoord4i( GLint s, GLint t, GLint r, GLint q ) +{ + TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); +} + +static void GLAPIENTRY +loopback_TexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) +{ + TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q); +} + +static void GLAPIENTRY +loopback_TexCoord1dv( const GLdouble *v ) +{ + TEXCOORD1((GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_TexCoord1iv( const GLint *v ) +{ + TEXCOORD1((GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_TexCoord1sv( const GLshort *v ) +{ + TEXCOORD1((GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_TexCoord2dv( const GLdouble *v ) +{ + TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_TexCoord2iv( const GLint *v ) +{ + TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_TexCoord2sv( const GLshort *v ) +{ + TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_TexCoord3dv( const GLdouble *v ) +{ + TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_TexCoord3iv( const GLint *v ) +{ + TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_TexCoord3sv( const GLshort *v ) +{ + TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_TexCoord4dv( const GLdouble *v ) +{ + TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_TexCoord4iv( const GLint *v ) +{ + TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_TexCoord4sv( const GLshort *v ) +{ + TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_Vertex2d( GLdouble x, GLdouble y ) +{ + VERTEX2( (GLfloat) x, (GLfloat) y ); +} + +static void GLAPIENTRY +loopback_Vertex2i( GLint x, GLint y ) +{ + VERTEX2( (GLfloat) x, (GLfloat) y ); +} + +static void GLAPIENTRY +loopback_Vertex2s( GLshort x, GLshort y ) +{ + VERTEX2( (GLfloat) x, (GLfloat) y ); +} + +static void GLAPIENTRY +loopback_Vertex3d( GLdouble x, GLdouble y, GLdouble z ) +{ + VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + +static void GLAPIENTRY +loopback_Vertex3i( GLint x, GLint y, GLint z ) +{ + VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + +static void GLAPIENTRY +loopback_Vertex3s( GLshort x, GLshort y, GLshort z ) +{ + VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z ); +} + +static void GLAPIENTRY +loopback_Vertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) +{ + VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); +} + +static void GLAPIENTRY +loopback_Vertex4i( GLint x, GLint y, GLint z, GLint w ) +{ + VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); +} + +static void GLAPIENTRY +loopback_Vertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) +{ + VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w ); +} + +static void GLAPIENTRY +loopback_Vertex2dv( const GLdouble *v ) +{ + VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_Vertex2iv( const GLint *v ) +{ + VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_Vertex2sv( const GLshort *v ) +{ + VERTEX2( (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_Vertex3dv( const GLdouble *v ) +{ + VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_Vertex3iv( const GLint *v ) +{ + VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_Vertex3sv( const GLshort *v ) +{ + VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_Vertex4dv( const GLdouble *v ) +{ + VERTEX4( (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_Vertex4iv( const GLint *v ) +{ + VERTEX4( (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_Vertex4sv( const GLshort *v ) +{ + VERTEX4( (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1dARB(GLenum target, GLdouble s) +{ + MULTI_TEXCOORD1( target, (GLfloat) s ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1dvARB(GLenum target, const GLdouble *v) +{ + MULTI_TEXCOORD1( target, (GLfloat) v[0] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1iARB(GLenum target, GLint s) +{ + MULTI_TEXCOORD1( target, (GLfloat) s ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1ivARB(GLenum target, const GLint *v) +{ + MULTI_TEXCOORD1( target, (GLfloat) v[0] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1sARB(GLenum target, GLshort s) +{ + MULTI_TEXCOORD1( target, (GLfloat) s ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord1svARB(GLenum target, const GLshort *v) +{ + MULTI_TEXCOORD1( target, (GLfloat) v[0] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t) +{ + MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2dvARB(GLenum target, const GLdouble *v) +{ + MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2iARB(GLenum target, GLint s, GLint t) +{ + MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2ivARB(GLenum target, const GLint *v) +{ + MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2sARB(GLenum target, GLshort s, GLshort t) +{ + MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord2svARB(GLenum target, const GLshort *v) +{ + MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r) +{ + MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3dvARB(GLenum target, const GLdouble *v) +{ + MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r) +{ + MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3ivARB(GLenum target, const GLint *v) +{ + MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r) +{ + MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord3svARB(GLenum target, const GLshort *v) +{ + MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) +{ + MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4dvARB(GLenum target, const GLdouble *v) +{ + MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q) +{ + MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4ivARB(GLenum target, const GLint *v) +{ + MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) +{ + MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, + (GLfloat) r, (GLfloat) q ); +} + +static void GLAPIENTRY +loopback_MultiTexCoord4svARB(GLenum target, const GLshort *v) +{ + MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3] ); +} + +static void GLAPIENTRY +loopback_EvalCoord2dv( const GLdouble *u ) +{ + EVALCOORD2( (GLfloat) u[0], (GLfloat) u[1] ); +} + +static void GLAPIENTRY +loopback_EvalCoord2fv( const GLfloat *u ) +{ + EVALCOORD2( u[0], u[1] ); +} + +static void GLAPIENTRY +loopback_EvalCoord2d( GLdouble u, GLdouble v ) +{ + EVALCOORD2( (GLfloat) u, (GLfloat) v ); +} + +static void GLAPIENTRY +loopback_EvalCoord1dv( const GLdouble *u ) +{ + EVALCOORD1( (GLfloat) *u ); +} + +static void GLAPIENTRY +loopback_EvalCoord1fv( const GLfloat *u ) +{ + EVALCOORD1( (GLfloat) *u ); +} + +static void GLAPIENTRY +loopback_EvalCoord1d( GLdouble u ) +{ + EVALCOORD1( (GLfloat) u ); +} + +static void GLAPIENTRY +loopback_Materialf( GLenum face, GLenum pname, GLfloat param ) +{ + GLfloat fparam[4]; + fparam[0] = param; + MATERIALFV( face, pname, fparam ); +} + +static void GLAPIENTRY +loopback_Materiali(GLenum face, GLenum pname, GLint param ) +{ + GLfloat p = (GLfloat) param; + MATERIALFV(face, pname, &p); +} + +static void GLAPIENTRY +loopback_Materialiv(GLenum face, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_AMBIENT_AND_DIFFUSE: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_SHININESS: + fparam[0] = (GLfloat) params[0]; + break; + case GL_COLOR_INDEXES: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + default: + ; + } + MATERIALFV(face, pname, fparam); +} + + +static void GLAPIENTRY +loopback_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) +{ + RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); +} + +static void GLAPIENTRY +loopback_Rectdv(const GLdouble *v1, const GLdouble *v2) +{ + RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); +} + +static void GLAPIENTRY +loopback_Rectfv(const GLfloat *v1, const GLfloat *v2) +{ + RECTF(v1[0], v1[1], v2[0], v2[1]); +} + +static void GLAPIENTRY +loopback_Recti(GLint x1, GLint y1, GLint x2, GLint y2) +{ + RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); +} + +static void GLAPIENTRY +loopback_Rectiv(const GLint *v1, const GLint *v2) +{ + RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); +} + +static void GLAPIENTRY +loopback_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) +{ + RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2); +} + +static void GLAPIENTRY +loopback_Rectsv(const GLshort *v1, const GLshort *v2) +{ + RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]); +} + +static void GLAPIENTRY +loopback_SecondaryColor3bEXT_f( GLbyte red, GLbyte green, GLbyte blue ) +{ + SECONDARYCOLORF( BYTE_TO_FLOAT(red), + BYTE_TO_FLOAT(green), + BYTE_TO_FLOAT(blue) ); +} + +static void GLAPIENTRY +loopback_SecondaryColor3dEXT_f( GLdouble red, GLdouble green, GLdouble blue ) +{ + SECONDARYCOLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue ); +} + +static void GLAPIENTRY +loopback_SecondaryColor3iEXT_f( GLint red, GLint green, GLint blue ) +{ + SECONDARYCOLORF( INT_TO_FLOAT(red), + INT_TO_FLOAT(green), + INT_TO_FLOAT(blue)); +} + +static void GLAPIENTRY +loopback_SecondaryColor3sEXT_f( GLshort red, GLshort green, GLshort blue ) +{ + SECONDARYCOLORF(SHORT_TO_FLOAT(red), + SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue)); +} + +static void GLAPIENTRY +loopback_SecondaryColor3uiEXT_f( GLuint red, GLuint green, GLuint blue ) +{ + SECONDARYCOLORF(UINT_TO_FLOAT(red), + UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue)); +} + +static void GLAPIENTRY +loopback_SecondaryColor3usEXT_f( GLushort red, GLushort green, GLushort blue ) +{ + SECONDARYCOLORF(USHORT_TO_FLOAT(red), + USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue)); +} + +static void GLAPIENTRY +loopback_SecondaryColor3ubEXT_f( GLubyte red, GLubyte green, GLubyte blue ) +{ + SECONDARYCOLORF(UBYTE_TO_FLOAT(red), + UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue)); +} + +static void GLAPIENTRY +loopback_SecondaryColor3bvEXT_f( const GLbyte *v ) +{ + SECONDARYCOLORF(BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2])); +} + +static void GLAPIENTRY +loopback_SecondaryColor3dvEXT_f( const GLdouble *v ) +{ + SECONDARYCOLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); +} +static void GLAPIENTRY +loopback_SecondaryColor3ivEXT_f( const GLint *v ) +{ + SECONDARYCOLORF(INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2])); +} + +static void GLAPIENTRY +loopback_SecondaryColor3svEXT_f( const GLshort *v ) +{ + SECONDARYCOLORF(SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2])); +} + +static void GLAPIENTRY +loopback_SecondaryColor3uivEXT_f( const GLuint *v ) +{ + SECONDARYCOLORF(UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2])); +} + +static void GLAPIENTRY +loopback_SecondaryColor3usvEXT_f( const GLushort *v ) +{ + SECONDARYCOLORF(USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2])); +} + +static void GLAPIENTRY +loopback_SecondaryColor3ubvEXT_f( const GLubyte *v ) +{ + SECONDARYCOLORF(UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2])); +} + + +/* + * GL_NV_vertex_program: + * Always loop-back to one of the VertexAttrib[1234]f[v]NV functions. + * Note that attribute indexes DO alias conventional vertex attributes. + */ + +static void GLAPIENTRY +loopback_VertexAttrib1sNV(GLuint index, GLshort x) +{ + ATTRIB1NV(index, (GLfloat) x); +} + +static void GLAPIENTRY +loopback_VertexAttrib1dNV(GLuint index, GLdouble x) +{ + ATTRIB1NV(index, (GLfloat) x); +} + +static void GLAPIENTRY +loopback_VertexAttrib2sNV(GLuint index, GLshort x, GLshort y) +{ + ATTRIB2NV(index, (GLfloat) x, y); +} + +static void GLAPIENTRY +loopback_VertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y) +{ + ATTRIB2NV(index, (GLfloat) x, (GLfloat) y); +} + +static void GLAPIENTRY +loopback_VertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z) +{ + ATTRIB3NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + +static void GLAPIENTRY +loopback_VertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z) +{ + ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +loopback_VertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) +{ + ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +loopback_VertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +loopback_VertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) +{ + ATTRIB4NV(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), + UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); +} + +static void GLAPIENTRY +loopback_VertexAttrib1svNV(GLuint index, const GLshort *v) +{ + ATTRIB1NV(index, (GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttrib1dvNV(GLuint index, const GLdouble *v) +{ + ATTRIB1NV(index, (GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttrib2svNV(GLuint index, const GLshort *v) +{ + ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_VertexAttrib2dvNV(GLuint index, const GLdouble *v) +{ + ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_VertexAttrib3svNV(GLuint index, const GLshort *v) +{ + ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_VertexAttrib3dvNV(GLuint index, const GLdouble *v) +{ + ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4svNV(GLuint index, const GLshort *v) +{ + ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + (GLfloat)v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4dvNV(GLuint index, const GLdouble *v) +{ + ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4ubvNV(GLuint index, const GLubyte *v) +{ + ATTRIB4NV(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); +} + + +static void GLAPIENTRY +loopback_VertexAttribs1svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib1svNV(index + i, v + i); +} + +static void GLAPIENTRY +loopback_VertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + ATTRIB1NV(index + i, v[i]); +} + +static void GLAPIENTRY +loopback_VertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib1dvNV(index + i, v + i); +} + +static void GLAPIENTRY +loopback_VertexAttribs2svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib2svNV(index + i, v + 2 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + ATTRIB2NV(index + i, v[2 * i], v[2 * i + 1]); +} + +static void GLAPIENTRY +loopback_VertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib2dvNV(index + i, v + 2 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs3svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib3svNV(index + i, v + 3 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + ATTRIB3NV(index + i, v[3 * i], v[3 * i + 1], v[3 * i + 2]); +} + +static void GLAPIENTRY +loopback_VertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib3dvNV(index + i, v + 3 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs4svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib4svNV(index + i, v + 4 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + ATTRIB4NV(index + i, v[4 * i], v[4 * i + 1], v[4 * i + 2], v[4 * i + 3]); +} + +static void GLAPIENTRY +loopback_VertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib4dvNV(index + i, v + 4 * i); +} + +static void GLAPIENTRY +loopback_VertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) +{ + GLint i; + for (i = n - 1; i >= 0; i--) + loopback_VertexAttrib4ubvNV(index + i, v + 4 * i); +} + + +/* + * GL_ARB_vertex_program + * Always loop-back to one of the VertexAttrib[1234]f[v]ARB functions. + * Note that attribute indexes do NOT alias conventional attributes. + */ + +static void GLAPIENTRY +loopback_VertexAttrib1sARB(GLuint index, GLshort x) +{ + ATTRIB1ARB(index, (GLfloat) x); +} + +static void GLAPIENTRY +loopback_VertexAttrib1dARB(GLuint index, GLdouble x) +{ + ATTRIB1ARB(index, (GLfloat) x); +} + +static void GLAPIENTRY +loopback_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y) +{ + ATTRIB2ARB(index, (GLfloat) x, y); +} + +static void GLAPIENTRY +loopback_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) +{ + ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y); +} + +static void GLAPIENTRY +loopback_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) +{ + ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + +static void GLAPIENTRY +loopback_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z) +{ + ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +loopback_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) +{ + ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +loopback_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +loopback_VertexAttrib1svARB(GLuint index, const GLshort *v) +{ + ATTRIB1ARB(index, (GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttrib1dvARB(GLuint index, const GLdouble *v) +{ + ATTRIB1ARB(index, (GLfloat) v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttrib2svARB(GLuint index, const GLshort *v) +{ + ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_VertexAttrib2dvARB(GLuint index, const GLdouble *v) +{ + ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); +} + +static void GLAPIENTRY +loopback_VertexAttrib3svARB(GLuint index, const GLshort *v) +{ + ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_VertexAttrib3dvARB(GLuint index, const GLdouble *v) +{ + ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4svARB(GLuint index, const GLshort *v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + (GLfloat)v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4dvARB(GLuint index, const GLdouble *v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4bvARB(GLuint index, const GLbyte * v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4ivARB(GLuint index, const GLint * v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4ubvARB(GLuint index, const GLubyte * v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4usvARB(GLuint index, const GLushort * v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4uivARB(GLuint index, const GLuint * v) +{ + ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NbvARB(GLuint index, const GLbyte * v) +{ + ATTRIB4ARB(index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3])); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NsvARB(GLuint index, const GLshort * v) +{ + ATTRIB4ARB(index, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3])); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NivARB(GLuint index, const GLint * v) +{ + ATTRIB4ARB(index, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3])); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) +{ + ATTRIB4ARB(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), + UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NubvARB(GLuint index, const GLubyte * v) +{ + ATTRIB4ARB(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NusvARB(GLuint index, const GLushort * v) +{ + ATTRIB4ARB(index, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3])); +} + +static void GLAPIENTRY +loopback_VertexAttrib4NuivARB(GLuint index, const GLuint * v) +{ + ATTRIB4ARB(index, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3])); +} + + + +/** + * GL_EXT_gpu_shader / GL 3.0 signed/unsigned integer-valued attributes. + * Note that attribute indexes do NOT alias conventional attributes. + */ + +static void GLAPIENTRY +loopback_VertexAttribI1iv(GLuint index, const GLint *v) +{ + ATTRIBI_1I(index, v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttribI1uiv(GLuint index, const GLuint *v) +{ + ATTRIBI_1UI(index, v[0]); +} + +static void GLAPIENTRY +loopback_VertexAttribI4bv(GLuint index, const GLbyte *v) +{ + ATTRIBI_4I(index, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttribI4sv(GLuint index, const GLshort *v) +{ + ATTRIBI_4I(index, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttribI4ubv(GLuint index, const GLubyte *v) +{ + ATTRIBI_4UI(index, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +loopback_VertexAttribI4usv(GLuint index, const GLushort *v) +{ + ATTRIBI_4UI(index, v[0], v[1], v[2], v[3]); +} + + + + +/* + * This code never registers handlers for any of the entry points + * listed in vtxfmt.h. + */ +void +_mesa_loopback_init_api_table( struct _glapi_table *dest ) +{ + SET_Color3b(dest, loopback_Color3b_f); + SET_Color3d(dest, loopback_Color3d_f); + SET_Color3i(dest, loopback_Color3i_f); + SET_Color3s(dest, loopback_Color3s_f); + SET_Color3ui(dest, loopback_Color3ui_f); + SET_Color3us(dest, loopback_Color3us_f); + SET_Color3ub(dest, loopback_Color3ub_f); + SET_Color4b(dest, loopback_Color4b_f); + SET_Color4d(dest, loopback_Color4d_f); + SET_Color4i(dest, loopback_Color4i_f); + SET_Color4s(dest, loopback_Color4s_f); + SET_Color4ui(dest, loopback_Color4ui_f); + SET_Color4us(dest, loopback_Color4us_f); + SET_Color4ub(dest, loopback_Color4ub_f); + SET_Color3bv(dest, loopback_Color3bv_f); + SET_Color3dv(dest, loopback_Color3dv_f); + SET_Color3iv(dest, loopback_Color3iv_f); + SET_Color3sv(dest, loopback_Color3sv_f); + SET_Color3uiv(dest, loopback_Color3uiv_f); + SET_Color3usv(dest, loopback_Color3usv_f); + SET_Color3ubv(dest, loopback_Color3ubv_f); + SET_Color4bv(dest, loopback_Color4bv_f); + SET_Color4dv(dest, loopback_Color4dv_f); + SET_Color4iv(dest, loopback_Color4iv_f); + SET_Color4sv(dest, loopback_Color4sv_f); + SET_Color4uiv(dest, loopback_Color4uiv_f); + SET_Color4usv(dest, loopback_Color4usv_f); + SET_Color4ubv(dest, loopback_Color4ubv_f); + + SET_SecondaryColor3bEXT(dest, loopback_SecondaryColor3bEXT_f); + SET_SecondaryColor3dEXT(dest, loopback_SecondaryColor3dEXT_f); + SET_SecondaryColor3iEXT(dest, loopback_SecondaryColor3iEXT_f); + SET_SecondaryColor3sEXT(dest, loopback_SecondaryColor3sEXT_f); + SET_SecondaryColor3uiEXT(dest, loopback_SecondaryColor3uiEXT_f); + SET_SecondaryColor3usEXT(dest, loopback_SecondaryColor3usEXT_f); + SET_SecondaryColor3ubEXT(dest, loopback_SecondaryColor3ubEXT_f); + SET_SecondaryColor3bvEXT(dest, loopback_SecondaryColor3bvEXT_f); + SET_SecondaryColor3dvEXT(dest, loopback_SecondaryColor3dvEXT_f); + SET_SecondaryColor3ivEXT(dest, loopback_SecondaryColor3ivEXT_f); + SET_SecondaryColor3svEXT(dest, loopback_SecondaryColor3svEXT_f); + SET_SecondaryColor3uivEXT(dest, loopback_SecondaryColor3uivEXT_f); + SET_SecondaryColor3usvEXT(dest, loopback_SecondaryColor3usvEXT_f); + SET_SecondaryColor3ubvEXT(dest, loopback_SecondaryColor3ubvEXT_f); + + SET_EdgeFlagv(dest, loopback_EdgeFlagv); + + SET_Indexd(dest, loopback_Indexd); + SET_Indexi(dest, loopback_Indexi); + SET_Indexs(dest, loopback_Indexs); + SET_Indexub(dest, loopback_Indexub); + SET_Indexdv(dest, loopback_Indexdv); + SET_Indexiv(dest, loopback_Indexiv); + SET_Indexsv(dest, loopback_Indexsv); + SET_Indexubv(dest, loopback_Indexubv); + SET_Normal3b(dest, loopback_Normal3b); + SET_Normal3d(dest, loopback_Normal3d); + SET_Normal3i(dest, loopback_Normal3i); + SET_Normal3s(dest, loopback_Normal3s); + SET_Normal3bv(dest, loopback_Normal3bv); + SET_Normal3dv(dest, loopback_Normal3dv); + SET_Normal3iv(dest, loopback_Normal3iv); + SET_Normal3sv(dest, loopback_Normal3sv); + SET_TexCoord1d(dest, loopback_TexCoord1d); + SET_TexCoord1i(dest, loopback_TexCoord1i); + SET_TexCoord1s(dest, loopback_TexCoord1s); + SET_TexCoord2d(dest, loopback_TexCoord2d); + SET_TexCoord2s(dest, loopback_TexCoord2s); + SET_TexCoord2i(dest, loopback_TexCoord2i); + SET_TexCoord3d(dest, loopback_TexCoord3d); + SET_TexCoord3i(dest, loopback_TexCoord3i); + SET_TexCoord3s(dest, loopback_TexCoord3s); + SET_TexCoord4d(dest, loopback_TexCoord4d); + SET_TexCoord4i(dest, loopback_TexCoord4i); + SET_TexCoord4s(dest, loopback_TexCoord4s); + SET_TexCoord1dv(dest, loopback_TexCoord1dv); + SET_TexCoord1iv(dest, loopback_TexCoord1iv); + SET_TexCoord1sv(dest, loopback_TexCoord1sv); + SET_TexCoord2dv(dest, loopback_TexCoord2dv); + SET_TexCoord2iv(dest, loopback_TexCoord2iv); + SET_TexCoord2sv(dest, loopback_TexCoord2sv); + SET_TexCoord3dv(dest, loopback_TexCoord3dv); + SET_TexCoord3iv(dest, loopback_TexCoord3iv); + SET_TexCoord3sv(dest, loopback_TexCoord3sv); + SET_TexCoord4dv(dest, loopback_TexCoord4dv); + SET_TexCoord4iv(dest, loopback_TexCoord4iv); + SET_TexCoord4sv(dest, loopback_TexCoord4sv); + SET_Vertex2d(dest, loopback_Vertex2d); + SET_Vertex2i(dest, loopback_Vertex2i); + SET_Vertex2s(dest, loopback_Vertex2s); + SET_Vertex3d(dest, loopback_Vertex3d); + SET_Vertex3i(dest, loopback_Vertex3i); + SET_Vertex3s(dest, loopback_Vertex3s); + SET_Vertex4d(dest, loopback_Vertex4d); + SET_Vertex4i(dest, loopback_Vertex4i); + SET_Vertex4s(dest, loopback_Vertex4s); + SET_Vertex2dv(dest, loopback_Vertex2dv); + SET_Vertex2iv(dest, loopback_Vertex2iv); + SET_Vertex2sv(dest, loopback_Vertex2sv); + SET_Vertex3dv(dest, loopback_Vertex3dv); + SET_Vertex3iv(dest, loopback_Vertex3iv); + SET_Vertex3sv(dest, loopback_Vertex3sv); + SET_Vertex4dv(dest, loopback_Vertex4dv); + SET_Vertex4iv(dest, loopback_Vertex4iv); + SET_Vertex4sv(dest, loopback_Vertex4sv); + SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB); + SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB); + SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB); + SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB); + SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB); + SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB); + SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB); + SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB); + SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB); + SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB); + SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB); + SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB); + SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB); + SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB); + SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB); + SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB); + SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB); + SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB); + SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB); + SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB); + SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB); + SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB); + SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB); + SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB); + SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); + SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); + SET_EvalCoord2d(dest, loopback_EvalCoord2d); + SET_EvalCoord1dv(dest, loopback_EvalCoord1dv); + SET_EvalCoord1fv(dest, loopback_EvalCoord1fv); + SET_EvalCoord1d(dest, loopback_EvalCoord1d); + SET_Materialf(dest, loopback_Materialf); + SET_Materiali(dest, loopback_Materiali); + SET_Materialiv(dest, loopback_Materialiv); + SET_Rectd(dest, loopback_Rectd); + SET_Rectdv(dest, loopback_Rectdv); + SET_Rectfv(dest, loopback_Rectfv); + SET_Recti(dest, loopback_Recti); + SET_Rectiv(dest, loopback_Rectiv); + SET_Rects(dest, loopback_Rects); + SET_Rectsv(dest, loopback_Rectsv); + SET_FogCoorddEXT(dest, loopback_FogCoorddEXT); + SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT); + + SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV); + SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV); + SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV); + SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV); + SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV); + SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV); + SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV); + SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV); + SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV); + SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV); + SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV); + SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV); + SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV); + SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV); + SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV); + SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV); + SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV); + SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV); + SET_VertexAttribs1svNV(dest, loopback_VertexAttribs1svNV); + SET_VertexAttribs1fvNV(dest, loopback_VertexAttribs1fvNV); + SET_VertexAttribs1dvNV(dest, loopback_VertexAttribs1dvNV); + SET_VertexAttribs2svNV(dest, loopback_VertexAttribs2svNV); + SET_VertexAttribs2fvNV(dest, loopback_VertexAttribs2fvNV); + SET_VertexAttribs2dvNV(dest, loopback_VertexAttribs2dvNV); + SET_VertexAttribs3svNV(dest, loopback_VertexAttribs3svNV); + SET_VertexAttribs3fvNV(dest, loopback_VertexAttribs3fvNV); + SET_VertexAttribs3dvNV(dest, loopback_VertexAttribs3dvNV); + SET_VertexAttribs4svNV(dest, loopback_VertexAttribs4svNV); + SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV); + SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV); + SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV); + + SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB); + SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB); + SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB); + SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB); + SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB); + SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB); + SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB); + SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB); + SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB); + SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB); + SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB); + SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB); + SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB); + SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB); + SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB); + SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB); + SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB); + SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB); + SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB); + SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB); + SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB); + SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB); + SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB); + SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB); + SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB); + SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB); + SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); + SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); + + /* GL_EXT_gpu_shader4, GL 3.0 */ + SET_VertexAttribI1ivEXT(dest, loopback_VertexAttribI1iv); + SET_VertexAttribI1uivEXT(dest, loopback_VertexAttribI1uiv); + SET_VertexAttribI4bvEXT(dest, loopback_VertexAttribI4bv); + SET_VertexAttribI4svEXT(dest, loopback_VertexAttribI4sv); + SET_VertexAttribI4ubvEXT(dest, loopback_VertexAttribI4ubv); + SET_VertexAttribI4usvEXT(dest, loopback_VertexAttribI4usv); +} + + +#endif /* FEATURE_beginend */ diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h index 3140eb515..921637641 100644 --- a/mesalib/src/mesa/main/api_loopback.h +++ b/mesalib/src/mesa/main/api_loopback.h @@ -1,45 +1,48 @@ -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef API_LOOPBACK_H -#define API_LOOPBACK_H - -#include "main/mtypes.h" - -#if FEATURE_beginend - -extern void _mesa_loopback_init_api_table( struct _glapi_table *dest ); - -#else /* FEATURE_beginend */ - -static INLINE void -_mesa_loopback_init_api_table( struct _glapi_table *dest ) -{ -} - -#endif /* FEATURE_beginend */ - -#endif /* API_LOOPBACK_H */ +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef API_LOOPBACK_H +#define API_LOOPBACK_H + +#include "main/compiler.h" +#include "main/mfeatures.h" + +struct _glapi_table; + +#if FEATURE_beginend + +extern void _mesa_loopback_init_api_table( struct _glapi_table *dest ); + +#else /* FEATURE_beginend */ + +static INLINE void +_mesa_loopback_init_api_table( struct _glapi_table *dest ) +{ +} + +#endif /* FEATURE_beginend */ + +#endif /* API_LOOPBACK_H */ diff --git a/mesalib/src/mesa/main/api_noop.c b/mesalib/src/mesa/main/api_noop.c index 9a36394d6..f13d3641b 100644 --- a/mesalib/src/mesa/main/api_noop.c +++ b/mesalib/src/mesa/main/api_noop.c @@ -1,1072 +1,1084 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "api_noop.h" -#include "api_validate.h" -#include "api_arrayelt.h" -#include "context.h" -#include "light.h" -#include "macros.h" -#include "dlist.h" -#include "eval.h" -#include "main/dispatch.h" - - -/** - * \file - * Just update the ctx->Current vertex attributes. - * These functions are used when outside glBegin/glEnd or outside display - * lists. - */ - - -#if FEATURE_beginend - - -static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b; -} - -static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = f; -} - -static void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = *v; -} - -static void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; - dest[0] = a; - dest[1] = 0.0; - dest[2] = 0.0; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; - dest[0] = v[0]; - dest[1] = 0.0; - dest[2] = 0.0; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = d; -} - -static void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = v[3]; -} - -static void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, - GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = d; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = v[3]; - } -} - -static void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = d; -} - -static void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = v[3]; -} - - -/** - * GL_NV_vertex_program attributes. - * Note that these attributes alias the conventional vertex attributes. - */ - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, - GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvNV(index)" ); -} - - - -/** - * GL_ARB_vertex_program attributes. - * Note that these attributes DO NOT alias the conventional vertex attributes. - */ - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvARB(index)" ); -} - - - -/** - * Called by glMaterial*() - */ -void GLAPIENTRY -_mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i, nr; - struct gl_material *mat = &ctx->Light.Material; - GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, - "_mesa_noop_Materialfv" ); - - if (ctx->Light.ColorMaterialEnabled) - bitmask &= ~ctx->Light.ColorMaterialBitmask; - - if (bitmask == 0) - return; - - switch (pname) { - case GL_SHININESS: nr = 1; break; - case GL_COLOR_INDEXES: nr = 3; break; - default: nr = 4 ; break; - } - - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<Attrib[i], nr, params ); - - _mesa_update_material( ctx, bitmask ); -} - - -/** - * These really are noops outside begin/end: - */ -static void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b ) -{ - (void) a; (void) b; -} - -static void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c ) -{ - (void) a; (void) b; (void) c; -} - -static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - (void) a; (void) b; (void) c; (void) d; -} - - -#if FEATURE_evaluators -/* Similarly, these have no effect outside begin/end: - */ -static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a ) -{ - (void) a; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b ) -{ - (void) a; (void) b; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a ) -{ - (void) a; -} - -static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b ) -{ - (void) a; (void) b; -} -#endif /* FEATURE_evaluators */ - - -/* Begin -- call into driver, should result in the vtxfmt being - * swapped out: - */ -static void GLAPIENTRY _mesa_noop_Begin( GLenum mode ) -{ - (void) mode; -} - - -/* End -- just raise an error - */ -static void GLAPIENTRY _mesa_noop_End( void ) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd(no glBegin)" ); -} - - -/** - * Execute a glRectf() function. This is not suitable for GL_COMPILE - * modes (as the test for outside begin/end is not compiled), - * but may be useful for drivers in circumstances which exclude - * display list interactions. - * - * (None of the functions in this file are suitable for GL_COMPILE - * modes). - */ -void GLAPIENTRY -_mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - { - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - } - - CALL_Begin(GET_DISPATCH(), (GL_QUADS)); - CALL_Vertex2f(GET_DISPATCH(), (x1, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y2)); - CALL_Vertex2f(GET_DISPATCH(), (x1, y2)); - CALL_End(GET_DISPATCH(), ()); -} - - -/** - * Some very basic support for arrays. Drivers without explicit array - * support can hook these in, but still need to supply an array-elt - * implementation. - */ -static void GLAPIENTRY -_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (start + i)); - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] )); - break; - case GL_UNSIGNED_SHORT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] )); - break; - case GL_UNSIGNED_INT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] )); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); - break; - } - - CALL_End(GET_DISPATCH(), ()); -} - -static void GLAPIENTRY -_mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, - basevertex )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] + - basevertex)); - break; - case GL_UNSIGNED_SHORT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] + - basevertex )); - break; - case GL_UNSIGNED_INT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] + - basevertex )); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElementsBaseVertex(type)" ); - break; - } - - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -_mesa_noop_DrawRangeElements(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - - if (_mesa_validate_DrawRangeElements( ctx, mode, - start, end, - count, type, indices, 0 )) - CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices)); -} - -/* GL_EXT_multi_draw_arrays */ -void GLAPIENTRY -_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - GLsizei i; - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i])); - } - } -} - -static void GLAPIENTRY -_mesa_noop_DrawRangeElementsBaseVertex(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - - if (_mesa_validate_DrawRangeElements( ctx, mode, - start, end, - count, type, indices, basevertex )) - CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count, type, indices, - basevertex)); -} - -/* GL_EXT_multi_draw_arrays */ -void GLAPIENTRY -_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex) -{ - GLsizei i; - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type, - indices[i], - basevertex[i])); - } - } -} - -/* - * Eval Mesh - */ - -/** - * KW: - * If are compiling, we don't know whether eval will produce a - * vertex when it is run in the future. If this is pure immediate - * mode, eval is a noop if neither vertex map is enabled. - * - * Thus we need to have a check in the display list code or elsewhere - * for eval(1,2) vertices in the case where map(1,2)_vertex is - * disabled, and to purge those vertices from the vb. - */ -void GLAPIENTRY -_mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLfloat u, du; - GLenum prim; - - switch (mode) { - case GL_POINT: - prim = GL_POINTS; - break; - case GL_LINE: - prim = GL_LINE_STRIP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map1Vertex4 && - !ctx->Eval.Map1Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid1du; - u = ctx->Eval.MapGrid1u1 + i1 * du; - - CALL_Begin(GET_DISPATCH(), (prim)); - for (i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord1f(GET_DISPATCH(), (u)); - } - CALL_End(GET_DISPATCH(), ()); -} - - - -void GLAPIENTRY -_mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat u, du, v, dv, v1, u1; - GLint i, j; - - switch (mode) { - case GL_POINT: - case GL_LINE: - case GL_FILL: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map2Vertex4 && - !ctx->Eval.Map2Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid2du; - dv = ctx->Eval.MapGrid2dv; - v1 = ctx->Eval.MapGrid2v1 + j1 * dv; - u1 = ctx->Eval.MapGrid2u1 + i1 * du; - - switch (mode) { - case GL_POINT: - CALL_Begin(GET_DISPATCH(), (GL_POINTS)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - } - CALL_End(GET_DISPATCH(), ()); - break; - case GL_LINE: - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - break; - case GL_FILL: - for (v=v1,j=j1;jBegin = _mesa_noop_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); - - vfmt->Color3f = _mesa_noop_Color3f; - vfmt->Color3fv = _mesa_noop_Color3fv; - vfmt->Color4f = _mesa_noop_Color4f; - vfmt->Color4fv = _mesa_noop_Color4fv; - vfmt->EdgeFlag = _mesa_noop_EdgeFlag; - vfmt->End = _mesa_noop_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); - - vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; - vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; - vfmt->Indexf = _mesa_noop_Indexf; - vfmt->Indexfv = _mesa_noop_Indexfv; - vfmt->Materialfv = _mesa_noop_Materialfv; - vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB; - vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB; - vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB; - vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB; - vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB; - vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB; - vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB; - vfmt->Normal3f = _mesa_noop_Normal3f; - vfmt->Normal3fv = _mesa_noop_Normal3fv; - vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT; - vfmt->TexCoord1f = _mesa_noop_TexCoord1f; - vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv; - vfmt->TexCoord2f = _mesa_noop_TexCoord2f; - vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv; - vfmt->TexCoord3f = _mesa_noop_TexCoord3f; - vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv; - vfmt->TexCoord4f = _mesa_noop_TexCoord4f; - vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv; - vfmt->Vertex2f = _mesa_noop_Vertex2f; - vfmt->Vertex2fv = _mesa_noop_Vertex2fv; - vfmt->Vertex3f = _mesa_noop_Vertex3f; - vfmt->Vertex3fv = _mesa_noop_Vertex3fv; - vfmt->Vertex4f = _mesa_noop_Vertex4f; - vfmt->Vertex4fv = _mesa_noop_Vertex4fv; - vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB; - - vfmt->Rectf = _mesa_noop_Rectf; - - vfmt->DrawArrays = _mesa_noop_DrawArrays; - vfmt->DrawElements = _mesa_noop_DrawElements; - vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; - vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; - vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex; - vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; - vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; -} - - -#endif /* FEATURE_beginend */ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "api_noop.h" +#include "api_validate.h" +#include "api_arrayelt.h" +#include "context.h" +#include "light.h" +#include "macros.h" +#include "dlist.h" +#include "eval.h" +#include "main/dispatch.h" + + +/** + * \file + * Just update the ctx->Current vertex attributes. + * These functions are used when outside glBegin/glEnd or outside display + * lists. + */ + + +#if FEATURE_beginend + + +static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b ) +{ + GET_CURRENT_CONTEXT(ctx); + ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b; +} + +static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f ) +{ + GET_CURRENT_CONTEXT(ctx); + ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = f; +} + +static void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = *v; +} + +static void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; + dest[0] = a; + dest[1] = 0.0; + dest[2] = 0.0; + dest[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; + dest[0] = v[0]; + dest[1] = 0.0; + dest[2] = 0.0; + dest[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; + dest[0] = a; + dest[1] = b; + dest[2] = c; + dest[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = v[2]; + dest[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + color[0] = a; + color[1] = b; + color[2] = c; + color[3] = d; +} + +static void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + color[0] = v[0]; + color[1] = v[1]; + color[2] = v[2]; + color[3] = v[3]; +} + +static void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + color[0] = a; + color[1] = b; + color[2] = c; + color[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + color[0] = v[0]; + color[1] = v[1]; + color[2] = v[2]; + color[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = a; + dest[1] = 0; + dest[2] = 0; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = v[0]; + dest[1] = 0; + dest[2] = 0; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = a; + dest[1] = b; + dest[2] = 0; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = 0; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = a; + dest[1] = b; + dest[2] = c; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = v[2]; + dest[3] = 1; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, + GLfloat c, GLfloat d ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = a; + dest[1] = b; + dest[2] = c; + dest[3] = d; + } +} + +static void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint unit = target - GL_TEXTURE0_ARB; + + /* unit is unsigned -- cannot be less than zero. + */ + if (unit < MAX_TEXTURE_COORD_UNITS) + { + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = v[2]; + dest[3] = v[3]; + } +} + +static void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; + color[0] = a; + color[1] = b; + color[2] = c; + color[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; + color[0] = v[0]; + color[1] = v[1]; + color[2] = v[2]; + color[3] = 1.0; +} + +static void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = a; + dest[1] = 0; + dest[2] = 0; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = v[0]; + dest[1] = 0; + dest[2] = 0; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = a; + dest[1] = b; + dest[2] = 0; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = 0; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = a; + dest[1] = b; + dest[2] = c; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = v[2]; + dest[3] = 1; +} + +static void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = a; + dest[1] = b; + dest[2] = c; + dest[3] = d; +} + +static void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; + dest[0] = v[0]; + dest[1] = v[1]; + dest[2] = v[2]; + dest[3] = v[3]; +} + + +/** + * GL_NV_vertex_program attributes. + * Note that these attributes alias the conventional vertex attributes. + */ + +static void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, + GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fNV(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { + ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvNV(index)" ); +} + + + +/** + * GL_ARB_vertex_program attributes. + * Note that these attributes DO NOT alias the conventional vertex attributes. + */ + +static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, + GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fARB(index)" ); +} + +static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + if (index < MAX_VERTEX_GENERIC_ATTRIBS) { + ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]); + } + else + _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvARB(index)" ); +} + + + +/** + * Called by glMaterial*() + */ +void GLAPIENTRY +_mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i, nr; + struct gl_material *mat = &ctx->Light.Material; + GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, + "_mesa_noop_Materialfv" ); + + if (ctx->Light.ColorMaterialEnabled) + bitmask &= ~ctx->Light.ColorMaterialBitmask; + + if (bitmask == 0) + return; + + switch (pname) { + case GL_SHININESS: nr = 1; break; + case GL_COLOR_INDEXES: nr = 3; break; + default: nr = 4 ; break; + } + + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<Attrib[i], nr, params ); + + _mesa_update_material( ctx, bitmask ); +} + + +/** + * These really are noops outside begin/end: + */ +static void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v ) +{ + (void) v; +} + +static void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v ) +{ + (void) v; +} + +static void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v ) +{ + (void) v; +} + +static void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b ) +{ + (void) a; (void) b; +} + +static void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c ) +{ + (void) a; (void) b; (void) c; +} + +static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) +{ + (void) a; (void) b; (void) c; (void) d; +} + + +#if FEATURE_evaluators +/* Similarly, these have no effect outside begin/end: + */ +static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a ) +{ + (void) a; +} + +static void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v ) +{ + (void) v; +} + +static void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b ) +{ + (void) a; (void) b; +} + +static void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v ) +{ + (void) v; +} + +static void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a ) +{ + (void) a; +} + +static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b ) +{ + (void) a; (void) b; +} +#endif /* FEATURE_evaluators */ + + +/* Begin -- call into driver, should result in the vtxfmt being + * swapped out: + */ +static void GLAPIENTRY _mesa_noop_Begin( GLenum mode ) +{ + (void) mode; +} + + +/* End -- just raise an error + */ +static void GLAPIENTRY _mesa_noop_End( void ) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd(no glBegin)" ); +} + + +/*** + * PrimitiveRestart called outside glBegin()/End(): raise an error + */ +static void GLAPIENTRY _mesa_noop_PrimitiveRestartNV( void ) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartNV(no glBegin)"); +} + + +/** + * Execute a glRectf() function. This is not suitable for GL_COMPILE + * modes (as the test for outside begin/end is not compiled), + * but may be useful for drivers in circumstances which exclude + * display list interactions. + * + * (None of the functions in this file are suitable for GL_COMPILE + * modes). + */ +void GLAPIENTRY +_mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +{ + { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + } + + CALL_Begin(GET_DISPATCH(), (GL_QUADS)); + CALL_Vertex2f(GET_DISPATCH(), (x1, y1)); + CALL_Vertex2f(GET_DISPATCH(), (x2, y1)); + CALL_Vertex2f(GET_DISPATCH(), (x2, y2)); + CALL_Vertex2f(GET_DISPATCH(), (x1, y2)); + CALL_End(GET_DISPATCH(), ()); +} + + +/** + * Some very basic support for arrays. Drivers without explicit array + * support can hook these in, but still need to supply an array-elt + * implementation. + */ +static void GLAPIENTRY +_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) + return; + + CALL_Begin(GET_DISPATCH(), (mode)); + for (i = 0; i < count; i++) + CALL_ArrayElement(GET_DISPATCH(), (start + i)); + CALL_End(GET_DISPATCH(), ()); +} + + +static void GLAPIENTRY +_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) + return; + + CALL_Begin(GET_DISPATCH(), (mode)); + + switch (type) { + case GL_UNSIGNED_BYTE: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] )); + break; + case GL_UNSIGNED_SHORT: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] )); + break; + case GL_UNSIGNED_INT: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] )); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); + break; + } + + CALL_End(GET_DISPATCH(), ()); +} + +static void GLAPIENTRY +_mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, + basevertex )) + return; + + CALL_Begin(GET_DISPATCH(), (mode)); + + switch (type) { + case GL_UNSIGNED_BYTE: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] + + basevertex)); + break; + case GL_UNSIGNED_SHORT: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] + + basevertex )); + break; + case GL_UNSIGNED_INT: + for (i = 0 ; i < count ; i++) + CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] + + basevertex )); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElementsBaseVertex(type)" ); + break; + } + + CALL_End(GET_DISPATCH(), ()); +} + + +static void GLAPIENTRY +_mesa_noop_DrawRangeElements(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + + if (_mesa_validate_DrawRangeElements( ctx, mode, + start, end, + count, type, indices, 0 )) + CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices)); +} + +/* GL_EXT_multi_draw_arrays */ +void GLAPIENTRY +_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount) +{ + GLsizei i; + + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i])); + } + } +} + +static void GLAPIENTRY +_mesa_noop_DrawRangeElementsBaseVertex(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + + if (_mesa_validate_DrawRangeElements( ctx, mode, + start, end, + count, type, indices, basevertex )) + CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count, type, indices, + basevertex)); +} + +/* GL_EXT_multi_draw_arrays */ +void GLAPIENTRY +_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex) +{ + GLsizei i; + + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type, + indices[i], + basevertex[i])); + } + } +} + +/* + * Eval Mesh + */ + +/** + * KW: + * If are compiling, we don't know whether eval will produce a + * vertex when it is run in the future. If this is pure immediate + * mode, eval is a noop if neither vertex map is enabled. + * + * Thus we need to have a check in the display list code or elsewhere + * for eval(1,2) vertices in the case where map(1,2)_vertex is + * disabled, and to purge those vertices from the vb. + */ +void GLAPIENTRY +_mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLfloat u, du; + GLenum prim; + + switch (mode) { + case GL_POINT: + prim = GL_POINTS; + break; + case GL_LINE: + prim = GL_LINE_STRIP; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); + return; + } + + /* No effect if vertex maps disabled. + */ + if (!ctx->Eval.Map1Vertex4 && + !ctx->Eval.Map1Vertex3 && + !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) + return; + + du = ctx->Eval.MapGrid1du; + u = ctx->Eval.MapGrid1u1 + i1 * du; + + CALL_Begin(GET_DISPATCH(), (prim)); + for (i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord1f(GET_DISPATCH(), (u)); + } + CALL_End(GET_DISPATCH(), ()); +} + + + +void GLAPIENTRY +_mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat u, du, v, dv, v1, u1; + GLint i, j; + + switch (mode) { + case GL_POINT: + case GL_LINE: + case GL_FILL: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); + return; + } + + /* No effect if vertex maps disabled. + */ + if (!ctx->Eval.Map2Vertex4 && + !ctx->Eval.Map2Vertex3 && + !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) + return; + + du = ctx->Eval.MapGrid2du; + dv = ctx->Eval.MapGrid2dv; + v1 = ctx->Eval.MapGrid2v1 + j1 * dv; + u1 = ctx->Eval.MapGrid2u1 + i1 * du; + + switch (mode) { + case GL_POINT: + CALL_Begin(GET_DISPATCH(), (GL_POINTS)); + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + } + CALL_End(GET_DISPATCH(), ()); + break; + case GL_LINE: + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + CALL_End(GET_DISPATCH(), ()); + } + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + CALL_End(GET_DISPATCH(), ()); + } + break; + case GL_FILL: + for (v=v1,j=j1;jBegin = _mesa_noop_Begin; + + _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); + + vfmt->Color3f = _mesa_noop_Color3f; + vfmt->Color3fv = _mesa_noop_Color3fv; + vfmt->Color4f = _mesa_noop_Color4f; + vfmt->Color4fv = _mesa_noop_Color4fv; + vfmt->EdgeFlag = _mesa_noop_EdgeFlag; + vfmt->End = _mesa_noop_End; + + vfmt->PrimitiveRestartNV = _mesa_noop_PrimitiveRestartNV; + + _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); + + vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; + vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; + vfmt->Indexf = _mesa_noop_Indexf; + vfmt->Indexfv = _mesa_noop_Indexfv; + vfmt->Materialfv = _mesa_noop_Materialfv; + vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB; + vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB; + vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB; + vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB; + vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB; + vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB; + vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB; + vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB; + vfmt->Normal3f = _mesa_noop_Normal3f; + vfmt->Normal3fv = _mesa_noop_Normal3fv; + vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT; + vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT; + vfmt->TexCoord1f = _mesa_noop_TexCoord1f; + vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv; + vfmt->TexCoord2f = _mesa_noop_TexCoord2f; + vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv; + vfmt->TexCoord3f = _mesa_noop_TexCoord3f; + vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv; + vfmt->TexCoord4f = _mesa_noop_TexCoord4f; + vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv; + vfmt->Vertex2f = _mesa_noop_Vertex2f; + vfmt->Vertex2fv = _mesa_noop_Vertex2fv; + vfmt->Vertex3f = _mesa_noop_Vertex3f; + vfmt->Vertex3fv = _mesa_noop_Vertex3fv; + vfmt->Vertex4f = _mesa_noop_Vertex4f; + vfmt->Vertex4fv = _mesa_noop_Vertex4fv; + vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV; + vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV; + vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV; + vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV; + vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV; + vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; + vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; + vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB; + vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB; + vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB; + vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB; + vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB; + vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB; + vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB; + vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB; + + vfmt->Rectf = _mesa_noop_Rectf; + + vfmt->DrawArrays = _mesa_noop_DrawArrays; + vfmt->DrawElements = _mesa_noop_DrawElements; + vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; + vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; + vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex; + vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; + vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; +} + + +#endif /* FEATURE_beginend */ diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index b3b5c6cc0..e48a18a00 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -1,431 +1,432 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "api_validate.h" -#include "bufferobj.h" -#include "context.h" -#include "imports.h" -#include "mtypes.h" -#include "vbo/vbo.h" - - -/** - * \return number of bytes in array [count] of type. - */ -static GLsizei -index_bytes(GLenum type, GLsizei count) -{ - if (type == GL_UNSIGNED_INT) { - return count * sizeof(GLuint); - } - else if (type == GL_UNSIGNED_BYTE) { - return count * sizeof(GLubyte); - } - else { - ASSERT(type == GL_UNSIGNED_SHORT); - return count * sizeof(GLushort); - } -} - - -/** - * Find the max index in the given element/index buffer - */ -GLuint -_mesa_max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf) -{ - const GLubyte *map = NULL; - GLuint max = 0; - GLuint i; - - if (_mesa_is_bufferobj(elementBuf)) { - /* elements are in a user-defined buffer object. need to map it */ - map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, - GL_READ_ONLY, elementBuf); - /* Actual address is the sum of pointers */ - indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); - } - - if (type == GL_UNSIGNED_INT) { - for (i = 0; i < count; i++) - if (((GLuint *) indices)[i] > max) - max = ((GLuint *) indices)[i]; - } - else if (type == GL_UNSIGNED_SHORT) { - for (i = 0; i < count; i++) - if (((GLushort *) indices)[i] > max) - max = ((GLushort *) indices)[i]; - } - else { - ASSERT(type == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) - if (((GLubyte *) indices)[i] > max) - max = ((GLubyte *) indices)[i]; - } - - if (map) { - ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, elementBuf); - } - - return max; -} - - -/** - * Check if OK to draw arrays/elements. - */ -static GLboolean -check_valid_to_render(GLcontext *ctx, const char *function) -{ - if (!_mesa_valid_to_render(ctx, function)) { - return GL_FALSE; - } - - switch (ctx->API) { -#if FEATURE_es2_glsl - case API_OPENGLES2: - /* For ES2, we can draw if any vertex array is enabled (and we - * should always have a vertex program/shader). */ - if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current) - return GL_FALSE; - break; -#endif - -#if FEATURE_ES1 || FEATURE_GL - case API_OPENGLES: - case API_OPENGL: - /* For regular OpenGL, only draw if we have vertex positions - * (regardless of whether or not we have a vertex program/shader). */ - if (!ctx->Array.ArrayObj->Vertex.Enabled && - !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) - return GL_FALSE; - break; -#endif - - default: - ASSERT_NO_FEATURE(); - } - - return GL_TRUE; -} - - -/** - * Do bounds checking on array element indexes. Check that the vertices - * pointed to by the indices don't lie outside buffer object bounds. - * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds - */ -static GLboolean -check_index_bounds(GLcontext *ctx, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - struct _mesa_prim prim; - struct _mesa_index_buffer ib; - GLuint min, max; - - /* Only the X Server needs to do this -- otherwise, accessing outside - * array/BO bounds allows application termination. - */ - if (!ctx->Const.CheckArrayBounds) - return GL_TRUE; - - memset(&prim, 0, sizeof(prim)); - prim.count = count; - - memset(&ib, 0, sizeof(ib)); - ib.type = type; - ib.ptr = indices; - ib.obj = ctx->Array.ElementArrayBufferObj; - - vbo_get_minmax_index(ctx, &prim, &ib, &min, &max); - - if ((int)(min + basevertex) < 0 || - max + basevertex > ctx->Array.ArrayObj->_MaxElement) { - /* the max element is out of bounds of one or more enabled arrays */ - _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", - max, ctx->Array.ArrayObj->_MaxElement); - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Error checking for glDrawElements(). Includes parameter checking - * and VBO bounds checking. - * \return GL_TRUE if OK to render, GL_FALSE if error found - */ -GLboolean -_mesa_validate_DrawElements(GLcontext *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" ); - return GL_FALSE; - } - - if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" ); - return GL_FALSE; - } - - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) - { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawElements")) - return GL_FALSE; - - /* Vertex buffer object tests */ - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - /* use indices in the buffer object */ - /* make sure count doesn't go outside buffer bounds */ - if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { - _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); - return GL_FALSE; - } - } - else { - /* not using a VBO */ - if (!indices) - return GL_FALSE; - } - - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Error checking for glDrawRangeElements(). Includes parameter checking - * and VBO bounds checking. - * \return GL_TRUE if OK to render, GL_FALSE if error found - */ -GLboolean -_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" ); - return GL_FALSE; - } - - if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(mode)" ); - return GL_FALSE; - } - - if (end < start) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(endArray.ElementArrayBufferObj)) { - /* use indices in the buffer object */ - /* make sure count doesn't go outside buffer bounds */ - if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { - _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds"); - return GL_FALSE; - } - } - else { - /* not using a VBO */ - if (!indices) - return GL_FALSE; - } - - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Called from the tnl module to error check the function parameters and - * verify that we really can draw something. - * \return GL_TRUE if OK to render, GL_FALSE if error found - */ -GLboolean -_mesa_validate_DrawArrays(GLcontext *ctx, - GLenum mode, GLint start, GLsizei count) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); - return GL_FALSE; - } - - if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" ); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawArrays")) - return GL_FALSE; - - if (ctx->Const.CheckArrayBounds) { - if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement) - return GL_FALSE; - } - - return GL_TRUE; -} - - -GLboolean -_mesa_validate_DrawArraysInstanced(GLcontext *ctx, GLenum mode, GLint first, - GLsizei count, GLsizei primcount) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawArraysInstanced(count=%d)", count); - return GL_FALSE; - } - - if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glDrawArraysInstanced(mode=0x%x)", mode); - return GL_FALSE; - } - - if (primcount <= 0) { - if (primcount < 0) - _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawArraysInstanced(primcount=%d)", primcount); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) - return GL_FALSE; - - if (ctx->CompileFlag) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawArraysInstanced(display list"); - return GL_FALSE; - } - - if (ctx->Const.CheckArrayBounds) { - if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement) - return GL_FALSE; - } - - return GL_TRUE; -} - - -GLboolean -_mesa_validate_DrawElementsInstanced(GLcontext *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei primcount) -{ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (count <= 0) { - if (count < 0) - _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawElementsInstanced(count=%d)", count); - return GL_FALSE; - } - - if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glDrawElementsInstanced(mode = 0x%x)", mode); - return GL_FALSE; - } - - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glDrawElementsInstanced(type=0x%x)", type); - return GL_FALSE; - } - - if (primcount <= 0) { - if (primcount < 0) - _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawElementsInstanced(primcount=%d)", primcount); - return GL_FALSE; - } - - if (!check_valid_to_render(ctx, "glDrawElementsInstanced")) - return GL_FALSE; - - /* Vertex buffer object tests */ - if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - /* use indices in the buffer object */ - /* make sure count doesn't go outside buffer bounds */ - if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { - _mesa_warning(ctx, - "glDrawElementsInstanced index out of buffer bounds"); - return GL_FALSE; - } - } - else { - /* not using a VBO */ - if (!indices) - return GL_FALSE; - } - - if (!check_index_bounds(ctx, count, type, indices, 0)) - return GL_FALSE; - - return GL_TRUE; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "api_validate.h" +#include "bufferobj.h" +#include "context.h" +#include "imports.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "vbo/vbo.h" + + +/** + * \return number of bytes in array [count] of type. + */ +static GLsizei +index_bytes(GLenum type, GLsizei count) +{ + if (type == GL_UNSIGNED_INT) { + return count * sizeof(GLuint); + } + else if (type == GL_UNSIGNED_BYTE) { + return count * sizeof(GLubyte); + } + else { + ASSERT(type == GL_UNSIGNED_SHORT); + return count * sizeof(GLushort); + } +} + + +/** + * Find the max index in the given element/index buffer + */ +GLuint +_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, + const void *indices, + struct gl_buffer_object *elementBuf) +{ + const GLubyte *map = NULL; + GLuint max = 0; + GLuint i; + + if (_mesa_is_bufferobj(elementBuf)) { + /* elements are in a user-defined buffer object. need to map it */ + map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, + GL_READ_ONLY, elementBuf); + /* Actual address is the sum of pointers */ + indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); + } + + if (type == GL_UNSIGNED_INT) { + for (i = 0; i < count; i++) + if (((GLuint *) indices)[i] > max) + max = ((GLuint *) indices)[i]; + } + else if (type == GL_UNSIGNED_SHORT) { + for (i = 0; i < count; i++) + if (((GLushort *) indices)[i] > max) + max = ((GLushort *) indices)[i]; + } + else { + ASSERT(type == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) + if (((GLubyte *) indices)[i] > max) + max = ((GLubyte *) indices)[i]; + } + + if (map) { + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, elementBuf); + } + + return max; +} + + +/** + * Check if OK to draw arrays/elements. + */ +static GLboolean +check_valid_to_render(struct gl_context *ctx, const char *function) +{ + if (!_mesa_valid_to_render(ctx, function)) { + return GL_FALSE; + } + + switch (ctx->API) { +#if FEATURE_es2_glsl + case API_OPENGLES2: + /* For ES2, we can draw if any vertex array is enabled (and we + * should always have a vertex program/shader). */ + if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current) + return GL_FALSE; + break; +#endif + +#if FEATURE_ES1 || FEATURE_GL + case API_OPENGLES: + case API_OPENGL: + /* For regular OpenGL, only draw if we have vertex positions + * (regardless of whether or not we have a vertex program/shader). */ + if (!ctx->Array.ArrayObj->Vertex.Enabled && + !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) + return GL_FALSE; + break; +#endif + + default: + ASSERT_NO_FEATURE(); + } + + return GL_TRUE; +} + + +/** + * Do bounds checking on array element indexes. Check that the vertices + * pointed to by the indices don't lie outside buffer object bounds. + * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds + */ +static GLboolean +check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + struct _mesa_prim prim; + struct _mesa_index_buffer ib; + GLuint min, max; + + /* Only the X Server needs to do this -- otherwise, accessing outside + * array/BO bounds allows application termination. + */ + if (!ctx->Const.CheckArrayBounds) + return GL_TRUE; + + memset(&prim, 0, sizeof(prim)); + prim.count = count; + + memset(&ib, 0, sizeof(ib)); + ib.type = type; + ib.ptr = indices; + ib.obj = ctx->Array.ElementArrayBufferObj; + + vbo_get_minmax_index(ctx, &prim, &ib, &min, &max); + + if ((int)(min + basevertex) < 0 || + max + basevertex > ctx->Array.ArrayObj->_MaxElement) { + /* the max element is out of bounds of one or more enabled arrays */ + _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", + max, ctx->Array.ArrayObj->_MaxElement); + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Error checking for glDrawElements(). Includes parameter checking + * and VBO bounds checking. + * \return GL_TRUE if OK to render, GL_FALSE if error found + */ +GLboolean +_mesa_validate_DrawElements(struct gl_context *ctx, + GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (count <= 0) { + if (count < 0) + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" ); + return GL_FALSE; + } + + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" ); + return GL_FALSE; + } + + if (type != GL_UNSIGNED_INT && + type != GL_UNSIGNED_BYTE && + type != GL_UNSIGNED_SHORT) + { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); + return GL_FALSE; + } + + if (!check_valid_to_render(ctx, "glDrawElements")) + return GL_FALSE; + + /* Vertex buffer object tests */ + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { + /* use indices in the buffer object */ + /* make sure count doesn't go outside buffer bounds */ + if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); + return GL_FALSE; + } + } + else { + /* not using a VBO */ + if (!indices) + return GL_FALSE; + } + + if (!check_index_bounds(ctx, count, type, indices, basevertex)) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Error checking for glDrawRangeElements(). Includes parameter checking + * and VBO bounds checking. + * \return GL_TRUE if OK to render, GL_FALSE if error found + */ +GLboolean +_mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex) +{ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (count <= 0) { + if (count < 0) + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" ); + return GL_FALSE; + } + + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(mode)" ); + return GL_FALSE; + } + + if (end < start) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(endArray.ElementArrayBufferObj)) { + /* use indices in the buffer object */ + /* make sure count doesn't go outside buffer bounds */ + if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds"); + return GL_FALSE; + } + } + else { + /* not using a VBO */ + if (!indices) + return GL_FALSE; + } + + if (!check_index_bounds(ctx, count, type, indices, basevertex)) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Called from the tnl module to error check the function parameters and + * verify that we really can draw something. + * \return GL_TRUE if OK to render, GL_FALSE if error found + */ +GLboolean +_mesa_validate_DrawArrays(struct gl_context *ctx, + GLenum mode, GLint start, GLsizei count) +{ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (count <= 0) { + if (count < 0) + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" ); + return GL_FALSE; + } + + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" ); + return GL_FALSE; + } + + if (!check_valid_to_render(ctx, "glDrawArrays")) + return GL_FALSE; + + if (ctx->Const.CheckArrayBounds) { + if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement) + return GL_FALSE; + } + + return GL_TRUE; +} + + +GLboolean +_mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first, + GLsizei count, GLsizei primcount) +{ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (count <= 0) { + if (count < 0) + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawArraysInstanced(count=%d)", count); + return GL_FALSE; + } + + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDrawArraysInstanced(mode=0x%x)", mode); + return GL_FALSE; + } + + if (primcount <= 0) { + if (primcount < 0) + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawArraysInstanced(primcount=%d)", primcount); + return GL_FALSE; + } + + if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) + return GL_FALSE; + + if (ctx->CompileFlag) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawArraysInstanced(display list"); + return GL_FALSE; + } + + if (ctx->Const.CheckArrayBounds) { + if (first + count > (GLint) ctx->Array.ArrayObj->_MaxElement) + return GL_FALSE; + } + + return GL_TRUE; +} + + +GLboolean +_mesa_validate_DrawElementsInstanced(struct gl_context *ctx, + GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLsizei primcount) +{ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (count <= 0) { + if (count < 0) + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawElementsInstanced(count=%d)", count); + return GL_FALSE; + } + + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDrawElementsInstanced(mode = 0x%x)", mode); + return GL_FALSE; + } + + if (type != GL_UNSIGNED_INT && + type != GL_UNSIGNED_BYTE && + type != GL_UNSIGNED_SHORT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDrawElementsInstanced(type=0x%x)", type); + return GL_FALSE; + } + + if (primcount <= 0) { + if (primcount < 0) + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawElementsInstanced(primcount=%d)", primcount); + return GL_FALSE; + } + + if (!check_valid_to_render(ctx, "glDrawElementsInstanced")) + return GL_FALSE; + + /* Vertex buffer object tests */ + if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { + /* use indices in the buffer object */ + /* make sure count doesn't go outside buffer bounds */ + if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, + "glDrawElementsInstanced index out of buffer bounds"); + return GL_FALSE; + } + } + else { + /* not using a VBO */ + if (!indices) + return GL_FALSE; + } + + if (!check_index_bounds(ctx, count, type, indices, 0)) + return GL_FALSE; + + return GL_TRUE; +} diff --git a/mesalib/src/mesa/main/api_validate.h b/mesalib/src/mesa/main/api_validate.h index cd27d58aa..dca3e53e8 100644 --- a/mesalib/src/mesa/main/api_validate.h +++ b/mesalib/src/mesa/main/api_validate.h @@ -1,65 +1,68 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef API_VALIDATE_H -#define API_VALIDATE_H - - -#include "mtypes.h" - - -extern GLuint -_mesa_max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, - const void *indices, - struct gl_buffer_object *elementBuf); - -extern GLboolean -_mesa_validate_DrawArrays(GLcontext *ctx, - GLenum mode, GLint start, GLsizei count); - -extern GLboolean -_mesa_validate_DrawElements(GLcontext *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex); - -extern GLboolean -_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex); - - -extern GLboolean -_mesa_validate_DrawArraysInstanced(GLcontext *ctx, GLenum mode, GLint first, - GLsizei count, GLsizei primcount); - -extern GLboolean -_mesa_validate_DrawElementsInstanced(GLcontext *ctx, - GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLsizei primcount); - - -#endif + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef API_VALIDATE_H +#define API_VALIDATE_H + + +#include "glheader.h" + +struct gl_buffer_object; +struct gl_context; + + +extern GLuint +_mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type, + const void *indices, + struct gl_buffer_object *elementBuf); + +extern GLboolean +_mesa_validate_DrawArrays(struct gl_context *ctx, + GLenum mode, GLint start, GLsizei count); + +extern GLboolean +_mesa_validate_DrawElements(struct gl_context *ctx, + GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex); + +extern GLboolean +_mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex); + + +extern GLboolean +_mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint first, + GLsizei count, GLsizei primcount); + +extern GLboolean +_mesa_validate_DrawElementsInstanced(struct gl_context *ctx, + GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLsizei primcount); + + +#endif diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 0069cd3dc..37ecb6b97 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -1,576 +1,576 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * (C) Copyright IBM Corporation 2006 - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL OR IBM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/** - * \file arrayobj.c - * Functions for the GL_APPLE_vertex_array_object extension. - * - * \todo - * The code in this file borrows a lot from bufferobj.c. There's a certain - * amount of cruft left over from that origin that may be unnecessary. - * - * \author Ian Romanick - * \author Brian Paul - */ - - -#include "glheader.h" -#include "hash.h" -#include "imports.h" -#include "context.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#include "macros.h" -#include "main/dispatch.h" - - -/** - * Look up the array object for the given ID. - * - * \returns - * Either a pointer to the array object with the specified ID or \c NULL for - * a non-existent ID. The spec defines ID 0 as being technically - * non-existent. - */ - -static INLINE struct gl_array_object * -lookup_arrayobj(GLcontext *ctx, GLuint id) -{ - if (id == 0) - return NULL; - else - return (struct gl_array_object *) - _mesa_HashLookup(ctx->Array.Objects, id); -} - - -/** - * For all the vertex arrays in the array object, unbind any pointers - * to any buffer objects (VBOs). - * This is done just prior to array object destruction. - */ -static void -unbind_array_object_vbos(GLcontext *ctx, struct gl_array_object *obj) -{ - GLuint i; - - _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->FogCoord.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL); - - for (i = 0; i < Elements(obj->TexCoord); i++) - _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL); - - for (i = 0; i < Elements(obj->VertexAttrib); i++) - _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL); - -#if FEATURE_point_size_array - _mesa_reference_buffer_object(ctx, &obj->PointSize.BufferObj, NULL); -#endif -} - - -/** - * Allocate and initialize a new vertex array object. - * - * This function is intended to be called via - * \c dd_function_table::NewArrayObject. - */ -struct gl_array_object * -_mesa_new_array_object( GLcontext *ctx, GLuint name ) -{ - struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object); - if (obj) - _mesa_initialize_array_object(ctx, obj, name); - return obj; -} - - -/** - * Delete an array object. - * - * This function is intended to be called via - * \c dd_function_table::DeleteArrayObject. - */ -void -_mesa_delete_array_object( GLcontext *ctx, struct gl_array_object *obj ) -{ - (void) ctx; - unbind_array_object_vbos(ctx, obj); - _glthread_DESTROY_MUTEX(obj->Mutex); - free(obj); -} - - -/** - * Set ptr to arrayObj w/ reference counting. - */ -void -_mesa_reference_array_object(GLcontext *ctx, - struct gl_array_object **ptr, - struct gl_array_object *arrayObj) -{ - if (*ptr == arrayObj) - return; - - if (*ptr) { - /* Unreference the old array object */ - GLboolean deleteFlag = GL_FALSE; - struct gl_array_object *oldObj = *ptr; - - _glthread_LOCK_MUTEX(oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); - oldObj->RefCount--; -#if 0 - printf("ArrayObj %p %d DECR to %d\n", - (void *) oldObj, oldObj->Name, oldObj->RefCount); -#endif - deleteFlag = (oldObj->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldObj->Mutex); - - if (deleteFlag) { - ASSERT(ctx->Driver.DeleteArrayObject); - ctx->Driver.DeleteArrayObject(ctx, oldObj); - } - - *ptr = NULL; - } - ASSERT(!*ptr); - - if (arrayObj) { - /* reference new array object */ - _glthread_LOCK_MUTEX(arrayObj->Mutex); - if (arrayObj->RefCount == 0) { - /* this array's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted array object"); - *ptr = NULL; - } - else { - arrayObj->RefCount++; -#if 0 - printf("ArrayObj %p %d INCR to %d\n", - (void *) arrayObj, arrayObj->Name, arrayObj->RefCount); -#endif - *ptr = arrayObj; - } - _glthread_UNLOCK_MUTEX(arrayObj->Mutex); - } -} - - - -static void -init_array(GLcontext *ctx, - struct gl_client_array *array, GLint size, GLint type) -{ - array->Size = size; - array->Type = type; - array->Format = GL_RGBA; /* only significant for GL_EXT_vertex_array_bgra */ - array->Stride = 0; - array->StrideB = 0; - array->Ptr = NULL; - array->Enabled = GL_FALSE; - array->Normalized = GL_FALSE; -#if FEATURE_ARB_vertex_buffer_object - /* Vertex array buffers */ - _mesa_reference_buffer_object(ctx, &array->BufferObj, - ctx->Shared->NullBufferObj); -#endif -} - - -/** - * Initialize a gl_array_object's arrays. - */ -void -_mesa_initialize_array_object( GLcontext *ctx, - struct gl_array_object *obj, - GLuint name ) -{ - GLuint i; - - obj->Name = name; - - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - - /* Init the individual arrays */ - init_array(ctx, &obj->Vertex, 4, GL_FLOAT); - init_array(ctx, &obj->Weight, 1, GL_FLOAT); - init_array(ctx, &obj->Normal, 3, GL_FLOAT); - init_array(ctx, &obj->Color, 4, GL_FLOAT); - init_array(ctx, &obj->SecondaryColor, 4, GL_FLOAT); - init_array(ctx, &obj->FogCoord, 1, GL_FLOAT); - init_array(ctx, &obj->Index, 1, GL_FLOAT); - for (i = 0; i < Elements(obj->TexCoord); i++) { - init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT); - } - init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL); - for (i = 0; i < Elements(obj->VertexAttrib); i++) { - init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT); - } - -#if FEATURE_point_size_array - init_array(ctx, &obj->PointSize, 1, GL_FLOAT); -#endif -} - - -/** - * Add the given array object to the array object pool. - */ -static void -save_array_object( GLcontext *ctx, struct gl_array_object *obj ) -{ - if (obj->Name > 0) { - /* insert into hash table */ - _mesa_HashInsert(ctx->Array.Objects, obj->Name, obj); - } -} - - -/** - * Remove the given array object from the array object pool. - * Do not deallocate the array object though. - */ -static void -remove_array_object( GLcontext *ctx, struct gl_array_object *obj ) -{ - if (obj->Name > 0) { - /* remove from hash table */ - _mesa_HashRemove(ctx->Array.Objects, obj->Name); - } -} - - - -/** - * Compute the index of the last array element that can be safely accessed - * in a vertex array. We can really only do this when the array lives in - * a VBO. - * The array->_MaxElement field will be updated. - * Later in glDrawArrays/Elements/etc we can do some bounds checking. - */ -static void -compute_max_element(struct gl_client_array *array) -{ - if (array->BufferObj->Name) { - /* Compute the max element we can access in the VBO without going - * out of bounds. - */ - array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size - - (GLsizeiptrARB) array->Ptr + array->StrideB - - array->_ElementSize) / array->StrideB; - if (0) - printf("%s Object %u Size %u MaxElement %u\n", - __FUNCTION__, - array->BufferObj->Name, - (GLuint) array->BufferObj->Size, - array->_MaxElement); - } - else { - /* user-space array, no idea how big it is */ - array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ - } -} - - -/** - * Helper for update_arrays(). - * \return min(current min, array->_MaxElement). - */ -static GLuint -update_min(GLuint min, struct gl_client_array *array) -{ - compute_max_element(array); - if (array->Enabled) - return MIN2(min, array->_MaxElement); - else - return min; -} - - -/** - * Examine vertex arrays to update the gl_array_object::_MaxElement field. - */ -void -_mesa_update_array_object_max_element(GLcontext *ctx, - struct gl_array_object *arrayObj) -{ - GLuint i, min = ~0; - - min = update_min(min, &arrayObj->Vertex); - min = update_min(min, &arrayObj->Weight); - min = update_min(min, &arrayObj->Normal); - min = update_min(min, &arrayObj->Color); - min = update_min(min, &arrayObj->SecondaryColor); - min = update_min(min, &arrayObj->FogCoord); - min = update_min(min, &arrayObj->Index); - min = update_min(min, &arrayObj->EdgeFlag); -#if FEATURE_point_size_array - min = update_min(min, &arrayObj->PointSize); -#endif - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) - min = update_min(min, &arrayObj->TexCoord[i]); - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) - min = update_min(min, &arrayObj->VertexAttrib[i]); - - /* _MaxElement is one past the last legal array element */ - arrayObj->_MaxElement = min; -} - - -/**********************************************************************/ -/* API Functions */ -/**********************************************************************/ - - -/** - * Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE(). - * \param genRequired specifies behavour when id was not generated with - * glGenVertexArrays(). - */ -static void -bind_vertex_array(GLcontext *ctx, GLuint id, GLboolean genRequired) -{ - struct gl_array_object * const oldObj = ctx->Array.ArrayObj; - struct gl_array_object *newObj = NULL; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - ASSERT(oldObj != NULL); - - if ( oldObj->Name == id ) - return; /* rebinding the same array object- no change */ - - /* - * Get pointer to new array object (newObj) - */ - if (id == 0) { - /* The spec says there is no array object named 0, but we use - * one internally because it simplifies things. - */ - newObj = ctx->Array.DefaultArrayObj; - } - else { - /* non-default array object */ - newObj = lookup_arrayobj(ctx, id); - if (!newObj) { - if (genRequired) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindVertexArray(id)"); - return; - } - - /* For APPLE version, generate a new array object now */ - newObj = (*ctx->Driver.NewArrayObject)(ctx, id); - if (!newObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE"); - return; - } - save_array_object(ctx, newObj); - } - } - - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= _NEW_ARRAY_ALL; - _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj); - - /* Pass BindVertexArray call to device driver */ - if (ctx->Driver.BindArrayObject && newObj) - ctx->Driver.BindArrayObject(ctx, newObj); -} - - -/** - * ARB version of glBindVertexArray() - * This function behaves differently from glBindVertexArrayAPPLE() in - * that this function requires all ids to have been previously generated - * by glGenVertexArrays[APPLE](). - */ -void GLAPIENTRY -_mesa_BindVertexArray( GLuint id ) -{ - GET_CURRENT_CONTEXT(ctx); - bind_vertex_array(ctx, id, GL_TRUE); -} - - -/** - * Bind a new array. - * - * \todo - * The binding could be done more efficiently by comparing the non-NULL - * pointers in the old and new objects. The only arrays that are "dirty" are - * the ones that are non-NULL in either object. - */ -void GLAPIENTRY -_mesa_BindVertexArrayAPPLE( GLuint id ) -{ - GET_CURRENT_CONTEXT(ctx); - bind_vertex_array(ctx, id, GL_FALSE); -} - - -/** - * Delete a set of array objects. - * - * \param n Number of array objects to delete. - * \param ids Array of \c n array object IDs. - */ -void GLAPIENTRY -_mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) -{ - GET_CURRENT_CONTEXT(ctx); - GLsizei i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteVertexArrayAPPLE(n)"); - return; - } - - for (i = 0; i < n; i++) { - struct gl_array_object *obj = lookup_arrayobj(ctx, ids[i]); - - if ( obj != NULL ) { - ASSERT( obj->Name == ids[i] ); - - /* If the array object is currently bound, the spec says "the binding - * for that object reverts to zero and the default vertex array - * becomes current." - */ - if ( obj == ctx->Array.ArrayObj ) { - CALL_BindVertexArrayAPPLE( ctx->Exec, (0) ); - } - - /* The ID is immediately freed for re-use */ - remove_array_object(ctx, obj); - - /* Unreference the array object. - * If refcount hits zero, the object will be deleted. - */ - _mesa_reference_array_object(ctx, &obj, NULL); - } - } -} - - -/** - * Generate a set of unique array object IDs and store them in \c arrays. - * Helper for _mesa_GenVertexArrays[APPLE]() functions below. - * \param n Number of IDs to generate. - * \param arrays Array of \c n locations to store the IDs. - * \param vboOnly Will arrays have to reside in VBOs? - */ -static void -gen_vertex_arrays(GLcontext *ctx, GLsizei n, GLuint *arrays, GLboolean vboOnly) -{ - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenVertexArraysAPPLE"); - return; - } - - if (!arrays) { - return; - } - - first = _mesa_HashFindFreeKeyBlock(ctx->Array.Objects, n); - - /* Allocate new, empty array objects and return identifiers */ - for (i = 0; i < n; i++) { - struct gl_array_object *obj; - GLuint name = first + i; - - obj = (*ctx->Driver.NewArrayObject)( ctx, name ); - if (!obj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE"); - return; - } - obj->VBOonly = vboOnly; - save_array_object(ctx, obj); - arrays[i] = first + i; - } -} - - -/** - * ARB version of glGenVertexArrays() - * All arrays will be required to live in VBOs. - */ -void GLAPIENTRY -_mesa_GenVertexArrays(GLsizei n, GLuint *arrays) -{ - GET_CURRENT_CONTEXT(ctx); - gen_vertex_arrays(ctx, n, arrays, GL_TRUE); -} - - -/** - * APPLE version of glGenVertexArraysAPPLE() - * Arrays may live in VBOs or ordinary memory. - */ -void GLAPIENTRY -_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays) -{ - GET_CURRENT_CONTEXT(ctx); - gen_vertex_arrays(ctx, n, arrays, GL_FALSE); -} - - -/** - * Determine if ID is the name of an array object. - * - * \param id ID of the potential array object. - * \return \c GL_TRUE if \c id is the name of a array object, - * \c GL_FALSE otherwise. - */ -GLboolean GLAPIENTRY -_mesa_IsVertexArrayAPPLE( GLuint id ) -{ - struct gl_array_object * obj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (id == 0) - return GL_FALSE; - - obj = lookup_arrayobj(ctx, id); - - return (obj != NULL) ? GL_TRUE : GL_FALSE; -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * (C) Copyright IBM Corporation 2006 + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL OR IBM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + +/** + * \file arrayobj.c + * Functions for the GL_APPLE_vertex_array_object extension. + * + * \todo + * The code in this file borrows a lot from bufferobj.c. There's a certain + * amount of cruft left over from that origin that may be unnecessary. + * + * \author Ian Romanick + * \author Brian Paul + */ + + +#include "glheader.h" +#include "hash.h" +#include "imports.h" +#include "context.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#include "macros.h" +#include "main/dispatch.h" + + +/** + * Look up the array object for the given ID. + * + * \returns + * Either a pointer to the array object with the specified ID or \c NULL for + * a non-existent ID. The spec defines ID 0 as being technically + * non-existent. + */ + +static INLINE struct gl_array_object * +lookup_arrayobj(struct gl_context *ctx, GLuint id) +{ + if (id == 0) + return NULL; + else + return (struct gl_array_object *) + _mesa_HashLookup(ctx->Array.Objects, id); +} + + +/** + * For all the vertex arrays in the array object, unbind any pointers + * to any buffer objects (VBOs). + * This is done just prior to array object destruction. + */ +static void +unbind_array_object_vbos(struct gl_context *ctx, struct gl_array_object *obj) +{ + GLuint i; + + _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->FogCoord.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL); + + for (i = 0; i < Elements(obj->TexCoord); i++) + _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL); + + for (i = 0; i < Elements(obj->VertexAttrib); i++) + _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL); + +#if FEATURE_point_size_array + _mesa_reference_buffer_object(ctx, &obj->PointSize.BufferObj, NULL); +#endif +} + + +/** + * Allocate and initialize a new vertex array object. + * + * This function is intended to be called via + * \c dd_function_table::NewArrayObject. + */ +struct gl_array_object * +_mesa_new_array_object( struct gl_context *ctx, GLuint name ) +{ + struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object); + if (obj) + _mesa_initialize_array_object(ctx, obj, name); + return obj; +} + + +/** + * Delete an array object. + * + * This function is intended to be called via + * \c dd_function_table::DeleteArrayObject. + */ +void +_mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj ) +{ + (void) ctx; + unbind_array_object_vbos(ctx, obj); + _glthread_DESTROY_MUTEX(obj->Mutex); + free(obj); +} + + +/** + * Set ptr to arrayObj w/ reference counting. + */ +void +_mesa_reference_array_object(struct gl_context *ctx, + struct gl_array_object **ptr, + struct gl_array_object *arrayObj) +{ + if (*ptr == arrayObj) + return; + + if (*ptr) { + /* Unreference the old array object */ + GLboolean deleteFlag = GL_FALSE; + struct gl_array_object *oldObj = *ptr; + + _glthread_LOCK_MUTEX(oldObj->Mutex); + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; +#if 0 + printf("ArrayObj %p %d DECR to %d\n", + (void *) oldObj, oldObj->Name, oldObj->RefCount); +#endif + deleteFlag = (oldObj->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldObj->Mutex); + + if (deleteFlag) { + ASSERT(ctx->Driver.DeleteArrayObject); + ctx->Driver.DeleteArrayObject(ctx, oldObj); + } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (arrayObj) { + /* reference new array object */ + _glthread_LOCK_MUTEX(arrayObj->Mutex); + if (arrayObj->RefCount == 0) { + /* this array's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted array object"); + *ptr = NULL; + } + else { + arrayObj->RefCount++; +#if 0 + printf("ArrayObj %p %d INCR to %d\n", + (void *) arrayObj, arrayObj->Name, arrayObj->RefCount); +#endif + *ptr = arrayObj; + } + _glthread_UNLOCK_MUTEX(arrayObj->Mutex); + } +} + + + +static void +init_array(struct gl_context *ctx, + struct gl_client_array *array, GLint size, GLint type) +{ + array->Size = size; + array->Type = type; + array->Format = GL_RGBA; /* only significant for GL_EXT_vertex_array_bgra */ + array->Stride = 0; + array->StrideB = 0; + array->Ptr = NULL; + array->Enabled = GL_FALSE; + array->Normalized = GL_FALSE; +#if FEATURE_ARB_vertex_buffer_object + /* Vertex array buffers */ + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Shared->NullBufferObj); +#endif +} + + +/** + * Initialize a gl_array_object's arrays. + */ +void +_mesa_initialize_array_object( struct gl_context *ctx, + struct gl_array_object *obj, + GLuint name ) +{ + GLuint i; + + obj->Name = name; + + _glthread_INIT_MUTEX(obj->Mutex); + obj->RefCount = 1; + + /* Init the individual arrays */ + init_array(ctx, &obj->Vertex, 4, GL_FLOAT); + init_array(ctx, &obj->Weight, 1, GL_FLOAT); + init_array(ctx, &obj->Normal, 3, GL_FLOAT); + init_array(ctx, &obj->Color, 4, GL_FLOAT); + init_array(ctx, &obj->SecondaryColor, 4, GL_FLOAT); + init_array(ctx, &obj->FogCoord, 1, GL_FLOAT); + init_array(ctx, &obj->Index, 1, GL_FLOAT); + for (i = 0; i < Elements(obj->TexCoord); i++) { + init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT); + } + init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL); + for (i = 0; i < Elements(obj->VertexAttrib); i++) { + init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT); + } + +#if FEATURE_point_size_array + init_array(ctx, &obj->PointSize, 1, GL_FLOAT); +#endif +} + + +/** + * Add the given array object to the array object pool. + */ +static void +save_array_object( struct gl_context *ctx, struct gl_array_object *obj ) +{ + if (obj->Name > 0) { + /* insert into hash table */ + _mesa_HashInsert(ctx->Array.Objects, obj->Name, obj); + } +} + + +/** + * Remove the given array object from the array object pool. + * Do not deallocate the array object though. + */ +static void +remove_array_object( struct gl_context *ctx, struct gl_array_object *obj ) +{ + if (obj->Name > 0) { + /* remove from hash table */ + _mesa_HashRemove(ctx->Array.Objects, obj->Name); + } +} + + + +/** + * Compute the index of the last array element that can be safely accessed + * in a vertex array. We can really only do this when the array lives in + * a VBO. + * The array->_MaxElement field will be updated. + * Later in glDrawArrays/Elements/etc we can do some bounds checking. + */ +static void +compute_max_element(struct gl_client_array *array) +{ + if (array->BufferObj->Name) { + /* Compute the max element we can access in the VBO without going + * out of bounds. + */ + array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size + - (GLsizeiptrARB) array->Ptr + array->StrideB + - array->_ElementSize) / array->StrideB; + if (0) + printf("%s Object %u Size %u MaxElement %u\n", + __FUNCTION__, + array->BufferObj->Name, + (GLuint) array->BufferObj->Size, + array->_MaxElement); + } + else { + /* user-space array, no idea how big it is */ + array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ + } +} + + +/** + * Helper for update_arrays(). + * \return min(current min, array->_MaxElement). + */ +static GLuint +update_min(GLuint min, struct gl_client_array *array) +{ + compute_max_element(array); + if (array->Enabled) + return MIN2(min, array->_MaxElement); + else + return min; +} + + +/** + * Examine vertex arrays to update the gl_array_object::_MaxElement field. + */ +void +_mesa_update_array_object_max_element(struct gl_context *ctx, + struct gl_array_object *arrayObj) +{ + GLuint i, min = ~0; + + min = update_min(min, &arrayObj->Vertex); + min = update_min(min, &arrayObj->Weight); + min = update_min(min, &arrayObj->Normal); + min = update_min(min, &arrayObj->Color); + min = update_min(min, &arrayObj->SecondaryColor); + min = update_min(min, &arrayObj->FogCoord); + min = update_min(min, &arrayObj->Index); + min = update_min(min, &arrayObj->EdgeFlag); +#if FEATURE_point_size_array + min = update_min(min, &arrayObj->PointSize); +#endif + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) + min = update_min(min, &arrayObj->TexCoord[i]); + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) + min = update_min(min, &arrayObj->VertexAttrib[i]); + + /* _MaxElement is one past the last legal array element */ + arrayObj->_MaxElement = min; +} + + +/**********************************************************************/ +/* API Functions */ +/**********************************************************************/ + + +/** + * Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE(). + * \param genRequired specifies behavour when id was not generated with + * glGenVertexArrays(). + */ +static void +bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) +{ + struct gl_array_object * const oldObj = ctx->Array.ArrayObj; + struct gl_array_object *newObj = NULL; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + ASSERT(oldObj != NULL); + + if ( oldObj->Name == id ) + return; /* rebinding the same array object- no change */ + + /* + * Get pointer to new array object (newObj) + */ + if (id == 0) { + /* The spec says there is no array object named 0, but we use + * one internally because it simplifies things. + */ + newObj = ctx->Array.DefaultArrayObj; + } + else { + /* non-default array object */ + newObj = lookup_arrayobj(ctx, id); + if (!newObj) { + if (genRequired) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindVertexArray(id)"); + return; + } + + /* For APPLE version, generate a new array object now */ + newObj = (*ctx->Driver.NewArrayObject)(ctx, id); + if (!newObj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE"); + return; + } + save_array_object(ctx, newObj); + } + } + + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= _NEW_ARRAY_ALL; + _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj); + + /* Pass BindVertexArray call to device driver */ + if (ctx->Driver.BindArrayObject && newObj) + ctx->Driver.BindArrayObject(ctx, newObj); +} + + +/** + * ARB version of glBindVertexArray() + * This function behaves differently from glBindVertexArrayAPPLE() in + * that this function requires all ids to have been previously generated + * by glGenVertexArrays[APPLE](). + */ +void GLAPIENTRY +_mesa_BindVertexArray( GLuint id ) +{ + GET_CURRENT_CONTEXT(ctx); + bind_vertex_array(ctx, id, GL_TRUE); +} + + +/** + * Bind a new array. + * + * \todo + * The binding could be done more efficiently by comparing the non-NULL + * pointers in the old and new objects. The only arrays that are "dirty" are + * the ones that are non-NULL in either object. + */ +void GLAPIENTRY +_mesa_BindVertexArrayAPPLE( GLuint id ) +{ + GET_CURRENT_CONTEXT(ctx); + bind_vertex_array(ctx, id, GL_FALSE); +} + + +/** + * Delete a set of array objects. + * + * \param n Number of array objects to delete. + * \param ids Array of \c n array object IDs. + */ +void GLAPIENTRY +_mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) +{ + GET_CURRENT_CONTEXT(ctx); + GLsizei i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteVertexArrayAPPLE(n)"); + return; + } + + for (i = 0; i < n; i++) { + struct gl_array_object *obj = lookup_arrayobj(ctx, ids[i]); + + if ( obj != NULL ) { + ASSERT( obj->Name == ids[i] ); + + /* If the array object is currently bound, the spec says "the binding + * for that object reverts to zero and the default vertex array + * becomes current." + */ + if ( obj == ctx->Array.ArrayObj ) { + CALL_BindVertexArrayAPPLE( ctx->Exec, (0) ); + } + + /* The ID is immediately freed for re-use */ + remove_array_object(ctx, obj); + + /* Unreference the array object. + * If refcount hits zero, the object will be deleted. + */ + _mesa_reference_array_object(ctx, &obj, NULL); + } + } +} + + +/** + * Generate a set of unique array object IDs and store them in \c arrays. + * Helper for _mesa_GenVertexArrays[APPLE]() functions below. + * \param n Number of IDs to generate. + * \param arrays Array of \c n locations to store the IDs. + * \param vboOnly Will arrays have to reside in VBOs? + */ +static void +gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays, GLboolean vboOnly) +{ + GLuint first; + GLint i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenVertexArraysAPPLE"); + return; + } + + if (!arrays) { + return; + } + + first = _mesa_HashFindFreeKeyBlock(ctx->Array.Objects, n); + + /* Allocate new, empty array objects and return identifiers */ + for (i = 0; i < n; i++) { + struct gl_array_object *obj; + GLuint name = first + i; + + obj = (*ctx->Driver.NewArrayObject)( ctx, name ); + if (!obj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE"); + return; + } + obj->VBOonly = vboOnly; + save_array_object(ctx, obj); + arrays[i] = first + i; + } +} + + +/** + * ARB version of glGenVertexArrays() + * All arrays will be required to live in VBOs. + */ +void GLAPIENTRY +_mesa_GenVertexArrays(GLsizei n, GLuint *arrays) +{ + GET_CURRENT_CONTEXT(ctx); + gen_vertex_arrays(ctx, n, arrays, GL_TRUE); +} + + +/** + * APPLE version of glGenVertexArraysAPPLE() + * Arrays may live in VBOs or ordinary memory. + */ +void GLAPIENTRY +_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays) +{ + GET_CURRENT_CONTEXT(ctx); + gen_vertex_arrays(ctx, n, arrays, GL_FALSE); +} + + +/** + * Determine if ID is the name of an array object. + * + * \param id ID of the potential array object. + * \return \c GL_TRUE if \c id is the name of a array object, + * \c GL_FALSE otherwise. + */ +GLboolean GLAPIENTRY +_mesa_IsVertexArrayAPPLE( GLuint id ) +{ + struct gl_array_object * obj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (id == 0) + return GL_FALSE; + + obj = lookup_arrayobj(ctx, id); + + return (obj != NULL) ? GL_TRUE : GL_FALSE; +} diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h index fdf7e2bca..44f771417 100644 --- a/mesalib/src/mesa/main/arrayobj.h +++ b/mesalib/src/mesa/main/arrayobj.h @@ -1,83 +1,85 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * (C) Copyright IBM Corporation 2006 - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL OR IBM 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. - */ - -#ifndef ARRAYOBJ_H -#define ARRAYOBJ_H - -#include "mtypes.h" - -/** - * \file arrayobj.h - * Functions for the GL_APPLE_vertex_array_object extension. - * - * \author Ian Romanick - * \author Brian Paul - */ - -/* - * Internal functions - */ - -extern struct gl_array_object * -_mesa_new_array_object( GLcontext *ctx, GLuint name ); - -extern void -_mesa_delete_array_object( GLcontext *ctx, struct gl_array_object *obj ); - -extern void -_mesa_reference_array_object(GLcontext *ctx, - struct gl_array_object **ptr, - struct gl_array_object *arrayObj); - -extern void -_mesa_initialize_array_object( GLcontext *ctx, - struct gl_array_object *obj, GLuint name ); - - -extern void -_mesa_update_array_object_max_element(GLcontext *ctx, - struct gl_array_object *arrayObj); - - -/* - * API functions - */ - - -void GLAPIENTRY _mesa_BindVertexArray( GLuint id ); - -void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id ); - -void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids); - -void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays); - -void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer); - -GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id ); - -#endif /* ARRAYOBJ_H */ +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * (C) Copyright IBM Corporation 2006 + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL OR IBM 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. + */ + +#ifndef ARRAYOBJ_H +#define ARRAYOBJ_H + +#include "glheader.h" + +struct gl_context; + +/** + * \file arrayobj.h + * Functions for the GL_APPLE_vertex_array_object extension. + * + * \author Ian Romanick + * \author Brian Paul + */ + +/* + * Internal functions + */ + +extern struct gl_array_object * +_mesa_new_array_object( struct gl_context *ctx, GLuint name ); + +extern void +_mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj ); + +extern void +_mesa_reference_array_object(struct gl_context *ctx, + struct gl_array_object **ptr, + struct gl_array_object *arrayObj); + +extern void +_mesa_initialize_array_object( struct gl_context *ctx, + struct gl_array_object *obj, GLuint name ); + + +extern void +_mesa_update_array_object_max_element(struct gl_context *ctx, + struct gl_array_object *arrayObj); + + +/* + * API functions + */ + + +void GLAPIENTRY _mesa_BindVertexArray( GLuint id ); + +void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id ); + +void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids); + +void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays); + +void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer); + +GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id ); + +#endif /* ARRAYOBJ_H */ diff --git a/mesalib/src/mesa/main/atifragshader.c b/mesalib/src/mesa/main/atifragshader.c index 550f50b7a..f2a41e30b 100644 --- a/mesalib/src/mesa/main/atifragshader.c +++ b/mesalib/src/mesa/main/atifragshader.c @@ -1,794 +1,795 @@ -/** - * \file atifragshader.c - * \author David Airlie - * Copyright (C) 2004 David Airlie All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID AIRLIE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/enums.h" -#include "main/mtypes.h" -#include "main/dispatch.h" -#include "main/atifragshader.h" - -#if FEATURE_ATI_fragment_shader - -#define MESA_DEBUG_ATI_FS 0 - -static struct ati_fragment_shader DummyShader; - - -void -_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) -{ - SET_GenFragmentShadersATI(disp, _mesa_GenFragmentShadersATI); - SET_BindFragmentShaderATI(disp, _mesa_BindFragmentShaderATI); - SET_DeleteFragmentShaderATI(disp, _mesa_DeleteFragmentShaderATI); - SET_BeginFragmentShaderATI(disp, _mesa_BeginFragmentShaderATI); - SET_EndFragmentShaderATI(disp, _mesa_EndFragmentShaderATI); - SET_PassTexCoordATI(disp, _mesa_PassTexCoordATI); - SET_SampleMapATI(disp, _mesa_SampleMapATI); - SET_ColorFragmentOp1ATI(disp, _mesa_ColorFragmentOp1ATI); - SET_ColorFragmentOp2ATI(disp, _mesa_ColorFragmentOp2ATI); - SET_ColorFragmentOp3ATI(disp, _mesa_ColorFragmentOp3ATI); - SET_AlphaFragmentOp1ATI(disp, _mesa_AlphaFragmentOp1ATI); - SET_AlphaFragmentOp2ATI(disp, _mesa_AlphaFragmentOp2ATI); - SET_AlphaFragmentOp3ATI(disp, _mesa_AlphaFragmentOp3ATI); - SET_SetFragmentShaderConstantATI(disp, _mesa_SetFragmentShaderConstantATI); -} - - -/** - * Allocate and initialize a new ATI fragment shader object. - */ -struct ati_fragment_shader * -_mesa_new_ati_fragment_shader(GLcontext *ctx, GLuint id) -{ - struct ati_fragment_shader *s = CALLOC_STRUCT(ati_fragment_shader); - (void) ctx; - if (s) { - s->Id = id; - s->RefCount = 1; - } - return s; -} - - -/** - * Delete the given ati fragment shader - */ -void -_mesa_delete_ati_fragment_shader(GLcontext *ctx, struct ati_fragment_shader *s) -{ - GLuint i; - for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { - if (s->Instructions[i]) - free(s->Instructions[i]); - if (s->SetupInst[i]) - free(s->SetupInst[i]); - } - free(s); -} - - - -static void -new_arith_inst(struct ati_fragment_shader *prog) -{ -/* set "default" instruction as not all may get defined. - there is no specified way to express a nop with ati fragment shaders we use - GL_NONE as the op enum and just set some params to 0 - so nothing to do here */ - prog->numArithInstr[prog->cur_pass >> 1]++; -} - -static void -new_tex_inst(struct ati_fragment_shader *prog) -{ -} - -static void match_pair_inst(struct ati_fragment_shader *curProg, GLuint optype) -{ - if (optype == curProg->last_optype) { - curProg->last_optype = 1; - } -} - -#if MESA_DEBUG_ATI_FS -static char * -create_dst_mod_str(GLuint mod) -{ - static char ret_str[1024]; - - memset(ret_str, 0, 1024); - if (mod & GL_2X_BIT_ATI) - strncat(ret_str, "|2X", 1024); - - if (mod & GL_4X_BIT_ATI) - strncat(ret_str, "|4X", 1024); - - if (mod & GL_8X_BIT_ATI) - strncat(ret_str, "|8X", 1024); - if (mod & GL_HALF_BIT_ATI) - strncat(ret_str, "|HA", 1024); - if (mod & GL_QUARTER_BIT_ATI) - strncat(ret_str, "|QU", 1024); - if (mod & GL_EIGHTH_BIT_ATI) - strncat(ret_str, "|EI", 1024); - - if (mod & GL_SATURATE_BIT_ATI) - strncat(ret_str, "|SAT", 1024); - - if (strlen(ret_str) == 0) - strncat(ret_str, "NONE", 1024); - return ret_str; -} - -static char *atifs_ops[] = {"ColorFragmentOp1ATI", "ColorFragmentOp2ATI", "ColorFragmentOp3ATI", - "AlphaFragmentOp1ATI", "AlphaFragmentOp2ATI", "AlphaFragmentOp3ATI" }; - -static void debug_op(GLint optype, GLuint arg_count, GLenum op, GLuint dst, - GLuint dstMask, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, - GLuint arg3Rep, GLuint arg3Mod) -{ - char *op_name; - - op_name = atifs_ops[(arg_count-1)+(optype?3:0)]; - - fprintf(stderr, "%s(%s, %s", op_name, _mesa_lookup_enum_by_nr(op), - _mesa_lookup_enum_by_nr(dst)); - if (!optype) - fprintf(stderr, ", %d", dstMask); - - fprintf(stderr, ", %s", create_dst_mod_str(dstMod)); - - fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg1), - _mesa_lookup_enum_by_nr(arg1Rep), arg1Mod); - if (arg_count>1) - fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg2), - _mesa_lookup_enum_by_nr(arg2Rep), arg2Mod); - if (arg_count>2) - fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg3), - _mesa_lookup_enum_by_nr(arg3Rep), arg3Mod); - - fprintf(stderr,")\n"); - -} -#endif - -static int check_arith_arg(struct ati_fragment_shader *curProg, - GLuint optype, GLuint arg, GLuint argRep) -{ - GET_CURRENT_CONTEXT(ctx); - - if (((arg < GL_CON_0_ATI) || (arg > GL_CON_7_ATI)) && - ((arg < GL_REG_0_ATI) || (arg > GL_REG_5_ATI)) && - (arg != GL_ZERO) && (arg != GL_ONE) && - (arg != GL_PRIMARY_COLOR_ARB) && (arg != GL_SECONDARY_INTERPOLATOR_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(arg)"); - return 0; - } - if ((arg == GL_SECONDARY_INTERPOLATOR_ATI) && (((optype == 0) && (argRep == GL_ALPHA)) || - ((optype == 1) && ((arg == GL_ALPHA) || (argRep == GL_NONE))))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); - return 0; - } - if ((arg == GL_SECONDARY_INTERPOLATOR_ATI) && (((optype == 0) && (argRep == GL_ALPHA)) || - ((optype == 1) && ((arg == GL_ALPHA) || (argRep == GL_NONE))))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); - return 0; - } - if ((curProg->cur_pass == 1) && - ((arg == GL_PRIMARY_COLOR_ARB) || (arg == GL_SECONDARY_INTERPOLATOR_ATI))) { - curProg->interpinp1 = GL_TRUE; - } - return 1; -} - -GLuint GLAPIENTRY -_mesa_GenFragmentShadersATI(GLuint range) -{ - GLuint first; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - - if (range == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenFragmentShadersATI(range)"); - return 0; - } - - if (ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGenFragmentShadersATI(insideShader)"); - return 0; - } - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->ATIShaders, range); - for (i = 0; i < range; i++) { - _mesa_HashInsert(ctx->Shared->ATIShaders, first + i, &DummyShader); - } - - return first; -} - -void GLAPIENTRY -_mesa_BindFragmentShaderATI(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; - struct ati_fragment_shader *newProg; - - if (ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFragmentShaderATI(insideShader)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - if (curProg->Id == id) { - return; - } - - /* unbind current */ - if (curProg->Id != 0) { - curProg->RefCount--; - if (curProg->RefCount <= 0) { - _mesa_HashRemove(ctx->Shared->ATIShaders, id); - } - } - - /* find new shader */ - if (id == 0) { - newProg = ctx->Shared->DefaultFragmentShader; - } - else { - newProg = (struct ati_fragment_shader *) - _mesa_HashLookup(ctx->Shared->ATIShaders, id); - if (!newProg || newProg == &DummyShader) { - /* allocate a new program now */ - newProg = _mesa_new_ati_fragment_shader(ctx, id); - if (!newProg) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI"); - return; - } - _mesa_HashInsert(ctx->Shared->ATIShaders, id, newProg); - } - - } - - /* do actual bind */ - ctx->ATIFragmentShader.Current = newProg; - - ASSERT(ctx->ATIFragmentShader.Current); - if (newProg) - newProg->RefCount++; - - /*if (ctx->Driver.BindProgram) - ctx->Driver.BindProgram(ctx, target, prog); */ -} - -void GLAPIENTRY -_mesa_DeleteFragmentShaderATI(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteFragmentShaderATI(insideShader)"); - return; - } - - if (id != 0) { - struct ati_fragment_shader *prog = (struct ati_fragment_shader *) - _mesa_HashLookup(ctx->Shared->ATIShaders, id); - if (prog == &DummyShader) { - _mesa_HashRemove(ctx->Shared->ATIShaders, id); - } - else if (prog) { - if (ctx->ATIFragmentShader.Current && - ctx->ATIFragmentShader.Current->Id == id) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - _mesa_BindFragmentShaderATI(0); - } - } - - /* The ID is immediately available for re-use now */ - _mesa_HashRemove(ctx->Shared->ATIShaders, id); - if (prog) { - prog->RefCount--; - if (prog->RefCount <= 0) { - free(prog); - } - } - } -} - - -void GLAPIENTRY -_mesa_BeginFragmentShaderATI(void) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - if (ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginFragmentShaderATI(insideShader)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - /* if the shader was already defined free instructions and get new ones - (or, could use the same mem but would need to reinitialize) */ - /* no idea if it's allowed to redefine a shader */ - for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { - if (ctx->ATIFragmentShader.Current->Instructions[i]) - free(ctx->ATIFragmentShader.Current->Instructions[i]); - if (ctx->ATIFragmentShader.Current->SetupInst[i]) - free(ctx->ATIFragmentShader.Current->SetupInst[i]); - } - - /* malloc the instructions here - not sure if the best place but its - a start */ - for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { - ctx->ATIFragmentShader.Current->Instructions[i] = - (struct atifs_instruction *) - calloc(1, sizeof(struct atifs_instruction) * - (MAX_NUM_INSTRUCTIONS_PER_PASS_ATI)); - ctx->ATIFragmentShader.Current->SetupInst[i] = - (struct atifs_setupinst *) - calloc(1, sizeof(struct atifs_setupinst) * - (MAX_NUM_FRAGMENT_REGISTERS_ATI)); - } - -/* can't rely on calloc for initialization as it's possible to redefine a shader (?) */ - ctx->ATIFragmentShader.Current->LocalConstDef = 0; - ctx->ATIFragmentShader.Current->numArithInstr[0] = 0; - ctx->ATIFragmentShader.Current->numArithInstr[1] = 0; - ctx->ATIFragmentShader.Current->regsAssigned[0] = 0; - ctx->ATIFragmentShader.Current->regsAssigned[1] = 0; - ctx->ATIFragmentShader.Current->NumPasses = 0; - ctx->ATIFragmentShader.Current->cur_pass = 0; - ctx->ATIFragmentShader.Current->last_optype = 0; - ctx->ATIFragmentShader.Current->interpinp1 = GL_FALSE; - ctx->ATIFragmentShader.Current->isValid = GL_FALSE; - ctx->ATIFragmentShader.Current->swizzlerq = 0; - ctx->ATIFragmentShader.Compiling = 1; -} - -void GLAPIENTRY -_mesa_EndFragmentShaderATI(void) -{ - GET_CURRENT_CONTEXT(ctx); - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; -#if MESA_DEBUG_ATI_FS - GLint i, j; -#endif - - if (!ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(outsideShader)"); - return; - } - if (curProg->interpinp1 && (ctx->ATIFragmentShader.Current->cur_pass > 1)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(interpinfirstpass)"); - /* according to spec, DON'T return here */ - } - - match_pair_inst(curProg, 0); - ctx->ATIFragmentShader.Compiling = 0; - ctx->ATIFragmentShader.Current->isValid = GL_TRUE; - if ((ctx->ATIFragmentShader.Current->cur_pass == 0) || - (ctx->ATIFragmentShader.Current->cur_pass == 2)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(noarithinst)"); - } - if (ctx->ATIFragmentShader.Current->cur_pass > 1) - ctx->ATIFragmentShader.Current->NumPasses = 2; - else - ctx->ATIFragmentShader.Current->NumPasses = 1; - - ctx->ATIFragmentShader.Current->cur_pass = 0; - -#if MESA_DEBUG_ATI_FS - for (j = 0; j < MAX_NUM_PASSES_ATI; j++) { - for (i = 0; i < MAX_NUM_FRAGMENT_REGISTERS_ATI; i++) { - GLuint op = curProg->SetupInst[j][i].Opcode; - const char *op_enum = op > 5 ? _mesa_lookup_enum_by_nr(op) : "0"; - GLuint src = curProg->SetupInst[j][i].src; - GLuint swizzle = curProg->SetupInst[j][i].swizzle; - fprintf(stderr, "%2d %04X %s %d %04X\n", i, op, op_enum, src, - swizzle); - } - for (i = 0; i < curProg->numArithInstr[j]; i++) { - GLuint op0 = curProg->Instructions[j][i].Opcode[0]; - GLuint op1 = curProg->Instructions[j][i].Opcode[1]; - const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0"; - const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0"; - GLuint count0 = curProg->Instructions[j][i].ArgCount[0]; - GLuint count1 = curProg->Instructions[j][i].ArgCount[1]; - fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0, - op1, op1_enum, count1); - } - } -#endif - - if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI, NULL)) { - ctx->ATIFragmentShader.Current->isValid = GL_FALSE; - /* XXX is this the right error? */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEndFragmentShaderATI(driver rejected shader)"); - } -} - -void GLAPIENTRY -_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) -{ - GET_CURRENT_CONTEXT(ctx); - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; - struct atifs_setupinst *curI; - - if (!ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(outsideShader)"); - return; - } - - if (curProg->cur_pass == 1) { - match_pair_inst(curProg, 0); - curProg->cur_pass = 2; - } - if ((curProg->cur_pass > 2) || - ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoord(pass)"); - return; - } - if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || - ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(dst)"); - return; - } - if (((coord < GL_REG_0_ATI) || (coord > GL_REG_5_ATI)) && - ((coord < GL_TEXTURE0_ARB) || (coord > GL_TEXTURE7_ARB) || - ((coord - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(coord)"); - return; - } - if ((curProg->cur_pass == 0) && (coord >= GL_REG_0_ATI)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(coord)"); - return; - } - if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(swizzle)"); - return; - } - if ((swizzle & 1) && (coord >= GL_REG_0_ATI)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); - return; - } - if (coord <= GL_TEXTURE7_ARB) { - GLuint tmp = coord - GL_TEXTURE0_ARB; - if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && - (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); - return; - } else { - curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); - } - } - - curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); - new_tex_inst(curProg); - - /* add the instructions */ - curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; - - curI->Opcode = ATI_FRAGMENT_SHADER_PASS_OP; - curI->src = coord; - curI->swizzle = swizzle; - -#if MESA_DEBUG_ATI_FS - _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord), - _mesa_lookup_enum_by_nr(swizzle)); -#endif -} - -void GLAPIENTRY -_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) -{ - GET_CURRENT_CONTEXT(ctx); - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; - struct atifs_setupinst *curI; - - if (!ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(outsideShader)"); - return; - } - - if (curProg->cur_pass == 1) { - match_pair_inst(curProg, 0); - curProg->cur_pass = 2; - } - if ((curProg->cur_pass > 2) || - ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(pass)"); - return; - } - if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || - ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(dst)"); - return; - } - if (((interp < GL_REG_0_ATI) || (interp > GL_REG_5_ATI)) && - ((interp < GL_TEXTURE0_ARB) || (interp > GL_TEXTURE7_ARB) || - ((interp - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { - /* is this texture5 or texture7? spec is a bit unclear there */ - _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(interp)"); - return; - } - if ((curProg->cur_pass == 0) && (interp >= GL_REG_0_ATI)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(interp)"); - return; - } - if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(swizzle)"); - return; - } - if ((swizzle & 1) && (interp >= GL_REG_0_ATI)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); - return; - } - if (interp <= GL_TEXTURE7_ARB) { - GLuint tmp = interp - GL_TEXTURE0_ARB; - if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && - (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); - return; - } else { - curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); - } - } - - curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); - new_tex_inst(curProg); - - /* add the instructions */ - curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; - - curI->Opcode = ATI_FRAGMENT_SHADER_SAMPLE_OP; - curI->src = interp; - curI->swizzle = swizzle; - -#if MESA_DEBUG_ATI_FS - _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, - _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp), - _mesa_lookup_enum_by_nr(swizzle)); -#endif -} - -static void -_mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst, - GLuint dstMask, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, - GLuint arg3Rep, GLuint arg3Mod) -{ - GET_CURRENT_CONTEXT(ctx); - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; - GLint ci; - struct atifs_instruction *curI; - GLuint modtemp = dstMod & ~GL_SATURATE_BIT_ATI; - - if (!ctx->ATIFragmentShader.Compiling) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(outsideShader)"); - return; - } - - if (curProg->cur_pass==0) - curProg->cur_pass=1; - - else if (curProg->cur_pass==2) - curProg->cur_pass=3; - - /* decide whether this is a new instruction or not ... all color instructions are new, - and alpha instructions might also be new if there was no preceding color inst */ - if ((optype == 0) || (curProg->last_optype == optype)) { - if (curProg->numArithInstr[curProg->cur_pass >> 1] > 7) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(instrCount)"); - return; - } - /* easier to do that here slight side effect invalid instr will still be inserted as nops */ - match_pair_inst(curProg, optype); - new_arith_inst(curProg); - } - curProg->last_optype = optype; - ci = curProg->numArithInstr[curProg->cur_pass >> 1] - 1; - - /* add the instructions */ - curI = &curProg->Instructions[curProg->cur_pass >> 1][ci]; - - /* error checking */ - if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dst)"); - return; - } - if ((modtemp != GL_NONE) && (modtemp != GL_2X_BIT_ATI) && - (modtemp != GL_4X_BIT_ATI) && (modtemp != GL_8X_BIT_ATI) && - (modtemp != GL_HALF_BIT_ATI) && !(modtemp != GL_QUARTER_BIT_ATI) && - (modtemp != GL_EIGHTH_BIT_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dstMod)%x", modtemp); - return; - } - /* op checking? Actually looks like that's missing in the spec but we'll do it anyway */ - if (((op < GL_ADD_ATI) || (op > GL_DOT2_ADD_ATI)) && !(op == GL_MOV_ATI)) { - _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(op)"); - return; - } - if (optype == 1) { - if (((op == GL_DOT2_ADD_ATI) && (curI->Opcode[0] != GL_DOT2_ADD_ATI)) || - ((op == GL_DOT3_ATI) && (curI->Opcode[0] != GL_DOT3_ATI)) || - ((op == GL_DOT4_ATI) && (curI->Opcode[0] != GL_DOT4_ATI)) || - ((op != GL_DOT4_ATI) && (curI->Opcode[0] == GL_DOT4_ATI))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "AFragmentOpATI(op)"); - return; - } - } - if ((op == GL_DOT4_ATI) && - (((arg1 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg1Rep == GL_ALPHA) || (arg1Rep == GL_NONE))) || - (((arg2 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg2Rep == GL_ALPHA) || (arg2Rep == GL_NONE)))))) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); - } - - if (!check_arith_arg(curProg, optype, arg1, arg1Rep)) { - return; - } - if (arg2) { - if (!check_arith_arg(curProg, optype, arg2, arg2Rep)) { - return; - } - } - if (arg3) { - if (!check_arith_arg(curProg, optype, arg3, arg3Rep)) { - return; - } - if ((arg1 >= GL_CON_0_ATI) && (arg1 <= GL_CON_7_ATI) && - (arg2 >= GL_CON_0_ATI) && (arg2 <= GL_CON_7_ATI) && - (arg3 >= GL_CON_0_ATI) && (arg3 <= GL_CON_7_ATI) && - (arg1 != arg2) && (arg1 != arg3) && (arg2 != arg3)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(3Consts)"); - return; - } - } - - /* all ok - not all fully validated though (e.g. argNMod - spec doesn't say anything) */ - - curI->Opcode[optype] = op; - curI->SrcReg[optype][0].Index = arg1; - curI->SrcReg[optype][0].argRep = arg1Rep; - curI->SrcReg[optype][0].argMod = arg1Mod; - curI->ArgCount[optype] = arg_count; - - if (arg2) { - curI->SrcReg[optype][1].Index = arg2; - curI->SrcReg[optype][1].argRep = arg2Rep; - curI->SrcReg[optype][1].argMod = arg2Mod; - } - - if (arg3) { - curI->SrcReg[optype][2].Index = arg3; - curI->SrcReg[optype][2].argRep = arg3Rep; - curI->SrcReg[optype][2].argMod = arg3Mod; - } - - curI->DstReg[optype].Index = dst; - curI->DstReg[optype].dstMod = dstMod; - curI->DstReg[optype].dstMask = dstMask; - -#if MESA_DEBUG_ATI_FS - debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); -#endif - -} - -void GLAPIENTRY -_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 1, op, dst, dstMask, - dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); -} - -void GLAPIENTRY -_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 2, op, dst, dstMask, - dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, - arg2Mod, 0, 0, 0); -} - -void GLAPIENTRY -_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, - GLuint arg3Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 3, op, dst, dstMask, - dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, - arg2Mod, arg3, arg3Rep, arg3Mod); -} - -void GLAPIENTRY -_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 1, op, dst, 0, dstMod, - arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); -} - -void GLAPIENTRY -_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 2, op, dst, 0, dstMod, - arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0, - 0); -} - -void GLAPIENTRY -_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, - GLuint arg3Rep, GLuint arg3Mod) -{ - _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 3, op, dst, 0, dstMod, - arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, - arg3Rep, arg3Mod); -} - -void GLAPIENTRY -_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value) -{ - GLuint dstindex; - GET_CURRENT_CONTEXT(ctx); - - if ((dst < GL_CON_0_ATI) || (dst > GL_CON_7_ATI)) { - /* spec says nothing about what should happen here but we can't just segfault...*/ - _mesa_error(ctx, GL_INVALID_ENUM, "glSetFragmentShaderConstantATI(dst)"); - return; - } - - dstindex = dst - GL_CON_0_ATI; - if (ctx->ATIFragmentShader.Compiling) { - struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; - COPY_4V(curProg->Constants[dstindex], value); - curProg->LocalConstDef |= 1 << dstindex; - } - else { - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - COPY_4V(ctx->ATIFragmentShader.GlobalConstants[dstindex], value); - } -} - -#endif /* FEATURE_ATI_fragment_shader */ +/** + * \file atifragshader.c + * \author David Airlie + * Copyright (C) 2004 David Airlie All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * DAVID AIRLIE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/enums.h" +#include "main/mtypes.h" +#include "main/dispatch.h" +#include "main/atifragshader.h" + +#if FEATURE_ATI_fragment_shader + +#define MESA_DEBUG_ATI_FS 0 + +static struct ati_fragment_shader DummyShader; + + +void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) +{ + SET_GenFragmentShadersATI(disp, _mesa_GenFragmentShadersATI); + SET_BindFragmentShaderATI(disp, _mesa_BindFragmentShaderATI); + SET_DeleteFragmentShaderATI(disp, _mesa_DeleteFragmentShaderATI); + SET_BeginFragmentShaderATI(disp, _mesa_BeginFragmentShaderATI); + SET_EndFragmentShaderATI(disp, _mesa_EndFragmentShaderATI); + SET_PassTexCoordATI(disp, _mesa_PassTexCoordATI); + SET_SampleMapATI(disp, _mesa_SampleMapATI); + SET_ColorFragmentOp1ATI(disp, _mesa_ColorFragmentOp1ATI); + SET_ColorFragmentOp2ATI(disp, _mesa_ColorFragmentOp2ATI); + SET_ColorFragmentOp3ATI(disp, _mesa_ColorFragmentOp3ATI); + SET_AlphaFragmentOp1ATI(disp, _mesa_AlphaFragmentOp1ATI); + SET_AlphaFragmentOp2ATI(disp, _mesa_AlphaFragmentOp2ATI); + SET_AlphaFragmentOp3ATI(disp, _mesa_AlphaFragmentOp3ATI); + SET_SetFragmentShaderConstantATI(disp, _mesa_SetFragmentShaderConstantATI); +} + + +/** + * Allocate and initialize a new ATI fragment shader object. + */ +struct ati_fragment_shader * +_mesa_new_ati_fragment_shader(struct gl_context *ctx, GLuint id) +{ + struct ati_fragment_shader *s = CALLOC_STRUCT(ati_fragment_shader); + (void) ctx; + if (s) { + s->Id = id; + s->RefCount = 1; + } + return s; +} + + +/** + * Delete the given ati fragment shader + */ +void +_mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_shader *s) +{ + GLuint i; + for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { + if (s->Instructions[i]) + free(s->Instructions[i]); + if (s->SetupInst[i]) + free(s->SetupInst[i]); + } + free(s); +} + + + +static void +new_arith_inst(struct ati_fragment_shader *prog) +{ +/* set "default" instruction as not all may get defined. + there is no specified way to express a nop with ati fragment shaders we use + GL_NONE as the op enum and just set some params to 0 - so nothing to do here */ + prog->numArithInstr[prog->cur_pass >> 1]++; +} + +static void +new_tex_inst(struct ati_fragment_shader *prog) +{ +} + +static void match_pair_inst(struct ati_fragment_shader *curProg, GLuint optype) +{ + if (optype == curProg->last_optype) { + curProg->last_optype = 1; + } +} + +#if MESA_DEBUG_ATI_FS +static char * +create_dst_mod_str(GLuint mod) +{ + static char ret_str[1024]; + + memset(ret_str, 0, 1024); + if (mod & GL_2X_BIT_ATI) + strncat(ret_str, "|2X", 1024); + + if (mod & GL_4X_BIT_ATI) + strncat(ret_str, "|4X", 1024); + + if (mod & GL_8X_BIT_ATI) + strncat(ret_str, "|8X", 1024); + if (mod & GL_HALF_BIT_ATI) + strncat(ret_str, "|HA", 1024); + if (mod & GL_QUARTER_BIT_ATI) + strncat(ret_str, "|QU", 1024); + if (mod & GL_EIGHTH_BIT_ATI) + strncat(ret_str, "|EI", 1024); + + if (mod & GL_SATURATE_BIT_ATI) + strncat(ret_str, "|SAT", 1024); + + if (strlen(ret_str) == 0) + strncat(ret_str, "NONE", 1024); + return ret_str; +} + +static char *atifs_ops[] = {"ColorFragmentOp1ATI", "ColorFragmentOp2ATI", "ColorFragmentOp3ATI", + "AlphaFragmentOp1ATI", "AlphaFragmentOp2ATI", "AlphaFragmentOp3ATI" }; + +static void debug_op(GLint optype, GLuint arg_count, GLenum op, GLuint dst, + GLuint dstMask, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + char *op_name; + + op_name = atifs_ops[(arg_count-1)+(optype?3:0)]; + + fprintf(stderr, "%s(%s, %s", op_name, _mesa_lookup_enum_by_nr(op), + _mesa_lookup_enum_by_nr(dst)); + if (!optype) + fprintf(stderr, ", %d", dstMask); + + fprintf(stderr, ", %s", create_dst_mod_str(dstMod)); + + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg1), + _mesa_lookup_enum_by_nr(arg1Rep), arg1Mod); + if (arg_count>1) + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg2), + _mesa_lookup_enum_by_nr(arg2Rep), arg2Mod); + if (arg_count>2) + fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg3), + _mesa_lookup_enum_by_nr(arg3Rep), arg3Mod); + + fprintf(stderr,")\n"); + +} +#endif + +static int check_arith_arg(struct ati_fragment_shader *curProg, + GLuint optype, GLuint arg, GLuint argRep) +{ + GET_CURRENT_CONTEXT(ctx); + + if (((arg < GL_CON_0_ATI) || (arg > GL_CON_7_ATI)) && + ((arg < GL_REG_0_ATI) || (arg > GL_REG_5_ATI)) && + (arg != GL_ZERO) && (arg != GL_ONE) && + (arg != GL_PRIMARY_COLOR_ARB) && (arg != GL_SECONDARY_INTERPOLATOR_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(arg)"); + return 0; + } + if ((arg == GL_SECONDARY_INTERPOLATOR_ATI) && (((optype == 0) && (argRep == GL_ALPHA)) || + ((optype == 1) && ((arg == GL_ALPHA) || (argRep == GL_NONE))))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); + return 0; + } + if ((arg == GL_SECONDARY_INTERPOLATOR_ATI) && (((optype == 0) && (argRep == GL_ALPHA)) || + ((optype == 1) && ((arg == GL_ALPHA) || (argRep == GL_NONE))))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); + return 0; + } + if ((curProg->cur_pass == 1) && + ((arg == GL_PRIMARY_COLOR_ARB) || (arg == GL_SECONDARY_INTERPOLATOR_ATI))) { + curProg->interpinp1 = GL_TRUE; + } + return 1; +} + +GLuint GLAPIENTRY +_mesa_GenFragmentShadersATI(GLuint range) +{ + GLuint first; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + + if (range == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenFragmentShadersATI(range)"); + return 0; + } + + if (ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGenFragmentShadersATI(insideShader)"); + return 0; + } + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->ATIShaders, range); + for (i = 0; i < range; i++) { + _mesa_HashInsert(ctx->Shared->ATIShaders, first + i, &DummyShader); + } + + return first; +} + +void GLAPIENTRY +_mesa_BindFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + struct ati_fragment_shader *newProg; + + if (ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFragmentShaderATI(insideShader)"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + if (curProg->Id == id) { + return; + } + + /* unbind current */ + if (curProg->Id != 0) { + curProg->RefCount--; + if (curProg->RefCount <= 0) { + _mesa_HashRemove(ctx->Shared->ATIShaders, id); + } + } + + /* find new shader */ + if (id == 0) { + newProg = ctx->Shared->DefaultFragmentShader; + } + else { + newProg = (struct ati_fragment_shader *) + _mesa_HashLookup(ctx->Shared->ATIShaders, id); + if (!newProg || newProg == &DummyShader) { + /* allocate a new program now */ + newProg = _mesa_new_ati_fragment_shader(ctx, id); + if (!newProg) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI"); + return; + } + _mesa_HashInsert(ctx->Shared->ATIShaders, id, newProg); + } + + } + + /* do actual bind */ + ctx->ATIFragmentShader.Current = newProg; + + ASSERT(ctx->ATIFragmentShader.Current); + if (newProg) + newProg->RefCount++; + + /*if (ctx->Driver.BindProgram) + ctx->Driver.BindProgram(ctx, target, prog); */ +} + +void GLAPIENTRY +_mesa_DeleteFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + + if (ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteFragmentShaderATI(insideShader)"); + return; + } + + if (id != 0) { + struct ati_fragment_shader *prog = (struct ati_fragment_shader *) + _mesa_HashLookup(ctx->Shared->ATIShaders, id); + if (prog == &DummyShader) { + _mesa_HashRemove(ctx->Shared->ATIShaders, id); + } + else if (prog) { + if (ctx->ATIFragmentShader.Current && + ctx->ATIFragmentShader.Current->Id == id) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + _mesa_BindFragmentShaderATI(0); + } + } + + /* The ID is immediately available for re-use now */ + _mesa_HashRemove(ctx->Shared->ATIShaders, id); + if (prog) { + prog->RefCount--; + if (prog->RefCount <= 0) { + assert(prog != &DummyShader); + free(prog); + } + } + } +} + + +void GLAPIENTRY +_mesa_BeginFragmentShaderATI(void) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + if (ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginFragmentShaderATI(insideShader)"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + /* if the shader was already defined free instructions and get new ones + (or, could use the same mem but would need to reinitialize) */ + /* no idea if it's allowed to redefine a shader */ + for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { + if (ctx->ATIFragmentShader.Current->Instructions[i]) + free(ctx->ATIFragmentShader.Current->Instructions[i]); + if (ctx->ATIFragmentShader.Current->SetupInst[i]) + free(ctx->ATIFragmentShader.Current->SetupInst[i]); + } + + /* malloc the instructions here - not sure if the best place but its + a start */ + for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { + ctx->ATIFragmentShader.Current->Instructions[i] = + (struct atifs_instruction *) + calloc(1, sizeof(struct atifs_instruction) * + (MAX_NUM_INSTRUCTIONS_PER_PASS_ATI)); + ctx->ATIFragmentShader.Current->SetupInst[i] = + (struct atifs_setupinst *) + calloc(1, sizeof(struct atifs_setupinst) * + (MAX_NUM_FRAGMENT_REGISTERS_ATI)); + } + +/* can't rely on calloc for initialization as it's possible to redefine a shader (?) */ + ctx->ATIFragmentShader.Current->LocalConstDef = 0; + ctx->ATIFragmentShader.Current->numArithInstr[0] = 0; + ctx->ATIFragmentShader.Current->numArithInstr[1] = 0; + ctx->ATIFragmentShader.Current->regsAssigned[0] = 0; + ctx->ATIFragmentShader.Current->regsAssigned[1] = 0; + ctx->ATIFragmentShader.Current->NumPasses = 0; + ctx->ATIFragmentShader.Current->cur_pass = 0; + ctx->ATIFragmentShader.Current->last_optype = 0; + ctx->ATIFragmentShader.Current->interpinp1 = GL_FALSE; + ctx->ATIFragmentShader.Current->isValid = GL_FALSE; + ctx->ATIFragmentShader.Current->swizzlerq = 0; + ctx->ATIFragmentShader.Compiling = 1; +} + +void GLAPIENTRY +_mesa_EndFragmentShaderATI(void) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; +#if MESA_DEBUG_ATI_FS + GLint i, j; +#endif + + if (!ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(outsideShader)"); + return; + } + if (curProg->interpinp1 && (ctx->ATIFragmentShader.Current->cur_pass > 1)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(interpinfirstpass)"); + /* according to spec, DON'T return here */ + } + + match_pair_inst(curProg, 0); + ctx->ATIFragmentShader.Compiling = 0; + ctx->ATIFragmentShader.Current->isValid = GL_TRUE; + if ((ctx->ATIFragmentShader.Current->cur_pass == 0) || + (ctx->ATIFragmentShader.Current->cur_pass == 2)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndFragmentShaderATI(noarithinst)"); + } + if (ctx->ATIFragmentShader.Current->cur_pass > 1) + ctx->ATIFragmentShader.Current->NumPasses = 2; + else + ctx->ATIFragmentShader.Current->NumPasses = 1; + + ctx->ATIFragmentShader.Current->cur_pass = 0; + +#if MESA_DEBUG_ATI_FS + for (j = 0; j < MAX_NUM_PASSES_ATI; j++) { + for (i = 0; i < MAX_NUM_FRAGMENT_REGISTERS_ATI; i++) { + GLuint op = curProg->SetupInst[j][i].Opcode; + const char *op_enum = op > 5 ? _mesa_lookup_enum_by_nr(op) : "0"; + GLuint src = curProg->SetupInst[j][i].src; + GLuint swizzle = curProg->SetupInst[j][i].swizzle; + fprintf(stderr, "%2d %04X %s %d %04X\n", i, op, op_enum, src, + swizzle); + } + for (i = 0; i < curProg->numArithInstr[j]; i++) { + GLuint op0 = curProg->Instructions[j][i].Opcode[0]; + GLuint op1 = curProg->Instructions[j][i].Opcode[1]; + const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0"; + const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0"; + GLuint count0 = curProg->Instructions[j][i].ArgCount[0]; + GLuint count1 = curProg->Instructions[j][i].ArgCount[1]; + fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0, + op1, op1_enum, count1); + } + } +#endif + + if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI, NULL)) { + ctx->ATIFragmentShader.Current->isValid = GL_FALSE; + /* XXX is this the right error? */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndFragmentShaderATI(driver rejected shader)"); + } +} + +void GLAPIENTRY +_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + struct atifs_setupinst *curI; + + if (!ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(outsideShader)"); + return; + } + + if (curProg->cur_pass == 1) { + match_pair_inst(curProg, 0); + curProg->cur_pass = 2; + } + if ((curProg->cur_pass > 2) || + ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoord(pass)"); + return; + } + if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || + ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(dst)"); + return; + } + if (((coord < GL_REG_0_ATI) || (coord > GL_REG_5_ATI)) && + ((coord < GL_TEXTURE0_ARB) || (coord > GL_TEXTURE7_ARB) || + ((coord - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(coord)"); + return; + } + if ((curProg->cur_pass == 0) && (coord >= GL_REG_0_ATI)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(coord)"); + return; + } + if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(swizzle)"); + return; + } + if ((swizzle & 1) && (coord >= GL_REG_0_ATI)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); + return; + } + if (coord <= GL_TEXTURE7_ARB) { + GLuint tmp = coord - GL_TEXTURE0_ARB; + if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && + (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); + return; + } else { + curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); + } + } + + curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); + new_tex_inst(curProg); + + /* add the instructions */ + curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; + + curI->Opcode = ATI_FRAGMENT_SHADER_PASS_OP; + curI->src = coord; + curI->swizzle = swizzle; + +#if MESA_DEBUG_ATI_FS + _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord), + _mesa_lookup_enum_by_nr(swizzle)); +#endif +} + +void GLAPIENTRY +_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + struct atifs_setupinst *curI; + + if (!ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(outsideShader)"); + return; + } + + if (curProg->cur_pass == 1) { + match_pair_inst(curProg, 0); + curProg->cur_pass = 2; + } + if ((curProg->cur_pass > 2) || + ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(pass)"); + return; + } + if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || + ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(dst)"); + return; + } + if (((interp < GL_REG_0_ATI) || (interp > GL_REG_5_ATI)) && + ((interp < GL_TEXTURE0_ARB) || (interp > GL_TEXTURE7_ARB) || + ((interp - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { + /* is this texture5 or texture7? spec is a bit unclear there */ + _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(interp)"); + return; + } + if ((curProg->cur_pass == 0) && (interp >= GL_REG_0_ATI)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(interp)"); + return; + } + if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(swizzle)"); + return; + } + if ((swizzle & 1) && (interp >= GL_REG_0_ATI)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); + return; + } + if (interp <= GL_TEXTURE7_ARB) { + GLuint tmp = interp - GL_TEXTURE0_ARB; + if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && + (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); + return; + } else { + curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); + } + } + + curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); + new_tex_inst(curProg); + + /* add the instructions */ + curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; + + curI->Opcode = ATI_FRAGMENT_SHADER_SAMPLE_OP; + curI->src = interp; + curI->swizzle = swizzle; + +#if MESA_DEBUG_ATI_FS + _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, + _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp), + _mesa_lookup_enum_by_nr(swizzle)); +#endif +} + +static void +_mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst, + GLuint dstMask, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + GET_CURRENT_CONTEXT(ctx); + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + GLint ci; + struct atifs_instruction *curI; + GLuint modtemp = dstMod & ~GL_SATURATE_BIT_ATI; + + if (!ctx->ATIFragmentShader.Compiling) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(outsideShader)"); + return; + } + + if (curProg->cur_pass==0) + curProg->cur_pass=1; + + else if (curProg->cur_pass==2) + curProg->cur_pass=3; + + /* decide whether this is a new instruction or not ... all color instructions are new, + and alpha instructions might also be new if there was no preceding color inst */ + if ((optype == 0) || (curProg->last_optype == optype)) { + if (curProg->numArithInstr[curProg->cur_pass >> 1] > 7) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(instrCount)"); + return; + } + /* easier to do that here slight side effect invalid instr will still be inserted as nops */ + match_pair_inst(curProg, optype); + new_arith_inst(curProg); + } + curProg->last_optype = optype; + ci = curProg->numArithInstr[curProg->cur_pass >> 1] - 1; + + /* add the instructions */ + curI = &curProg->Instructions[curProg->cur_pass >> 1][ci]; + + /* error checking */ + if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dst)"); + return; + } + if ((modtemp != GL_NONE) && (modtemp != GL_2X_BIT_ATI) && + (modtemp != GL_4X_BIT_ATI) && (modtemp != GL_8X_BIT_ATI) && + (modtemp != GL_HALF_BIT_ATI) && !(modtemp != GL_QUARTER_BIT_ATI) && + (modtemp != GL_EIGHTH_BIT_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dstMod)%x", modtemp); + return; + } + /* op checking? Actually looks like that's missing in the spec but we'll do it anyway */ + if (((op < GL_ADD_ATI) || (op > GL_DOT2_ADD_ATI)) && !(op == GL_MOV_ATI)) { + _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(op)"); + return; + } + if (optype == 1) { + if (((op == GL_DOT2_ADD_ATI) && (curI->Opcode[0] != GL_DOT2_ADD_ATI)) || + ((op == GL_DOT3_ATI) && (curI->Opcode[0] != GL_DOT3_ATI)) || + ((op == GL_DOT4_ATI) && (curI->Opcode[0] != GL_DOT4_ATI)) || + ((op != GL_DOT4_ATI) && (curI->Opcode[0] == GL_DOT4_ATI))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "AFragmentOpATI(op)"); + return; + } + } + if ((op == GL_DOT4_ATI) && + (((arg1 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg1Rep == GL_ALPHA) || (arg1Rep == GL_NONE))) || + (((arg2 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg2Rep == GL_ALPHA) || (arg2Rep == GL_NONE)))))) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); + } + + if (!check_arith_arg(curProg, optype, arg1, arg1Rep)) { + return; + } + if (arg2) { + if (!check_arith_arg(curProg, optype, arg2, arg2Rep)) { + return; + } + } + if (arg3) { + if (!check_arith_arg(curProg, optype, arg3, arg3Rep)) { + return; + } + if ((arg1 >= GL_CON_0_ATI) && (arg1 <= GL_CON_7_ATI) && + (arg2 >= GL_CON_0_ATI) && (arg2 <= GL_CON_7_ATI) && + (arg3 >= GL_CON_0_ATI) && (arg3 <= GL_CON_7_ATI) && + (arg1 != arg2) && (arg1 != arg3) && (arg2 != arg3)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(3Consts)"); + return; + } + } + + /* all ok - not all fully validated though (e.g. argNMod - spec doesn't say anything) */ + + curI->Opcode[optype] = op; + curI->SrcReg[optype][0].Index = arg1; + curI->SrcReg[optype][0].argRep = arg1Rep; + curI->SrcReg[optype][0].argMod = arg1Mod; + curI->ArgCount[optype] = arg_count; + + if (arg2) { + curI->SrcReg[optype][1].Index = arg2; + curI->SrcReg[optype][1].argRep = arg2Rep; + curI->SrcReg[optype][1].argMod = arg2Mod; + } + + if (arg3) { + curI->SrcReg[optype][2].Index = arg3; + curI->SrcReg[optype][2].argRep = arg3Rep; + curI->SrcReg[optype][2].argMod = arg3Mod; + } + + curI->DstReg[optype].Index = dst; + curI->DstReg[optype].dstMod = dstMod; + curI->DstReg[optype].dstMask = dstMask; + +#if MESA_DEBUG_ATI_FS + debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); +#endif + +} + +void GLAPIENTRY +_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 1, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 2, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, + arg2Mod, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 3, op, dst, dstMask, + dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, + arg2Mod, arg3, arg3Rep, arg3Mod); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 1, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 2, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0, + 0); +} + +void GLAPIENTRY +_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod) +{ + _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 3, op, dst, 0, dstMod, + arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, + arg3Rep, arg3Mod); +} + +void GLAPIENTRY +_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value) +{ + GLuint dstindex; + GET_CURRENT_CONTEXT(ctx); + + if ((dst < GL_CON_0_ATI) || (dst > GL_CON_7_ATI)) { + /* spec says nothing about what should happen here but we can't just segfault...*/ + _mesa_error(ctx, GL_INVALID_ENUM, "glSetFragmentShaderConstantATI(dst)"); + return; + } + + dstindex = dst - GL_CON_0_ATI; + if (ctx->ATIFragmentShader.Compiling) { + struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; + COPY_4V(curProg->Constants[dstindex], value); + curProg->LocalConstDef |= 1 << dstindex; + } + else { + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + COPY_4V(ctx->ATIFragmentShader.GlobalConstants[dstindex], value); + } +} + +#endif /* FEATURE_ATI_fragment_shader */ diff --git a/mesalib/src/mesa/main/atifragshader.h b/mesalib/src/mesa/main/atifragshader.h index 31c335ec8..838d327c0 100644 --- a/mesalib/src/mesa/main/atifragshader.h +++ b/mesalib/src/mesa/main/atifragshader.h @@ -1,149 +1,154 @@ -/* - * Mesa 3-D graphics library ATI Fragment Shader - * - * Copyright (C) 2004 David Airlie All Rights Reserved. - * - */ - -#ifndef ATIFRAGSHADER_H -#define ATIFRAGSHADER_H - -#include "main/mtypes.h" - -#define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8 -#define MAX_NUM_PASSES_ATI 2 -#define MAX_NUM_FRAGMENT_REGISTERS_ATI 6 - -struct ati_fs_opcode_st -{ - GLenum opcode; - GLint num_src_args; -}; - -extern struct ati_fs_opcode_st ati_fs_opcodes[]; - -struct atifragshader_src_register -{ - GLuint Index; - GLuint argRep; - GLuint argMod; -}; - -struct atifragshader_dst_register -{ - GLuint Index; - GLuint dstMod; - GLuint dstMask; -}; - -#define ATI_FRAGMENT_SHADER_COLOR_OP 0 -#define ATI_FRAGMENT_SHADER_ALPHA_OP 1 -#define ATI_FRAGMENT_SHADER_PASS_OP 2 -#define ATI_FRAGMENT_SHADER_SAMPLE_OP 3 - -/* two opcodes - one for color/one for alpha */ -/* up to three source registers for most ops */ -struct atifs_instruction -{ - GLenum Opcode[2]; - GLuint ArgCount[2]; - struct atifragshader_src_register SrcReg[2][3]; - struct atifragshader_dst_register DstReg[2]; -}; - -/* different from arithmetic shader instruction */ -struct atifs_setupinst -{ - GLenum Opcode; - GLuint src; - GLenum swizzle; -}; - - -#if FEATURE_ATI_fragment_shader - -extern void -_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp); - -extern struct ati_fragment_shader * -_mesa_new_ati_fragment_shader(GLcontext *ctx, GLuint id); - -extern void -_mesa_delete_ati_fragment_shader(GLcontext *ctx, - struct ati_fragment_shader *s); - - -extern GLuint GLAPIENTRY _mesa_GenFragmentShadersATI(GLuint range); - -extern void GLAPIENTRY _mesa_BindFragmentShaderATI(GLuint id); - -extern void GLAPIENTRY _mesa_DeleteFragmentShaderATI(GLuint id); - -extern void GLAPIENTRY _mesa_BeginFragmentShaderATI(void); - -extern void GLAPIENTRY _mesa_EndFragmentShaderATI(void); - -extern void GLAPIENTRY -_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle); - -extern void GLAPIENTRY -_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle); - -extern void GLAPIENTRY -_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod); - -extern void GLAPIENTRY -_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod); - -extern void GLAPIENTRY -_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, - GLuint dstMod, GLuint arg1, GLuint arg1Rep, - GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, - GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, - GLuint arg3Mod); - -extern void GLAPIENTRY -_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod); - -extern void GLAPIENTRY -_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod); - -extern void GLAPIENTRY -_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, - GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, - GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, - GLuint arg3Rep, GLuint arg3Mod); - -extern void GLAPIENTRY -_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value); - -#else /* FEATURE_ATI_fragment_shader */ - -static INLINE void -_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) -{ -} - -static INLINE struct ati_fragment_shader * -_mesa_new_ati_fragment_shader(GLcontext *ctx, GLuint id) -{ - return NULL; -} - -static INLINE void -_mesa_delete_ati_fragment_shader(GLcontext *ctx, - struct ati_fragment_shader *s) -{ -} - -#endif /* FEATURE_ATI_fragment_shader */ - -#endif /* ATIFRAGSHADER_H */ +/* + * Mesa 3-D graphics library ATI Fragment Shader + * + * Copyright (C) 2004 David Airlie All Rights Reserved. + * + */ + +#ifndef ATIFRAGSHADER_H +#define ATIFRAGSHADER_H + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct gl_context; + +#define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8 +#define MAX_NUM_PASSES_ATI 2 +#define MAX_NUM_FRAGMENT_REGISTERS_ATI 6 + +struct ati_fs_opcode_st +{ + GLenum opcode; + GLint num_src_args; +}; + +extern struct ati_fs_opcode_st ati_fs_opcodes[]; + +struct atifragshader_src_register +{ + GLuint Index; + GLuint argRep; + GLuint argMod; +}; + +struct atifragshader_dst_register +{ + GLuint Index; + GLuint dstMod; + GLuint dstMask; +}; + +#define ATI_FRAGMENT_SHADER_COLOR_OP 0 +#define ATI_FRAGMENT_SHADER_ALPHA_OP 1 +#define ATI_FRAGMENT_SHADER_PASS_OP 2 +#define ATI_FRAGMENT_SHADER_SAMPLE_OP 3 + +/* two opcodes - one for color/one for alpha */ +/* up to three source registers for most ops */ +struct atifs_instruction +{ + GLenum Opcode[2]; + GLuint ArgCount[2]; + struct atifragshader_src_register SrcReg[2][3]; + struct atifragshader_dst_register DstReg[2]; +}; + +/* different from arithmetic shader instruction */ +struct atifs_setupinst +{ + GLenum Opcode; + GLuint src; + GLenum swizzle; +}; + + +#if FEATURE_ATI_fragment_shader + +extern void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp); + +extern struct ati_fragment_shader * +_mesa_new_ati_fragment_shader(struct gl_context *ctx, GLuint id); + +extern void +_mesa_delete_ati_fragment_shader(struct gl_context *ctx, + struct ati_fragment_shader *s); + + +extern GLuint GLAPIENTRY _mesa_GenFragmentShadersATI(GLuint range); + +extern void GLAPIENTRY _mesa_BindFragmentShaderATI(GLuint id); + +extern void GLAPIENTRY _mesa_DeleteFragmentShaderATI(GLuint id); + +extern void GLAPIENTRY _mesa_BeginFragmentShaderATI(void); + +extern void GLAPIENTRY _mesa_EndFragmentShaderATI(void); + +extern void GLAPIENTRY +_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle); + +extern void GLAPIENTRY +_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod); + +extern void GLAPIENTRY +_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, + GLuint dstMod, GLuint arg1, GLuint arg1Rep, + GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, + GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, + GLuint arg3Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod); + +extern void GLAPIENTRY +_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, + GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, + GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, + GLuint arg3Rep, GLuint arg3Mod); + +extern void GLAPIENTRY +_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value); + +#else /* FEATURE_ATI_fragment_shader */ + +static INLINE void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) +{ +} + +static INLINE struct ati_fragment_shader * +_mesa_new_ati_fragment_shader(struct gl_context *ctx, GLuint id) +{ + return NULL; +} + +static INLINE void +_mesa_delete_ati_fragment_shader(struct gl_context *ctx, + struct ati_fragment_shader *s) +{ +} + +#endif /* FEATURE_ATI_fragment_shader */ + +#endif /* ATIFRAGSHADER_H */ diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 753949be5..23ba36fba 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1,1575 +1,1546 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "imports.h" -#include "accum.h" -#include "arrayobj.h" -#include "attrib.h" -#include "blend.h" -#include "buffers.h" -#include "bufferobj.h" -#include "clear.h" -#include "colormac.h" -#include "context.h" -#include "depth.h" -#include "enable.h" -#include "enums.h" -#include "fog.h" -#include "hint.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "multisample.h" -#include "points.h" -#include "polygon.h" -#include "scissor.h" -#include "stencil.h" -#include "texenv.h" -#include "texgen.h" -#include "texobj.h" -#include "texparam.h" -#include "texstate.h" -#include "varray.h" -#include "viewport.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -/** - * glEnable()/glDisable() attribute group (GL_ENABLE_BIT). - */ -struct gl_enable_attrib -{ - GLboolean AlphaTest; - GLboolean AutoNormal; - GLboolean Blend; - GLbitfield ClipPlanes; - GLboolean ColorMaterial; - GLboolean ColorTable[COLORTABLE_MAX]; - GLboolean Convolution1D; - GLboolean Convolution2D; - GLboolean Separable2D; - GLboolean CullFace; - GLboolean DepthClamp; - GLboolean DepthTest; - GLboolean Dither; - GLboolean Fog; - GLboolean Histogram; - GLboolean Light[MAX_LIGHTS]; - GLboolean Lighting; - GLboolean LineSmooth; - GLboolean LineStipple; - GLboolean IndexLogicOp; - GLboolean ColorLogicOp; - - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ - - GLboolean MinMax; - GLboolean Normalize; - GLboolean PixelTexture; - GLboolean PointSmooth; - GLboolean PolygonOffsetPoint; - GLboolean PolygonOffsetLine; - GLboolean PolygonOffsetFill; - GLboolean PolygonSmooth; - GLboolean PolygonStipple; - GLboolean RescaleNormals; - GLboolean Scissor; - GLboolean Stencil; - GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */ - GLboolean MultisampleEnabled; /* GL_ARB_multisample */ - GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ - GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ - GLboolean SampleCoverage; /* GL_ARB_multisample */ - GLboolean SampleCoverageInvert; /* GL_ARB_multisample */ - GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ - - GLbitfield Texture[MAX_TEXTURE_UNITS]; - GLbitfield TexGen[MAX_TEXTURE_UNITS]; - - /* SGI_texture_color_table */ - GLboolean TextureColorTable[MAX_TEXTURE_UNITS]; - - /* GL_ARB_vertex_program / GL_NV_vertex_program */ - GLboolean VertexProgram; - GLboolean VertexProgramPointSize; - GLboolean VertexProgramTwoSide; - - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - GLboolean PointSprite; - GLboolean FragmentShaderATI; -}; - - -/** - * Node for the attribute stack. - */ -struct gl_attrib_node -{ - GLbitfield kind; - void *data; - struct gl_attrib_node *next; -}; - - - -/** - * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) - */ -struct texture_state -{ - struct gl_texture_attrib Texture; /**< The usual context state */ - - /** to save per texture object state (wrap modes, filters, etc): */ - struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; - - /** - * To save references to texture objects (so they don't get accidentally - * deleted while saved in the attribute stack). - */ - struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; -}; - - -#if FEATURE_attrib_stack - - -/** - * Allocate new attribute node of given type/kind. Attach payload data. - * Insert it into the linked list named by 'head'. - */ -static void -save_attrib_data(struct gl_attrib_node **head, - GLbitfield kind, void *payload) -{ - struct gl_attrib_node *n = MALLOC_STRUCT(gl_attrib_node); - if (n) { - n->kind = kind; - n->data = payload; - /* insert at head */ - n->next = *head; - *head = n; - } - else { - /* out of memory! */ - } -} - - -void GLAPIENTRY -_mesa_PushAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); - - if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute */ - /* groups specified by the mask. */ - head = NULL; - - if (mask & GL_ACCUM_BUFFER_BIT) { - struct gl_accum_attrib *attr; - attr = MALLOC_STRUCT( gl_accum_attrib ); - memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); - save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr); - } - - if (mask & GL_COLOR_BUFFER_BIT) { - GLuint i; - struct gl_colorbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); - memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); - /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ - for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) - attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; - save_attrib_data(&head, GL_COLOR_BUFFER_BIT, attr); - } - - if (mask & GL_CURRENT_BIT) { - struct gl_current_attrib *attr; - FLUSH_CURRENT( ctx, 0 ); - attr = MALLOC_STRUCT( gl_current_attrib ); - memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); - save_attrib_data(&head, GL_CURRENT_BIT, attr); - } - - if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_depthbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); - memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); - save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr); - } - - if (mask & GL_ENABLE_BIT) { - struct gl_enable_attrib *attr; - GLuint i; - attr = MALLOC_STRUCT( gl_enable_attrib ); - /* Copy enable flags from all other attributes into the enable struct. */ - attr->AlphaTest = ctx->Color.AlphaEnabled; - attr->AutoNormal = ctx->Eval.AutoNormal; - attr->Blend = ctx->Color.BlendEnabled; - attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; - attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - for (i = 0; i < COLORTABLE_MAX; i++) { - attr->ColorTable[i] = ctx->Pixel.ColorTableEnabled[i]; - } - attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; - attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; - attr->Separable2D = ctx->Pixel.Separable2DEnabled; - attr->CullFace = ctx->Polygon.CullFlag; - attr->DepthClamp = ctx->Transform.DepthClamp; - attr->DepthTest = ctx->Depth.Test; - attr->Dither = ctx->Color.DitherFlag; - attr->Fog = ctx->Fog.Enabled; - for (i = 0; i < ctx->Const.MaxLights; i++) { - attr->Light[i] = ctx->Light.Light[i].Enabled; - } - attr->Lighting = ctx->Light.Enabled; - attr->LineSmooth = ctx->Line.SmoothFlag; - attr->LineStipple = ctx->Line.StippleFlag; - attr->Histogram = ctx->Pixel.HistogramEnabled; - attr->MinMax = ctx->Pixel.MinMaxEnabled; - attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; - attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; - attr->Map1Color4 = ctx->Eval.Map1Color4; - attr->Map1Index = ctx->Eval.Map1Index; - attr->Map1Normal = ctx->Eval.Map1Normal; - attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; - attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; - attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; - attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; - attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; - attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; - memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); - attr->Map2Color4 = ctx->Eval.Map2Color4; - attr->Map2Index = ctx->Eval.Map2Index; - attr->Map2Normal = ctx->Eval.Map2Normal; - attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; - attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; - attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; - attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; - attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; - attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; - memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); - attr->Normalize = ctx->Transform.Normalize; - attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; - attr->PointSmooth = ctx->Point.SmoothFlag; - attr->PointSprite = ctx->Point.PointSprite; - attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; - attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; - attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; - attr->PolygonSmooth = ctx->Polygon.SmoothFlag; - attr->PolygonStipple = ctx->Polygon.StippleFlag; - attr->RescaleNormals = ctx->Transform.RescaleNormals; - attr->Scissor = ctx->Scissor.Enabled; - attr->Stencil = ctx->Stencil.Enabled; - attr->StencilTwoSide = ctx->Stencil.TestTwoSide; - attr->MultisampleEnabled = ctx->Multisample.Enabled; - attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; - attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; - attr->SampleCoverage = ctx->Multisample.SampleCoverage; - attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - attr->Texture[i] = ctx->Texture.Unit[i].Enabled; - attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; - attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled; - } - /* GL_NV_vertex_program */ - attr->VertexProgram = ctx->VertexProgram.Enabled; - attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; - attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; - save_attrib_data(&head, GL_ENABLE_BIT, attr); - } - - if (mask & GL_EVAL_BIT) { - struct gl_eval_attrib *attr; - attr = MALLOC_STRUCT( gl_eval_attrib ); - memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); - save_attrib_data(&head, GL_EVAL_BIT, attr); - } - - if (mask & GL_FOG_BIT) { - struct gl_fog_attrib *attr; - attr = MALLOC_STRUCT( gl_fog_attrib ); - memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); - save_attrib_data(&head, GL_FOG_BIT, attr); - } - - if (mask & GL_HINT_BIT) { - struct gl_hint_attrib *attr; - attr = MALLOC_STRUCT( gl_hint_attrib ); - memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); - save_attrib_data(&head, GL_HINT_BIT, attr); - } - - if (mask & GL_LIGHTING_BIT) { - struct gl_light_attrib *attr; - FLUSH_CURRENT(ctx, 0); /* flush material changes */ - attr = MALLOC_STRUCT( gl_light_attrib ); - memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); - save_attrib_data(&head, GL_LIGHTING_BIT, attr); - } - - if (mask & GL_LINE_BIT) { - struct gl_line_attrib *attr; - attr = MALLOC_STRUCT( gl_line_attrib ); - memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); - save_attrib_data(&head, GL_LINE_BIT, attr); - } - - if (mask & GL_LIST_BIT) { - struct gl_list_attrib *attr; - attr = MALLOC_STRUCT( gl_list_attrib ); - memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) ); - save_attrib_data(&head, GL_LIST_BIT, attr); - } - - if (mask & GL_PIXEL_MODE_BIT) { - struct gl_pixel_attrib *attr; - attr = MALLOC_STRUCT( gl_pixel_attrib ); - memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); - /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */ - attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; - save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr); - } - - if (mask & GL_POINT_BIT) { - struct gl_point_attrib *attr; - attr = MALLOC_STRUCT( gl_point_attrib ); - memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); - save_attrib_data(&head, GL_POINT_BIT, attr); - } - - if (mask & GL_POLYGON_BIT) { - struct gl_polygon_attrib *attr; - attr = MALLOC_STRUCT( gl_polygon_attrib ); - memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); - save_attrib_data(&head, GL_POLYGON_BIT, attr); - } - - if (mask & GL_POLYGON_STIPPLE_BIT) { - GLuint *stipple; - stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); - memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); - save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple); - } - - if (mask & GL_SCISSOR_BIT) { - struct gl_scissor_attrib *attr; - attr = MALLOC_STRUCT( gl_scissor_attrib ); - memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); - save_attrib_data(&head, GL_SCISSOR_BIT, attr); - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_stencil_attrib *attr; - attr = MALLOC_STRUCT( gl_stencil_attrib ); - memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); - save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr); - } - - if (mask & GL_TEXTURE_BIT) { - struct texture_state *texstate = CALLOC_STRUCT(texture_state); - GLuint u, tex; - - if (!texstate) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); - goto end; - } - - _mesa_lock_context_textures(ctx); - - /* copy/save the bulk of texture state here */ - memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); - - /* Save references to the currently bound texture objects so they don't - * accidentally get deleted while referenced in the attribute stack. - */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } - } - - /* copy state/contents of the currently bound texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_copy_texture_object(&texstate->SavedObj[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } - } - - _mesa_unlock_context_textures(ctx); - - save_attrib_data(&head, GL_TEXTURE_BIT, texstate); - } - - if (mask & GL_TRANSFORM_BIT) { - struct gl_transform_attrib *attr; - attr = MALLOC_STRUCT( gl_transform_attrib ); - memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); - save_attrib_data(&head, GL_TRANSFORM_BIT, attr); - } - - if (mask & GL_VIEWPORT_BIT) { - struct gl_viewport_attrib *attr; - attr = MALLOC_STRUCT( gl_viewport_attrib ); - memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); - save_attrib_data(&head, GL_VIEWPORT_BIT, attr); - } - - /* GL_ARB_multisample */ - if (mask & GL_MULTISAMPLE_BIT_ARB) { - struct gl_multisample_attrib *attr; - attr = MALLOC_STRUCT( gl_multisample_attrib ); - memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); - save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr); - } - -end: - ctx->AttribStack[ctx->AttribStackDepth] = head; - ctx->AttribStackDepth++; -} - - - -static void -pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) -{ - const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; - GLuint i; - -#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ - if ((VALUE) != (NEWVALUE)) { \ - _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ - } - - TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); - if (ctx->Color.BlendEnabled != enable->Blend) { - if (ctx->Extensions.EXT_draw_buffers2) { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1); - } - } - else { - _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1)); - } - } - - for (i=0;iTransform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) - _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), - (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE)); - } - - TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, - GL_COLOR_MATERIAL); - TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION], - enable->ColorTable[COLORTABLE_PRECONVOLUTION], - GL_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION], - enable->ColorTable[COLORTABLE_POSTCONVOLUTION], - GL_POST_CONVOLUTION_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX], - enable->ColorTable[COLORTABLE_POSTCOLORMATRIX], - GL_POST_COLOR_MATRIX_COLOR_TABLE); - TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); - TEST_AND_UPDATE(ctx->Transform.DepthClamp, enable->DepthClamp, - GL_DEPTH_CLAMP); - TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); - TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); - TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D, - GL_CONVOLUTION_1D); - TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D, - GL_CONVOLUTION_2D); - TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D, - GL_SEPARABLE_2D); - TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); - TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); - TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); - TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, - GL_LINE_STIPPLE); - TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, - GL_INDEX_LOGIC_OP); - TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, - GL_COLOR_LOGIC_OP); - - TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, - GL_MAP1_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, - GL_MAP1_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, - GL_MAP1_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, - GL_MAP1_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, - GL_MAP1_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, - GL_MAP1_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], - GL_MAP1_VERTEX_ATTRIB0_4_NV + i); - } - - TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, - GL_MAP2_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, - GL_MAP2_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, - GL_MAP2_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, - GL_MAP2_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, - GL_MAP2_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, - GL_MAP2_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], - GL_MAP2_VERTEX_ATTRIB0_4_NV + i); - } - - TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); - TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); - TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, - GL_RESCALE_NORMAL_EXT); - TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, - enable->RasterPositionUnclipped, - GL_RASTER_POSITION_UNCLIPPED_IBM); - TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, - GL_POINT_SMOOTH); - if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) { - TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, - GL_POINT_SPRITE_NV); - } - TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, - GL_POLYGON_OFFSET_POINT); - TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, - GL_POLYGON_OFFSET_LINE); - TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, - GL_POLYGON_OFFSET_FILL); - TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, - GL_POLYGON_SMOOTH); - TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, - GL_POLYGON_STIPPLE); - TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); - TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); - if (ctx->Extensions.EXT_stencil_two_side) { - TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT); - } - TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, - GL_MULTISAMPLE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, - enable->SampleAlphaToCoverage, - GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, - enable->SampleAlphaToOne, - GL_SAMPLE_ALPHA_TO_ONE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, - enable->SampleCoverage, - GL_SAMPLE_COVERAGE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert, - enable->SampleCoverageInvert, - GL_SAMPLE_COVERAGE_INVERT_ARB); - /* GL_ARB_vertex_program, GL_NV_vertex_program */ - TEST_AND_UPDATE(ctx->VertexProgram.Enabled, - enable->VertexProgram, - GL_VERTEX_PROGRAM_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, - enable->VertexProgramPointSize, - GL_VERTEX_PROGRAM_POINT_SIZE_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, - enable->VertexProgramTwoSide, - GL_VERTEX_PROGRAM_TWO_SIDE_ARB); - -#undef TEST_AND_UPDATE - - /* texture unit enables */ - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const GLbitfield enabled = enable->Texture[i]; - const GLbitfield genEnabled = enable->TexGen[i]; - - if (ctx->Texture.Unit[i].Enabled != enabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); - - _mesa_set_enable(ctx, GL_TEXTURE_1D, - (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, - (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, - (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); - if (ctx->Extensions.NV_texture_rectangle) { - _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB, - (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, - (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.MESA_texture_array) { - _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, - (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, - (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - } - } - - if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, - (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, - (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, - (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, - (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE); - } - - /* GL_SGI_texture_color_table */ - ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i]; - } - - _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); -} - - -/** - * Pop/restore texture attribute/group state. - */ -static void -pop_texture_group(GLcontext *ctx, struct texture_state *texstate) -{ - GLuint u; - - _mesa_lock_context_textures(ctx); - - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; - GLuint tgt; - - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); - _mesa_set_enable(ctx, GL_TEXTURE_1D, - (unit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, - (unit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, - (unit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, - (unit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.NV_texture_rectangle) { - _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, - (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.MESA_texture_array) { - _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, - (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, - (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - } - - if (ctx->Extensions.SGI_texture_color_table) { - _mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI, - unit->ColorTableEnabled); - } - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); - _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); - _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); - _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); - _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); - _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); - _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); - _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); - _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); - _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); - /* Eye plane done differently to avoid re-transformation */ - { - struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; - COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); - COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); - COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); - COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); - if (ctx->Driver.TexGen) { - ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); - ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); - ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); - ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); - } - } - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, - ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, - ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, - ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, - ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE)); - if (ctx->Extensions.EXT_texture_lod_bias) { - _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, - GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias); - } - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, - unit->Combine.ModeRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, - unit->Combine.ModeA); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, - unit->Combine.SourceRGB[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, - unit->Combine.SourceRGB[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, - unit->Combine.SourceRGB[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, - unit->Combine.SourceA[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, - unit->Combine.SourceA[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, - unit->Combine.SourceA[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, - unit->Combine.OperandRGB[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, - unit->Combine.OperandRGB[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, - unit->Combine.OperandRGB[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, - unit->Combine.OperandA[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, - unit->Combine.OperandA[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, - unit->Combine.OperandA[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, - 1 << unit->Combine.ScaleShiftRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, - 1 << unit->Combine.ScaleShiftA); - } - - /* Restore texture object state for each target */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - const struct gl_texture_object *obj = NULL; - GLenum target; - - obj = &texstate->SavedObj[u][tgt]; - - /* don't restore state for unsupported targets to prevent - * raising GL errors. - */ - if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && - !ctx->Extensions.ARB_texture_cube_map) { - continue; - } - else if (obj->Target == GL_TEXTURE_RECTANGLE_NV && - !ctx->Extensions.NV_texture_rectangle) { - continue; - } - else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT || - obj->Target == GL_TEXTURE_2D_ARRAY_EXT) && - !ctx->Extensions.MESA_texture_array) { - continue; - } - - target = obj->Target; - - _mesa_BindTexture(target, obj->Name); - - _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor.f); - _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR); - _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, obj->MinFilter); - _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter); - _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod); - _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod); - _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias); - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); - if (target != GL_TEXTURE_RECTANGLE_ARB) - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, - obj->MaxAnisotropy); - } - if (ctx->Extensions.ARB_shadow_ambient) { - _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, - obj->CompareFailValue); - } - } - - /* remove saved references to the texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } - } - - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); - - _mesa_unlock_context_textures(ctx); -} - - -/* - * This function is kind of long just because we have to call a lot - * of device driver functions to update device driver state. - * - * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions - * in order to restore GL state. This isn't terribly efficient but it - * ensures that dirty flags and any derived state gets updated correctly. - * We could at least check if the value to restore equals the current value - * and then skip the Mesa call. - */ -void GLAPIENTRY -_mesa_PopAttrib(void) -{ - struct gl_attrib_node *attr, *next; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->AttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); - return; - } - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - - if (MESA_VERBOSE & VERBOSE_API) { - _mesa_debug(ctx, "glPopAttrib %s\n", - _mesa_lookup_enum_by_nr(attr->kind)); - } - - switch (attr->kind) { - case GL_ACCUM_BUFFER_BIT: - { - const struct gl_accum_attrib *accum; - accum = (const struct gl_accum_attrib *) attr->data; - _mesa_ClearAccum(accum->ClearColor[0], - accum->ClearColor[1], - accum->ClearColor[2], - accum->ClearColor[3]); - } - break; - case GL_COLOR_BUFFER_BIT: - { - const struct gl_colorbuffer_attrib *color; - - color = (const struct gl_colorbuffer_attrib *) attr->data; - _mesa_ClearIndex((GLfloat) color->ClearIndex); - _mesa_ClearColor(color->ClearColor[0], - color->ClearColor[1], - color->ClearColor[2], - color->ClearColor[3]); - _mesa_IndexMask(color->IndexMask); - if (!ctx->Extensions.EXT_draw_buffers2) { - _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0), - (GLboolean) (color->ColorMask[0][1] != 0), - (GLboolean) (color->ColorMask[0][2] != 0), - (GLboolean) (color->ColorMask[0][3] != 0)); - } - else { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_ColorMaskIndexed(i, - (GLboolean) (color->ColorMask[i][0] != 0), - (GLboolean) (color->ColorMask[i][1] != 0), - (GLboolean) (color->ColorMask[i][2] != 0), - (GLboolean) (color->ColorMask[i][3] != 0)); - } - } - { - /* Need to determine if more than one color output is - * specified. If so, call glDrawBuffersARB, else call - * glDrawBuffer(). This is a subtle, but essential point - * since GL_FRONT (for example) is illegal for the former - * function, but legal for the later. - */ - GLboolean multipleBuffers = GL_FALSE; - GLuint i; - - for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { - if (color->DrawBuffer[i] != GL_NONE) { - multipleBuffers = GL_TRUE; - break; - } - } - /* Call the API_level functions, not _mesa_drawbuffers() - * since we need to do error checking on the pop'd - * GL_DRAW_BUFFER. - * Ex: if GL_FRONT were pushed, but we're popping with a - * user FBO bound, GL_FRONT will be illegal and we'll need - * to record that error. Per OpenGL ARB decision. - */ - if (multipleBuffers) - _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers, - color->DrawBuffer); - else - _mesa_DrawBuffer(color->DrawBuffer[0]); - } - _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); - _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); - if (ctx->Color.BlendEnabled != color->BlendEnabled) { - if (ctx->Extensions.EXT_draw_buffers2) { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_set_enablei(ctx, GL_BLEND, i, - (color->BlendEnabled >> i) & 1); - } - } - else { - _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); - } - } - _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB, - color->BlendDstRGB, - color->BlendSrcA, - color->BlendDstA); - /* This special case is because glBlendEquationSeparateEXT - * cannot take GL_LOGIC_OP as a parameter. - */ - if ( color->BlendEquationRGB == color->BlendEquationA ) { - _mesa_BlendEquation(color->BlendEquationRGB); - } - else { - _mesa_BlendEquationSeparateEXT(color->BlendEquationRGB, - color->BlendEquationA); - } - _mesa_BlendColor(color->BlendColor[0], - color->BlendColor[1], - color->BlendColor[2], - color->BlendColor[3]); - _mesa_LogicOp(color->LogicOp); - _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, - color->ColorLogicOpEnabled); - _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, - color->IndexLogicOpEnabled); - _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); - } - break; - case GL_CURRENT_BIT: - FLUSH_CURRENT( ctx, 0 ); - memcpy( &ctx->Current, attr->data, - sizeof(struct gl_current_attrib) ); - break; - case GL_DEPTH_BUFFER_BIT: - { - const struct gl_depthbuffer_attrib *depth; - depth = (const struct gl_depthbuffer_attrib *) attr->data; - _mesa_DepthFunc(depth->Func); - _mesa_ClearDepth(depth->Clear); - _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); - _mesa_DepthMask(depth->Mask); - } - break; - case GL_ENABLE_BIT: - { - const struct gl_enable_attrib *enable; - enable = (const struct gl_enable_attrib *) attr->data; - pop_enable_group(ctx, enable); - ctx->NewState |= _NEW_ALL; - } - break; - case GL_EVAL_BIT: - memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); - ctx->NewState |= _NEW_EVAL; - break; - case GL_FOG_BIT: - { - const struct gl_fog_attrib *fog; - fog = (const struct gl_fog_attrib *) attr->data; - _mesa_set_enable(ctx, GL_FOG, fog->Enabled); - _mesa_Fogfv(GL_FOG_COLOR, fog->Color); - _mesa_Fogf(GL_FOG_DENSITY, fog->Density); - _mesa_Fogf(GL_FOG_START, fog->Start); - _mesa_Fogf(GL_FOG_END, fog->End); - _mesa_Fogf(GL_FOG_INDEX, fog->Index); - _mesa_Fogi(GL_FOG_MODE, fog->Mode); - } - break; - case GL_HINT_BIT: - { - const struct gl_hint_attrib *hint; - hint = (const struct gl_hint_attrib *) attr->data; - _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, - hint->PerspectiveCorrection ); - _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); - _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); - _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); - _mesa_Hint(GL_FOG_HINT, hint->Fog); - _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, - hint->ClipVolumeClipping); - _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, - hint->TextureCompression); - } - break; - case GL_LIGHTING_BIT: - { - GLuint i; - const struct gl_light_attrib *light; - light = (const struct gl_light_attrib *) attr->data; - /* lighting enable */ - _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); - /* per-light state */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - for (i = 0; i < ctx->Const.MaxLights; i++) { - const struct gl_light *l = &light->Light[i]; - _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); - _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); - _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); - _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); - _mesa_light(ctx, i, GL_POSITION, l->EyePosition); - _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection); - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotExponent; - _mesa_light(ctx, i, GL_SPOT_EXPONENT, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotCutoff; - _mesa_light(ctx, i, GL_SPOT_CUTOFF, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->ConstantAttenuation; - _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->LinearAttenuation; - _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->QuadraticAttenuation; - _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p); - } - } - /* light model */ - _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, - light->Model.Ambient); - _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, - (GLfloat) light->Model.LocalViewer); - _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, - (GLfloat) light->Model.TwoSide); - _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, - (GLfloat) light->Model.ColorControl); - /* shade model */ - _mesa_ShadeModel(light->ShadeModel); - /* color material */ - _mesa_ColorMaterial(light->ColorMaterialFace, - light->ColorMaterialMode); - _mesa_set_enable(ctx, GL_COLOR_MATERIAL, - light->ColorMaterialEnabled); - /* materials */ - memcpy(&ctx->Light.Material, &light->Material, - sizeof(struct gl_material)); - } - break; - case GL_LINE_BIT: - { - const struct gl_line_attrib *line; - line = (const struct gl_line_attrib *) attr->data; - _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); - _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); - _mesa_LineStipple(line->StippleFactor, line->StipplePattern); - _mesa_LineWidth(line->Width); - } - break; - case GL_LIST_BIT: - memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); - break; - case GL_PIXEL_MODE_BIT: - memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); - /* XXX what other pixel state needs to be set by function calls? */ - _mesa_ReadBuffer(ctx->Pixel.ReadBuffer); - ctx->NewState |= _NEW_PIXEL; - break; - case GL_POINT_BIT: - { - const struct gl_point_attrib *point; - point = (const struct gl_point_attrib *) attr->data; - _mesa_PointSize(point->Size); - _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); - if (ctx->Extensions.EXT_point_parameters) { - _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT, - point->Params); - _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT, - point->MinSize); - _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT, - point->MaxSize); - _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, - point->Threshold); - } - if (ctx->Extensions.NV_point_sprite - || ctx->Extensions.ARB_point_sprite) { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, - (GLint) point->CoordReplace[u]); - } - _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); - if (ctx->Extensions.NV_point_sprite) - _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, - ctx->Point.SpriteRMode); - _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, - (GLfloat)ctx->Point.SpriteOrigin); - } - } - break; - case GL_POLYGON_BIT: - { - const struct gl_polygon_attrib *polygon; - polygon = (const struct gl_polygon_attrib *) attr->data; - _mesa_CullFace(polygon->CullFaceMode); - _mesa_FrontFace(polygon->FrontFace); - _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); - _mesa_PolygonMode(GL_BACK, polygon->BackMode); - _mesa_PolygonOffset(polygon->OffsetFactor, - polygon->OffsetUnits); - _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); - _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); - _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, - polygon->OffsetPoint); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, - polygon->OffsetLine); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, - polygon->OffsetFill); - } - break; - case GL_POLYGON_STIPPLE_BIT: - memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); - ctx->NewState |= _NEW_POLYGONSTIPPLE; - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); - break; - case GL_SCISSOR_BIT: - { - const struct gl_scissor_attrib *scissor; - scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_Scissor(scissor->X, scissor->Y, - scissor->Width, scissor->Height); - _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); - } - break; - case GL_STENCIL_BUFFER_BIT: - { - const struct gl_stencil_attrib *stencil; - stencil = (const struct gl_stencil_attrib *) attr->data; - _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); - _mesa_ClearStencil(stencil->Clear); - if (ctx->Extensions.EXT_stencil_two_side) { - _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, - stencil->TestTwoSide); - _mesa_ActiveStencilFaceEXT(stencil->ActiveFace - ? GL_BACK : GL_FRONT); - } - /* front state */ - _mesa_StencilFuncSeparate(GL_FRONT, - stencil->Function[0], - stencil->Ref[0], - stencil->ValueMask[0]); - _mesa_StencilMaskSeparate(GL_FRONT, stencil->WriteMask[0]); - _mesa_StencilOpSeparate(GL_FRONT, stencil->FailFunc[0], - stencil->ZFailFunc[0], - stencil->ZPassFunc[0]); - /* back state */ - _mesa_StencilFuncSeparate(GL_BACK, - stencil->Function[1], - stencil->Ref[1], - stencil->ValueMask[1]); - _mesa_StencilMaskSeparate(GL_BACK, stencil->WriteMask[1]); - _mesa_StencilOpSeparate(GL_BACK, stencil->FailFunc[1], - stencil->ZFailFunc[1], - stencil->ZPassFunc[1]); - } - break; - case GL_TRANSFORM_BIT: - { - GLuint i; - const struct gl_transform_attrib *xform; - xform = (const struct gl_transform_attrib *) attr->data; - _mesa_MatrixMode(xform->MatrixMode); - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* restore clip planes */ - for (i = 0; i < MAX_CLIP_PLANES; i++) { - const GLuint mask = 1 << i; - const GLfloat *eyePlane = xform->EyeUserPlane[i]; - COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); - if (xform->ClipPlanesEnabled & mask) { - _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); - } - else { - _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); - } - if (ctx->Driver.ClipPlane) - ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); - } - - /* normalize/rescale */ - if (xform->Normalize != ctx->Transform.Normalize) - _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); - if (xform->RescaleNormals != ctx->Transform.RescaleNormals) - _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, - ctx->Transform.RescaleNormals); - if (xform->DepthClamp != ctx->Transform.DepthClamp) - _mesa_set_enable(ctx, GL_DEPTH_CLAMP, - ctx->Transform.DepthClamp); - } - break; - case GL_TEXTURE_BIT: - /* Take care of texture object reference counters */ - { - struct texture_state *texstate - = (struct texture_state *) attr->data; - pop_texture_group(ctx, texstate); - ctx->NewState |= _NEW_TEXTURE; - } - break; - case GL_VIEWPORT_BIT: - { - const struct gl_viewport_attrib *vp; - vp = (const struct gl_viewport_attrib *) attr->data; - _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); - _mesa_DepthRange(vp->Near, vp->Far); - } - break; - case GL_MULTISAMPLE_BIT_ARB: - { - const struct gl_multisample_attrib *ms; - ms = (const struct gl_multisample_attrib *) attr->data; - _mesa_SampleCoverageARB(ms->SampleCoverageValue, - ms->SampleCoverageInvert); - } - break; - - default: - _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); - break; - } - - next = attr->next; - FREE( attr->data ); - FREE( attr ); - attr = next; - } -} - - -/** - * Helper for incrementing/decrementing vertex buffer object reference - * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. - */ -static void -adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step) -{ - GLuint i; - - arrayObj->Vertex.BufferObj->RefCount += step; - arrayObj->Weight.BufferObj->RefCount += step; - arrayObj->Normal.BufferObj->RefCount += step; - arrayObj->Color.BufferObj->RefCount += step; - arrayObj->SecondaryColor.BufferObj->RefCount += step; - arrayObj->FogCoord.BufferObj->RefCount += step; - arrayObj->Index.BufferObj->RefCount += step; - arrayObj->EdgeFlag.BufferObj->RefCount += step; - for (i = 0; i < Elements(arrayObj->TexCoord); i++) - arrayObj->TexCoord[i].BufferObj->RefCount += step; - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) - arrayObj->VertexAttrib[i].BufferObj->RefCount += step; -} - - -/** - * Copy gl_pixelstore_attrib from src to dst, updating buffer - * object refcounts. - */ -static void -copy_pixelstore(GLcontext *ctx, - struct gl_pixelstore_attrib *dst, - const struct gl_pixelstore_attrib *src) -{ - dst->Alignment = src->Alignment; - dst->RowLength = src->RowLength; - dst->SkipPixels = src->SkipPixels; - dst->SkipRows = src->SkipRows; - dst->ImageHeight = src->ImageHeight; - dst->SkipImages = src->SkipImages; - dst->SwapBytes = src->SwapBytes; - dst->LsbFirst = src->LsbFirst; - dst->ClientStorage = src->ClientStorage; - dst->Invert = src->Invert; - _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); -} - - -#define GL_CLIENT_PACK_BIT (1<<20) -#define GL_CLIENT_UNPACK_BIT (1<<21) - - -void GLAPIENTRY -_mesa_PushClientAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute - * groups specified by the mask. - */ - head = NULL; - - if (mask & GL_CLIENT_PIXEL_STORE_BIT) { - struct gl_pixelstore_attrib *attr; - /* packing attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Pack); - save_attrib_data(&head, GL_CLIENT_PACK_BIT, attr); - /* unpacking attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Unpack); - save_attrib_data(&head, GL_CLIENT_UNPACK_BIT, attr); - } - - if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { - struct gl_array_attrib *attr; - struct gl_array_object *obj; - - attr = MALLOC_STRUCT( gl_array_attrib ); - obj = MALLOC_STRUCT( gl_array_object ); - -#if FEATURE_ARB_vertex_buffer_object - /* increment ref counts since we're copying pointers to these objects */ - ctx->Array.ArrayBufferObj->RefCount++; - ctx->Array.ElementArrayBufferObj->RefCount++; -#endif - - memcpy( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); - memcpy( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) ); - - attr->ArrayObj = obj; - - save_attrib_data(&head, GL_CLIENT_VERTEX_ARRAY_BIT, attr); - - /* bump reference counts on buffer objects */ - adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, 1); - } - - ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; - ctx->ClientAttribStackDepth++; -} - - - - -void GLAPIENTRY -_mesa_PopClientAttrib(void) -{ - struct gl_attrib_node *node, *next; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->ClientAttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); - return; - } - - ctx->ClientAttribStackDepth--; - node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; - - while (node) { - switch (node->kind) { - case GL_CLIENT_PACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Pack, store); - _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_UNPACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Unpack, store); - _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_VERTEX_ARRAY_BIT: { - struct gl_array_attrib * data = - (struct gl_array_attrib *) node->data; - - adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1); - - ctx->Array.ActiveTexture = data->ActiveTexture; - if (data->LockCount != 0) - _mesa_LockArraysEXT(data->LockFirst, data->LockCount); - else if (ctx->Array.LockCount) - _mesa_UnlockArraysEXT(); - - _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name ); - -#if FEATURE_ARB_vertex_buffer_object - _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, - data->ArrayBufferObj->Name); - _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, - data->ElementArrayBufferObj->Name); -#endif - - memcpy( ctx->Array.ArrayObj, data->ArrayObj, - sizeof( struct gl_array_object ) ); - - FREE( data->ArrayObj ); - - /* FIXME: Should some bits in ctx->Array->NewState also be set - * FIXME: here? It seems like it should be set to inclusive-or - * FIXME: of the old ArrayObj->_Enabled and the new _Enabled. - */ - - ctx->NewState |= _NEW_ARRAY; - break; - } - default: - _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); - break; - } - - next = node->next; - FREE( node->data ); - FREE( node ); - node = next; - } -} - - -void -_mesa_init_attrib_dispatch(struct _glapi_table *disp) -{ - SET_PopAttrib(disp, _mesa_PopAttrib); - SET_PushAttrib(disp, _mesa_PushAttrib); - SET_PopClientAttrib(disp, _mesa_PopClientAttrib); - SET_PushClientAttrib(disp, _mesa_PushClientAttrib); -} - - -#endif /* FEATURE_attrib_stack */ - - -/** - * Free any attribute state data that might be attached to the context. - */ -void -_mesa_free_attrib_data(GLcontext *ctx) -{ - while (ctx->AttribStackDepth > 0) { - struct gl_attrib_node *attr, *next; - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - if (attr->kind == GL_TEXTURE_BIT) { - struct texture_state *texstate = (struct texture_state*)attr->data; - GLuint u, tgt; - /* clear references to the saved texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } - } - } - else { - /* any other chunks of state that requires special handling? */ - } - - next = attr->next; - free(attr->data); - free(attr); - attr = next; - } - } -} - - -void _mesa_init_attrib( GLcontext *ctx ) -{ - /* Renderer and client attribute stacks */ - ctx->AttribStackDepth = 0; - ctx->ClientAttribStackDepth = 0; -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "imports.h" +#include "accum.h" +#include "arrayobj.h" +#include "attrib.h" +#include "blend.h" +#include "buffers.h" +#include "bufferobj.h" +#include "clear.h" +#include "colormac.h" +#include "context.h" +#include "depth.h" +#include "enable.h" +#include "enums.h" +#include "fog.h" +#include "hint.h" +#include "light.h" +#include "lines.h" +#include "macros.h" +#include "matrix.h" +#include "multisample.h" +#include "points.h" +#include "polygon.h" +#include "scissor.h" +#include "stencil.h" +#include "texenv.h" +#include "texgen.h" +#include "texobj.h" +#include "texparam.h" +#include "texstate.h" +#include "varray.h" +#include "viewport.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +/** + * glEnable()/glDisable() attribute group (GL_ENABLE_BIT). + */ +struct gl_enable_attrib +{ + GLboolean AlphaTest; + GLboolean AutoNormal; + GLboolean Blend; + GLbitfield ClipPlanes; + GLboolean ColorMaterial; + GLboolean CullFace; + GLboolean DepthClamp; + GLboolean DepthTest; + GLboolean Dither; + GLboolean Fog; + GLboolean Light[MAX_LIGHTS]; + GLboolean Lighting; + GLboolean LineSmooth; + GLboolean LineStipple; + GLboolean IndexLogicOp; + GLboolean ColorLogicOp; + + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ + + GLboolean Normalize; + GLboolean PixelTexture; + GLboolean PointSmooth; + GLboolean PolygonOffsetPoint; + GLboolean PolygonOffsetLine; + GLboolean PolygonOffsetFill; + GLboolean PolygonSmooth; + GLboolean PolygonStipple; + GLboolean RescaleNormals; + GLboolean Scissor; + GLboolean Stencil; + GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */ + GLboolean MultisampleEnabled; /* GL_ARB_multisample */ + GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ + GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ + GLboolean SampleCoverage; /* GL_ARB_multisample */ + GLboolean SampleCoverageInvert; /* GL_ARB_multisample */ + GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ + + GLbitfield Texture[MAX_TEXTURE_UNITS]; + GLbitfield TexGen[MAX_TEXTURE_UNITS]; + + /* SGI_texture_color_table */ + GLboolean TextureColorTable[MAX_TEXTURE_UNITS]; + + /* GL_ARB_vertex_program / GL_NV_vertex_program */ + GLboolean VertexProgram; + GLboolean VertexProgramPointSize; + GLboolean VertexProgramTwoSide; + + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + GLboolean PointSprite; + GLboolean FragmentShaderATI; +}; + + +/** + * Node for the attribute stack. + */ +struct gl_attrib_node +{ + GLbitfield kind; + void *data; + struct gl_attrib_node *next; +}; + + + +/** + * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) + */ +struct texture_state +{ + struct gl_texture_attrib Texture; /**< The usual context state */ + + /** to save per texture object state (wrap modes, filters, etc): */ + struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; + + /** + * To save references to texture objects (so they don't get accidentally + * deleted while saved in the attribute stack). + */ + struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; +}; + + +#if FEATURE_attrib_stack + + +/** + * Allocate new attribute node of given type/kind. Attach payload data. + * Insert it into the linked list named by 'head'. + */ +static void +save_attrib_data(struct gl_attrib_node **head, + GLbitfield kind, void *payload) +{ + struct gl_attrib_node *n = MALLOC_STRUCT(gl_attrib_node); + if (n) { + n->kind = kind; + n->data = payload; + /* insert at head */ + n->next = *head; + *head = n; + } + else { + /* out of memory! */ + } +} + + +void GLAPIENTRY +_mesa_PushAttrib(GLbitfield mask) +{ + struct gl_attrib_node *head; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); + + if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { + _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute */ + /* groups specified by the mask. */ + head = NULL; + + if (mask & GL_ACCUM_BUFFER_BIT) { + struct gl_accum_attrib *attr; + attr = MALLOC_STRUCT( gl_accum_attrib ); + memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); + save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr); + } + + if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; + struct gl_colorbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); + memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) + attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; + save_attrib_data(&head, GL_COLOR_BUFFER_BIT, attr); + } + + if (mask & GL_CURRENT_BIT) { + struct gl_current_attrib *attr; + FLUSH_CURRENT( ctx, 0 ); + attr = MALLOC_STRUCT( gl_current_attrib ); + memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); + save_attrib_data(&head, GL_CURRENT_BIT, attr); + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + struct gl_depthbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); + memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); + save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr); + } + + if (mask & GL_ENABLE_BIT) { + struct gl_enable_attrib *attr; + GLuint i; + attr = MALLOC_STRUCT( gl_enable_attrib ); + /* Copy enable flags from all other attributes into the enable struct. */ + attr->AlphaTest = ctx->Color.AlphaEnabled; + attr->AutoNormal = ctx->Eval.AutoNormal; + attr->Blend = ctx->Color.BlendEnabled; + attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; + attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; + attr->CullFace = ctx->Polygon.CullFlag; + attr->DepthClamp = ctx->Transform.DepthClamp; + attr->DepthTest = ctx->Depth.Test; + attr->Dither = ctx->Color.DitherFlag; + attr->Fog = ctx->Fog.Enabled; + for (i = 0; i < ctx->Const.MaxLights; i++) { + attr->Light[i] = ctx->Light.Light[i].Enabled; + } + attr->Lighting = ctx->Light.Enabled; + attr->LineSmooth = ctx->Line.SmoothFlag; + attr->LineStipple = ctx->Line.StippleFlag; + attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; + attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; + attr->Map1Color4 = ctx->Eval.Map1Color4; + attr->Map1Index = ctx->Eval.Map1Index; + attr->Map1Normal = ctx->Eval.Map1Normal; + attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; + attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; + attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; + attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; + attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; + attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; + memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); + attr->Map2Color4 = ctx->Eval.Map2Color4; + attr->Map2Index = ctx->Eval.Map2Index; + attr->Map2Normal = ctx->Eval.Map2Normal; + attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; + attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; + attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; + attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; + attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; + attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; + memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); + attr->Normalize = ctx->Transform.Normalize; + attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; + attr->PointSmooth = ctx->Point.SmoothFlag; + attr->PointSprite = ctx->Point.PointSprite; + attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; + attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; + attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; + attr->PolygonSmooth = ctx->Polygon.SmoothFlag; + attr->PolygonStipple = ctx->Polygon.StippleFlag; + attr->RescaleNormals = ctx->Transform.RescaleNormals; + attr->Scissor = ctx->Scissor.Enabled; + attr->Stencil = ctx->Stencil.Enabled; + attr->StencilTwoSide = ctx->Stencil.TestTwoSide; + attr->MultisampleEnabled = ctx->Multisample.Enabled; + attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; + attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; + attr->SampleCoverage = ctx->Multisample.SampleCoverage; + attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + attr->Texture[i] = ctx->Texture.Unit[i].Enabled; + attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; + attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled; + } + /* GL_NV_vertex_program */ + attr->VertexProgram = ctx->VertexProgram.Enabled; + attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; + attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; + save_attrib_data(&head, GL_ENABLE_BIT, attr); + } + + if (mask & GL_EVAL_BIT) { + struct gl_eval_attrib *attr; + attr = MALLOC_STRUCT( gl_eval_attrib ); + memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); + save_attrib_data(&head, GL_EVAL_BIT, attr); + } + + if (mask & GL_FOG_BIT) { + struct gl_fog_attrib *attr; + attr = MALLOC_STRUCT( gl_fog_attrib ); + memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); + save_attrib_data(&head, GL_FOG_BIT, attr); + } + + if (mask & GL_HINT_BIT) { + struct gl_hint_attrib *attr; + attr = MALLOC_STRUCT( gl_hint_attrib ); + memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); + save_attrib_data(&head, GL_HINT_BIT, attr); + } + + if (mask & GL_LIGHTING_BIT) { + struct gl_light_attrib *attr; + FLUSH_CURRENT(ctx, 0); /* flush material changes */ + attr = MALLOC_STRUCT( gl_light_attrib ); + memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); + save_attrib_data(&head, GL_LIGHTING_BIT, attr); + } + + if (mask & GL_LINE_BIT) { + struct gl_line_attrib *attr; + attr = MALLOC_STRUCT( gl_line_attrib ); + memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); + save_attrib_data(&head, GL_LINE_BIT, attr); + } + + if (mask & GL_LIST_BIT) { + struct gl_list_attrib *attr; + attr = MALLOC_STRUCT( gl_list_attrib ); + memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) ); + save_attrib_data(&head, GL_LIST_BIT, attr); + } + + if (mask & GL_PIXEL_MODE_BIT) { + struct gl_pixel_attrib *attr; + attr = MALLOC_STRUCT( gl_pixel_attrib ); + memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); + /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */ + attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; + save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr); + } + + if (mask & GL_POINT_BIT) { + struct gl_point_attrib *attr; + attr = MALLOC_STRUCT( gl_point_attrib ); + memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); + save_attrib_data(&head, GL_POINT_BIT, attr); + } + + if (mask & GL_POLYGON_BIT) { + struct gl_polygon_attrib *attr; + attr = MALLOC_STRUCT( gl_polygon_attrib ); + memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); + save_attrib_data(&head, GL_POLYGON_BIT, attr); + } + + if (mask & GL_POLYGON_STIPPLE_BIT) { + GLuint *stipple; + stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); + memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); + save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple); + } + + if (mask & GL_SCISSOR_BIT) { + struct gl_scissor_attrib *attr; + attr = MALLOC_STRUCT( gl_scissor_attrib ); + memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); + save_attrib_data(&head, GL_SCISSOR_BIT, attr); + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + struct gl_stencil_attrib *attr; + attr = MALLOC_STRUCT( gl_stencil_attrib ); + memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); + save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr); + } + + if (mask & GL_TEXTURE_BIT) { + struct texture_state *texstate = CALLOC_STRUCT(texture_state); + GLuint u, tex; + + if (!texstate) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); + goto end; + } + + _mesa_lock_context_textures(ctx); + + /* copy/save the bulk of texture state here */ + memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); + + /* Save references to the currently bound texture objects so they don't + * accidentally get deleted while referenced in the attribute stack. + */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tex], + ctx->Texture.Unit[u].CurrentTex[tex]); + } + } + + /* copy state/contents of the currently bound texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_copy_texture_object(&texstate->SavedObj[u][tex], + ctx->Texture.Unit[u].CurrentTex[tex]); + } + } + + _mesa_unlock_context_textures(ctx); + + save_attrib_data(&head, GL_TEXTURE_BIT, texstate); + } + + if (mask & GL_TRANSFORM_BIT) { + struct gl_transform_attrib *attr; + attr = MALLOC_STRUCT( gl_transform_attrib ); + memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); + save_attrib_data(&head, GL_TRANSFORM_BIT, attr); + } + + if (mask & GL_VIEWPORT_BIT) { + struct gl_viewport_attrib *attr; + attr = MALLOC_STRUCT( gl_viewport_attrib ); + memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); + save_attrib_data(&head, GL_VIEWPORT_BIT, attr); + } + + /* GL_ARB_multisample */ + if (mask & GL_MULTISAMPLE_BIT_ARB) { + struct gl_multisample_attrib *attr; + attr = MALLOC_STRUCT( gl_multisample_attrib ); + memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); + save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr); + } + +end: + ctx->AttribStack[ctx->AttribStackDepth] = head; + ctx->AttribStackDepth++; +} + + + +static void +pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) +{ + const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; + GLuint i; + +#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ + if ((VALUE) != (NEWVALUE)) { \ + _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ + } + + TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); + if (ctx->Color.BlendEnabled != enable->Blend) { + if (ctx->Extensions.EXT_draw_buffers2) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1)); + } + } + + for (i=0;iTransform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) + _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), + (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE)); + } + + TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, + GL_COLOR_MATERIAL); + TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); + TEST_AND_UPDATE(ctx->Transform.DepthClamp, enable->DepthClamp, + GL_DEPTH_CLAMP); + TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); + TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); + TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); + TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); + TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); + TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, + GL_LINE_STIPPLE); + TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, + GL_INDEX_LOGIC_OP); + TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, + GL_COLOR_LOGIC_OP); + + TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); + TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); + TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, + GL_MAP1_TEXTURE_COORD_1); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, + GL_MAP1_TEXTURE_COORD_2); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, + GL_MAP1_TEXTURE_COORD_3); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, + GL_MAP1_TEXTURE_COORD_4); + TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, + GL_MAP1_VERTEX_3); + TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, + GL_MAP1_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], + GL_MAP1_VERTEX_ATTRIB0_4_NV + i); + } + + TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); + TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); + TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, + GL_MAP2_TEXTURE_COORD_1); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, + GL_MAP2_TEXTURE_COORD_2); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, + GL_MAP2_TEXTURE_COORD_3); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, + GL_MAP2_TEXTURE_COORD_4); + TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, + GL_MAP2_VERTEX_3); + TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, + GL_MAP2_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], + GL_MAP2_VERTEX_ATTRIB0_4_NV + i); + } + + TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); + TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); + TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, + GL_RESCALE_NORMAL_EXT); + TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, + enable->RasterPositionUnclipped, + GL_RASTER_POSITION_UNCLIPPED_IBM); + TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, + GL_POINT_SMOOTH); + if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) { + TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, + GL_POINT_SPRITE_NV); + } + TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, + GL_POLYGON_OFFSET_POINT); + TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, + GL_POLYGON_OFFSET_LINE); + TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, + GL_POLYGON_OFFSET_FILL); + TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, + GL_POLYGON_SMOOTH); + TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, + GL_POLYGON_STIPPLE); + TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); + TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); + if (ctx->Extensions.EXT_stencil_two_side) { + TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT); + } + TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, + GL_MULTISAMPLE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, + enable->SampleAlphaToCoverage, + GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, + enable->SampleAlphaToOne, + GL_SAMPLE_ALPHA_TO_ONE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, + enable->SampleCoverage, + GL_SAMPLE_COVERAGE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert, + enable->SampleCoverageInvert, + GL_SAMPLE_COVERAGE_INVERT_ARB); + /* GL_ARB_vertex_program, GL_NV_vertex_program */ + TEST_AND_UPDATE(ctx->VertexProgram.Enabled, + enable->VertexProgram, + GL_VERTEX_PROGRAM_ARB); + TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, + enable->VertexProgramPointSize, + GL_VERTEX_PROGRAM_POINT_SIZE_ARB); + TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, + enable->VertexProgramTwoSide, + GL_VERTEX_PROGRAM_TWO_SIDE_ARB); + +#undef TEST_AND_UPDATE + + /* texture unit enables */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + const GLbitfield enabled = enable->Texture[i]; + const GLbitfield genEnabled = enable->TexGen[i]; + + if (ctx->Texture.Unit[i].Enabled != enabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + + _mesa_set_enable(ctx, GL_TEXTURE_1D, + (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, + (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, + (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); + if (ctx->Extensions.NV_texture_rectangle) { + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB, + (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.ARB_texture_cube_map) { + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, + (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + } + } + + if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, + (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, + (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, + (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, + (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE); + } + + /* GL_SGI_texture_color_table */ + ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i]; + } + + _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); +} + + +/** + * Pop/restore texture attribute/group state. + */ +static void +pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) +{ + GLuint u; + + _mesa_lock_context_textures(ctx); + + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; + GLuint tgt; + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); + _mesa_set_enable(ctx, GL_TEXTURE_1D, + (unit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, + (unit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, + (unit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); + if (ctx->Extensions.ARB_texture_cube_map) { + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, + (unit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.NV_texture_rectangle) { + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, + (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + } + + if (ctx->Extensions.SGI_texture_color_table) { + _mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI, + unit->ColorTableEnabled); + } + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); + _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); + _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); + _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); + _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); + _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); + _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); + _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); + _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); + _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); + /* Eye plane done differently to avoid re-transformation */ + { + struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; + COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); + COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); + COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); + COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); + if (ctx->Driver.TexGen) { + ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); + ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); + ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); + ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); + } + } + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, + ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, + ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, + ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, + ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE)); + if (ctx->Extensions.EXT_texture_lod_bias) { + _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, + GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias); + } + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, + unit->Combine.ModeRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, + unit->Combine.ModeA); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, + unit->Combine.SourceRGB[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, + unit->Combine.SourceRGB[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, + unit->Combine.SourceRGB[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, + unit->Combine.SourceA[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, + unit->Combine.SourceA[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, + unit->Combine.SourceA[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, + unit->Combine.OperandRGB[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, + unit->Combine.OperandRGB[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, + unit->Combine.OperandRGB[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, + unit->Combine.OperandA[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, + unit->Combine.OperandA[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, + unit->Combine.OperandA[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, + 1 << unit->Combine.ScaleShiftRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, + 1 << unit->Combine.ScaleShiftA); + } + + /* Restore texture object state for each target */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + const struct gl_texture_object *obj = NULL; + GLenum target; + + obj = &texstate->SavedObj[u][tgt]; + + /* don't restore state for unsupported targets to prevent + * raising GL errors. + */ + if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && + !ctx->Extensions.ARB_texture_cube_map) { + continue; + } + else if (obj->Target == GL_TEXTURE_RECTANGLE_NV && + !ctx->Extensions.NV_texture_rectangle) { + continue; + } + else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT || + obj->Target == GL_TEXTURE_2D_ARRAY_EXT) && + !ctx->Extensions.MESA_texture_array) { + continue; + } + + target = obj->Target; + + _mesa_BindTexture(target, obj->Name); + + _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor.f); + _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR); + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, obj->MinFilter); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter); + _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod); + _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod); + _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias); + _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); + if (target != GL_TEXTURE_RECTANGLE_ARB) + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, + obj->MaxAnisotropy); + } + if (ctx->Extensions.ARB_shadow_ambient) { + _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, + obj->CompareFailValue); + } + } + + /* remove saved references to the texture objects */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } + } + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); + + _mesa_unlock_context_textures(ctx); +} + + +/* + * This function is kind of long just because we have to call a lot + * of device driver functions to update device driver state. + * + * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions + * in order to restore GL state. This isn't terribly efficient but it + * ensures that dirty flags and any derived state gets updated correctly. + * We could at least check if the value to restore equals the current value + * and then skip the Mesa call. + */ +void GLAPIENTRY +_mesa_PopAttrib(void) +{ + struct gl_attrib_node *attr, *next; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->AttribStackDepth == 0) { + _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); + return; + } + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + + if (MESA_VERBOSE & VERBOSE_API) { + _mesa_debug(ctx, "glPopAttrib %s\n", + _mesa_lookup_enum_by_nr(attr->kind)); + } + + switch (attr->kind) { + case GL_ACCUM_BUFFER_BIT: + { + const struct gl_accum_attrib *accum; + accum = (const struct gl_accum_attrib *) attr->data; + _mesa_ClearAccum(accum->ClearColor[0], + accum->ClearColor[1], + accum->ClearColor[2], + accum->ClearColor[3]); + } + break; + case GL_COLOR_BUFFER_BIT: + { + const struct gl_colorbuffer_attrib *color; + + color = (const struct gl_colorbuffer_attrib *) attr->data; + _mesa_ClearIndex((GLfloat) color->ClearIndex); + _mesa_ClearColor(color->ClearColor[0], + color->ClearColor[1], + color->ClearColor[2], + color->ClearColor[3]); + _mesa_IndexMask(color->IndexMask); + if (!ctx->Extensions.EXT_draw_buffers2) { + _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0), + (GLboolean) (color->ColorMask[0][1] != 0), + (GLboolean) (color->ColorMask[0][2] != 0), + (GLboolean) (color->ColorMask[0][3] != 0)); + } + else { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_ColorMaskIndexed(i, + (GLboolean) (color->ColorMask[i][0] != 0), + (GLboolean) (color->ColorMask[i][1] != 0), + (GLboolean) (color->ColorMask[i][2] != 0), + (GLboolean) (color->ColorMask[i][3] != 0)); + } + } + { + /* Need to determine if more than one color output is + * specified. If so, call glDrawBuffersARB, else call + * glDrawBuffer(). This is a subtle, but essential point + * since GL_FRONT (for example) is illegal for the former + * function, but legal for the later. + */ + GLboolean multipleBuffers = GL_FALSE; + GLuint i; + + for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { + if (color->DrawBuffer[i] != GL_NONE) { + multipleBuffers = GL_TRUE; + break; + } + } + /* Call the API_level functions, not _mesa_drawbuffers() + * since we need to do error checking on the pop'd + * GL_DRAW_BUFFER. + * Ex: if GL_FRONT were pushed, but we're popping with a + * user FBO bound, GL_FRONT will be illegal and we'll need + * to record that error. Per OpenGL ARB decision. + */ + if (multipleBuffers) + _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers, + color->DrawBuffer); + else + _mesa_DrawBuffer(color->DrawBuffer[0]); + } + _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); + _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); + if (ctx->Color.BlendEnabled != color->BlendEnabled) { + if (ctx->Extensions.EXT_draw_buffers2) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, + (color->BlendEnabled >> i) & 1); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); + } + } + _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB, + color->BlendDstRGB, + color->BlendSrcA, + color->BlendDstA); + /* This special case is because glBlendEquationSeparateEXT + * cannot take GL_LOGIC_OP as a parameter. + */ + if ( color->BlendEquationRGB == color->BlendEquationA ) { + _mesa_BlendEquation(color->BlendEquationRGB); + } + else { + _mesa_BlendEquationSeparateEXT(color->BlendEquationRGB, + color->BlendEquationA); + } + _mesa_BlendColor(color->BlendColor[0], + color->BlendColor[1], + color->BlendColor[2], + color->BlendColor[3]); + _mesa_LogicOp(color->LogicOp); + _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, + color->ColorLogicOpEnabled); + _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, + color->IndexLogicOpEnabled); + _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); + } + break; + case GL_CURRENT_BIT: + FLUSH_CURRENT( ctx, 0 ); + memcpy( &ctx->Current, attr->data, + sizeof(struct gl_current_attrib) ); + break; + case GL_DEPTH_BUFFER_BIT: + { + const struct gl_depthbuffer_attrib *depth; + depth = (const struct gl_depthbuffer_attrib *) attr->data; + _mesa_DepthFunc(depth->Func); + _mesa_ClearDepth(depth->Clear); + _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); + _mesa_DepthMask(depth->Mask); + } + break; + case GL_ENABLE_BIT: + { + const struct gl_enable_attrib *enable; + enable = (const struct gl_enable_attrib *) attr->data; + pop_enable_group(ctx, enable); + ctx->NewState |= _NEW_ALL; + } + break; + case GL_EVAL_BIT: + memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); + ctx->NewState |= _NEW_EVAL; + break; + case GL_FOG_BIT: + { + const struct gl_fog_attrib *fog; + fog = (const struct gl_fog_attrib *) attr->data; + _mesa_set_enable(ctx, GL_FOG, fog->Enabled); + _mesa_Fogfv(GL_FOG_COLOR, fog->Color); + _mesa_Fogf(GL_FOG_DENSITY, fog->Density); + _mesa_Fogf(GL_FOG_START, fog->Start); + _mesa_Fogf(GL_FOG_END, fog->End); + _mesa_Fogf(GL_FOG_INDEX, fog->Index); + _mesa_Fogi(GL_FOG_MODE, fog->Mode); + } + break; + case GL_HINT_BIT: + { + const struct gl_hint_attrib *hint; + hint = (const struct gl_hint_attrib *) attr->data; + _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, + hint->PerspectiveCorrection ); + _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); + _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); + _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); + _mesa_Hint(GL_FOG_HINT, hint->Fog); + _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, + hint->ClipVolumeClipping); + _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, + hint->TextureCompression); + } + break; + case GL_LIGHTING_BIT: + { + GLuint i; + const struct gl_light_attrib *light; + light = (const struct gl_light_attrib *) attr->data; + /* lighting enable */ + _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); + /* per-light state */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + + for (i = 0; i < ctx->Const.MaxLights; i++) { + const struct gl_light *l = &light->Light[i]; + _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); + _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); + _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); + _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); + _mesa_light(ctx, i, GL_POSITION, l->EyePosition); + _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection); + { + GLfloat p[4] = { 0 }; + p[0] = l->SpotExponent; + _mesa_light(ctx, i, GL_SPOT_EXPONENT, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->SpotCutoff; + _mesa_light(ctx, i, GL_SPOT_CUTOFF, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->ConstantAttenuation; + _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->LinearAttenuation; + _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->QuadraticAttenuation; + _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p); + } + } + /* light model */ + _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, + light->Model.Ambient); + _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, + (GLfloat) light->Model.LocalViewer); + _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, + (GLfloat) light->Model.TwoSide); + _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, + (GLfloat) light->Model.ColorControl); + /* shade model */ + _mesa_ShadeModel(light->ShadeModel); + /* color material */ + _mesa_ColorMaterial(light->ColorMaterialFace, + light->ColorMaterialMode); + _mesa_set_enable(ctx, GL_COLOR_MATERIAL, + light->ColorMaterialEnabled); + /* materials */ + memcpy(&ctx->Light.Material, &light->Material, + sizeof(struct gl_material)); + } + break; + case GL_LINE_BIT: + { + const struct gl_line_attrib *line; + line = (const struct gl_line_attrib *) attr->data; + _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); + _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); + _mesa_LineStipple(line->StippleFactor, line->StipplePattern); + _mesa_LineWidth(line->Width); + } + break; + case GL_LIST_BIT: + memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); + break; + case GL_PIXEL_MODE_BIT: + memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); + /* XXX what other pixel state needs to be set by function calls? */ + _mesa_ReadBuffer(ctx->Pixel.ReadBuffer); + ctx->NewState |= _NEW_PIXEL; + break; + case GL_POINT_BIT: + { + const struct gl_point_attrib *point; + point = (const struct gl_point_attrib *) attr->data; + _mesa_PointSize(point->Size); + _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); + if (ctx->Extensions.EXT_point_parameters) { + _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT, + point->Params); + _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT, + point->MinSize); + _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT, + point->MaxSize); + _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, + point->Threshold); + } + if (ctx->Extensions.NV_point_sprite + || ctx->Extensions.ARB_point_sprite) { + GLuint u; + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, + (GLint) point->CoordReplace[u]); + } + _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); + if (ctx->Extensions.NV_point_sprite) + _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, + ctx->Point.SpriteRMode); + _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, + (GLfloat)ctx->Point.SpriteOrigin); + } + } + break; + case GL_POLYGON_BIT: + { + const struct gl_polygon_attrib *polygon; + polygon = (const struct gl_polygon_attrib *) attr->data; + _mesa_CullFace(polygon->CullFaceMode); + _mesa_FrontFace(polygon->FrontFace); + _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); + _mesa_PolygonMode(GL_BACK, polygon->BackMode); + _mesa_PolygonOffset(polygon->OffsetFactor, + polygon->OffsetUnits); + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); + _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, + polygon->OffsetPoint); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, + polygon->OffsetLine); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, + polygon->OffsetFill); + } + break; + case GL_POLYGON_STIPPLE_BIT: + memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); + ctx->NewState |= _NEW_POLYGONSTIPPLE; + if (ctx->Driver.PolygonStipple) + ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); + break; + case GL_SCISSOR_BIT: + { + const struct gl_scissor_attrib *scissor; + scissor = (const struct gl_scissor_attrib *) attr->data; + _mesa_Scissor(scissor->X, scissor->Y, + scissor->Width, scissor->Height); + _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); + } + break; + case GL_STENCIL_BUFFER_BIT: + { + const struct gl_stencil_attrib *stencil; + stencil = (const struct gl_stencil_attrib *) attr->data; + _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); + _mesa_ClearStencil(stencil->Clear); + if (ctx->Extensions.EXT_stencil_two_side) { + _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, + stencil->TestTwoSide); + _mesa_ActiveStencilFaceEXT(stencil->ActiveFace + ? GL_BACK : GL_FRONT); + } + /* front state */ + _mesa_StencilFuncSeparate(GL_FRONT, + stencil->Function[0], + stencil->Ref[0], + stencil->ValueMask[0]); + _mesa_StencilMaskSeparate(GL_FRONT, stencil->WriteMask[0]); + _mesa_StencilOpSeparate(GL_FRONT, stencil->FailFunc[0], + stencil->ZFailFunc[0], + stencil->ZPassFunc[0]); + /* back state */ + _mesa_StencilFuncSeparate(GL_BACK, + stencil->Function[1], + stencil->Ref[1], + stencil->ValueMask[1]); + _mesa_StencilMaskSeparate(GL_BACK, stencil->WriteMask[1]); + _mesa_StencilOpSeparate(GL_BACK, stencil->FailFunc[1], + stencil->ZFailFunc[1], + stencil->ZPassFunc[1]); + } + break; + case GL_TRANSFORM_BIT: + { + GLuint i; + const struct gl_transform_attrib *xform; + xform = (const struct gl_transform_attrib *) attr->data; + _mesa_MatrixMode(xform->MatrixMode); + if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) + _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); + + /* restore clip planes */ + for (i = 0; i < MAX_CLIP_PLANES; i++) { + const GLuint mask = 1 << i; + const GLfloat *eyePlane = xform->EyeUserPlane[i]; + COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); + if (xform->ClipPlanesEnabled & mask) { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); + } + else { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); + } + if (ctx->Driver.ClipPlane) + ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); + } + + /* normalize/rescale */ + if (xform->Normalize != ctx->Transform.Normalize) + _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); + if (xform->RescaleNormals != ctx->Transform.RescaleNormals) + _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, + ctx->Transform.RescaleNormals); + if (xform->DepthClamp != ctx->Transform.DepthClamp) + _mesa_set_enable(ctx, GL_DEPTH_CLAMP, + ctx->Transform.DepthClamp); + } + break; + case GL_TEXTURE_BIT: + /* Take care of texture object reference counters */ + { + struct texture_state *texstate + = (struct texture_state *) attr->data; + pop_texture_group(ctx, texstate); + ctx->NewState |= _NEW_TEXTURE; + } + break; + case GL_VIEWPORT_BIT: + { + const struct gl_viewport_attrib *vp; + vp = (const struct gl_viewport_attrib *) attr->data; + _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); + _mesa_DepthRange(vp->Near, vp->Far); + } + break; + case GL_MULTISAMPLE_BIT_ARB: + { + const struct gl_multisample_attrib *ms; + ms = (const struct gl_multisample_attrib *) attr->data; + _mesa_SampleCoverageARB(ms->SampleCoverageValue, + ms->SampleCoverageInvert); + } + break; + + default: + _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); + break; + } + + next = attr->next; + FREE( attr->data ); + FREE( attr ); + attr = next; + } +} + + +/** + * Helper for incrementing/decrementing vertex buffer object reference + * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. + */ +static void +adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step) +{ + GLuint i; + + arrayObj->Vertex.BufferObj->RefCount += step; + arrayObj->Weight.BufferObj->RefCount += step; + arrayObj->Normal.BufferObj->RefCount += step; + arrayObj->Color.BufferObj->RefCount += step; + arrayObj->SecondaryColor.BufferObj->RefCount += step; + arrayObj->FogCoord.BufferObj->RefCount += step; + arrayObj->Index.BufferObj->RefCount += step; + arrayObj->EdgeFlag.BufferObj->RefCount += step; + for (i = 0; i < Elements(arrayObj->TexCoord); i++) + arrayObj->TexCoord[i].BufferObj->RefCount += step; + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) + arrayObj->VertexAttrib[i].BufferObj->RefCount += step; +} + + +/** + * Copy gl_pixelstore_attrib from src to dst, updating buffer + * object refcounts. + */ +static void +copy_pixelstore(struct gl_context *ctx, + struct gl_pixelstore_attrib *dst, + const struct gl_pixelstore_attrib *src) +{ + dst->Alignment = src->Alignment; + dst->RowLength = src->RowLength; + dst->SkipPixels = src->SkipPixels; + dst->SkipRows = src->SkipRows; + dst->ImageHeight = src->ImageHeight; + dst->SkipImages = src->SkipImages; + dst->SwapBytes = src->SwapBytes; + dst->LsbFirst = src->LsbFirst; + dst->ClientStorage = src->ClientStorage; + dst->Invert = src->Invert; + _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); +} + + +#define GL_CLIENT_PACK_BIT (1<<20) +#define GL_CLIENT_UNPACK_BIT (1<<21) + + +void GLAPIENTRY +_mesa_PushClientAttrib(GLbitfield mask) +{ + struct gl_attrib_node *head; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { + _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute + * groups specified by the mask. + */ + head = NULL; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + struct gl_pixelstore_attrib *attr; + /* packing attribs */ + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Pack); + save_attrib_data(&head, GL_CLIENT_PACK_BIT, attr); + /* unpacking attribs */ + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Unpack); + save_attrib_data(&head, GL_CLIENT_UNPACK_BIT, attr); + } + + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + struct gl_array_attrib *attr; + struct gl_array_object *obj; + + attr = MALLOC_STRUCT( gl_array_attrib ); + obj = MALLOC_STRUCT( gl_array_object ); + +#if FEATURE_ARB_vertex_buffer_object + /* increment ref counts since we're copying pointers to these objects */ + ctx->Array.ArrayBufferObj->RefCount++; + ctx->Array.ElementArrayBufferObj->RefCount++; +#endif + + memcpy( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); + memcpy( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) ); + + attr->ArrayObj = obj; + + save_attrib_data(&head, GL_CLIENT_VERTEX_ARRAY_BIT, attr); + + /* bump reference counts on buffer objects */ + adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, 1); + } + + ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; + ctx->ClientAttribStackDepth++; +} + + + + +void GLAPIENTRY +_mesa_PopClientAttrib(void) +{ + struct gl_attrib_node *node, *next; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->ClientAttribStackDepth == 0) { + _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); + return; + } + + ctx->ClientAttribStackDepth--; + node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; + + while (node) { + switch (node->kind) { + case GL_CLIENT_PACK_BIT: + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Pack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); + } + ctx->NewState |= _NEW_PACKUNPACK; + break; + case GL_CLIENT_UNPACK_BIT: + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Unpack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); + } + ctx->NewState |= _NEW_PACKUNPACK; + break; + case GL_CLIENT_VERTEX_ARRAY_BIT: { + struct gl_array_attrib * data = + (struct gl_array_attrib *) node->data; + + adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1); + + ctx->Array.ActiveTexture = data->ActiveTexture; + if (data->LockCount != 0) + _mesa_LockArraysEXT(data->LockFirst, data->LockCount); + else if (ctx->Array.LockCount) + _mesa_UnlockArraysEXT(); + + _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name ); + +#if FEATURE_ARB_vertex_buffer_object + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, + data->ArrayBufferObj->Name); + _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, + data->ElementArrayBufferObj->Name); +#endif + + memcpy( ctx->Array.ArrayObj, data->ArrayObj, + sizeof( struct gl_array_object ) ); + + FREE( data->ArrayObj ); + + /* FIXME: Should some bits in ctx->Array->NewState also be set + * FIXME: here? It seems like it should be set to inclusive-or + * FIXME: of the old ArrayObj->_Enabled and the new _Enabled. + */ + + ctx->NewState |= _NEW_ARRAY; + break; + } + default: + _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); + break; + } + + next = node->next; + FREE( node->data ); + FREE( node ); + node = next; + } +} + + +void +_mesa_init_attrib_dispatch(struct _glapi_table *disp) +{ + SET_PopAttrib(disp, _mesa_PopAttrib); + SET_PushAttrib(disp, _mesa_PushAttrib); + SET_PopClientAttrib(disp, _mesa_PopClientAttrib); + SET_PushClientAttrib(disp, _mesa_PushClientAttrib); +} + + +#endif /* FEATURE_attrib_stack */ + + +/** + * Free any attribute state data that might be attached to the context. + */ +void +_mesa_free_attrib_data(struct gl_context *ctx) +{ + while (ctx->AttribStackDepth > 0) { + struct gl_attrib_node *attr, *next; + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + if (attr->kind == GL_TEXTURE_BIT) { + struct texture_state *texstate = (struct texture_state*)attr->data; + GLuint u, tgt; + /* clear references to the saved texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } + } + } + else { + /* any other chunks of state that requires special handling? */ + } + + next = attr->next; + free(attr->data); + free(attr); + attr = next; + } + } +} + + +void _mesa_init_attrib( struct gl_context *ctx ) +{ + /* Renderer and client attribute stacks */ + ctx->AttribStackDepth = 0; + ctx->ClientAttribStackDepth = 0; +} diff --git a/mesalib/src/mesa/main/attrib.h b/mesalib/src/mesa/main/attrib.h index 83b28a65b..8e7969a65 100644 --- a/mesalib/src/mesa/main/attrib.h +++ b/mesalib/src/mesa/main/attrib.h @@ -1,78 +1,80 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef ATTRIB_H -#define ATTRIB_H - - -#include "main/mtypes.h" - - -#if FEATURE_attrib_stack - -extern void GLAPIENTRY -_mesa_PushAttrib( GLbitfield mask ); - -extern void GLAPIENTRY -_mesa_PopAttrib( void ); - -extern void GLAPIENTRY -_mesa_PushClientAttrib( GLbitfield mask ); - -extern void GLAPIENTRY -_mesa_PopClientAttrib( void ); - -extern void -_mesa_init_attrib_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_attrib_stack */ - -#include "main/compiler.h" - -static INLINE void -_mesa_PushClientAttrib( GLbitfield mask ) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_PopClientAttrib( void ) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_init_attrib_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_attrib_stack */ - -extern void -_mesa_init_attrib( GLcontext *ctx ); - -extern void -_mesa_free_attrib_data( GLcontext *ctx ); - -#endif /* ATTRIB_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef ATTRIB_H +#define ATTRIB_H + + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct gl_context; + +#if FEATURE_attrib_stack + +extern void GLAPIENTRY +_mesa_PushAttrib( GLbitfield mask ); + +extern void GLAPIENTRY +_mesa_PopAttrib( void ); + +extern void GLAPIENTRY +_mesa_PushClientAttrib( GLbitfield mask ); + +extern void GLAPIENTRY +_mesa_PopClientAttrib( void ); + +extern void +_mesa_init_attrib_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_attrib_stack */ + +static INLINE void +_mesa_PushClientAttrib( GLbitfield mask ) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_PopClientAttrib( void ) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_init_attrib_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_attrib_stack */ + +extern void +_mesa_init_attrib( struct gl_context *ctx ); + +extern void +_mesa_free_attrib_data( struct gl_context *ctx ); + +#endif /* ATTRIB_H */ diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c index d022770f2..10e384a40 100644 --- a/mesalib/src/mesa/main/blend.c +++ b/mesalib/src/mesa/main/blend.c @@ -1,631 +1,629 @@ -/** - * \file blend.c - * Blending operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#include "glheader.h" -#include "blend.h" -#include "context.h" -#include "enums.h" -#include "macros.h" -#include "mtypes.h" - - -/** - * Specify the blending operation. - * - * \param sfactor source factor operator. - * \param dfactor destination factor operator. - * - * \sa glBlendFunc, glBlendFuncSeparateEXT - */ -void GLAPIENTRY -_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) -{ - _mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor); -} - - -/** - * Process GL_EXT_blend_func_separate(). - * - * \param sfactorRGB RGB source factor operator. - * \param dfactorRGB RGB destination factor operator. - * \param sfactorA alpha source factor operator. - * \param dfactorA alpha destination factor operator. - * - * Verifies the parameters and updates gl_colorbuffer_attrib. - * On a change, flush the vertices and notify the driver via - * dd_function_table::BlendFuncSeparate. - */ -void GLAPIENTRY -_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n", - _mesa_lookup_enum_by_nr(sfactorRGB), - _mesa_lookup_enum_by_nr(dfactorRGB), - _mesa_lookup_enum_by_nr(sfactorA), - _mesa_lookup_enum_by_nr(dfactorA)); - - switch (sfactorRGB) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - if (!ctx->Extensions.NV_blend_square) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)"); - return; - } - /* fall-through */ - case GL_ZERO: - case GL_ONE: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_SRC_ALPHA_SATURATE: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)"); - return; - } - - switch (dfactorRGB) { - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - if (!ctx->Extensions.NV_blend_square) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)"); - return; - } - /* fall-through */ - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)"); - return; - } - - switch (sfactorA) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - if (!ctx->Extensions.NV_blend_square) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)"); - return; - } - /* fall-through */ - case GL_ZERO: - case GL_ONE: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_SRC_ALPHA_SATURATE: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)"); - return; - } - - switch (dfactorA) { - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - if (!ctx->Extensions.NV_blend_square) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)"); - return; - } - /* fall-through */ - case GL_ZERO: - case GL_ONE: - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - case GL_SRC_ALPHA: - case GL_ONE_MINUS_SRC_ALPHA: - case GL_DST_ALPHA: - case GL_ONE_MINUS_DST_ALPHA: - case GL_CONSTANT_COLOR: - case GL_ONE_MINUS_CONSTANT_COLOR: - case GL_CONSTANT_ALPHA: - case GL_ONE_MINUS_CONSTANT_ALPHA: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)" ); - return; - } - - if (ctx->Color.BlendSrcRGB == sfactorRGB && - ctx->Color.BlendDstRGB == dfactorRGB && - ctx->Color.BlendSrcA == sfactorA && - ctx->Color.BlendDstA == dfactorA) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - - ctx->Color.BlendSrcRGB = sfactorRGB; - ctx->Color.BlendDstRGB = dfactorRGB; - ctx->Color.BlendSrcA = sfactorA; - ctx->Color.BlendDstA = dfactorA; - - if (ctx->Driver.BlendFuncSeparate) { - (*ctx->Driver.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB, - sfactorA, dfactorA ); - } -} - - -#if _HAVE_FULL_GL - -static GLboolean -_mesa_validate_blend_equation( GLcontext *ctx, - GLenum mode, GLboolean is_separate ) -{ - switch (mode) { - case GL_FUNC_ADD: - break; - case GL_MIN: - case GL_MAX: - if (!ctx->Extensions.EXT_blend_minmax && - !ctx->Extensions.ARB_imaging) { - return GL_FALSE; - } - break; - /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter. - */ - case GL_LOGIC_OP: - if (!ctx->Extensions.EXT_blend_logic_op || is_separate) { - return GL_FALSE; - } - break; - case GL_FUNC_SUBTRACT: - case GL_FUNC_REVERSE_SUBTRACT: - if (!ctx->Extensions.EXT_blend_subtract && - !ctx->Extensions.ARB_imaging) { - return GL_FALSE; - } - break; - default: - return GL_FALSE; - } - - return GL_TRUE; -} - - -/* This is really an extension function! */ -void GLAPIENTRY -_mesa_BlendEquation( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBlendEquation %s\n", - _mesa_lookup_enum_by_nr(mode)); - - if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation"); - return; - } - - if ( (ctx->Color.BlendEquationRGB == mode) && - (ctx->Color.BlendEquationA == mode) ) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEquationRGB = mode; - ctx->Color.BlendEquationA = mode; - - if (ctx->Driver.BlendEquationSeparate) - (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode ); -} - - -void GLAPIENTRY -_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n", - _mesa_lookup_enum_by_nr(modeRGB), - _mesa_lookup_enum_by_nr(modeA)); - - if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlendEquationSeparateEXT not supported by driver"); - return; - } - - if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)"); - return; - } - - if ( ! _mesa_validate_blend_equation( ctx, modeA, GL_TRUE ) ) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)"); - return; - } - - - if ( (ctx->Color.BlendEquationRGB == modeRGB) && - (ctx->Color.BlendEquationA == modeA) ) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEquationRGB = modeRGB; - ctx->Color.BlendEquationA = modeA; - - if (ctx->Driver.BlendEquationSeparate) - (*ctx->Driver.BlendEquationSeparate)( ctx, modeRGB, modeA ); -} -#endif - - -/** - * Set the blending color. - * - * \param red red color component. - * \param green green color component. - * \param blue blue color component. - * \param alpha alpha color component. - * - * \sa glBlendColor(). - * - * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a - * change, flushes the vertices and notifies the driver via - * dd_function_table::BlendColor callback. - */ -void GLAPIENTRY -_mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = CLAMP( red, 0.0F, 1.0F ); - tmp[1] = CLAMP( green, 0.0F, 1.0F ); - tmp[2] = CLAMP( blue, 0.0F, 1.0F ); - tmp[3] = CLAMP( alpha, 0.0F, 1.0F ); - - if (TEST_EQ_4V(tmp, ctx->Color.BlendColor)) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4FV( ctx->Color.BlendColor, tmp ); - - if (ctx->Driver.BlendColor) - (*ctx->Driver.BlendColor)(ctx, tmp); -} - - -/** - * Specify the alpha test function. - * - * \param func alpha comparison function. - * \param ref reference value. - * - * Verifies the parameters and updates gl_colorbuffer_attrib. - * On a change, flushes the vertices and notifies the driver via - * dd_function_table::AlphaFunc callback. - */ -void GLAPIENTRY -_mesa_AlphaFunc( GLenum func, GLclampf ref ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (func) { - case GL_NEVER: - case GL_LESS: - case GL_EQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_GEQUAL: - case GL_ALWAYS: - ref = CLAMP(ref, 0.0F, 1.0F); - - if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.AlphaFunc = func; - ctx->Color.AlphaRef = ref; - - if (ctx->Driver.AlphaFunc) - ctx->Driver.AlphaFunc(ctx, func, ref); - return; - - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" ); - return; - } -} - - -/** - * Specify a logic pixel operation for color index rendering. - * - * \param opcode operation. - * - * Verifies that \p opcode is a valid enum and updates -gl_colorbuffer_attrib::LogicOp. - * On a change, flushes the vertices and notifies the driver via the - * dd_function_table::LogicOpcode callback. - */ -void GLAPIENTRY -_mesa_LogicOp( GLenum opcode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (opcode) { - case GL_CLEAR: - case GL_SET: - case GL_COPY: - case GL_COPY_INVERTED: - case GL_NOOP: - case GL_INVERT: - case GL_AND: - case GL_NAND: - case GL_OR: - case GL_NOR: - case GL_XOR: - case GL_EQUIV: - case GL_AND_REVERSE: - case GL_AND_INVERTED: - case GL_OR_REVERSE: - case GL_OR_INVERTED: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); - return; - } - - if (ctx->Color.LogicOp == opcode) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.LogicOp = opcode; - - if (ctx->Driver.LogicOpcode) - ctx->Driver.LogicOpcode( ctx, opcode ); -} - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_IndexMask( GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Color.IndexMask == mask) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.IndexMask = mask; -} -#endif - - -/** - * Enable or disable writing of frame buffer color components. - * - * \param red whether to mask writing of the red color component. - * \param green whether to mask writing of the green color component. - * \param blue whether to mask writing of the blue color component. - * \param alpha whether to mask writing of the alpha color component. - * - * \sa glColorMask(). - * - * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a - * change, flushes the vertices and notifies the driver via the - * dd_function_table::ColorMask callback. - */ -void GLAPIENTRY -_mesa_ColorMask( GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ) -{ - GET_CURRENT_CONTEXT(ctx); - GLubyte tmp[4]; - GLuint i; - GLboolean flushed; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glColorMask %d %d %d %d\n", red, green, blue, alpha); - - /* Shouldn't have any information about channel depth in core mesa - * -- should probably store these as the native booleans: - */ - tmp[RCOMP] = red ? 0xff : 0x0; - tmp[GCOMP] = green ? 0xff : 0x0; - tmp[BCOMP] = blue ? 0xff : 0x0; - tmp[ACOMP] = alpha ? 0xff : 0x0; - - flushed = GL_FALSE; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) { - if (!flushed) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - } - flushed = GL_TRUE; - COPY_4UBV(ctx->Color.ColorMask[i], tmp); - } - } - - if (ctx->Driver.ColorMask) - ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); -} - - -/** - * For GL_EXT_draw_buffers2 and GL3 - */ -void GLAPIENTRY -_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ) -{ - GLubyte tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n", - buf, red, green, blue, alpha); - - if (buf >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf); - return; - } - - /* Shouldn't have any information about channel depth in core mesa - * -- should probably store these as the native booleans: - */ - tmp[RCOMP] = red ? 0xff : 0x0; - tmp[GCOMP] = green ? 0xff : 0x0; - tmp[BCOMP] = blue ? 0xff : 0x0; - tmp[ACOMP] = alpha ? 0xff : 0x0; - - if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf])) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4UBV(ctx->Color.ColorMask[buf], tmp); - - if (ctx->Driver.ColorMaskIndexed) - ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha); -} - - -extern void GLAPIENTRY -_mesa_ClampColorARB(GLenum target, GLenum clamp) -{ - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (clamp != GL_TRUE && clamp != GL_FALSE && clamp != GL_FIXED_ONLY_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(clamp)"); - return; - } - - switch (target) { - case GL_CLAMP_VERTEX_COLOR_ARB: - ctx->Light.ClampVertexColor = clamp; - break; - case GL_CLAMP_FRAGMENT_COLOR_ARB: - ctx->Color.ClampFragmentColor = clamp; - break; - case GL_CLAMP_READ_COLOR_ARB: - ctx->Color.ClampReadColor = clamp; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)"); - return; - } -} - - - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialization of the context's Color attribute group. - * - * \param ctx GL context. - * - * Initializes the related fields in the context color attribute group, - * __GLcontextRec::Color. - */ -void _mesa_init_color( GLcontext * ctx ) -{ - /* Color buffer group */ - ctx->Color.IndexMask = ~0u; - memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask)); - ctx->Color.ClearIndex = 0; - ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 ); - ctx->Color.AlphaEnabled = GL_FALSE; - ctx->Color.AlphaFunc = GL_ALWAYS; - ctx->Color.AlphaRef = 0; - ctx->Color.BlendEnabled = 0x0; - ctx->Color.BlendSrcRGB = GL_ONE; - ctx->Color.BlendDstRGB = GL_ZERO; - ctx->Color.BlendSrcA = GL_ONE; - ctx->Color.BlendDstA = GL_ZERO; - ctx->Color.BlendEquationRGB = GL_FUNC_ADD; - ctx->Color.BlendEquationA = GL_FUNC_ADD; - ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 ); - ctx->Color.IndexLogicOpEnabled = GL_FALSE; - ctx->Color.ColorLogicOpEnabled = GL_FALSE; - ctx->Color._LogicOpEnabled = GL_FALSE; - ctx->Color.LogicOp = GL_COPY; - ctx->Color.DitherFlag = GL_TRUE; - - if (ctx->Visual.doubleBufferMode) { - ctx->Color.DrawBuffer[0] = GL_BACK; - } - else { - ctx->Color.DrawBuffer[0] = GL_FRONT; - } - - ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; - ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB; -} - -/*@}*/ +/** + * \file blend.c + * Blending operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#include "glheader.h" +#include "blend.h" +#include "context.h" +#include "enums.h" +#include "macros.h" +#include "mtypes.h" + + +/** + * Specify the blending operation. + * + * \param sfactor source factor operator. + * \param dfactor destination factor operator. + * + * \sa glBlendFunc, glBlendFuncSeparateEXT + */ +void GLAPIENTRY +_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) +{ + _mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor); +} + + +/** + * Process GL_EXT_blend_func_separate(). + * + * \param sfactorRGB RGB source factor operator. + * \param dfactorRGB RGB destination factor operator. + * \param sfactorA alpha source factor operator. + * \param dfactorA alpha destination factor operator. + * + * Verifies the parameters and updates gl_colorbuffer_attrib. + * On a change, flush the vertices and notify the driver via + * dd_function_table::BlendFuncSeparate. + */ +void GLAPIENTRY +_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n", + _mesa_lookup_enum_by_nr(sfactorRGB), + _mesa_lookup_enum_by_nr(dfactorRGB), + _mesa_lookup_enum_by_nr(sfactorA), + _mesa_lookup_enum_by_nr(dfactorA)); + + switch (sfactorRGB) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + if (!ctx->Extensions.NV_blend_square) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)"); + return; + } + /* fall-through */ + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)"); + return; + } + + switch (dfactorRGB) { + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + if (!ctx->Extensions.NV_blend_square) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)"); + return; + } + /* fall-through */ + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)"); + return; + } + + switch (sfactorA) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + if (!ctx->Extensions.NV_blend_square) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)"); + return; + } + /* fall-through */ + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)"); + return; + } + + switch (dfactorA) { + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + if (!ctx->Extensions.NV_blend_square) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)"); + return; + } + /* fall-through */ + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)" ); + return; + } + + if (ctx->Color.BlendSrcRGB == sfactorRGB && + ctx->Color.BlendDstRGB == dfactorRGB && + ctx->Color.BlendSrcA == sfactorA && + ctx->Color.BlendDstA == dfactorA) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + + ctx->Color.BlendSrcRGB = sfactorRGB; + ctx->Color.BlendDstRGB = dfactorRGB; + ctx->Color.BlendSrcA = sfactorA; + ctx->Color.BlendDstA = dfactorA; + + if (ctx->Driver.BlendFuncSeparate) { + (*ctx->Driver.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB, + sfactorA, dfactorA ); + } +} + + +#if _HAVE_FULL_GL + +static GLboolean +_mesa_validate_blend_equation( struct gl_context *ctx, + GLenum mode, GLboolean is_separate ) +{ + switch (mode) { + case GL_FUNC_ADD: + break; + case GL_MIN: + case GL_MAX: + if (!ctx->Extensions.EXT_blend_minmax) { + return GL_FALSE; + } + break; + /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter. + */ + case GL_LOGIC_OP: + if (!ctx->Extensions.EXT_blend_logic_op || is_separate) { + return GL_FALSE; + } + break; + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + if (!ctx->Extensions.EXT_blend_subtract) { + return GL_FALSE; + } + break; + default: + return GL_FALSE; + } + + return GL_TRUE; +} + + +/* This is really an extension function! */ +void GLAPIENTRY +_mesa_BlendEquation( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBlendEquation %s\n", + _mesa_lookup_enum_by_nr(mode)); + + if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation"); + return; + } + + if ( (ctx->Color.BlendEquationRGB == mode) && + (ctx->Color.BlendEquationA == mode) ) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.BlendEquationRGB = mode; + ctx->Color.BlendEquationA = mode; + + if (ctx->Driver.BlendEquationSeparate) + (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode ); +} + + +void GLAPIENTRY +_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n", + _mesa_lookup_enum_by_nr(modeRGB), + _mesa_lookup_enum_by_nr(modeA)); + + if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlendEquationSeparateEXT not supported by driver"); + return; + } + + if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)"); + return; + } + + if ( ! _mesa_validate_blend_equation( ctx, modeA, GL_TRUE ) ) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)"); + return; + } + + + if ( (ctx->Color.BlendEquationRGB == modeRGB) && + (ctx->Color.BlendEquationA == modeA) ) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.BlendEquationRGB = modeRGB; + ctx->Color.BlendEquationA = modeA; + + if (ctx->Driver.BlendEquationSeparate) + (*ctx->Driver.BlendEquationSeparate)( ctx, modeRGB, modeA ); +} +#endif + + +/** + * Set the blending color. + * + * \param red red color component. + * \param green green color component. + * \param blue blue color component. + * \param alpha alpha color component. + * + * \sa glBlendColor(). + * + * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a + * change, flushes the vertices and notifies the driver via + * dd_function_table::BlendColor callback. + */ +void GLAPIENTRY +_mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = CLAMP( red, 0.0F, 1.0F ); + tmp[1] = CLAMP( green, 0.0F, 1.0F ); + tmp[2] = CLAMP( blue, 0.0F, 1.0F ); + tmp[3] = CLAMP( alpha, 0.0F, 1.0F ); + + if (TEST_EQ_4V(tmp, ctx->Color.BlendColor)) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + COPY_4FV( ctx->Color.BlendColor, tmp ); + + if (ctx->Driver.BlendColor) + (*ctx->Driver.BlendColor)(ctx, tmp); +} + + +/** + * Specify the alpha test function. + * + * \param func alpha comparison function. + * \param ref reference value. + * + * Verifies the parameters and updates gl_colorbuffer_attrib. + * On a change, flushes the vertices and notifies the driver via + * dd_function_table::AlphaFunc callback. + */ +void GLAPIENTRY +_mesa_AlphaFunc( GLenum func, GLclampf ref ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + ref = CLAMP(ref, 0.0F, 1.0F); + + if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.AlphaFunc = func; + ctx->Color.AlphaRef = ref; + + if (ctx->Driver.AlphaFunc) + ctx->Driver.AlphaFunc(ctx, func, ref); + return; + + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" ); + return; + } +} + + +/** + * Specify a logic pixel operation for color index rendering. + * + * \param opcode operation. + * + * Verifies that \p opcode is a valid enum and updates +gl_colorbuffer_attrib::LogicOp. + * On a change, flushes the vertices and notifies the driver via the + * dd_function_table::LogicOpcode callback. + */ +void GLAPIENTRY +_mesa_LogicOp( GLenum opcode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (opcode) { + case GL_CLEAR: + case GL_SET: + case GL_COPY: + case GL_COPY_INVERTED: + case GL_NOOP: + case GL_INVERT: + case GL_AND: + case GL_NAND: + case GL_OR: + case GL_NOR: + case GL_XOR: + case GL_EQUIV: + case GL_AND_REVERSE: + case GL_AND_INVERTED: + case GL_OR_REVERSE: + case GL_OR_INVERTED: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" ); + return; + } + + if (ctx->Color.LogicOp == opcode) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.LogicOp = opcode; + + if (ctx->Driver.LogicOpcode) + ctx->Driver.LogicOpcode( ctx, opcode ); +} + +#if _HAVE_FULL_GL +void GLAPIENTRY +_mesa_IndexMask( GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Color.IndexMask == mask) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.IndexMask = mask; +} +#endif + + +/** + * Enable or disable writing of frame buffer color components. + * + * \param red whether to mask writing of the red color component. + * \param green whether to mask writing of the green color component. + * \param blue whether to mask writing of the blue color component. + * \param alpha whether to mask writing of the alpha color component. + * + * \sa glColorMask(). + * + * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a + * change, flushes the vertices and notifies the driver via the + * dd_function_table::ColorMask callback. + */ +void GLAPIENTRY +_mesa_ColorMask( GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + GET_CURRENT_CONTEXT(ctx); + GLubyte tmp[4]; + GLuint i; + GLboolean flushed; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glColorMask %d %d %d %d\n", red, green, blue, alpha); + + /* Shouldn't have any information about channel depth in core mesa + * -- should probably store these as the native booleans: + */ + tmp[RCOMP] = red ? 0xff : 0x0; + tmp[GCOMP] = green ? 0xff : 0x0; + tmp[BCOMP] = blue ? 0xff : 0x0; + tmp[ACOMP] = alpha ? 0xff : 0x0; + + flushed = GL_FALSE; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) { + if (!flushed) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + } + flushed = GL_TRUE; + COPY_4UBV(ctx->Color.ColorMask[i], tmp); + } + } + + if (ctx->Driver.ColorMask) + ctx->Driver.ColorMask( ctx, red, green, blue, alpha ); +} + + +/** + * For GL_EXT_draw_buffers2 and GL3 + */ +void GLAPIENTRY +_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) +{ + GLubyte tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n", + buf, red, green, blue, alpha); + + if (buf >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf); + return; + } + + /* Shouldn't have any information about channel depth in core mesa + * -- should probably store these as the native booleans: + */ + tmp[RCOMP] = red ? 0xff : 0x0; + tmp[GCOMP] = green ? 0xff : 0x0; + tmp[BCOMP] = blue ? 0xff : 0x0; + tmp[ACOMP] = alpha ? 0xff : 0x0; + + if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf])) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + COPY_4UBV(ctx->Color.ColorMask[buf], tmp); + + if (ctx->Driver.ColorMaskIndexed) + ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha); +} + + +extern void GLAPIENTRY +_mesa_ClampColorARB(GLenum target, GLenum clamp) +{ + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (clamp != GL_TRUE && clamp != GL_FALSE && clamp != GL_FIXED_ONLY_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(clamp)"); + return; + } + + switch (target) { + case GL_CLAMP_VERTEX_COLOR_ARB: + ctx->Light.ClampVertexColor = clamp; + break; + case GL_CLAMP_FRAGMENT_COLOR_ARB: + ctx->Color.ClampFragmentColor = clamp; + break; + case GL_CLAMP_READ_COLOR_ARB: + ctx->Color.ClampReadColor = clamp; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)"); + return; + } +} + + + + +/**********************************************************************/ +/** \name Initialization */ +/*@{*/ + +/** + * Initialization of the context's Color attribute group. + * + * \param ctx GL context. + * + * Initializes the related fields in the context color attribute group, + * __struct gl_contextRec::Color. + */ +void _mesa_init_color( struct gl_context * ctx ) +{ + /* Color buffer group */ + ctx->Color.IndexMask = ~0u; + memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask)); + ctx->Color.ClearIndex = 0; + ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 ); + ctx->Color.AlphaEnabled = GL_FALSE; + ctx->Color.AlphaFunc = GL_ALWAYS; + ctx->Color.AlphaRef = 0; + ctx->Color.BlendEnabled = 0x0; + ctx->Color.BlendSrcRGB = GL_ONE; + ctx->Color.BlendDstRGB = GL_ZERO; + ctx->Color.BlendSrcA = GL_ONE; + ctx->Color.BlendDstA = GL_ZERO; + ctx->Color.BlendEquationRGB = GL_FUNC_ADD; + ctx->Color.BlendEquationA = GL_FUNC_ADD; + ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 ); + ctx->Color.IndexLogicOpEnabled = GL_FALSE; + ctx->Color.ColorLogicOpEnabled = GL_FALSE; + ctx->Color._LogicOpEnabled = GL_FALSE; + ctx->Color.LogicOp = GL_COPY; + ctx->Color.DitherFlag = GL_TRUE; + + if (ctx->Visual.doubleBufferMode) { + ctx->Color.DrawBuffer[0] = GL_BACK; + } + else { + ctx->Color.DrawBuffer[0] = GL_FRONT; + } + + ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; + ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB; +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/blend.h b/mesalib/src/mesa/main/blend.h index b4fd7470e..4437ba1bd 100644 --- a/mesalib/src/mesa/main/blend.h +++ b/mesalib/src/mesa/main/blend.h @@ -1,87 +1,89 @@ -/** - * \file blend.h - * Blending functions operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BLEND_H -#define BLEND_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ); - - -extern void GLAPIENTRY -_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ); - - -extern void GLAPIENTRY -_mesa_BlendEquation( GLenum mode ); - - -extern void GLAPIENTRY -_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ); - - -extern void GLAPIENTRY -_mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - - -extern void GLAPIENTRY -_mesa_AlphaFunc( GLenum func, GLclampf ref ); - - -extern void GLAPIENTRY -_mesa_LogicOp( GLenum opcode ); - - -extern void GLAPIENTRY -_mesa_IndexMask( GLuint mask ); - -extern void GLAPIENTRY -_mesa_ColorMask( GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ); - -extern void GLAPIENTRY -_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ); - - -extern void GLAPIENTRY -_mesa_ClampColorARB(GLenum target, GLenum clamp); - - -extern void -_mesa_init_color( GLcontext * ctx ); - -#endif +/** + * \file blend.h + * Blending functions operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef BLEND_H +#define BLEND_H + + +#include "glheader.h" + +struct gl_context; + + +extern void GLAPIENTRY +_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ); + + +extern void GLAPIENTRY +_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA ); + + +extern void GLAPIENTRY +_mesa_BlendEquation( GLenum mode ); + + +extern void GLAPIENTRY +_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ); + + +extern void GLAPIENTRY +_mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + + +extern void GLAPIENTRY +_mesa_AlphaFunc( GLenum func, GLclampf ref ); + + +extern void GLAPIENTRY +_mesa_LogicOp( GLenum opcode ); + + +extern void GLAPIENTRY +_mesa_IndexMask( GLuint mask ); + +extern void GLAPIENTRY +_mesa_ColorMask( GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ); + +extern void GLAPIENTRY +_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ); + + +extern void GLAPIENTRY +_mesa_ClampColorARB(GLenum target, GLenum clamp); + + +extern void +_mesa_init_color( struct gl_context * ctx ); + +#endif diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 4797f29b4..a70c75750 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -1,2142 +1,2143 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file bufferobj.c - * \brief Functions for the GL_ARB_vertex/pixel_buffer_object extensions. - * \author Brian Paul, Ian Romanick - */ - - -#include "glheader.h" -#include "enums.h" -#include "hash.h" -#include "imports.h" -#include "image.h" -#include "context.h" -#include "bufferobj.h" -#include "fbobject.h" -#include "texobj.h" - - -/* Debug flags */ -/*#define VBO_DEBUG*/ -/*#define BOUNDS_CHECK*/ - - -#if FEATURE_OES_mapbuffer -#define DEFAULT_ACCESS GL_MAP_WRITE_BIT -#else -#define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT) -#endif - - -/** - * Return pointer to address of a buffer object target. - * \param ctx the GL context - * \param target the buffer object target to be retrieved. - * \return pointer to pointer to the buffer object bound to \c target in the - * specified context or \c NULL if \c target is invalid. - */ -static INLINE struct gl_buffer_object ** -get_buffer_target(GLcontext *ctx, GLenum target) -{ - switch (target) { - case GL_ARRAY_BUFFER_ARB: - return &ctx->Array.ArrayBufferObj; - case GL_ELEMENT_ARRAY_BUFFER_ARB: - return &ctx->Array.ElementArrayBufferObj; - case GL_PIXEL_PACK_BUFFER_EXT: - return &ctx->Pack.BufferObj; - case GL_PIXEL_UNPACK_BUFFER_EXT: - return &ctx->Unpack.BufferObj; - case GL_COPY_READ_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - return &ctx->CopyReadBuffer; - } - break; - case GL_COPY_WRITE_BUFFER: - if (ctx->Extensions.ARB_copy_buffer) { - return &ctx->CopyWriteBuffer; - } - break; -#if FEATURE_EXT_transform_feedback - case GL_TRANSFORM_FEEDBACK_BUFFER: - if (ctx->Extensions.EXT_transform_feedback) { - return &ctx->TransformFeedback.CurrentBuffer; - } - break; -#endif - default: - return NULL; - } - return NULL; -} - - -/** - * Get the buffer object bound to the specified target in a GL context. - * \param ctx the GL context - * \param target the buffer object target to be retrieved. - * \return pointer to the buffer object bound to \c target in the - * specified context or \c NULL if \c target is invalid. - */ -static INLINE struct gl_buffer_object * -get_buffer(GLcontext *ctx, GLenum target) -{ - struct gl_buffer_object **bufObj = get_buffer_target(ctx, target); - if (bufObj) - return *bufObj; - return NULL; -} - - -/** - * Convert a GLbitfield describing the mapped buffer access flags - * into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY. - */ -static GLenum -simplified_access_mode(GLbitfield access) -{ - const GLbitfield rwFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; - if ((access & rwFlags) == rwFlags) - return GL_READ_WRITE; - if ((access & GL_MAP_READ_BIT) == GL_MAP_READ_BIT) - return GL_READ_ONLY; - if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT) - return GL_WRITE_ONLY; - return GL_READ_WRITE; /* this should never happen, but no big deal */ -} - - -/** - * Tests the subdata range parameters and sets the GL error code for - * \c glBufferSubDataARB and \c glGetBufferSubDataARB. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte of the subdata range. - * \param size Size, in bytes, of the subdata range. - * \param caller Name of calling function for recording errors. - * \return A pointer to the buffer object bound to \c target in the - * specified context or \c NULL if any of the parameter or state - * conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB - * are invalid. - * - * \sa glBufferSubDataARB, glGetBufferSubDataARB - */ -static struct gl_buffer_object * -buffer_object_subdata_range_good( GLcontext * ctx, GLenum target, - GLintptrARB offset, GLsizeiptrARB size, - const char *caller ) -{ - struct gl_buffer_object *bufObj; - - if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller); - return NULL; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller); - return NULL; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", caller); - return NULL; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - if (offset + size > bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(size + offset > buffer size)", caller); - return NULL; - } - if (_mesa_bufferobj_mapped(bufObj)) { - /* Buffer is currently mapped */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - - return bufObj; -} - - -/** - * Allocate and initialize a new buffer object. - * - * Default callback for the \c dd_function_table::NewBufferObject() hook. - */ -static struct gl_buffer_object * -_mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target ) -{ - struct gl_buffer_object *obj; - - (void) ctx; - - obj = MALLOC_STRUCT(gl_buffer_object); - _mesa_initialize_buffer_object(obj, name, target); - return obj; -} - - -/** - * Delete a buffer object. - * - * Default callback for the \c dd_function_table::DeleteBuffer() hook. - */ -static void -_mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) -{ - (void) ctx; - - if (bufObj->Data) - free(bufObj->Data); - - /* assign strange values here to help w/ debugging */ - bufObj->RefCount = -1000; - bufObj->Name = ~0; - - _glthread_DESTROY_MUTEX(bufObj->Mutex); - free(bufObj); -} - - - -/** - * Set ptr to bufObj w/ reference counting. - */ -void -_mesa_reference_buffer_object(GLcontext *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj) -{ - if (*ptr == bufObj) - return; - - if (*ptr) { - /* Unreference the old buffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_buffer_object *oldObj = *ptr; - - _glthread_LOCK_MUTEX(oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); - oldObj->RefCount--; -#if 0 - printf("BufferObj %p %d DECR to %d\n", - (void *) oldObj, oldObj->Name, oldObj->RefCount); -#endif - deleteFlag = (oldObj->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldObj->Mutex); - - if (deleteFlag) { - - /* some sanity checking: don't delete a buffer still in use */ -#if 0 - /* unfortunately, these tests are invalid during context tear-down */ - ASSERT(ctx->Array.ArrayBufferObj != bufObj); - ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); - ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); -#endif - - ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer(ctx, oldObj); - } - - *ptr = NULL; - } - ASSERT(!*ptr); - - if (bufObj) { - /* reference new buffer */ - _glthread_LOCK_MUTEX(bufObj->Mutex); - if (bufObj->RefCount == 0) { - /* this buffer's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted buffer object"); - *ptr = NULL; - } - else { - bufObj->RefCount++; -#if 0 - printf("BufferObj %p %d INCR to %d\n", - (void *) bufObj, bufObj->Name, bufObj->RefCount); -#endif - *ptr = bufObj; - } - _glthread_UNLOCK_MUTEX(bufObj->Mutex); - } -} - - -/** - * Initialize a buffer object to default values. - */ -void -_mesa_initialize_buffer_object( struct gl_buffer_object *obj, - GLuint name, GLenum target ) -{ - (void) target; - - memset(obj, 0, sizeof(struct gl_buffer_object)); - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - obj->Name = name; - obj->Usage = GL_STATIC_DRAW_ARB; - obj->AccessFlags = DEFAULT_ACCESS; -} - - -/** - * Allocate space for and store data in a buffer object. Any data that was - * previously stored in the buffer object is lost. If \c data is \c NULL, - * memory will be allocated, but no copy will occur. - * - * This is the default callback for \c dd_function_table::BufferData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param size Size, in bytes, of the new data store. - * \param data Pointer to the data to store in the buffer object. This - * pointer may be \c NULL. - * \param usage Hints about how the data will be used. - * \param bufObj Object to be used. - * - * \return GL_TRUE for success, GL_FALSE for failure - * \sa glBufferDataARB, dd_function_table::BufferData. - */ -static GLboolean -_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage, - struct gl_buffer_object * bufObj ) -{ - void * new_data; - - (void) ctx; (void) target; - - new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size ); - if (new_data) { - bufObj->Data = (GLubyte *) new_data; - bufObj->Size = size; - bufObj->Usage = usage; - - if (data) { - memcpy( bufObj->Data, data, size ); - } - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - -/** - * Replace data in a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::BufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte to be modified. - * \param size Size, in bytes, of the data range. - * \param data Pointer to the data to store in the buffer object. - * \param bufObj Object to be used. - * - * \sa glBufferSubDataARB, dd_function_table::BufferSubData. - */ -static void -_mesa_buffer_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data, - struct gl_buffer_object * bufObj ) -{ - (void) ctx; (void) target; - - /* this should have been caught in _mesa_BufferSubData() */ - ASSERT(size + offset <= bufObj->Size); - - if (bufObj->Data) { - memcpy( (GLubyte *) bufObj->Data + offset, data, size ); - } -} - - -/** - * Retrieve data from a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::GetBufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte to be fetched. - * \param size Size, in bytes, of the data range. - * \param data Destination for data - * \param bufObj Object to be used. - * - * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData. - */ -static void -_mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset, - GLsizeiptrARB size, GLvoid * data, - struct gl_buffer_object * bufObj ) -{ - (void) ctx; (void) target; - - if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) { - memcpy( data, (GLubyte *) bufObj->Data + offset, size ); - } -} - - -/** - * Default callback for \c dd_function_tabel::MapBuffer(). - * - * The function parameters will have been already tested for errors. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param access Information about how the buffer will be accessed. - * \param bufObj Object to be mapped. - * \return A pointer to the object's internal data store that can be accessed - * by the processor - * - * \sa glMapBufferARB, dd_function_table::MapBuffer - */ -static void * -_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access, - struct gl_buffer_object *bufObj ) -{ - (void) ctx; - (void) target; - (void) access; - /* Just return a direct pointer to the data */ - if (_mesa_bufferobj_mapped(bufObj)) { - /* already mapped! */ - return NULL; - } - bufObj->Pointer = bufObj->Data; - bufObj->Length = bufObj->Size; - bufObj->Offset = 0; - return bufObj->Pointer; -} - - -/** - * Default fallback for \c dd_function_table::MapBufferRange(). - * Called via glMapBufferRange(). - */ -static void * -_mesa_buffer_map_range( GLcontext *ctx, GLenum target, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *bufObj ) -{ - (void) ctx; - (void) target; - assert(!_mesa_bufferobj_mapped(bufObj)); - /* Just return a direct pointer to the data */ - bufObj->Pointer = bufObj->Data + offset; - bufObj->Length = length; - bufObj->Offset = offset; - bufObj->AccessFlags = access; - return bufObj->Pointer; -} - - -/** - * Default fallback for \c dd_function_table::FlushMappedBufferRange(). - * Called via glFlushMappedBufferRange(). - */ -static void -_mesa_buffer_flush_mapped_range( GLcontext *ctx, GLenum target, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj ) -{ - (void) ctx; - (void) target; - (void) offset; - (void) length; - (void) obj; - /* no-op */ -} - - -/** - * Default callback for \c dd_function_table::MapBuffer(). - * - * The input parameters will have been already tested for errors. - * - * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer - */ -static GLboolean -_mesa_buffer_unmap( GLcontext *ctx, GLenum target, - struct gl_buffer_object *bufObj ) -{ - (void) ctx; - (void) target; - /* XXX we might assert here that bufObj->Pointer is non-null */ - bufObj->Pointer = NULL; - bufObj->Length = 0; - bufObj->Offset = 0; - bufObj->AccessFlags = 0x0; - return GL_TRUE; -} - - -/** - * Default fallback for \c dd_function_table::CopyBufferSubData(). - * Called via glCopyBuffserSubData(). - */ -static void -_mesa_copy_buffer_subdata(GLcontext *ctx, - struct gl_buffer_object *src, - struct gl_buffer_object *dst, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size) -{ - GLubyte *srcPtr, *dstPtr; - - /* buffer should not already be mapped */ - assert(!_mesa_bufferobj_mapped(src)); - assert(!_mesa_bufferobj_mapped(dst)); - - srcPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_READ_BUFFER, - GL_READ_ONLY, src); - dstPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_WRITE_BUFFER, - GL_WRITE_ONLY, dst); - - if (srcPtr && dstPtr) - memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); - - ctx->Driver.UnmapBuffer(ctx, GL_COPY_READ_BUFFER, src); - ctx->Driver.UnmapBuffer(ctx, GL_COPY_WRITE_BUFFER, dst); -} - - - -/** - * Initialize the state associated with buffer objects - */ -void -_mesa_init_buffer_objects( GLcontext *ctx ) -{ - _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, - ctx->Shared->NullBufferObj); - _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, - ctx->Shared->NullBufferObj); - _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, - ctx->Shared->NullBufferObj); -} - - -void -_mesa_free_buffer_objects( GLcontext *ctx ) -{ - _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL); - _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL); - - _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL); - _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL); -} - - -/** - * Bind the specified target to buffer for the specified context. - * Called by glBindBuffer() and other functions. - */ -static void -bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) -{ - struct gl_buffer_object *oldBufObj; - struct gl_buffer_object *newBufObj = NULL; - struct gl_buffer_object **bindTarget = NULL; - - bindTarget = get_buffer_target(ctx, target); - if (!bindTarget) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target); - return; - } - - /* Get pointer to old buffer object (to be unbound) */ - oldBufObj = *bindTarget; - if (oldBufObj && oldBufObj->Name == buffer) - return; /* rebinding the same buffer object- no change */ - - /* - * Get pointer to new buffer object (newBufObj) - */ - if (buffer == 0) { - /* The spec says there's not a buffer object named 0, but we use - * one internally because it simplifies things. - */ - newBufObj = ctx->Shared->NullBufferObj; - } - else { - /* non-default buffer object */ - newBufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!newBufObj) { - /* if this is a new buffer object id, allocate a buffer object now */ - ASSERT(ctx->Driver.NewBufferObject); - newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target); - if (!newBufObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); - return; - } - _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj); - } - } - - /* bind new buffer */ - _mesa_reference_buffer_object(ctx, bindTarget, newBufObj); - - /* Pass BindBuffer call to device driver */ - if (ctx->Driver.BindBuffer) - ctx->Driver.BindBuffer( ctx, target, newBufObj ); -} - - -/** - * Update the default buffer objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_buffer_objects(GLcontext *ctx) -{ - /* Bind the NullBufferObj to remove references to those - * in the shared context hash table. - */ - bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0); - bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0); -} - - -/** - * When we're about to read pixel data out of a PBO (via glDrawPixels, - * glTexImage, etc) or write data into a PBO (via glReadPixels, - * glGetTexImage, etc) we call this function to check that we're not - * going to read out of bounds. - * - * XXX This would also be a convenient time to check that the PBO isn't - * currently mapped. Whoever calls this function should check for that. - * Remember, we can't use a PBO when it's mapped! - * - * If we're not using a PBO, this is a no-op. - * - * \param width width of image to read/write - * \param height height of image to read/write - * \param depth depth of image to read/write - * \param format format of image to read/write - * \param type datatype of image to read/write - * \param ptr the user-provided pointer/offset - * \return GL_TRUE if the PBO access is OK, GL_FALSE if the access would - * go out of bounds. - */ -GLboolean -_mesa_validate_pbo_access(GLuint dimensions, - const struct gl_pixelstore_attrib *pack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *ptr) -{ - GLvoid *start, *end; - const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ - - if (!_mesa_is_bufferobj(pack->BufferObj)) - return GL_TRUE; /* no PBO, OK */ - - if (pack->BufferObj->Size == 0) - /* no buffer! */ - return GL_FALSE; - - /* get address of first pixel we'll read */ - start = _mesa_image_address(dimensions, pack, ptr, width, height, - format, type, 0, 0, 0); - - /* get address just past the last pixel we'll read */ - end = _mesa_image_address(dimensions, pack, ptr, width, height, - format, type, depth-1, height-1, width); - - - sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size; - - if ((const GLubyte *) start > sizeAddr) { - /* This will catch negative values / wrap-around */ - return GL_FALSE; - } - if ((const GLubyte *) end > sizeAddr) { - /* Image read goes beyond end of buffer */ - return GL_FALSE; - } - - /* OK! */ - return GL_TRUE; -} - - -/** - * For commands that read from a PBO (glDrawPixels, glTexImage, - * glPolygonStipple, etc), if we're reading from a PBO, map it read-only - * and return the pointer into the PBO. If we're not reading from a - * PBO, return \p src as-is. - * If non-null return, must call _mesa_unmap_pbo_source() when done. - * - * \return NULL if error, else pointer to start of data - */ -const GLvoid * -_mesa_map_pbo_source(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *src) -{ - const GLubyte *buf; - - if (_mesa_is_bufferobj(unpack->BufferObj)) { - /* unpack from PBO */ - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - unpack->BufferObj); - if (!buf) - return NULL; - - buf = ADD_POINTERS(buf, src); - } - else { - /* unpack from normal memory */ - buf = src; - } - - return buf; -} - - -/** - * Combine PBO-read validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. - * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_source - * A call to this function should have a matching call to - * _mesa_unmap_pbo_source(). - */ -const GLvoid * -_mesa_map_validate_pbo_source(GLcontext *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *ptr, - const char *where) -{ - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* non-PBO access: no validation to be done */ - return ptr; - } - - if (!_mesa_validate_pbo_access(dimensions, unpack, - width, height, depth, format, type, ptr)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return NULL; - } - - if (_mesa_bufferobj_mapped(unpack->BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; - } - - ptr = _mesa_map_pbo_source(ctx, unpack, ptr); - return ptr; -} - - -/** - * Counterpart to _mesa_map_pbo_source() - */ -void -_mesa_unmap_pbo_source(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack) -{ - ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ - if (_mesa_is_bufferobj(unpack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } -} - - -/** - * For commands that write to a PBO (glReadPixels, glGetColorTable, etc), - * if we're writing to a PBO, map it write-only and return the pointer - * into the PBO. If we're not writing to a PBO, return \p dst as-is. - * If non-null return, must call _mesa_unmap_pbo_dest() when done. - * - * \return NULL if error, else pointer to start of data - */ -void * -_mesa_map_pbo_dest(GLcontext *ctx, - const struct gl_pixelstore_attrib *pack, - GLvoid *dest) -{ - void *buf; - - if (_mesa_is_bufferobj(pack->BufferObj)) { - /* pack into PBO */ - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, - pack->BufferObj); - if (!buf) - return NULL; - - buf = ADD_POINTERS(buf, dest); - } - else { - /* pack to normal memory */ - buf = dest; - } - - return buf; -} - - -/** - * Combine PBO-write validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. - * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_dest - * A call to this function should have a matching call to - * _mesa_unmap_pbo_dest(). - */ -GLvoid * -_mesa_map_validate_pbo_dest(GLcontext *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLvoid *ptr, - const char *where) -{ - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* non-PBO access: no validation to be done */ - return ptr; - } - - if (!_mesa_validate_pbo_access(dimensions, unpack, - width, height, depth, format, type, ptr)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return NULL; - } - - if (_mesa_bufferobj_mapped(unpack->BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; - } - - ptr = _mesa_map_pbo_dest(ctx, unpack, ptr); - return ptr; -} - - -/** - * Counterpart to _mesa_map_pbo_dest() - */ -void -_mesa_unmap_pbo_dest(GLcontext *ctx, - const struct gl_pixelstore_attrib *pack) -{ - ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ - if (_mesa_is_bufferobj(pack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, pack->BufferObj); - } -} - - - -/** - * Return the gl_buffer_object for the given ID. - * Always return NULL for ID 0. - */ -struct gl_buffer_object * -_mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer) -{ - if (buffer == 0) - return NULL; - else - return (struct gl_buffer_object *) - _mesa_HashLookup(ctx->Shared->BufferObjects, buffer); -} - - -/** - * If *ptr points to obj, set ptr = the Null/default buffer object. - * This is a helper for buffer object deletion. - * The GL spec says that deleting a buffer object causes it to get - * unbound from all arrays in the current context. - */ -static void -unbind(GLcontext *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *obj) -{ - if (*ptr == obj) { - _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj); - } -} - - -/** - * Plug default/fallback buffer object functions into the device - * driver hooks. - */ -void -_mesa_init_buffer_object_functions(struct dd_function_table *driver) -{ - /* GL_ARB_vertex/pixel_buffer_object */ - driver->NewBufferObject = _mesa_new_buffer_object; - driver->DeleteBuffer = _mesa_delete_buffer_object; - driver->BindBuffer = NULL; - driver->BufferData = _mesa_buffer_data; - driver->BufferSubData = _mesa_buffer_subdata; - driver->GetBufferSubData = _mesa_buffer_get_subdata; - driver->MapBuffer = _mesa_buffer_map; - driver->UnmapBuffer = _mesa_buffer_unmap; - - /* GL_ARB_map_buffer_range */ - driver->MapBufferRange = _mesa_buffer_map_range; - driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; - - /* GL_ARB_copy_buffer */ - driver->CopyBufferSubData = _mesa_copy_buffer_subdata; -} - - - -/**********************************************************************/ -/* API Functions */ -/**********************************************************************/ - -void GLAPIENTRY -_mesa_BindBufferARB(GLenum target, GLuint buffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bind_buffer_object(ctx, target, buffer); -} - - -/** - * Delete a set of buffer objects. - * - * \param n Number of buffer objects to delete. - * \param ids Array of \c n buffer object IDs. - */ -void GLAPIENTRY -_mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) -{ - GET_CURRENT_CONTEXT(ctx); - GLsizei i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)"); - return; - } - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - for (i = 0; i < n; i++) { - struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]); - if (bufObj) { - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint j; - - ASSERT(bufObj->Name == ids[i]); - - if (_mesa_bufferobj_mapped(bufObj)) { - /* if mapped, unmap it now */ - ctx->Driver.UnmapBuffer(ctx, 0, bufObj); - bufObj->AccessFlags = DEFAULT_ACCESS; - bufObj->Pointer = NULL; - } - - /* unbind any vertex pointers bound to this buffer */ - unbind(ctx, &arrayObj->Vertex.BufferObj, bufObj); - unbind(ctx, &arrayObj->Weight.BufferObj, bufObj); - unbind(ctx, &arrayObj->Normal.BufferObj, bufObj); - unbind(ctx, &arrayObj->Color.BufferObj, bufObj); - unbind(ctx, &arrayObj->SecondaryColor.BufferObj, bufObj); - unbind(ctx, &arrayObj->FogCoord.BufferObj, bufObj); - unbind(ctx, &arrayObj->Index.BufferObj, bufObj); - unbind(ctx, &arrayObj->EdgeFlag.BufferObj, bufObj); - for (j = 0; j < Elements(arrayObj->TexCoord); j++) { - unbind(ctx, &arrayObj->TexCoord[j].BufferObj, bufObj); - } - for (j = 0; j < Elements(arrayObj->VertexAttrib); j++) { - unbind(ctx, &arrayObj->VertexAttrib[j].BufferObj, bufObj); - } - - if (ctx->Array.ArrayBufferObj == bufObj) { - _mesa_BindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); - } - if (ctx->Array.ElementArrayBufferObj == bufObj) { - _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); - } - - /* unbind any pixel pack/unpack pointers bound to this buffer */ - if (ctx->Pack.BufferObj == bufObj) { - _mesa_BindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, 0 ); - } - if (ctx->Unpack.BufferObj == bufObj) { - _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 ); - } - - /* The ID is immediately freed for re-use */ - _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name); - _mesa_reference_buffer_object(ctx, &bufObj, NULL); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Generate a set of unique buffer object IDs and store them in \c buffer. - * - * \param n Number of IDs to generate. - * \param buffer Array of \c n locations to store the IDs. - */ -void GLAPIENTRY -_mesa_GenBuffersARB(GLsizei n, GLuint *buffer) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB"); - return; - } - - if (!buffer) { - return; - } - - /* - * This must be atomic (generation and allocation of buffer object IDs) - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n); - - /* Allocate new, empty buffer objects and return identifiers */ - for (i = 0; i < n; i++) { - struct gl_buffer_object *bufObj; - GLuint name = first + i; - GLenum target = 0; - bufObj = ctx->Driver.NewBufferObject( ctx, name, target ); - if (!bufObj) { - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB"); - return; - } - _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj); - buffer[i] = first + i; - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Determine if ID is the name of a buffer object. - * - * \param id ID of the potential buffer object. - * \return \c GL_TRUE if \c id is the name of a buffer object, - * \c GL_FALSE otherwise. - */ -GLboolean GLAPIENTRY -_mesa_IsBufferARB(GLuint id) -{ - struct gl_buffer_object *bufObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - bufObj = _mesa_lookup_bufferobj(ctx, id); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return bufObj ? GL_TRUE : GL_FALSE; -} - - -void GLAPIENTRY -_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, - const GLvoid * data, GLenum usage) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (size < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)"); - return; - } - - switch (usage) { - case GL_STREAM_DRAW_ARB: - case GL_STREAM_READ_ARB: - case GL_STREAM_COPY_ARB: - case GL_STATIC_DRAW_ARB: - case GL_STATIC_READ_ARB: - case GL_STATIC_COPY_ARB: - case GL_DYNAMIC_DRAW_ARB: - case GL_DYNAMIC_READ_ARB: - case GL_DYNAMIC_COPY_ARB: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)"); - return; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(target)" ); - return; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB(buffer 0)" ); - return; - } - - if (_mesa_bufferobj_mapped(bufObj)) { - /* Unmap the existing buffer. We'll replace it now. Not an error. */ - ctx->Driver.UnmapBuffer(ctx, target, bufObj); - bufObj->AccessFlags = DEFAULT_ACCESS; - ASSERT(bufObj->Pointer == NULL); - } - - FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT); - - bufObj->Written = GL_TRUE; - -#ifdef VBO_DEBUG - printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", - bufObj->Name, size, data, usage); -#endif - -#ifdef BOUNDS_CHECK - size += 100; -#endif - - ASSERT(ctx->Driver.BufferData); - if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()"); - } -} - - -void GLAPIENTRY -_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, - "glBufferSubDataARB" ); - if (!bufObj) { - /* error already recorded */ - return; - } - - bufObj->Written = GL_TRUE; - - ASSERT(ctx->Driver.BufferSubData); - ctx->Driver.BufferSubData( ctx, target, offset, size, data, bufObj ); -} - - -void GLAPIENTRY -_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, - GLsizeiptrARB size, void * data) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, - "glGetBufferSubDataARB" ); - if (!bufObj) { - /* error already recorded */ - return; - } - - ASSERT(ctx->Driver.GetBufferSubData); - ctx->Driver.GetBufferSubData( ctx, target, offset, size, data, bufObj ); -} - - -void * GLAPIENTRY -_mesa_MapBufferARB(GLenum target, GLenum access) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; - GLbitfield accessFlags; - void *map; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - switch (access) { - case GL_READ_ONLY_ARB: - accessFlags = GL_MAP_READ_BIT; - break; - case GL_WRITE_ONLY_ARB: - accessFlags = GL_MAP_WRITE_BIT; - break; - case GL_READ_WRITE_ARB: - accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); - return NULL; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(target)" ); - return NULL; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(buffer 0)" ); - return NULL; - } - if (_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)"); - return NULL; - } - - ASSERT(ctx->Driver.MapBuffer); - map = ctx->Driver.MapBuffer( ctx, target, access, bufObj ); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); - return NULL; - } - else { - /* The driver callback should have set these fields. - * This is important because other modules (like VBO) might call - * the driver function directly. - */ - ASSERT(bufObj->Pointer == map); - ASSERT(bufObj->Length == bufObj->Size); - ASSERT(bufObj->Offset == 0); - bufObj->AccessFlags = accessFlags; - } - - if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB) - bufObj->Written = GL_TRUE; - -#ifdef VBO_DEBUG - printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", - bufObj->Name, bufObj->Size, access); - if (access == GL_WRITE_ONLY_ARB) { - GLuint i; - GLubyte *b = (GLubyte *) bufObj->Pointer; - for (i = 0; i < bufObj->Size; i++) - b[i] = i & 0xff; - } -#endif - -#ifdef BOUNDS_CHECK - { - GLubyte *buf = (GLubyte *) bufObj->Pointer; - GLuint i; - /* buffer is 100 bytes larger than requested, fill with magic value */ - for (i = 0; i < 100; i++) { - buf[bufObj->Size - i - 1] = 123; - } - } -#endif - - return bufObj->Pointer; -} - - -GLboolean GLAPIENTRY -_mesa_UnmapBufferARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - GLboolean status = GL_TRUE; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glUnmapBufferARB(target)" ); - return GL_FALSE; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" ); - return GL_FALSE; - } - if (!_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB"); - return GL_FALSE; - } - -#ifdef BOUNDS_CHECK - if (bufObj->Access != GL_READ_ONLY_ARB) { - GLubyte *buf = (GLubyte *) bufObj->Pointer; - GLuint i; - /* check that last 100 bytes are still = magic value */ - for (i = 0; i < 100; i++) { - GLuint pos = bufObj->Size - i - 1; - if (buf[pos] != 123) { - _mesa_warning(ctx, "Out of bounds buffer object write detected" - " at position %d (value = %u)\n", - pos, buf[pos]); - } - } - } -#endif - -#ifdef VBO_DEBUG - if (bufObj->AccessFlags & GL_MAP_WRITE_BIT) { - GLuint i, unchanged = 0; - GLubyte *b = (GLubyte *) bufObj->Pointer; - GLint pos = -1; - /* check which bytes changed */ - for (i = 0; i < bufObj->Size - 1; i++) { - if (b[i] == (i & 0xff) && b[i+1] == ((i+1) & 0xff)) { - unchanged++; - if (pos == -1) - pos = i; - } - } - if (unchanged) { - printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", - bufObj->Name, unchanged, bufObj->Size, pos); - } - } -#endif - - status = ctx->Driver.UnmapBuffer( ctx, target, bufObj ); - bufObj->AccessFlags = DEFAULT_ACCESS; - ASSERT(bufObj->Pointer == NULL); - ASSERT(bufObj->Offset == 0); - ASSERT(bufObj->Length == 0); - - return status; -} - - -void GLAPIENTRY -_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)" ); - return; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameterivARB" ); - return; - } - - switch (pname) { - case GL_BUFFER_SIZE_ARB: - *params = (GLint) bufObj->Size; - return; - case GL_BUFFER_USAGE_ARB: - *params = bufObj->Usage; - return; - case GL_BUFFER_ACCESS_ARB: - *params = simplified_access_mode(bufObj->AccessFlags); - return; - case GL_BUFFER_MAPPED_ARB: - *params = _mesa_bufferobj_mapped(bufObj); - return; - case GL_BUFFER_ACCESS_FLAGS: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = bufObj->AccessFlags; - return; - case GL_BUFFER_MAP_OFFSET: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = (GLint) bufObj->Offset; - return; - case GL_BUFFER_MAP_LENGTH: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = (GLint) bufObj->Length; - return; - default: - ; /* fall-through */ - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -/** - * New in GL 3.2 - * This is pretty much a duplicate of GetBufferParameteriv() but the - * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system. - */ -void GLAPIENTRY -_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(target)" ); - return; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameteri64v" ); - return; - } - - switch (pname) { - case GL_BUFFER_SIZE_ARB: - *params = bufObj->Size; - return; - case GL_BUFFER_USAGE_ARB: - *params = bufObj->Usage; - return; - case GL_BUFFER_ACCESS_ARB: - *params = simplified_access_mode(bufObj->AccessFlags); - return; - case GL_BUFFER_ACCESS_FLAGS: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = bufObj->AccessFlags; - return; - case GL_BUFFER_MAPPED_ARB: - *params = _mesa_bufferobj_mapped(bufObj); - return; - case GL_BUFFER_MAP_OFFSET: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = bufObj->Offset; - return; - case GL_BUFFER_MAP_LENGTH: - if (ctx->VersionMajor < 3) - goto invalid_pname; - *params = bufObj->Length; - return; - default: - ; /* fall-through */ - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -void GLAPIENTRY -_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object * bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname != GL_BUFFER_MAP_POINTER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); - return; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(target)" ); - return; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" ); - return; - } - - *params = bufObj->Pointer; -} - - -void GLAPIENTRY -_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *src, *dst; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - src = get_buffer(ctx, readTarget); - if (!src || !_mesa_is_bufferobj(src)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyBuffserSubData(readTarget = 0x%x)", readTarget); - return; - } - - dst = get_buffer(ctx, writeTarget); - if (!dst || !_mesa_is_bufferobj(dst)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget); - return; - } - - if (_mesa_bufferobj_mapped(src)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyBuffserSubData(readBuffer is mapped)"); - return; - } - - if (_mesa_bufferobj_mapped(dst)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyBuffserSubData(writeBuffer is mapped)"); - return; - } - - if (readOffset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBuffserSubData(readOffset = %d)", (int) readOffset); - return; - } - - if (writeOffset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBuffserSubData(writeOffset = %d)", (int) writeOffset); - return; - } - - if (readOffset + size > src->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBuffserSubData(readOffset + size = %d)", - (int) (readOffset + size)); - return; - } - - if (writeOffset + size > dst->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBuffserSubData(writeOffset + size = %d)", - (int) (writeOffset + size)); - return; - } - - if (src == dst) { - if (readOffset + size <= writeOffset) { - /* OK */ - } - else if (writeOffset + size <= readOffset) { - /* OK */ - } - else { - /* overlapping src/dst is illegal */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyBuffserSubData(overlapping src/dst)"); - return; - } - } - - ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size); -} - - -/** - * See GL_ARB_map_buffer_range spec - */ -void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - void *map; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - if (!ctx->Extensions.ARB_map_buffer_range) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(extension not supported)"); - return NULL; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset = %ld)", (long)offset); - return NULL; - } - - if (length < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(length = %ld)", (long)length); - return NULL; - } - - if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(access indicates neither read or write)"); - return NULL; - } - - if (access & GL_MAP_READ_BIT) { - if ((access & GL_MAP_INVALIDATE_RANGE_BIT) || - (access & GL_MAP_INVALIDATE_BUFFER_BIT) || - (access & GL_MAP_UNSYNCHRONIZED_BIT)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); - return NULL; - } - } - - if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) && - ((access & GL_MAP_WRITE_BIT) == 0)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(invalid access flags)"); - return NULL; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj || !_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glMapBufferRange(target = 0x%x)", target); - return NULL; - } - - if (offset + length > bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset + length > size)"); - return NULL; - } - - if (_mesa_bufferobj_mapped(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(buffer already mapped)"); - return NULL; - } - - ASSERT(ctx->Driver.MapBufferRange); - map = ctx->Driver.MapBufferRange(ctx, target, offset, length, - access, bufObj); - if (!map) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); - } - else { - /* The driver callback should have set all these fields. - * This is important because other modules (like VBO) might call - * the driver function directly. - */ - ASSERT(bufObj->Pointer == map); - ASSERT(bufObj->Length == length); - ASSERT(bufObj->Offset == offset); - ASSERT(bufObj->AccessFlags == access); - } - - return map; -} - - -/** - * See GL_ARB_map_buffer_range spec - */ -void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *bufObj; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ARB_map_buffer_range) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(extension not supported)"); - return; - } - - if (offset < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset = %ld)", (long)offset); - return; - } - - if (length < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(length = %ld)", (long)length); - return; - } - - bufObj = get_buffer(ctx, target); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glMapBufferRange(target = 0x%x)", target); - return; - } - - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(current buffer is 0)"); - return; - } - - if (!_mesa_bufferobj_mapped(bufObj)) { - /* buffer is not mapped */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(buffer is not mapped)"); - return; - } - - if ((bufObj->AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMapBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)"); - return; - } - - if (offset + length > bufObj->Length) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glMapBufferRange(offset %ld + length %ld > mapped length %ld)", - (long)offset, (long)length, (long)bufObj->Length); - return; - } - - ASSERT(bufObj->AccessFlags & GL_MAP_WRITE_BIT); - - if (ctx->Driver.FlushMappedBufferRange) - ctx->Driver.FlushMappedBufferRange(ctx, target, offset, length, bufObj); -} - - -#if FEATURE_APPLE_object_purgeable -static GLenum -_mesa_BufferObjectPurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_buffer_object *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_bufferobj(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectPurgeable(name = 0x%x)", name); - return 0; - } - if (!_mesa_is_bufferobj(bufObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glObjectPurgeable(buffer 0)" ); - return 0; - } - - if (bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectPurgeable(name = 0x%x) is already purgeable", name); - return GL_VOLATILE_APPLE; - } - - bufObj->Purgeable = GL_TRUE; - - retval = GL_VOLATILE_APPLE; - if (ctx->Driver.BufferObjectPurgeable) - retval = ctx->Driver.BufferObjectPurgeable(ctx, bufObj, option); - - return retval; -} - - -static GLenum -_mesa_RenderObjectPurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_renderbuffer *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_renderbuffer(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return 0; - } - - if (bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectPurgeable(name = 0x%x) is already purgeable", name); - return GL_VOLATILE_APPLE; - } - - bufObj->Purgeable = GL_TRUE; - - retval = GL_VOLATILE_APPLE; - if (ctx->Driver.RenderObjectPurgeable) - retval = ctx->Driver.RenderObjectPurgeable(ctx, bufObj, option); - - return retval; -} - - -static GLenum -_mesa_TextureObjectPurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_texture_object *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_texture(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectPurgeable(name = 0x%x)", name); - return 0; - } - - if (bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectPurgeable(name = 0x%x) is already purgeable", name); - return GL_VOLATILE_APPLE; - } - - bufObj->Purgeable = GL_TRUE; - - retval = GL_VOLATILE_APPLE; - if (ctx->Driver.TextureObjectPurgeable) - retval = ctx->Driver.TextureObjectPurgeable(ctx, bufObj, option); - - return retval; -} - - -GLenum GLAPIENTRY -_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option) -{ - GLenum retval; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectPurgeable(name = 0x%x)", name); - return 0; - } - - switch (option) { - case GL_VOLATILE_APPLE: - case GL_RELEASED_APPLE: - /* legal */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glObjectPurgeable(name = 0x%x) invalid option: %d", - name, option); - return 0; - } - - switch (objectType) { - case GL_TEXTURE: - retval = _mesa_TextureObjectPurgeable (ctx, name, option); - break; - case GL_RENDERBUFFER_EXT: - retval = _mesa_RenderObjectPurgeable (ctx, name, option); - break; - case GL_BUFFER_OBJECT_APPLE: - retval = _mesa_BufferObjectPurgeable (ctx, name, option); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glObjectPurgeable(name = 0x%x) invalid type: %d", - name, objectType); - return 0; - } - - /* In strict conformance to the spec, we must only return VOLATILE when - * when passed the VOLATILE option. Madness. - * - * XXX First fix the spec, then fix me. - */ - return option == GL_VOLATILE_APPLE ? GL_VOLATILE_APPLE : retval; -} - - -static GLenum -_mesa_BufferObjectUnpurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_buffer_object *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_bufferobj(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return 0; - } - - if (! bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectUnpurgeable(name = 0x%x) object is " - " already \"unpurged\"", name); - return 0; - } - - bufObj->Purgeable = GL_FALSE; - - retval = option; - if (ctx->Driver.BufferObjectUnpurgeable) - retval = ctx->Driver.BufferObjectUnpurgeable(ctx, bufObj, option); - - return retval; -} - - -static GLenum -_mesa_RenderObjectUnpurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_renderbuffer *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_renderbuffer(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return 0; - } - - if (! bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectUnpurgeable(name = 0x%x) object is " - " already \"unpurged\"", name); - return 0; - } - - bufObj->Purgeable = GL_FALSE; - - retval = option; - if (ctx->Driver.RenderObjectUnpurgeable) - retval = ctx->Driver.RenderObjectUnpurgeable(ctx, bufObj, option); - - return retval; -} - - -static GLenum -_mesa_TextureObjectUnpurgeable(GLcontext *ctx, GLuint name, GLenum option) -{ - struct gl_texture_object *bufObj; - GLenum retval; - - bufObj = _mesa_lookup_texture(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return 0; - } - - if (! bufObj->Purgeable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glObjectUnpurgeable(name = 0x%x) object is" - " already \"unpurged\"", name); - return 0; - } - - bufObj->Purgeable = GL_FALSE; - - retval = option; - if (ctx->Driver.TextureObjectUnpurgeable) - retval = ctx->Driver.TextureObjectUnpurgeable(ctx, bufObj, option); - - return retval; -} - - -GLenum GLAPIENTRY -_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return 0; - } - - switch (option) { - case GL_RETAINED_APPLE: - case GL_UNDEFINED_APPLE: - /* legal */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glObjectUnpurgeable(name = 0x%x) invalid option: %d", - name, option); - return 0; - } - - switch (objectType) { - case GL_BUFFER_OBJECT_APPLE: - return _mesa_BufferObjectUnpurgeable(ctx, name, option); - case GL_TEXTURE: - return _mesa_TextureObjectUnpurgeable(ctx, name, option); - case GL_RENDERBUFFER_EXT: - return _mesa_RenderObjectUnpurgeable(ctx, name, option); - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glObjectUnpurgeable(name = 0x%x) invalid type: %d", - name, objectType); - return 0; - } -} - - -static void -_mesa_GetBufferObjectParameterivAPPLE(GLcontext *ctx, GLuint name, - GLenum pname, GLint* params) -{ - struct gl_buffer_object *bufObj; - - bufObj = _mesa_lookup_bufferobj(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetObjectParameteriv(name = 0x%x) invalid object", name); - return; - } - - switch (pname) { - case GL_PURGEABLE_APPLE: - *params = bufObj->Purgeable; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", - name, pname); - break; - } -} - - -static void -_mesa_GetRenderObjectParameterivAPPLE(GLcontext *ctx, GLuint name, - GLenum pname, GLint* params) -{ - struct gl_renderbuffer *bufObj; - - bufObj = _mesa_lookup_renderbuffer(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return; - } - - switch (pname) { - case GL_PURGEABLE_APPLE: - *params = bufObj->Purgeable; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", - name, pname); - break; - } -} - - -static void -_mesa_GetTextureObjectParameterivAPPLE(GLcontext *ctx, GLuint name, - GLenum pname, GLint* params) -{ - struct gl_texture_object *bufObj; - - bufObj = _mesa_lookup_texture(ctx, name); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glObjectUnpurgeable(name = 0x%x)", name); - return; - } - - switch (pname) { - case GL_PURGEABLE_APPLE: - *params = bufObj->Purgeable; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", - name, pname); - break; - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, - GLint* params) -{ - GET_CURRENT_CONTEXT(ctx); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetObjectParameteriv(name = 0x%x)", name); - return; - } - - switch (objectType) { - case GL_TEXTURE: - _mesa_GetTextureObjectParameterivAPPLE (ctx, name, pname, params); - break; - case GL_BUFFER_OBJECT_APPLE: - _mesa_GetBufferObjectParameterivAPPLE (ctx, name, pname, params); - break; - case GL_RENDERBUFFER_EXT: - _mesa_GetRenderObjectParameterivAPPLE (ctx, name, pname, params); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetObjectParameteriv(name = 0x%x) invalid type: %d", - name, objectType); - } -} - -#endif /* FEATURE_APPLE_object_purgeable */ +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file bufferobj.c + * \brief Functions for the GL_ARB_vertex/pixel_buffer_object extensions. + * \author Brian Paul, Ian Romanick + */ + + +#include "glheader.h" +#include "enums.h" +#include "hash.h" +#include "imports.h" +#include "image.h" +#include "context.h" +#include "bufferobj.h" +#include "fbobject.h" +#include "texobj.h" + + +/* Debug flags */ +/*#define VBO_DEBUG*/ +/*#define BOUNDS_CHECK*/ + + +#if FEATURE_OES_mapbuffer +#define DEFAULT_ACCESS GL_MAP_WRITE_BIT +#else +#define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT) +#endif + + +/** + * Used as a placeholder for buffer objects between glGenBuffers() and + * glBindBuffer() so that glIsBuffer() can work correctly. + */ +static struct gl_buffer_object DummyBufferObject; + + +/** + * Return pointer to address of a buffer object target. + * \param ctx the GL context + * \param target the buffer object target to be retrieved. + * \return pointer to pointer to the buffer object bound to \c target in the + * specified context or \c NULL if \c target is invalid. + */ +static INLINE struct gl_buffer_object ** +get_buffer_target(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_ARRAY_BUFFER_ARB: + return &ctx->Array.ArrayBufferObj; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + return &ctx->Array.ElementArrayBufferObj; + case GL_PIXEL_PACK_BUFFER_EXT: + return &ctx->Pack.BufferObj; + case GL_PIXEL_UNPACK_BUFFER_EXT: + return &ctx->Unpack.BufferObj; + case GL_COPY_READ_BUFFER: + return &ctx->CopyReadBuffer; + case GL_COPY_WRITE_BUFFER: + return &ctx->CopyWriteBuffer; +#if FEATURE_EXT_transform_feedback + case GL_TRANSFORM_FEEDBACK_BUFFER: + if (ctx->Extensions.EXT_transform_feedback) { + return &ctx->TransformFeedback.CurrentBuffer; + } + break; +#endif + default: + return NULL; + } + return NULL; +} + + +/** + * Get the buffer object bound to the specified target in a GL context. + * \param ctx the GL context + * \param target the buffer object target to be retrieved. + * \return pointer to the buffer object bound to \c target in the + * specified context or \c NULL if \c target is invalid. + */ +static INLINE struct gl_buffer_object * +get_buffer(struct gl_context *ctx, GLenum target) +{ + struct gl_buffer_object **bufObj = get_buffer_target(ctx, target); + if (bufObj) + return *bufObj; + return NULL; +} + + +/** + * Convert a GLbitfield describing the mapped buffer access flags + * into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY. + */ +static GLenum +simplified_access_mode(GLbitfield access) +{ + const GLbitfield rwFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; + if ((access & rwFlags) == rwFlags) + return GL_READ_WRITE; + if ((access & GL_MAP_READ_BIT) == GL_MAP_READ_BIT) + return GL_READ_ONLY; + if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT) + return GL_WRITE_ONLY; + return GL_READ_WRITE; /* this should never happen, but no big deal */ +} + + +/** + * Tests the subdata range parameters and sets the GL error code for + * \c glBufferSubDataARB and \c glGetBufferSubDataARB. + * + * \param ctx GL context. + * \param target Buffer object target on which to operate. + * \param offset Offset of the first byte of the subdata range. + * \param size Size, in bytes, of the subdata range. + * \param caller Name of calling function for recording errors. + * \return A pointer to the buffer object bound to \c target in the + * specified context or \c NULL if any of the parameter or state + * conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB + * are invalid. + * + * \sa glBufferSubDataARB, glGetBufferSubDataARB + */ +static struct gl_buffer_object * +buffer_object_subdata_range_good( struct gl_context * ctx, GLenum target, + GLintptrARB offset, GLsizeiptrARB size, + const char *caller ) +{ + struct gl_buffer_object *bufObj; + + if (size < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", caller); + return NULL; + } + + if (offset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", caller); + return NULL; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", caller); + return NULL; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + return NULL; + } + if (offset + size > bufObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(size + offset > buffer size)", caller); + return NULL; + } + if (_mesa_bufferobj_mapped(bufObj)) { + /* Buffer is currently mapped */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + return NULL; + } + + return bufObj; +} + + +/** + * Allocate and initialize a new buffer object. + * + * Default callback for the \c dd_function_table::NewBufferObject() hook. + */ +static struct gl_buffer_object * +_mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target ) +{ + struct gl_buffer_object *obj; + + (void) ctx; + + obj = MALLOC_STRUCT(gl_buffer_object); + _mesa_initialize_buffer_object(obj, name, target); + return obj; +} + + +/** + * Delete a buffer object. + * + * Default callback for the \c dd_function_table::DeleteBuffer() hook. + */ +static void +_mesa_delete_buffer_object( struct gl_context *ctx, struct gl_buffer_object *bufObj ) +{ + (void) ctx; + + if (bufObj->Data) + free(bufObj->Data); + + /* assign strange values here to help w/ debugging */ + bufObj->RefCount = -1000; + bufObj->Name = ~0; + + _glthread_DESTROY_MUTEX(bufObj->Mutex); + free(bufObj); +} + + + +/** + * Set ptr to bufObj w/ reference counting. + */ +void +_mesa_reference_buffer_object(struct gl_context *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj) +{ + if (*ptr == bufObj) + return; + + if (*ptr) { + /* Unreference the old buffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_buffer_object *oldObj = *ptr; + + _glthread_LOCK_MUTEX(oldObj->Mutex); + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; +#if 0 + printf("BufferObj %p %d DECR to %d\n", + (void *) oldObj, oldObj->Name, oldObj->RefCount); +#endif + deleteFlag = (oldObj->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldObj->Mutex); + + if (deleteFlag) { + + /* some sanity checking: don't delete a buffer still in use */ +#if 0 + /* unfortunately, these tests are invalid during context tear-down */ + ASSERT(ctx->Array.ArrayBufferObj != bufObj); + ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); + ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); +#endif + + ASSERT(ctx->Driver.DeleteBuffer); + ctx->Driver.DeleteBuffer(ctx, oldObj); + } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (bufObj) { + /* reference new buffer */ + _glthread_LOCK_MUTEX(bufObj->Mutex); + if (bufObj->RefCount == 0) { + /* this buffer's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted buffer object"); + *ptr = NULL; + } + else { + bufObj->RefCount++; +#if 0 + printf("BufferObj %p %d INCR to %d\n", + (void *) bufObj, bufObj->Name, bufObj->RefCount); +#endif + *ptr = bufObj; + } + _glthread_UNLOCK_MUTEX(bufObj->Mutex); + } +} + + +/** + * Initialize a buffer object to default values. + */ +void +_mesa_initialize_buffer_object( struct gl_buffer_object *obj, + GLuint name, GLenum target ) +{ + (void) target; + + memset(obj, 0, sizeof(struct gl_buffer_object)); + _glthread_INIT_MUTEX(obj->Mutex); + obj->RefCount = 1; + obj->Name = name; + obj->Usage = GL_STATIC_DRAW_ARB; + obj->AccessFlags = DEFAULT_ACCESS; +} + + +/** + * Allocate space for and store data in a buffer object. Any data that was + * previously stored in the buffer object is lost. If \c data is \c NULL, + * memory will be allocated, but no copy will occur. + * + * This is the default callback for \c dd_function_table::BufferData() + * Note that all GL error checking will have been done already. + * + * \param ctx GL context. + * \param target Buffer object target on which to operate. + * \param size Size, in bytes, of the new data store. + * \param data Pointer to the data to store in the buffer object. This + * pointer may be \c NULL. + * \param usage Hints about how the data will be used. + * \param bufObj Object to be used. + * + * \return GL_TRUE for success, GL_FALSE for failure + * \sa glBufferDataARB, dd_function_table::BufferData. + */ +static GLboolean +_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, + const GLvoid * data, GLenum usage, + struct gl_buffer_object * bufObj ) +{ + void * new_data; + + (void) ctx; (void) target; + + new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size ); + if (new_data) { + bufObj->Data = (GLubyte *) new_data; + bufObj->Size = size; + bufObj->Usage = usage; + + if (data) { + memcpy( bufObj->Data, data, size ); + } + + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + +/** + * Replace data in a subrange of buffer object. If the data range + * specified by \c size + \c offset extends beyond the end of the buffer or + * if \c data is \c NULL, no copy is performed. + * + * This is the default callback for \c dd_function_table::BufferSubData() + * Note that all GL error checking will have been done already. + * + * \param ctx GL context. + * \param target Buffer object target on which to operate. + * \param offset Offset of the first byte to be modified. + * \param size Size, in bytes, of the data range. + * \param data Pointer to the data to store in the buffer object. + * \param bufObj Object to be used. + * + * \sa glBufferSubDataARB, dd_function_table::BufferSubData. + */ +static void +_mesa_buffer_subdata( struct gl_context *ctx, GLenum target, GLintptrARB offset, + GLsizeiptrARB size, const GLvoid * data, + struct gl_buffer_object * bufObj ) +{ + (void) ctx; (void) target; + + /* this should have been caught in _mesa_BufferSubData() */ + ASSERT(size + offset <= bufObj->Size); + + if (bufObj->Data) { + memcpy( (GLubyte *) bufObj->Data + offset, data, size ); + } +} + + +/** + * Retrieve data from a subrange of buffer object. If the data range + * specified by \c size + \c offset extends beyond the end of the buffer or + * if \c data is \c NULL, no copy is performed. + * + * This is the default callback for \c dd_function_table::GetBufferSubData() + * Note that all GL error checking will have been done already. + * + * \param ctx GL context. + * \param target Buffer object target on which to operate. + * \param offset Offset of the first byte to be fetched. + * \param size Size, in bytes, of the data range. + * \param data Destination for data + * \param bufObj Object to be used. + * + * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData. + */ +static void +_mesa_buffer_get_subdata( struct gl_context *ctx, GLenum target, GLintptrARB offset, + GLsizeiptrARB size, GLvoid * data, + struct gl_buffer_object * bufObj ) +{ + (void) ctx; (void) target; + + if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) { + memcpy( data, (GLubyte *) bufObj->Data + offset, size ); + } +} + + +/** + * Default callback for \c dd_function_tabel::MapBuffer(). + * + * The function parameters will have been already tested for errors. + * + * \param ctx GL context. + * \param target Buffer object target on which to operate. + * \param access Information about how the buffer will be accessed. + * \param bufObj Object to be mapped. + * \return A pointer to the object's internal data store that can be accessed + * by the processor + * + * \sa glMapBufferARB, dd_function_table::MapBuffer + */ +static void * +_mesa_buffer_map( struct gl_context *ctx, GLenum target, GLenum access, + struct gl_buffer_object *bufObj ) +{ + (void) ctx; + (void) target; + (void) access; + /* Just return a direct pointer to the data */ + if (_mesa_bufferobj_mapped(bufObj)) { + /* already mapped! */ + return NULL; + } + bufObj->Pointer = bufObj->Data; + bufObj->Length = bufObj->Size; + bufObj->Offset = 0; + return bufObj->Pointer; +} + + +/** + * Default fallback for \c dd_function_table::MapBufferRange(). + * Called via glMapBufferRange(). + */ +static void * +_mesa_buffer_map_range( struct gl_context *ctx, GLenum target, GLintptr offset, + GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *bufObj ) +{ + (void) ctx; + (void) target; + assert(!_mesa_bufferobj_mapped(bufObj)); + /* Just return a direct pointer to the data */ + bufObj->Pointer = bufObj->Data + offset; + bufObj->Length = length; + bufObj->Offset = offset; + bufObj->AccessFlags = access; + return bufObj->Pointer; +} + + +/** + * Default fallback for \c dd_function_table::FlushMappedBufferRange(). + * Called via glFlushMappedBufferRange(). + */ +static void +_mesa_buffer_flush_mapped_range( struct gl_context *ctx, GLenum target, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj ) +{ + (void) ctx; + (void) target; + (void) offset; + (void) length; + (void) obj; + /* no-op */ +} + + +/** + * Default callback for \c dd_function_table::MapBuffer(). + * + * The input parameters will have been already tested for errors. + * + * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer + */ +static GLboolean +_mesa_buffer_unmap( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *bufObj ) +{ + (void) ctx; + (void) target; + /* XXX we might assert here that bufObj->Pointer is non-null */ + bufObj->Pointer = NULL; + bufObj->Length = 0; + bufObj->Offset = 0; + bufObj->AccessFlags = 0x0; + return GL_TRUE; +} + + +/** + * Default fallback for \c dd_function_table::CopyBufferSubData(). + * Called via glCopyBuffserSubData(). + */ +static void +_mesa_copy_buffer_subdata(struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) +{ + GLubyte *srcPtr, *dstPtr; + + /* buffer should not already be mapped */ + assert(!_mesa_bufferobj_mapped(src)); + assert(!_mesa_bufferobj_mapped(dst)); + + srcPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_READ_BUFFER, + GL_READ_ONLY, src); + dstPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_COPY_WRITE_BUFFER, + GL_WRITE_ONLY, dst); + + if (srcPtr && dstPtr) + memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); + + ctx->Driver.UnmapBuffer(ctx, GL_COPY_READ_BUFFER, src); + ctx->Driver.UnmapBuffer(ctx, GL_COPY_WRITE_BUFFER, dst); +} + + + +/** + * Initialize the state associated with buffer objects + */ +void +_mesa_init_buffer_objects( struct gl_context *ctx ) +{ + memset(&DummyBufferObject, 0, sizeof(DummyBufferObject)); + DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */ + + _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, + ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, + ctx->Shared->NullBufferObj); + + _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, + ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, + ctx->Shared->NullBufferObj); +} + + +void +_mesa_free_buffer_objects( struct gl_context *ctx ) +{ + _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL); + _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL); + + _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL); + _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL); +} + + +/** + * Bind the specified target to buffer for the specified context. + * Called by glBindBuffer() and other functions. + */ +static void +bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer) +{ + struct gl_buffer_object *oldBufObj; + struct gl_buffer_object *newBufObj = NULL; + struct gl_buffer_object **bindTarget = NULL; + + bindTarget = get_buffer_target(ctx, target); + if (!bindTarget) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target); + return; + } + + /* Get pointer to old buffer object (to be unbound) */ + oldBufObj = *bindTarget; + if (oldBufObj && oldBufObj->Name == buffer) + return; /* rebinding the same buffer object- no change */ + + /* + * Get pointer to new buffer object (newBufObj) + */ + if (buffer == 0) { + /* The spec says there's not a buffer object named 0, but we use + * one internally because it simplifies things. + */ + newBufObj = ctx->Shared->NullBufferObj; + } + else { + /* non-default buffer object */ + newBufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!newBufObj || newBufObj == &DummyBufferObject) { + /* If this is a new buffer object id, or one which was generated but + * never used before, allocate a buffer object now. + */ + ASSERT(ctx->Driver.NewBufferObject); + newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target); + if (!newBufObj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); + return; + } + _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj); + } + } + + /* bind new buffer */ + _mesa_reference_buffer_object(ctx, bindTarget, newBufObj); + + /* Pass BindBuffer call to device driver */ + if (ctx->Driver.BindBuffer) + ctx->Driver.BindBuffer( ctx, target, newBufObj ); +} + + +/** + * Update the default buffer objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_buffer_objects(struct gl_context *ctx) +{ + /* Bind the NullBufferObj to remove references to those + * in the shared context hash table. + */ + bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0); +} + + +/** + * When we're about to read pixel data out of a PBO (via glDrawPixels, + * glTexImage, etc) or write data into a PBO (via glReadPixels, + * glGetTexImage, etc) we call this function to check that we're not + * going to read out of bounds. + * + * XXX This would also be a convenient time to check that the PBO isn't + * currently mapped. Whoever calls this function should check for that. + * Remember, we can't use a PBO when it's mapped! + * + * If we're not using a PBO, this is a no-op. + * + * \param width width of image to read/write + * \param height height of image to read/write + * \param depth depth of image to read/write + * \param format format of image to read/write + * \param type datatype of image to read/write + * \param ptr the user-provided pointer/offset + * \return GL_TRUE if the PBO access is OK, GL_FALSE if the access would + * go out of bounds. + */ +GLboolean +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *ptr) +{ + GLvoid *start, *end; + const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ + + if (!_mesa_is_bufferobj(pack->BufferObj)) + return GL_TRUE; /* no PBO, OK */ + + if (pack->BufferObj->Size == 0) + /* no buffer! */ + return GL_FALSE; + + /* get address of first pixel we'll read */ + start = _mesa_image_address(dimensions, pack, ptr, width, height, + format, type, 0, 0, 0); + + /* get address just past the last pixel we'll read */ + end = _mesa_image_address(dimensions, pack, ptr, width, height, + format, type, depth-1, height-1, width); + + + sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size; + + if ((const GLubyte *) start > sizeAddr) { + /* This will catch negative values / wrap-around */ + return GL_FALSE; + } + if ((const GLubyte *) end > sizeAddr) { + /* Image read goes beyond end of buffer */ + return GL_FALSE; + } + + /* OK! */ + return GL_TRUE; +} + + +/** + * For commands that read from a PBO (glDrawPixels, glTexImage, + * glPolygonStipple, etc), if we're reading from a PBO, map it read-only + * and return the pointer into the PBO. If we're not reading from a + * PBO, return \p src as-is. + * If non-null return, must call _mesa_unmap_pbo_source() when done. + * + * \return NULL if error, else pointer to start of data + */ +const GLvoid * +_mesa_map_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *src) +{ + const GLubyte *buf; + + if (_mesa_is_bufferobj(unpack->BufferObj)) { + /* unpack from PBO */ + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, + unpack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, src); + } + else { + /* unpack from normal memory */ + buf = src; + } + + return buf; +} + + +/** + * Combine PBO-read validation and mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_access + * \sa _mesa_map_pbo_source + * A call to this function should have a matching call to + * _mesa_unmap_pbo_source(). + */ +const GLvoid * +_mesa_map_validate_pbo_source(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *ptr, + const char *where) +{ + ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* non-PBO access: no validation to be done */ + return ptr; + } + + if (!_mesa_validate_pbo_access(dimensions, unpack, + width, height, depth, format, type, ptr)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds PBO access)", where); + return NULL; + } + + if (_mesa_bufferobj_mapped(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); + return NULL; + } + + ptr = _mesa_map_pbo_source(ctx, unpack, ptr); + return ptr; +} + + +/** + * Counterpart to _mesa_map_pbo_source() + */ +void +_mesa_unmap_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** + * For commands that write to a PBO (glReadPixels, glGetColorTable, etc), + * if we're writing to a PBO, map it write-only and return the pointer + * into the PBO. If we're not writing to a PBO, return \p dst as-is. + * If non-null return, must call _mesa_unmap_pbo_dest() when done. + * + * \return NULL if error, else pointer to start of data + */ +void * +_mesa_map_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest) +{ + void *buf; + + if (_mesa_is_bufferobj(pack->BufferObj)) { + /* pack into PBO */ + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + GL_WRITE_ONLY_ARB, + pack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, dest); + } + else { + /* pack to normal memory */ + buf = dest; + } + + return buf; +} + + +/** + * Combine PBO-write validation and mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_access + * \sa _mesa_map_pbo_dest + * A call to this function should have a matching call to + * _mesa_unmap_pbo_dest(). + */ +GLvoid * +_mesa_map_validate_pbo_dest(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLvoid *ptr, + const char *where) +{ + ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* non-PBO access: no validation to be done */ + return ptr; + } + + if (!_mesa_validate_pbo_access(dimensions, unpack, + width, height, depth, format, type, ptr)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds PBO access)", where); + return NULL; + } + + if (_mesa_bufferobj_mapped(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); + return NULL; + } + + ptr = _mesa_map_pbo_dest(ctx, unpack, ptr); + return ptr; +} + + +/** + * Counterpart to _mesa_map_pbo_dest() + */ +void +_mesa_unmap_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack) +{ + ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ + if (_mesa_is_bufferobj(pack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, pack->BufferObj); + } +} + + + +/** + * Return the gl_buffer_object for the given ID. + * Always return NULL for ID 0. + */ +struct gl_buffer_object * +_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer) +{ + if (buffer == 0) + return NULL; + else + return (struct gl_buffer_object *) + _mesa_HashLookup(ctx->Shared->BufferObjects, buffer); +} + + +/** + * If *ptr points to obj, set ptr = the Null/default buffer object. + * This is a helper for buffer object deletion. + * The GL spec says that deleting a buffer object causes it to get + * unbound from all arrays in the current context. + */ +static void +unbind(struct gl_context *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *obj) +{ + if (*ptr == obj) { + _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj); + } +} + + +/** + * Plug default/fallback buffer object functions into the device + * driver hooks. + */ +void +_mesa_init_buffer_object_functions(struct dd_function_table *driver) +{ + /* GL_ARB_vertex/pixel_buffer_object */ + driver->NewBufferObject = _mesa_new_buffer_object; + driver->DeleteBuffer = _mesa_delete_buffer_object; + driver->BindBuffer = NULL; + driver->BufferData = _mesa_buffer_data; + driver->BufferSubData = _mesa_buffer_subdata; + driver->GetBufferSubData = _mesa_buffer_get_subdata; + driver->MapBuffer = _mesa_buffer_map; + driver->UnmapBuffer = _mesa_buffer_unmap; + + /* GL_ARB_map_buffer_range */ + driver->MapBufferRange = _mesa_buffer_map_range; + driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range; + + /* GL_ARB_copy_buffer */ + driver->CopyBufferSubData = _mesa_copy_buffer_subdata; +} + + + +/**********************************************************************/ +/* API Functions */ +/**********************************************************************/ + +void GLAPIENTRY +_mesa_BindBufferARB(GLenum target, GLuint buffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bind_buffer_object(ctx, target, buffer); +} + + +/** + * Delete a set of buffer objects. + * + * \param n Number of buffer objects to delete. + * \param ids Array of \c n buffer object IDs. + */ +void GLAPIENTRY +_mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) +{ + GET_CURRENT_CONTEXT(ctx); + GLsizei i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)"); + return; + } + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + for (i = 0; i < n; i++) { + struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]); + if (bufObj) { + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint j; + + ASSERT(bufObj->Name == ids[i] || bufObj == &DummyBufferObject); + + if (_mesa_bufferobj_mapped(bufObj)) { + /* if mapped, unmap it now */ + ctx->Driver.UnmapBuffer(ctx, 0, bufObj); + bufObj->AccessFlags = DEFAULT_ACCESS; + bufObj->Pointer = NULL; + } + + /* unbind any vertex pointers bound to this buffer */ + unbind(ctx, &arrayObj->Vertex.BufferObj, bufObj); + unbind(ctx, &arrayObj->Weight.BufferObj, bufObj); + unbind(ctx, &arrayObj->Normal.BufferObj, bufObj); + unbind(ctx, &arrayObj->Color.BufferObj, bufObj); + unbind(ctx, &arrayObj->SecondaryColor.BufferObj, bufObj); + unbind(ctx, &arrayObj->FogCoord.BufferObj, bufObj); + unbind(ctx, &arrayObj->Index.BufferObj, bufObj); + unbind(ctx, &arrayObj->EdgeFlag.BufferObj, bufObj); + for (j = 0; j < Elements(arrayObj->TexCoord); j++) { + unbind(ctx, &arrayObj->TexCoord[j].BufferObj, bufObj); + } + for (j = 0; j < Elements(arrayObj->VertexAttrib); j++) { + unbind(ctx, &arrayObj->VertexAttrib[j].BufferObj, bufObj); + } + + if (ctx->Array.ArrayBufferObj == bufObj) { + _mesa_BindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); + } + if (ctx->Array.ElementArrayBufferObj == bufObj) { + _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); + } + + /* unbind any pixel pack/unpack pointers bound to this buffer */ + if (ctx->Pack.BufferObj == bufObj) { + _mesa_BindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, 0 ); + } + if (ctx->Unpack.BufferObj == bufObj) { + _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 ); + } + + /* The ID is immediately freed for re-use */ + _mesa_HashRemove(ctx->Shared->BufferObjects, ids[i]); + _mesa_reference_buffer_object(ctx, &bufObj, NULL); + } + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +/** + * Generate a set of unique buffer object IDs and store them in \c buffer. + * + * \param n Number of IDs to generate. + * \param buffer Array of \c n locations to store the IDs. + */ +void GLAPIENTRY +_mesa_GenBuffersARB(GLsizei n, GLuint *buffer) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB"); + return; + } + + if (!buffer) { + return; + } + + /* + * This must be atomic (generation and allocation of buffer object IDs) + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n); + + /* Insert the ID and pointer to dummy buffer object into hash table */ + for (i = 0; i < n; i++) { + _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, + &DummyBufferObject); + buffer[i] = first + i; + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +/** + * Determine if ID is the name of a buffer object. + * + * \param id ID of the potential buffer object. + * \return \c GL_TRUE if \c id is the name of a buffer object, + * \c GL_FALSE otherwise. + */ +GLboolean GLAPIENTRY +_mesa_IsBufferARB(GLuint id) +{ + struct gl_buffer_object *bufObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + bufObj = _mesa_lookup_bufferobj(ctx, id); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + return bufObj && bufObj != &DummyBufferObject; +} + + +void GLAPIENTRY +_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, + const GLvoid * data, GLenum usage) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (size < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)"); + return; + } + + switch (usage) { + case GL_STREAM_DRAW_ARB: + case GL_STREAM_READ_ARB: + case GL_STREAM_COPY_ARB: + case GL_STATIC_DRAW_ARB: + case GL_STATIC_READ_ARB: + case GL_STATIC_COPY_ARB: + case GL_DYNAMIC_DRAW_ARB: + case GL_DYNAMIC_READ_ARB: + case GL_DYNAMIC_COPY_ARB: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)"); + return; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(target)" ); + return; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB(buffer 0)" ); + return; + } + + if (_mesa_bufferobj_mapped(bufObj)) { + /* Unmap the existing buffer. We'll replace it now. Not an error. */ + ctx->Driver.UnmapBuffer(ctx, target, bufObj); + bufObj->AccessFlags = DEFAULT_ACCESS; + ASSERT(bufObj->Pointer == NULL); + } + + FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT); + + bufObj->Written = GL_TRUE; + +#ifdef VBO_DEBUG + printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", + bufObj->Name, size, data, usage); +#endif + +#ifdef BOUNDS_CHECK + size += 100; +#endif + + ASSERT(ctx->Driver.BufferData); + if (!ctx->Driver.BufferData( ctx, target, size, data, usage, bufObj )) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBufferDataARB()"); + } +} + + +void GLAPIENTRY +_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, + GLsizeiptrARB size, const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, + "glBufferSubDataARB" ); + if (!bufObj) { + /* error already recorded */ + return; + } + + if (size == 0) + return; + + bufObj->Written = GL_TRUE; + + ASSERT(ctx->Driver.BufferSubData); + ctx->Driver.BufferSubData( ctx, target, offset, size, data, bufObj ); +} + + +void GLAPIENTRY +_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, + GLsizeiptrARB size, void * data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bufObj = buffer_object_subdata_range_good( ctx, target, offset, size, + "glGetBufferSubDataARB" ); + if (!bufObj) { + /* error already recorded */ + return; + } + + ASSERT(ctx->Driver.GetBufferSubData); + ctx->Driver.GetBufferSubData( ctx, target, offset, size, data, bufObj ); +} + + +void * GLAPIENTRY +_mesa_MapBufferARB(GLenum target, GLenum access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object * bufObj; + GLbitfield accessFlags; + void *map; + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); + + switch (access) { + case GL_READ_ONLY_ARB: + accessFlags = GL_MAP_READ_BIT; + break; + case GL_WRITE_ONLY_ARB: + accessFlags = GL_MAP_WRITE_BIT; + break; + case GL_READ_WRITE_ARB: + accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); + return NULL; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(target)" ); + return NULL; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(buffer 0)" ); + return NULL; + } + if (_mesa_bufferobj_mapped(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)"); + return NULL; + } + + ASSERT(ctx->Driver.MapBuffer); + map = ctx->Driver.MapBuffer( ctx, target, access, bufObj ); + if (!map) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); + return NULL; + } + else { + /* The driver callback should have set these fields. + * This is important because other modules (like VBO) might call + * the driver function directly. + */ + ASSERT(bufObj->Pointer == map); + ASSERT(bufObj->Length == bufObj->Size); + ASSERT(bufObj->Offset == 0); + bufObj->AccessFlags = accessFlags; + } + + if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB) + bufObj->Written = GL_TRUE; + +#ifdef VBO_DEBUG + printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", + bufObj->Name, bufObj->Size, access); + if (access == GL_WRITE_ONLY_ARB) { + GLuint i; + GLubyte *b = (GLubyte *) bufObj->Pointer; + for (i = 0; i < bufObj->Size; i++) + b[i] = i & 0xff; + } +#endif + +#ifdef BOUNDS_CHECK + { + GLubyte *buf = (GLubyte *) bufObj->Pointer; + GLuint i; + /* buffer is 100 bytes larger than requested, fill with magic value */ + for (i = 0; i < 100; i++) { + buf[bufObj->Size - i - 1] = 123; + } + } +#endif + + return bufObj->Pointer; +} + + +GLboolean GLAPIENTRY +_mesa_UnmapBufferARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + GLboolean status = GL_TRUE; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glUnmapBufferARB(target)" ); + return GL_FALSE; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" ); + return GL_FALSE; + } + if (!_mesa_bufferobj_mapped(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB"); + return GL_FALSE; + } + +#ifdef BOUNDS_CHECK + if (bufObj->Access != GL_READ_ONLY_ARB) { + GLubyte *buf = (GLubyte *) bufObj->Pointer; + GLuint i; + /* check that last 100 bytes are still = magic value */ + for (i = 0; i < 100; i++) { + GLuint pos = bufObj->Size - i - 1; + if (buf[pos] != 123) { + _mesa_warning(ctx, "Out of bounds buffer object write detected" + " at position %d (value = %u)\n", + pos, buf[pos]); + } + } + } +#endif + +#ifdef VBO_DEBUG + if (bufObj->AccessFlags & GL_MAP_WRITE_BIT) { + GLuint i, unchanged = 0; + GLubyte *b = (GLubyte *) bufObj->Pointer; + GLint pos = -1; + /* check which bytes changed */ + for (i = 0; i < bufObj->Size - 1; i++) { + if (b[i] == (i & 0xff) && b[i+1] == ((i+1) & 0xff)) { + unchanged++; + if (pos == -1) + pos = i; + } + } + if (unchanged) { + printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", + bufObj->Name, unchanged, bufObj->Size, pos); + } + } +#endif + + status = ctx->Driver.UnmapBuffer( ctx, target, bufObj ); + bufObj->AccessFlags = DEFAULT_ACCESS; + ASSERT(bufObj->Pointer == NULL); + ASSERT(bufObj->Offset == 0); + ASSERT(bufObj->Length == 0); + + return status; +} + + +void GLAPIENTRY +_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)" ); + return; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameterivARB" ); + return; + } + + switch (pname) { + case GL_BUFFER_SIZE_ARB: + *params = (GLint) bufObj->Size; + return; + case GL_BUFFER_USAGE_ARB: + *params = bufObj->Usage; + return; + case GL_BUFFER_ACCESS_ARB: + *params = simplified_access_mode(bufObj->AccessFlags); + return; + case GL_BUFFER_MAPPED_ARB: + *params = _mesa_bufferobj_mapped(bufObj); + return; + case GL_BUFFER_ACCESS_FLAGS: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->AccessFlags; + return; + case GL_BUFFER_MAP_OFFSET: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = (GLint) bufObj->Offset; + return; + case GL_BUFFER_MAP_LENGTH: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = (GLint) bufObj->Length; + return; + default: + ; /* fall-through */ + } + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +/** + * New in GL 3.2 + * This is pretty much a duplicate of GetBufferParameteriv() but the + * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system. + */ +void GLAPIENTRY +_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(target)" ); + return; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameteri64v" ); + return; + } + + switch (pname) { + case GL_BUFFER_SIZE_ARB: + *params = bufObj->Size; + return; + case GL_BUFFER_USAGE_ARB: + *params = bufObj->Usage; + return; + case GL_BUFFER_ACCESS_ARB: + *params = simplified_access_mode(bufObj->AccessFlags); + return; + case GL_BUFFER_ACCESS_FLAGS: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->AccessFlags; + return; + case GL_BUFFER_MAPPED_ARB: + *params = _mesa_bufferobj_mapped(bufObj); + return; + case GL_BUFFER_MAP_OFFSET: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->Offset; + return; + case GL_BUFFER_MAP_LENGTH: + if (ctx->VersionMajor < 3) + goto invalid_pname; + *params = bufObj->Length; + return; + default: + ; /* fall-through */ + } + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +void GLAPIENTRY +_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object * bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname != GL_BUFFER_MAP_POINTER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); + return; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(target)" ); + return; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" ); + return; + } + + *params = bufObj->Pointer; +} + + +void GLAPIENTRY +_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *src, *dst; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + src = get_buffer(ctx, readTarget); + if (!src || !_mesa_is_bufferobj(src)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyBuffserSubData(readTarget = 0x%x)", readTarget); + return; + } + + dst = get_buffer(ctx, writeTarget); + if (!dst || !_mesa_is_bufferobj(dst)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget); + return; + } + + if (_mesa_bufferobj_mapped(src)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyBuffserSubData(readBuffer is mapped)"); + return; + } + + if (_mesa_bufferobj_mapped(dst)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyBuffserSubData(writeBuffer is mapped)"); + return; + } + + if (readOffset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyBuffserSubData(readOffset = %d)", (int) readOffset); + return; + } + + if (writeOffset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyBuffserSubData(writeOffset = %d)", (int) writeOffset); + return; + } + + if (readOffset + size > src->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyBuffserSubData(readOffset + size = %d)", + (int) (readOffset + size)); + return; + } + + if (writeOffset + size > dst->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyBuffserSubData(writeOffset + size = %d)", + (int) (writeOffset + size)); + return; + } + + if (src == dst) { + if (readOffset + size <= writeOffset) { + /* OK */ + } + else if (writeOffset + size <= readOffset) { + /* OK */ + } + else { + /* overlapping src/dst is illegal */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyBuffserSubData(overlapping src/dst)"); + return; + } + } + + ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size); +} + + +/** + * See GL_ARB_map_buffer_range spec + */ +void * GLAPIENTRY +_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, + GLbitfield access) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + void *map; + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); + + if (!ctx->Extensions.ARB_map_buffer_range) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(extension not supported)"); + return NULL; + } + + if (offset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(offset = %ld)", (long)offset); + return NULL; + } + + if (length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(length = %ld)", (long)length); + return NULL; + } + + if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(access indicates neither read or write)"); + return NULL; + } + + if (access & GL_MAP_READ_BIT) { + if ((access & GL_MAP_INVALIDATE_RANGE_BIT) || + (access & GL_MAP_INVALIDATE_BUFFER_BIT) || + (access & GL_MAP_UNSYNCHRONIZED_BIT)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(invalid access flags)"); + return NULL; + } + } + + if ((access & GL_MAP_FLUSH_EXPLICIT_BIT) && + ((access & GL_MAP_WRITE_BIT) == 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(invalid access flags)"); + return NULL; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj || !_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glMapBufferRange(target = 0x%x)", target); + return NULL; + } + + if (offset + length > bufObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(offset + length > size)"); + return NULL; + } + + if (_mesa_bufferobj_mapped(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(buffer already mapped)"); + return NULL; + } + + ASSERT(ctx->Driver.MapBufferRange); + map = ctx->Driver.MapBufferRange(ctx, target, offset, length, + access, bufObj); + if (!map) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)"); + } + else { + /* The driver callback should have set all these fields. + * This is important because other modules (like VBO) might call + * the driver function directly. + */ + ASSERT(bufObj->Pointer == map); + ASSERT(bufObj->Length == length); + ASSERT(bufObj->Offset == offset); + ASSERT(bufObj->AccessFlags == access); + } + + return map; +} + + +/** + * See GL_ARB_map_buffer_range spec + */ +void GLAPIENTRY +_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ARB_map_buffer_range) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(extension not supported)"); + return; + } + + if (offset < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(offset = %ld)", (long)offset); + return; + } + + if (length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(length = %ld)", (long)length); + return; + } + + bufObj = get_buffer(ctx, target); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glMapBufferRange(target = 0x%x)", target); + return; + } + + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(current buffer is 0)"); + return; + } + + if (!_mesa_bufferobj_mapped(bufObj)) { + /* buffer is not mapped */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(buffer is not mapped)"); + return; + } + + if ((bufObj->AccessFlags & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glMapBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)"); + return; + } + + if (offset + length > bufObj->Length) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glMapBufferRange(offset %ld + length %ld > mapped length %ld)", + (long)offset, (long)length, (long)bufObj->Length); + return; + } + + ASSERT(bufObj->AccessFlags & GL_MAP_WRITE_BIT); + + if (ctx->Driver.FlushMappedBufferRange) + ctx->Driver.FlushMappedBufferRange(ctx, target, offset, length, bufObj); +} + + +#if FEATURE_APPLE_object_purgeable +static GLenum +_mesa_BufferObjectPurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_buffer_object *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_bufferobj(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectPurgeable(name = 0x%x)", name); + return 0; + } + if (!_mesa_is_bufferobj(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glObjectPurgeable(buffer 0)" ); + return 0; + } + + if (bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectPurgeable(name = 0x%x) is already purgeable", name); + return GL_VOLATILE_APPLE; + } + + bufObj->Purgeable = GL_TRUE; + + retval = GL_VOLATILE_APPLE; + if (ctx->Driver.BufferObjectPurgeable) + retval = ctx->Driver.BufferObjectPurgeable(ctx, bufObj, option); + + return retval; +} + + +static GLenum +_mesa_RenderObjectPurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_renderbuffer *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_renderbuffer(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return 0; + } + + if (bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectPurgeable(name = 0x%x) is already purgeable", name); + return GL_VOLATILE_APPLE; + } + + bufObj->Purgeable = GL_TRUE; + + retval = GL_VOLATILE_APPLE; + if (ctx->Driver.RenderObjectPurgeable) + retval = ctx->Driver.RenderObjectPurgeable(ctx, bufObj, option); + + return retval; +} + + +static GLenum +_mesa_TextureObjectPurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_texture_object *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_texture(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectPurgeable(name = 0x%x)", name); + return 0; + } + + if (bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectPurgeable(name = 0x%x) is already purgeable", name); + return GL_VOLATILE_APPLE; + } + + bufObj->Purgeable = GL_TRUE; + + retval = GL_VOLATILE_APPLE; + if (ctx->Driver.TextureObjectPurgeable) + retval = ctx->Driver.TextureObjectPurgeable(ctx, bufObj, option); + + return retval; +} + + +GLenum GLAPIENTRY +_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option) +{ + GLenum retval; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectPurgeable(name = 0x%x)", name); + return 0; + } + + switch (option) { + case GL_VOLATILE_APPLE: + case GL_RELEASED_APPLE: + /* legal */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glObjectPurgeable(name = 0x%x) invalid option: %d", + name, option); + return 0; + } + + switch (objectType) { + case GL_TEXTURE: + retval = _mesa_TextureObjectPurgeable (ctx, name, option); + break; + case GL_RENDERBUFFER_EXT: + retval = _mesa_RenderObjectPurgeable (ctx, name, option); + break; + case GL_BUFFER_OBJECT_APPLE: + retval = _mesa_BufferObjectPurgeable (ctx, name, option); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glObjectPurgeable(name = 0x%x) invalid type: %d", + name, objectType); + return 0; + } + + /* In strict conformance to the spec, we must only return VOLATILE when + * when passed the VOLATILE option. Madness. + * + * XXX First fix the spec, then fix me. + */ + return option == GL_VOLATILE_APPLE ? GL_VOLATILE_APPLE : retval; +} + + +static GLenum +_mesa_BufferObjectUnpurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_buffer_object *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_bufferobj(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return 0; + } + + if (! bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectUnpurgeable(name = 0x%x) object is " + " already \"unpurged\"", name); + return 0; + } + + bufObj->Purgeable = GL_FALSE; + + retval = option; + if (ctx->Driver.BufferObjectUnpurgeable) + retval = ctx->Driver.BufferObjectUnpurgeable(ctx, bufObj, option); + + return retval; +} + + +static GLenum +_mesa_RenderObjectUnpurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_renderbuffer *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_renderbuffer(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return 0; + } + + if (! bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectUnpurgeable(name = 0x%x) object is " + " already \"unpurged\"", name); + return 0; + } + + bufObj->Purgeable = GL_FALSE; + + retval = option; + if (ctx->Driver.RenderObjectUnpurgeable) + retval = ctx->Driver.RenderObjectUnpurgeable(ctx, bufObj, option); + + return retval; +} + + +static GLenum +_mesa_TextureObjectUnpurgeable(struct gl_context *ctx, GLuint name, GLenum option) +{ + struct gl_texture_object *bufObj; + GLenum retval; + + bufObj = _mesa_lookup_texture(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return 0; + } + + if (! bufObj->Purgeable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glObjectUnpurgeable(name = 0x%x) object is" + " already \"unpurged\"", name); + return 0; + } + + bufObj->Purgeable = GL_FALSE; + + retval = option; + if (ctx->Driver.TextureObjectUnpurgeable) + retval = ctx->Driver.TextureObjectUnpurgeable(ctx, bufObj, option); + + return retval; +} + + +GLenum GLAPIENTRY +_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return 0; + } + + switch (option) { + case GL_RETAINED_APPLE: + case GL_UNDEFINED_APPLE: + /* legal */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glObjectUnpurgeable(name = 0x%x) invalid option: %d", + name, option); + return 0; + } + + switch (objectType) { + case GL_BUFFER_OBJECT_APPLE: + return _mesa_BufferObjectUnpurgeable(ctx, name, option); + case GL_TEXTURE: + return _mesa_TextureObjectUnpurgeable(ctx, name, option); + case GL_RENDERBUFFER_EXT: + return _mesa_RenderObjectUnpurgeable(ctx, name, option); + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glObjectUnpurgeable(name = 0x%x) invalid type: %d", + name, objectType); + return 0; + } +} + + +static void +_mesa_GetBufferObjectParameterivAPPLE(struct gl_context *ctx, GLuint name, + GLenum pname, GLint* params) +{ + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetObjectParameteriv(name = 0x%x) invalid object", name); + return; + } + + switch (pname) { + case GL_PURGEABLE_APPLE: + *params = bufObj->Purgeable; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", + name, pname); + break; + } +} + + +static void +_mesa_GetRenderObjectParameterivAPPLE(struct gl_context *ctx, GLuint name, + GLenum pname, GLint* params) +{ + struct gl_renderbuffer *bufObj; + + bufObj = _mesa_lookup_renderbuffer(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return; + } + + switch (pname) { + case GL_PURGEABLE_APPLE: + *params = bufObj->Purgeable; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", + name, pname); + break; + } +} + + +static void +_mesa_GetTextureObjectParameterivAPPLE(struct gl_context *ctx, GLuint name, + GLenum pname, GLint* params) +{ + struct gl_texture_object *bufObj; + + bufObj = _mesa_lookup_texture(ctx, name); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glObjectUnpurgeable(name = 0x%x)", name); + return; + } + + switch (pname) { + case GL_PURGEABLE_APPLE: + *params = bufObj->Purgeable; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetObjectParameteriv(name = 0x%x) invalid enum: %d", + name, pname); + break; + } +} + + +void GLAPIENTRY +_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, + GLint* params) +{ + GET_CURRENT_CONTEXT(ctx); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetObjectParameteriv(name = 0x%x)", name); + return; + } + + switch (objectType) { + case GL_TEXTURE: + _mesa_GetTextureObjectParameterivAPPLE (ctx, name, pname, params); + break; + case GL_BUFFER_OBJECT_APPLE: + _mesa_GetBufferObjectParameterivAPPLE (ctx, name, pname, params); + break; + case GL_RENDERBUFFER_EXT: + _mesa_GetRenderObjectParameterivAPPLE (ctx, name, pname, params); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetObjectParameteriv(name = 0x%x) invalid type: %d", + name, objectType); + } +} + +#endif /* FEATURE_APPLE_object_purgeable */ diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index f234d06c6..57aa82eda 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -1,189 +1,189 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BUFFEROBJ_H -#define BUFFEROBJ_H - - -#include "mtypes.h" - - -/* - * Internal functions - */ - - -/** Is the given buffer object currently mapped? */ -static INLINE GLboolean -_mesa_bufferobj_mapped(const struct gl_buffer_object *obj) -{ - return obj->Pointer != NULL; -} - -/** - * Is the given buffer object a user-created buffer object? - * Mesa uses default buffer objects in several places. Default buffers - * always have Name==0. User created buffers have Name!=0. - */ -static INLINE GLboolean -_mesa_is_bufferobj(const struct gl_buffer_object *obj) -{ - return obj->Name != 0; -} - - -extern void -_mesa_init_buffer_objects( GLcontext *ctx ); - -extern void -_mesa_free_buffer_objects( GLcontext *ctx ); - -extern void -_mesa_update_default_objects_buffer_objects(GLcontext *ctx); - - -extern struct gl_buffer_object * -_mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer); - -extern void -_mesa_initialize_buffer_object( struct gl_buffer_object *obj, - GLuint name, GLenum target ); - -extern void -_mesa_reference_buffer_object(GLcontext *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj); - -extern GLboolean -_mesa_validate_pbo_access(GLuint dimensions, - const struct gl_pixelstore_attrib *pack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *ptr); - -extern const GLvoid * -_mesa_map_pbo_source(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *src); - -extern const GLvoid * -_mesa_map_validate_pbo_source(GLcontext *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *ptr, - const char *where); - -extern void -_mesa_unmap_pbo_source(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack); - -extern void * -_mesa_map_pbo_dest(GLcontext *ctx, - const struct gl_pixelstore_attrib *pack, - GLvoid *dest); - -extern GLvoid * -_mesa_map_validate_pbo_dest(GLcontext *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLvoid *ptr, - const char *where); - -extern void -_mesa_unmap_pbo_dest(GLcontext *ctx, - const struct gl_pixelstore_attrib *pack); - - -extern void -_mesa_init_buffer_object_functions(struct dd_function_table *driver); - - -/* - * API functions - */ - -extern void GLAPIENTRY -_mesa_BindBufferARB(GLenum target, GLuint buffer); - -extern void GLAPIENTRY -_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); - -extern void GLAPIENTRY -_mesa_GenBuffersARB(GLsizei n, GLuint * buffer); - -extern GLboolean GLAPIENTRY -_mesa_IsBufferARB(GLuint buffer); - -extern void GLAPIENTRY -_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); - -extern void GLAPIENTRY -_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); - -extern void GLAPIENTRY -_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); - -extern void * GLAPIENTRY -_mesa_MapBufferARB(GLenum target, GLenum access); - -extern GLboolean GLAPIENTRY -_mesa_UnmapBufferARB(GLenum target); - -extern void GLAPIENTRY -_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); - -extern void GLAPIENTRY -_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params); - -extern void GLAPIENTRY -_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size); - -extern void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access); - -extern void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); - -#if FEATURE_APPLE_object_purgeable -extern GLenum GLAPIENTRY -_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern GLenum GLAPIENTRY -_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern void GLAPIENTRY -_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params); -#endif - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef BUFFEROBJ_H +#define BUFFEROBJ_H + + +#include "mtypes.h" + + +/* + * Internal functions + */ + + +/** Is the given buffer object currently mapped? */ +static INLINE GLboolean +_mesa_bufferobj_mapped(const struct gl_buffer_object *obj) +{ + return obj->Pointer != NULL; +} + +/** + * Is the given buffer object a user-created buffer object? + * Mesa uses default buffer objects in several places. Default buffers + * always have Name==0. User created buffers have Name!=0. + */ +static INLINE GLboolean +_mesa_is_bufferobj(const struct gl_buffer_object *obj) +{ + return obj->Name != 0; +} + + +extern void +_mesa_init_buffer_objects( struct gl_context *ctx ); + +extern void +_mesa_free_buffer_objects( struct gl_context *ctx ); + +extern void +_mesa_update_default_objects_buffer_objects(struct gl_context *ctx); + + +extern struct gl_buffer_object * +_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); + +extern void +_mesa_initialize_buffer_object( struct gl_buffer_object *obj, + GLuint name, GLenum target ); + +extern void +_mesa_reference_buffer_object(struct gl_context *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj); + +extern GLboolean +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *ptr); + +extern const GLvoid * +_mesa_map_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *src); + +extern const GLvoid * +_mesa_map_validate_pbo_source(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *ptr, + const char *where); + +extern void +_mesa_unmap_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + +extern void * +_mesa_map_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest); + +extern GLvoid * +_mesa_map_validate_pbo_dest(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLvoid *ptr, + const char *where); + +extern void +_mesa_unmap_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack); + + +extern void +_mesa_init_buffer_object_functions(struct dd_function_table *driver); + + +/* + * API functions + */ + +extern void GLAPIENTRY +_mesa_BindBufferARB(GLenum target, GLuint buffer); + +extern void GLAPIENTRY +_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); + +extern void GLAPIENTRY +_mesa_GenBuffersARB(GLsizei n, GLuint * buffer); + +extern GLboolean GLAPIENTRY +_mesa_IsBufferARB(GLuint buffer); + +extern void GLAPIENTRY +_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); + +extern void GLAPIENTRY +_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); + +extern void GLAPIENTRY +_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); + +extern void * GLAPIENTRY +_mesa_MapBufferARB(GLenum target, GLenum access); + +extern GLboolean GLAPIENTRY +_mesa_UnmapBufferARB(GLenum target); + +extern void GLAPIENTRY +_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); + +extern void GLAPIENTRY +_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params); + +extern void GLAPIENTRY +_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size); + +extern void * GLAPIENTRY +_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, + GLbitfield access); + +extern void GLAPIENTRY +_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); + +#if FEATURE_APPLE_object_purgeable +extern GLenum GLAPIENTRY +_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); + +extern GLenum GLAPIENTRY +_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); + +extern void GLAPIENTRY +_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params); +#endif + +#endif diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index fb30b5996..cdc174454 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -1,525 +1,525 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file buffers.c - * glReadBuffer, DrawBuffer functions. - */ - - - -#include "glheader.h" -#include "buffers.h" -#include "colormac.h" -#include "context.h" -#include "enums.h" - - -#define BAD_MASK ~0u - - -/** - * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are - * available to the rendering context (for drawing or reading). - * This depends on the type of framebuffer. For window system framebuffers - * we look at the framebuffer's visual. But for user-create framebuffers we - * look at the number of supported color attachments. - * \param fb the framebuffer to draw to, or read from - * \return bitmask of BUFFER_BIT_* flags - */ -static GLbitfield -supported_buffer_bitmask(const GLcontext *ctx, const struct gl_framebuffer *fb) -{ - GLbitfield mask = 0x0; - - if (fb->Name > 0) { - /* A user-created renderbuffer */ - GLuint i; - ASSERT(ctx->Extensions.EXT_framebuffer_object); - for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { - mask |= (BUFFER_BIT_COLOR0 << i); - } - } - else { - /* A window system framebuffer */ - GLint i; - mask = BUFFER_BIT_FRONT_LEFT; /* always have this */ - if (fb->Visual.stereoMode) { - mask |= BUFFER_BIT_FRONT_RIGHT; - if (fb->Visual.doubleBufferMode) { - mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; - } - } - else if (fb->Visual.doubleBufferMode) { - mask |= BUFFER_BIT_BACK_LEFT; - } - - for (i = 0; i < fb->Visual.numAuxBuffers; i++) { - mask |= (BUFFER_BIT_AUX0 << i); - } - } - - return mask; -} - - -/** - * Helper routine used by glDrawBuffer and glDrawBuffersARB. - * Given a GLenum naming one or more color buffers (such as - * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags. - */ -static GLbitfield -draw_buffer_enum_to_bitmask(GLenum buffer) -{ - switch (buffer) { - case GL_NONE: - return 0; - case GL_FRONT: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT; - case GL_BACK: - return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; - case GL_RIGHT: - return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; - case GL_FRONT_RIGHT: - return BUFFER_BIT_FRONT_RIGHT; - case GL_BACK_RIGHT: - return BUFFER_BIT_BACK_RIGHT; - case GL_BACK_LEFT: - return BUFFER_BIT_BACK_LEFT; - case GL_FRONT_AND_BACK: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT - | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; - case GL_LEFT: - return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT; - case GL_FRONT_LEFT: - return BUFFER_BIT_FRONT_LEFT; - case GL_AUX0: - return BUFFER_BIT_AUX0; - case GL_AUX1: - case GL_AUX2: - case GL_AUX3: - return 1 << BUFFER_COUNT; /* invalid, but not BAD_MASK */ - case GL_COLOR_ATTACHMENT0_EXT: - return BUFFER_BIT_COLOR0; - case GL_COLOR_ATTACHMENT1_EXT: - return BUFFER_BIT_COLOR1; - case GL_COLOR_ATTACHMENT2_EXT: - return BUFFER_BIT_COLOR2; - case GL_COLOR_ATTACHMENT3_EXT: - return BUFFER_BIT_COLOR3; - case GL_COLOR_ATTACHMENT4_EXT: - return BUFFER_BIT_COLOR4; - case GL_COLOR_ATTACHMENT5_EXT: - return BUFFER_BIT_COLOR5; - case GL_COLOR_ATTACHMENT6_EXT: - return BUFFER_BIT_COLOR6; - case GL_COLOR_ATTACHMENT7_EXT: - return BUFFER_BIT_COLOR7; - default: - /* error */ - return BAD_MASK; - } -} - - -/** - * Helper routine used by glReadBuffer. - * Given a GLenum naming a color buffer, return the index of the corresponding - * renderbuffer (a BUFFER_* value). - * return -1 for an invalid buffer. - */ -static GLint -read_buffer_enum_to_index(GLenum buffer) -{ - switch (buffer) { - case GL_FRONT: - return BUFFER_FRONT_LEFT; - case GL_BACK: - return BUFFER_BACK_LEFT; - case GL_RIGHT: - return BUFFER_FRONT_RIGHT; - case GL_FRONT_RIGHT: - return BUFFER_FRONT_RIGHT; - case GL_BACK_RIGHT: - return BUFFER_BACK_RIGHT; - case GL_BACK_LEFT: - return BUFFER_BACK_LEFT; - case GL_LEFT: - return BUFFER_FRONT_LEFT; - case GL_FRONT_LEFT: - return BUFFER_FRONT_LEFT; - case GL_AUX0: - return BUFFER_AUX0; - case GL_AUX1: - case GL_AUX2: - case GL_AUX3: - return BUFFER_COUNT; /* invalid, but not -1 */ - case GL_COLOR_ATTACHMENT0_EXT: - return BUFFER_COLOR0; - case GL_COLOR_ATTACHMENT1_EXT: - return BUFFER_COLOR1; - case GL_COLOR_ATTACHMENT2_EXT: - return BUFFER_COLOR2; - case GL_COLOR_ATTACHMENT3_EXT: - return BUFFER_COLOR3; - case GL_COLOR_ATTACHMENT4_EXT: - return BUFFER_COLOR4; - case GL_COLOR_ATTACHMENT5_EXT: - return BUFFER_COLOR5; - case GL_COLOR_ATTACHMENT6_EXT: - return BUFFER_COLOR6; - case GL_COLOR_ATTACHMENT7_EXT: - return BUFFER_COLOR7; - default: - /* error */ - return -1; - } -} - - -/** - * Called by glDrawBuffer(). - * Specify which renderbuffer(s) to draw into for the first color output. - * can name zero, one, two or four renderbuffers! - * \sa _mesa_DrawBuffersARB - * - * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc. - * - * Note that the behaviour of this function depends on whether the - * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or - * a user-created framebuffer object (Name!=0). - * In the former case, we update the per-context ctx->Color.DrawBuffer - * state var _and_ the FB's ColorDrawBuffer state. - * In the later case, we update the FB's ColorDrawBuffer state only. - * - * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the - * new FB is a window system FB, we need to re-update the FB's - * ColorDrawBuffer state to match the context. This is handled in - * _mesa_update_framebuffer(). - * - * See the GL_EXT_framebuffer_object spec for more info. - */ -void GLAPIENTRY -_mesa_DrawBuffer(GLenum buffer) -{ - GLbitfield destMask; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */ - - if (MESA_VERBOSE & VERBOSE_API) { - _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - } - - if (buffer == GL_NONE) { - destMask = 0x0; - } - else { - const GLbitfield supportedMask - = supported_buffer_bitmask(ctx, ctx->DrawBuffer); - destMask = draw_buffer_enum_to_bitmask(buffer); - if (destMask == BAD_MASK) { - /* totally bogus buffer */ - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer=0x%x)", buffer); - return; - } - destMask &= supportedMask; - if (destMask == 0x0) { - /* none of the named color buffers exist! */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawBuffer(buffer=0x%x)", buffer); - return; - } - } - - /* if we get here, there's no error so set new state */ - _mesa_drawbuffers(ctx, 1, &buffer, &destMask); - - /* - * Call device driver function. - */ - if (ctx->Driver.DrawBuffers) - ctx->Driver.DrawBuffers(ctx, 1, &buffer); - else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffer); -} - - -/** - * Called by glDrawBuffersARB; specifies the destination color renderbuffers - * for N fragment program color outputs. - * \sa _mesa_DrawBuffer - * \param n number of outputs - * \param buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the - * names cannot specify more than one buffer. For example, - * GL_FRONT_AND_BACK is illegal. - */ -void GLAPIENTRY -_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) -{ - GLint output; - GLbitfield usedBufferMask, supportedMask; - GLbitfield destMask[MAX_DRAW_BUFFERS]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - /* Turns out n==0 is a valid input that should not produce an error. - * The remaining code below correctly handles the n==0 case. - */ - if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)"); - return; - } - - supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer); - usedBufferMask = 0x0; - - /* complicated error checking... */ - for (output = 0; output < n; output++) { - if (buffers[output] == GL_NONE) { - destMask[output] = 0x0; - } - else { - destMask[output] = draw_buffer_enum_to_bitmask(buffers[output]); - if (destMask[output] == BAD_MASK - || _mesa_bitcount(destMask[output]) > 1) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)"); - return; - } - destMask[output] &= supportedMask; - if (destMask[output] == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawBuffersARB(unsupported buffer)"); - return; - } - if (destMask[output] & usedBufferMask) { - /* can't specify a dest buffer more than once! */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawBuffersARB(duplicated buffer)"); - return; - } - - /* update bitmask */ - usedBufferMask |= destMask[output]; - } - } - - /* OK, if we get here, there were no errors so set the new state */ - _mesa_drawbuffers(ctx, n, buffers, destMask); - - /* - * Call device driver function. Note that n can be equal to 0, - * in which case we don't want to reference buffers[0], which - * may not be valid. - */ - if (ctx->Driver.DrawBuffers) - ctx->Driver.DrawBuffers(ctx, n, buffers); - else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE); -} - - -/** - * Helper function to set the GL_DRAW_BUFFER state in the context and - * current FBO. Called via glDrawBuffer(), glDrawBuffersARB() - * - * All error checking will have been done prior to calling this function - * so nothing should go wrong at this point. - * - * \param ctx current context - * \param n number of color outputs to set - * \param buffers array[n] of colorbuffer names, like GL_LEFT. - * \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the - * colorbuffer names. (i.e. GL_FRONT_AND_BACK => - * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - */ -void -_mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, - const GLbitfield *destMask) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - GLbitfield mask[MAX_DRAW_BUFFERS]; - GLboolean newState = GL_FALSE; - - if (!destMask) { - /* compute destMask values now */ - const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb); - GLuint output; - for (output = 0; output < n; output++) { - mask[output] = draw_buffer_enum_to_bitmask(buffers[output]); - ASSERT(mask[output] != BAD_MASK); - mask[output] &= supportedMask; - } - destMask = mask; - } - - /* - * If n==1, destMask[0] may have up to four bits set. - * Otherwise, destMask[x] can only have one bit set. - */ - if (n == 1) { - GLuint count = 0, destMask0 = destMask[0]; - while (destMask0) { - GLint bufIndex = _mesa_ffs(destMask0) - 1; - if (fb->_ColorDrawBufferIndexes[count] != bufIndex) { - fb->_ColorDrawBufferIndexes[count] = bufIndex; - newState = GL_TRUE; - } - count++; - destMask0 &= ~(1 << bufIndex); - } - fb->ColorDrawBuffer[0] = buffers[0]; - if (fb->_NumColorDrawBuffers != count) { - fb->_NumColorDrawBuffers = count; - newState = GL_TRUE; - } - } - else { - GLuint buf, count = 0; - for (buf = 0; buf < n; buf++ ) { - if (destMask[buf]) { - GLint bufIndex = _mesa_ffs(destMask[buf]) - 1; - /* only one bit should be set in the destMask[buf] field */ - ASSERT(_mesa_bitcount(destMask[buf]) == 1); - if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { - fb->_ColorDrawBufferIndexes[buf] = bufIndex; - newState = GL_TRUE; - } - fb->ColorDrawBuffer[buf] = buffers[buf]; - count = buf + 1; - } - else { - if (fb->_ColorDrawBufferIndexes[buf] != -1) { - fb->_ColorDrawBufferIndexes[buf] = -1; - newState = GL_TRUE; - } - } - } - /* set remaining outputs to -1 (GL_NONE) */ - while (buf < ctx->Const.MaxDrawBuffers) { - if (fb->_ColorDrawBufferIndexes[buf] != -1) { - fb->_ColorDrawBufferIndexes[buf] = -1; - newState = GL_TRUE; - } - fb->ColorDrawBuffer[buf] = GL_NONE; - buf++; - } - fb->_NumColorDrawBuffers = count; - } - - if (fb->Name == 0) { - /* also set context drawbuffer state */ - GLuint buf; - for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { - if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) { - ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf]; - newState = GL_TRUE; - } - } - } - - if (newState) - FLUSH_VERTICES(ctx, _NEW_BUFFERS); -} - - -/** - * Like \sa _mesa_drawbuffers(), this is a helper function for setting - * GL_READ_BUFFER state in the context and current FBO. - * \param ctx the rendering context - * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc. - * \param bufferIndex the numerical index corresponding to 'buffer' - */ -void -_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex) -{ - struct gl_framebuffer *fb = ctx->ReadBuffer; - - if (fb->Name == 0) { - /* Only update the per-context READ_BUFFER state if we're bound to - * a window-system framebuffer. - */ - ctx->Pixel.ReadBuffer = buffer; - } - - fb->ColorReadBuffer = buffer; - fb->_ColorReadBufferIndex = bufferIndex; - - ctx->NewState |= _NEW_BUFFERS; -} - - - -/** - * Called by glReadBuffer to set the source renderbuffer for reading pixels. - * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - */ -void GLAPIENTRY -_mesa_ReadBuffer(GLenum buffer) -{ - struct gl_framebuffer *fb; - GLbitfield supportedMask; - GLint srcBuffer; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - - fb = ctx->ReadBuffer; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - - if (fb->Name > 0 && buffer == GL_NONE) { - /* This is legal for user-created framebuffer objects */ - srcBuffer = -1; - } - else { - /* general case / window-system framebuffer */ - srcBuffer = read_buffer_enum_to_index(buffer); - if (srcBuffer == -1) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glReadBuffer(buffer=0x%x)", buffer); - return; - } - supportedMask = supported_buffer_bitmask(ctx, fb); - if (((1 << srcBuffer) & supportedMask) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadBuffer(buffer=0x%x)", buffer); - return; - } - } - - /* OK, all error checking has been completed now */ - - _mesa_readbuffer(ctx, buffer, srcBuffer); - ctx->NewState |= _NEW_BUFFERS; - - /* - * Call device driver function. - */ - if (ctx->Driver.ReadBuffer) - (*ctx->Driver.ReadBuffer)(ctx, buffer); -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file buffers.c + * glReadBuffer, DrawBuffer functions. + */ + + + +#include "glheader.h" +#include "buffers.h" +#include "colormac.h" +#include "context.h" +#include "enums.h" + + +#define BAD_MASK ~0u + + +/** + * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are + * available to the rendering context (for drawing or reading). + * This depends on the type of framebuffer. For window system framebuffers + * we look at the framebuffer's visual. But for user-create framebuffers we + * look at the number of supported color attachments. + * \param fb the framebuffer to draw to, or read from + * \return bitmask of BUFFER_BIT_* flags + */ +static GLbitfield +supported_buffer_bitmask(const struct gl_context *ctx, const struct gl_framebuffer *fb) +{ + GLbitfield mask = 0x0; + + if (fb->Name > 0) { + /* A user-created renderbuffer */ + GLuint i; + ASSERT(ctx->Extensions.EXT_framebuffer_object); + for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { + mask |= (BUFFER_BIT_COLOR0 << i); + } + } + else { + /* A window system framebuffer */ + GLint i; + mask = BUFFER_BIT_FRONT_LEFT; /* always have this */ + if (fb->Visual.stereoMode) { + mask |= BUFFER_BIT_FRONT_RIGHT; + if (fb->Visual.doubleBufferMode) { + mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; + } + } + else if (fb->Visual.doubleBufferMode) { + mask |= BUFFER_BIT_BACK_LEFT; + } + + for (i = 0; i < fb->Visual.numAuxBuffers; i++) { + mask |= (BUFFER_BIT_AUX0 << i); + } + } + + return mask; +} + + +/** + * Helper routine used by glDrawBuffer and glDrawBuffersARB. + * Given a GLenum naming one or more color buffers (such as + * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags. + */ +static GLbitfield +draw_buffer_enum_to_bitmask(GLenum buffer) +{ + switch (buffer) { + case GL_NONE: + return 0; + case GL_FRONT: + return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT; + case GL_BACK: + return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT; + case GL_RIGHT: + return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; + case GL_FRONT_RIGHT: + return BUFFER_BIT_FRONT_RIGHT; + case GL_BACK_RIGHT: + return BUFFER_BIT_BACK_RIGHT; + case GL_BACK_LEFT: + return BUFFER_BIT_BACK_LEFT; + case GL_FRONT_AND_BACK: + return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT + | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT; + case GL_LEFT: + return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT; + case GL_FRONT_LEFT: + return BUFFER_BIT_FRONT_LEFT; + case GL_AUX0: + return BUFFER_BIT_AUX0; + case GL_AUX1: + case GL_AUX2: + case GL_AUX3: + return 1 << BUFFER_COUNT; /* invalid, but not BAD_MASK */ + case GL_COLOR_ATTACHMENT0_EXT: + return BUFFER_BIT_COLOR0; + case GL_COLOR_ATTACHMENT1_EXT: + return BUFFER_BIT_COLOR1; + case GL_COLOR_ATTACHMENT2_EXT: + return BUFFER_BIT_COLOR2; + case GL_COLOR_ATTACHMENT3_EXT: + return BUFFER_BIT_COLOR3; + case GL_COLOR_ATTACHMENT4_EXT: + return BUFFER_BIT_COLOR4; + case GL_COLOR_ATTACHMENT5_EXT: + return BUFFER_BIT_COLOR5; + case GL_COLOR_ATTACHMENT6_EXT: + return BUFFER_BIT_COLOR6; + case GL_COLOR_ATTACHMENT7_EXT: + return BUFFER_BIT_COLOR7; + default: + /* error */ + return BAD_MASK; + } +} + + +/** + * Helper routine used by glReadBuffer. + * Given a GLenum naming a color buffer, return the index of the corresponding + * renderbuffer (a BUFFER_* value). + * return -1 for an invalid buffer. + */ +static GLint +read_buffer_enum_to_index(GLenum buffer) +{ + switch (buffer) { + case GL_FRONT: + return BUFFER_FRONT_LEFT; + case GL_BACK: + return BUFFER_BACK_LEFT; + case GL_RIGHT: + return BUFFER_FRONT_RIGHT; + case GL_FRONT_RIGHT: + return BUFFER_FRONT_RIGHT; + case GL_BACK_RIGHT: + return BUFFER_BACK_RIGHT; + case GL_BACK_LEFT: + return BUFFER_BACK_LEFT; + case GL_LEFT: + return BUFFER_FRONT_LEFT; + case GL_FRONT_LEFT: + return BUFFER_FRONT_LEFT; + case GL_AUX0: + return BUFFER_AUX0; + case GL_AUX1: + case GL_AUX2: + case GL_AUX3: + return BUFFER_COUNT; /* invalid, but not -1 */ + case GL_COLOR_ATTACHMENT0_EXT: + return BUFFER_COLOR0; + case GL_COLOR_ATTACHMENT1_EXT: + return BUFFER_COLOR1; + case GL_COLOR_ATTACHMENT2_EXT: + return BUFFER_COLOR2; + case GL_COLOR_ATTACHMENT3_EXT: + return BUFFER_COLOR3; + case GL_COLOR_ATTACHMENT4_EXT: + return BUFFER_COLOR4; + case GL_COLOR_ATTACHMENT5_EXT: + return BUFFER_COLOR5; + case GL_COLOR_ATTACHMENT6_EXT: + return BUFFER_COLOR6; + case GL_COLOR_ATTACHMENT7_EXT: + return BUFFER_COLOR7; + default: + /* error */ + return -1; + } +} + + +/** + * Called by glDrawBuffer(). + * Specify which renderbuffer(s) to draw into for the first color output. + * can name zero, one, two or four renderbuffers! + * \sa _mesa_DrawBuffersARB + * + * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc. + * + * Note that the behaviour of this function depends on whether the + * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or + * a user-created framebuffer object (Name!=0). + * In the former case, we update the per-context ctx->Color.DrawBuffer + * state var _and_ the FB's ColorDrawBuffer state. + * In the later case, we update the FB's ColorDrawBuffer state only. + * + * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the + * new FB is a window system FB, we need to re-update the FB's + * ColorDrawBuffer state to match the context. This is handled in + * _mesa_update_framebuffer(). + * + * See the GL_EXT_framebuffer_object spec for more info. + */ +void GLAPIENTRY +_mesa_DrawBuffer(GLenum buffer) +{ + GLbitfield destMask; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */ + + if (MESA_VERBOSE & VERBOSE_API) { + _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + } + + if (buffer == GL_NONE) { + destMask = 0x0; + } + else { + const GLbitfield supportedMask + = supported_buffer_bitmask(ctx, ctx->DrawBuffer); + destMask = draw_buffer_enum_to_bitmask(buffer); + if (destMask == BAD_MASK) { + /* totally bogus buffer */ + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer=0x%x)", buffer); + return; + } + destMask &= supportedMask; + if (destMask == 0x0) { + /* none of the named color buffers exist! */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffer(buffer=0x%x)", buffer); + return; + } + } + + /* if we get here, there's no error so set new state */ + _mesa_drawbuffers(ctx, 1, &buffer, &destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, 1, &buffer); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffer); +} + + +/** + * Called by glDrawBuffersARB; specifies the destination color renderbuffers + * for N fragment program color outputs. + * \sa _mesa_DrawBuffer + * \param n number of outputs + * \param buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the + * names cannot specify more than one buffer. For example, + * GL_FRONT_AND_BACK is illegal. + */ +void GLAPIENTRY +_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) +{ + GLint output; + GLbitfield usedBufferMask, supportedMask; + GLbitfield destMask[MAX_DRAW_BUFFERS]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + /* Turns out n==0 is a valid input that should not produce an error. + * The remaining code below correctly handles the n==0 case. + */ + if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)"); + return; + } + + supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer); + usedBufferMask = 0x0; + + /* complicated error checking... */ + for (output = 0; output < n; output++) { + if (buffers[output] == GL_NONE) { + destMask[output] = 0x0; + } + else { + destMask[output] = draw_buffer_enum_to_bitmask(buffers[output]); + if (destMask[output] == BAD_MASK + || _mesa_bitcount(destMask[output]) > 1) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)"); + return; + } + destMask[output] &= supportedMask; + if (destMask[output] == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffersARB(unsupported buffer)"); + return; + } + if (destMask[output] & usedBufferMask) { + /* can't specify a dest buffer more than once! */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffersARB(duplicated buffer)"); + return; + } + + /* update bitmask */ + usedBufferMask |= destMask[output]; + } + } + + /* OK, if we get here, there were no errors so set the new state */ + _mesa_drawbuffers(ctx, n, buffers, destMask); + + /* + * Call device driver function. Note that n can be equal to 0, + * in which case we don't want to reference buffers[0], which + * may not be valid. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, n, buffers); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE); +} + + +/** + * Helper function to set the GL_DRAW_BUFFER state in the context and + * current FBO. Called via glDrawBuffer(), glDrawBuffersARB() + * + * All error checking will have been done prior to calling this function + * so nothing should go wrong at this point. + * + * \param ctx current context + * \param n number of color outputs to set + * \param buffers array[n] of colorbuffer names, like GL_LEFT. + * \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the + * colorbuffer names. (i.e. GL_FRONT_AND_BACK => + * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). + */ +void +_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, + const GLbitfield *destMask) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + GLbitfield mask[MAX_DRAW_BUFFERS]; + GLboolean newState = GL_FALSE; + + if (!destMask) { + /* compute destMask values now */ + const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb); + GLuint output; + for (output = 0; output < n; output++) { + mask[output] = draw_buffer_enum_to_bitmask(buffers[output]); + ASSERT(mask[output] != BAD_MASK); + mask[output] &= supportedMask; + } + destMask = mask; + } + + /* + * If n==1, destMask[0] may have up to four bits set. + * Otherwise, destMask[x] can only have one bit set. + */ + if (n == 1) { + GLuint count = 0, destMask0 = destMask[0]; + while (destMask0) { + GLint bufIndex = _mesa_ffs(destMask0) - 1; + if (fb->_ColorDrawBufferIndexes[count] != bufIndex) { + fb->_ColorDrawBufferIndexes[count] = bufIndex; + newState = GL_TRUE; + } + count++; + destMask0 &= ~(1 << bufIndex); + } + fb->ColorDrawBuffer[0] = buffers[0]; + if (fb->_NumColorDrawBuffers != count) { + fb->_NumColorDrawBuffers = count; + newState = GL_TRUE; + } + } + else { + GLuint buf, count = 0; + for (buf = 0; buf < n; buf++ ) { + if (destMask[buf]) { + GLint bufIndex = _mesa_ffs(destMask[buf]) - 1; + /* only one bit should be set in the destMask[buf] field */ + ASSERT(_mesa_bitcount(destMask[buf]) == 1); + if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { + fb->_ColorDrawBufferIndexes[buf] = bufIndex; + newState = GL_TRUE; + } + fb->ColorDrawBuffer[buf] = buffers[buf]; + count = buf + 1; + } + else { + if (fb->_ColorDrawBufferIndexes[buf] != -1) { + fb->_ColorDrawBufferIndexes[buf] = -1; + newState = GL_TRUE; + } + } + } + /* set remaining outputs to -1 (GL_NONE) */ + while (buf < ctx->Const.MaxDrawBuffers) { + if (fb->_ColorDrawBufferIndexes[buf] != -1) { + fb->_ColorDrawBufferIndexes[buf] = -1; + newState = GL_TRUE; + } + fb->ColorDrawBuffer[buf] = GL_NONE; + buf++; + } + fb->_NumColorDrawBuffers = count; + } + + if (fb->Name == 0) { + /* also set context drawbuffer state */ + GLuint buf; + for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { + if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) { + ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf]; + newState = GL_TRUE; + } + } + } + + if (newState) + FLUSH_VERTICES(ctx, _NEW_BUFFERS); +} + + +/** + * Like \sa _mesa_drawbuffers(), this is a helper function for setting + * GL_READ_BUFFER state in the context and current FBO. + * \param ctx the rendering context + * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc. + * \param bufferIndex the numerical index corresponding to 'buffer' + */ +void +_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex) +{ + struct gl_framebuffer *fb = ctx->ReadBuffer; + + if (fb->Name == 0) { + /* Only update the per-context READ_BUFFER state if we're bound to + * a window-system framebuffer. + */ + ctx->Pixel.ReadBuffer = buffer; + } + + fb->ColorReadBuffer = buffer; + fb->_ColorReadBufferIndex = bufferIndex; + + ctx->NewState |= _NEW_BUFFERS; +} + + + +/** + * Called by glReadBuffer to set the source renderbuffer for reading pixels. + * \param mode color buffer such as GL_FRONT, GL_BACK, etc. + */ +void GLAPIENTRY +_mesa_ReadBuffer(GLenum buffer) +{ + struct gl_framebuffer *fb; + GLbitfield supportedMask; + GLint srcBuffer; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + fb = ctx->ReadBuffer; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + if (fb->Name > 0 && buffer == GL_NONE) { + /* This is legal for user-created framebuffer objects */ + srcBuffer = -1; + } + else { + /* general case / window-system framebuffer */ + srcBuffer = read_buffer_enum_to_index(buffer); + if (srcBuffer == -1) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glReadBuffer(buffer=0x%x)", buffer); + return; + } + supportedMask = supported_buffer_bitmask(ctx, fb); + if (((1 << srcBuffer) & supportedMask) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadBuffer(buffer=0x%x)", buffer); + return; + } + } + + /* OK, all error checking has been completed now */ + + _mesa_readbuffer(ctx, buffer, srcBuffer); + ctx->NewState |= _NEW_BUFFERS; + + /* + * Call device driver function. + */ + if (ctx->Driver.ReadBuffer) + (*ctx->Driver.ReadBuffer)(ctx, buffer); +} diff --git a/mesalib/src/mesa/main/buffers.h b/mesalib/src/mesa/main/buffers.h index 8a7e7b5c1..cf684c5fe 100644 --- a/mesalib/src/mesa/main/buffers.h +++ b/mesalib/src/mesa/main/buffers.h @@ -1,56 +1,57 @@ -/** - * \file buffers.h - * Frame buffer management functions declarations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef BUFFERS_H -#define BUFFERS_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_DrawBuffer( GLenum mode ); - -extern void GLAPIENTRY -_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers); - -extern void -_mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, - const GLbitfield *destMask); - -extern void -_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex); - -extern void GLAPIENTRY -_mesa_ReadBuffer( GLenum mode ); - - -#endif +/** + * \file buffers.h + * Frame buffer management functions declarations. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef BUFFERS_H +#define BUFFERS_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_DrawBuffer( GLenum mode ); + +extern void GLAPIENTRY +_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers); + +extern void +_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, + const GLbitfield *destMask); + +extern void +_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex); + +extern void GLAPIENTRY +_mesa_ReadBuffer( GLenum mode ); + + +#endif diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index 49d86b3b1..3edcbe884 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -1,504 +1,566 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file clear.c - * glClearColor, glClearIndex, glClear() functions. - */ - - - -#include "glheader.h" -#include "clear.h" -#include "context.h" -#include "colormac.h" -#include "enums.h" -#include "macros.h" -#include "state.h" - - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_ClearIndex( GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Color.ClearIndex == (GLuint) c) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ClearIndex = (GLuint) c; -} -#endif - - -/** - * Specify the clear values for the color buffers. - * - * \param red red color component. - * \param green green color component. - * \param blue blue color component. - * \param alpha alpha component. - * - * \sa glClearColor(). - * - * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a - * change, flushes the vertices and notifies the driver via the - * dd_function_table::ClearColor callback. - */ -void GLAPIENTRY -_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = CLAMP(red, 0.0F, 1.0F); - tmp[1] = CLAMP(green, 0.0F, 1.0F); - tmp[2] = CLAMP(blue, 0.0F, 1.0F); - tmp[3] = CLAMP(alpha, 0.0F, 1.0F); - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4V(ctx->Color.ClearColor, tmp); - - if (ctx->Driver.ClearColor) { - /* it's OK to call glClearColor in CI mode but it should be a NOP */ - (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); - } -} - - -/** - * Clear buffers. - * - * \param mask bit-mask indicating the buffers to be cleared. - * - * Flushes the vertices and verifies the parameter. If __GLcontextRec::NewState - * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin, - * etc. If the rasterization mode is set to GL_RENDER then requests the driver - * to clear the buffers, via the dd_function_table::Clear callback. - */ -void GLAPIENTRY -_mesa_Clear( GLbitfield mask ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glClear 0x%x\n", mask); - - if (mask & ~(GL_COLOR_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_ACCUM_BUFFER_BIT)) { - /* invalid bit set */ - _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); - return; - } - - if (ctx->NewState) { - _mesa_update_state( ctx ); /* update _Xmin, etc */ - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glClear(incomplete framebuffer)"); - return; - } - - if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || - ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || - ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) - return; - - if (ctx->RenderMode == GL_RENDER) { - GLbitfield bufferMask; - - /* don't clear depth buffer if depth writing disabled */ - if (!ctx->Depth.Mask) - mask &= ~GL_DEPTH_BUFFER_BIT; - - /* Build the bitmask to send to device driver's Clear function. - * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 - * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the - * BUFFER_BIT_COLORn flags. - */ - bufferMask = 0; - if (mask & GL_COLOR_BUFFER_BIT) { - GLuint i; - for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { - bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); - } - } - - if ((mask & GL_DEPTH_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveDepthBuffer) { - bufferMask |= BUFFER_BIT_DEPTH; - } - - if ((mask & GL_STENCIL_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveStencilBuffer) { - bufferMask |= BUFFER_BIT_STENCIL; - } - - if ((mask & GL_ACCUM_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveAccumBuffer) { - bufferMask |= BUFFER_BIT_ACCUM; - } - - ASSERT(ctx->Driver.Clear); - ctx->Driver.Clear(ctx, bufferMask); - } -} - - -/** Returned by make_color_buffer_mask() for errors */ -#define INVALID_MASK ~0x0 - - -/** - * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of - * BUFFER_BIT_x values. - * Return INVALID_MASK if the drawbuffer value is invalid. - */ -static GLbitfield -make_color_buffer_mask(GLcontext *ctx, GLint drawbuffer) -{ - const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; - GLbitfield mask = 0x0; - - switch (drawbuffer) { - case GL_FRONT: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - break; - case GL_BACK: - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - case GL_LEFT: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - break; - case GL_RIGHT: - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - case GL_FRONT_AND_BACK: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - default: - if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) { - mask = INVALID_MASK; - } - else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) { - mask |= (BUFFER_BIT_COLOR0 << drawbuffer); - } - } - - return mask; -} - - - -/** - * New in GL 3.0 - * Clear signed integer color buffer or stencil buffer (not depth). - */ -void GLAPIENTRY -_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_STENCIL: - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", - drawbuffer); - return; - } - else { - /* Save current stencil clear value, set to 'value', do the - * stencil clear and restore the clear value. - * XXX in the future we may have a new ctx->Driver.ClearBuffer() - * hook instead. - */ - const GLuint clearSave = ctx->Stencil.Clear; - ctx->Stencil.Clear = *value; - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, *value); - ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL); - ctx->Stencil.Clear = clearSave; - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, clearSave); - } - break; - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - /* XXX note: we're putting the integer clear values into the - * floating point state var. This will not always work. We'll - * need a new ctx->Driver.ClearBuffer() hook.... - */ - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear unsigned integer color buffer (not depth, not stencil). - */ -void GLAPIENTRY -_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - /* XXX note: we're putting the uint clear values into the - * floating point state var. This will not always work. We'll - * need a new ctx->Driver.ClearBuffer() hook.... - */ - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear fixed-pt or float color buffer or depth buffer (not stencil). - */ -void GLAPIENTRY -_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_DEPTH: - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", - drawbuffer); - return; - } - else { - /* Save current depth clear value, set to 'value', do the - * depth clear and restore the clear value. - * XXX in the future we may have a new ctx->Driver.ClearBuffer() - * hook instead. - */ - const GLclampd clearSave = ctx->Depth.Clear; - ctx->Depth.Clear = *value; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, *value); - ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH); - ctx->Depth.Clear = clearSave; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, clearSave); - } - /* clear depth buffer to value */ - break; - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear depth/stencil buffer only. - */ -void GLAPIENTRY -_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (buffer != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } - - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)", - drawbuffer); - return; - } - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - { - /* save current clear values */ - const GLclampd clearDepthSave = ctx->Depth.Clear; - const GLuint clearStencilSave = ctx->Stencil.Clear; - - /* set new clear values */ - ctx->Depth.Clear = depth; - ctx->Stencil.Clear = stencil; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, depth); - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, stencil); - - /* clear buffers */ - ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - - /* restore */ - ctx->Depth.Clear = clearDepthSave; - ctx->Stencil.Clear = clearStencilSave; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, clearDepthSave); - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, clearStencilSave); - } -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file clear.c + * glClearColor, glClearIndex, glClear() functions. + */ + + + +#include "glheader.h" +#include "clear.h" +#include "context.h" +#include "colormac.h" +#include "enums.h" +#include "macros.h" +#include "state.h" + + + +#if _HAVE_FULL_GL +void GLAPIENTRY +_mesa_ClearIndex( GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Color.ClearIndex == (GLuint) c) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.ClearIndex = (GLuint) c; +} +#endif + + +/** + * Specify the clear values for the color buffers. + * + * \param red red color component. + * \param green green color component. + * \param blue blue color component. + * \param alpha alpha component. + * + * \sa glClearColor(). + * + * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a + * change, flushes the vertices and notifies the driver via the + * dd_function_table::ClearColor callback. + */ +void GLAPIENTRY +_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = CLAMP(red, 0.0F, 1.0F); + tmp[1] = CLAMP(green, 0.0F, 1.0F); + tmp[2] = CLAMP(blue, 0.0F, 1.0F); + tmp[3] = CLAMP(alpha, 0.0F, 1.0F); + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + COPY_4V(ctx->Color.ClearColor, tmp); + + if (ctx->Driver.ClearColor) { + /* it's OK to call glClearColor in CI mode but it should be a NOP */ + (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); + } +} + + +/** + * GL_EXT_texture_integer + */ +void GLAPIENTRY +_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = (GLfloat) r; + tmp[1] = (GLfloat) g; + tmp[2] = (GLfloat) b; + tmp[3] = (GLfloat) a; + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + + /* XXX we should eventually have a float/int/uint union for + * the ctx->Color.ClearColor state. + */ + COPY_4V(ctx->Color.ClearColor, tmp); + + if (ctx->Driver.ClearColor) { + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + } +} + + +/** + * GL_EXT_texture_integer + */ +void GLAPIENTRY +_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = (GLfloat) r; + tmp[1] = (GLfloat) g; + tmp[2] = (GLfloat) b; + tmp[3] = (GLfloat) a; + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + + /* XXX we should eventually have a float/int/uint union for + * the ctx->Color.ClearColor state. + */ + COPY_4V(ctx->Color.ClearColor, tmp); + + if (ctx->Driver.ClearColor) { + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + } +} + + +/** + * Clear buffers. + * + * \param mask bit-mask indicating the buffers to be cleared. + * + * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState + * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin, + * etc. If the rasterization mode is set to GL_RENDER then requests the driver + * to clear the buffers, via the dd_function_table::Clear callback. + */ +void GLAPIENTRY +_mesa_Clear( GLbitfield mask ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glClear 0x%x\n", mask); + + if (mask & ~(GL_COLOR_BUFFER_BIT | + GL_DEPTH_BUFFER_BIT | + GL_STENCIL_BUFFER_BIT | + GL_ACCUM_BUFFER_BIT)) { + /* invalid bit set */ + _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); + return; + } + + if (ctx->NewState) { + _mesa_update_state( ctx ); /* update _Xmin, etc */ + } + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glClear(incomplete framebuffer)"); + return; + } + + if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || + ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || + ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) + return; + + if (ctx->RenderMode == GL_RENDER) { + GLbitfield bufferMask; + + /* don't clear depth buffer if depth writing disabled */ + if (!ctx->Depth.Mask) + mask &= ~GL_DEPTH_BUFFER_BIT; + + /* Build the bitmask to send to device driver's Clear function. + * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 + * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the + * BUFFER_BIT_COLORn flags. + */ + bufferMask = 0; + if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; + for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { + bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); + } + } + + if ((mask & GL_DEPTH_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveDepthBuffer) { + bufferMask |= BUFFER_BIT_DEPTH; + } + + if ((mask & GL_STENCIL_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveStencilBuffer) { + bufferMask |= BUFFER_BIT_STENCIL; + } + + if ((mask & GL_ACCUM_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveAccumBuffer) { + bufferMask |= BUFFER_BIT_ACCUM; + } + + ASSERT(ctx->Driver.Clear); + ctx->Driver.Clear(ctx, bufferMask); + } +} + + +/** Returned by make_color_buffer_mask() for errors */ +#define INVALID_MASK ~0x0 + + +/** + * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of + * BUFFER_BIT_x values. + * Return INVALID_MASK if the drawbuffer value is invalid. + */ +static GLbitfield +make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer) +{ + const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; + GLbitfield mask = 0x0; + + switch (drawbuffer) { + case GL_FRONT: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + break; + case GL_BACK: + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + case GL_LEFT: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + break; + case GL_RIGHT: + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + case GL_FRONT_AND_BACK: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + default: + if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) { + mask = INVALID_MASK; + } + else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) { + mask |= (BUFFER_BIT_COLOR0 << drawbuffer); + } + } + + return mask; +} + + + +/** + * New in GL 3.0 + * Clear signed integer color buffer or stencil buffer (not depth). + */ +void GLAPIENTRY +_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_STENCIL: + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", + drawbuffer); + return; + } + else { + /* Save current stencil clear value, set to 'value', do the + * stencil clear and restore the clear value. + * XXX in the future we may have a new ctx->Driver.ClearBuffer() + * hook instead. + */ + const GLuint clearSave = ctx->Stencil.Clear; + ctx->Stencil.Clear = *value; + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, *value); + ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL); + ctx->Stencil.Clear = clearSave; + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, clearSave); + } + break; + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + /* XXX note: we're putting the integer clear values into the + * floating point state var. This will not always work. We'll + * need a new ctx->Driver.ClearBuffer() hook.... + */ + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear unsigned integer color buffer (not depth, not stencil). + */ +void GLAPIENTRY +_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + /* XXX note: we're putting the uint clear values into the + * floating point state var. This will not always work. We'll + * need a new ctx->Driver.ClearBuffer() hook.... + */ + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear fixed-pt or float color buffer or depth buffer (not stencil). + */ +void GLAPIENTRY +_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_DEPTH: + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", + drawbuffer); + return; + } + else { + /* Save current depth clear value, set to 'value', do the + * depth clear and restore the clear value. + * XXX in the future we may have a new ctx->Driver.ClearBuffer() + * hook instead. + */ + const GLclampd clearSave = ctx->Depth.Clear; + ctx->Depth.Clear = *value; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, *value); + ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH); + ctx->Depth.Clear = clearSave; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, clearSave); + } + /* clear depth buffer to value */ + break; + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear depth/stencil buffer only. + */ +void GLAPIENTRY +_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (buffer != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } + + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)", + drawbuffer); + return; + } + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + { + /* save current clear values */ + const GLclampd clearDepthSave = ctx->Depth.Clear; + const GLuint clearStencilSave = ctx->Stencil.Clear; + + /* set new clear values */ + ctx->Depth.Clear = depth; + ctx->Stencil.Clear = stencil; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, depth); + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, stencil); + + /* clear buffers */ + ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); + + /* restore */ + ctx->Depth.Clear = clearDepthSave; + ctx->Stencil.Clear = clearStencilSave; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, clearDepthSave); + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, clearStencilSave); + } +} diff --git a/mesalib/src/mesa/main/clear.h b/mesalib/src/mesa/main/clear.h index 6657370c4..d3d64fd62 100644 --- a/mesalib/src/mesa/main/clear.h +++ b/mesalib/src/mesa/main/clear.h @@ -1,57 +1,64 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef CLEAR_H -#define CLEAR_H - - -#include "glheader.h" - - -extern void GLAPIENTRY -_mesa_ClearIndex( GLfloat c ); - -extern void GLAPIENTRY -_mesa_ClearColor( GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ); - -extern void GLAPIENTRY -_mesa_Clear( GLbitfield mask ); - - -extern void GLAPIENTRY -_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value); - -extern void GLAPIENTRY -_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value); - -extern void GLAPIENTRY -_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value); - -extern void GLAPIENTRY -_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil); - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef CLEAR_H +#define CLEAR_H + + +#include "glheader.h" + + +extern void GLAPIENTRY +_mesa_ClearIndex( GLfloat c ); + +extern void GLAPIENTRY +_mesa_ClearColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +extern void GLAPIENTRY +_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a); + +extern void GLAPIENTRY +_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a); + + +extern void GLAPIENTRY +_mesa_Clear( GLbitfield mask ); + + +extern void GLAPIENTRY +_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value); + +extern void GLAPIENTRY +_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value); + +extern void GLAPIENTRY +_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value); + +extern void GLAPIENTRY +_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil); + +#endif diff --git a/mesalib/src/mesa/main/clip.c b/mesalib/src/mesa/main/clip.c index 96c80e6ef..bec04de72 100644 --- a/mesalib/src/mesa/main/clip.c +++ b/mesalib/src/mesa/main/clip.c @@ -1,159 +1,116 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "clip.h" -#include "context.h" -#include "macros.h" -#include "mtypes.h" - -#include "math/m_matrix.h" - - - -/**********************************************************************/ -/* Get/Set User clip-planes. */ -/**********************************************************************/ - - - -void GLAPIENTRY -_mesa_ClipPlane( GLenum plane, const GLdouble *eq ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint p; - GLfloat equation[4]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - p = (GLint) plane - (GLint) GL_CLIP_PLANE0; - if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { - _mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" ); - return; - } - - equation[0] = (GLfloat) eq[0]; - equation[1] = (GLfloat) eq[1]; - equation[2] = (GLfloat) eq[2]; - equation[3] = (GLfloat) eq[3]; - - /* - * The equation is transformed by the transpose of the inverse of the - * current modelview matrix and stored in the resulting eye coordinates. - * - * KW: Eqn is then transformed to the current clip space, where user - * clipping now takes place. The clip-space equations are recalculated - * whenever the projection matrix changes. - */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - _mesa_transform_vector( equation, equation, - ctx->ModelviewMatrixStack.Top->inv ); - - if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation)) - return; - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - COPY_4FV(ctx->Transform.EyeUserPlane[p], equation); - - /* Update derived state. This state also depends on the projection - * matrix, and is recalculated on changes to the projection matrix by - * code in _mesa_update_state(). - */ - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], - ctx->Transform.EyeUserPlane[p], - ctx->ProjectionMatrixStack.Top->inv ); - } - - if (ctx->Driver.ClipPlane) - ctx->Driver.ClipPlane( ctx, plane, equation ); -} - - -void GLAPIENTRY -_mesa_GetClipPlane( GLenum plane, GLdouble *equation ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint p; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - p = (GLint) (plane - GL_CLIP_PLANE0); - if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" ); - return; - } - - equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0]; - equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1]; - equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2]; - equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3]; -} - -void GLAPIENTRY -_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (cap) { - case GL_CULL_VERTEX_EYE_POSITION_EXT: - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - COPY_4FV(ctx->Transform.CullEyePos, v); - - _mesa_transform_vector( ctx->Transform.CullObjPos, - ctx->Transform.CullEyePos, - ctx->ModelviewMatrixStack.Top->inv ); - break; - - case GL_CULL_VERTEX_OBJECT_POSITION_EXT: - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - COPY_4FV(ctx->Transform.CullObjPos, v); - - _mesa_transform_vector( ctx->Transform.CullEyePos, - ctx->Transform.CullObjPos, - ctx->ModelviewMatrixStack.Top->m ); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glCullParameterfvEXT" ); - } -} - -void GLAPIENTRY -_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v) -{ - GLfloat f[4]; - - f[0] = (GLfloat)v[0]; - f[1] = (GLfloat)v[1]; - f[2] = (GLfloat)v[2]; - f[3] = (GLfloat)v[3]; - - _mesa_CullParameterfvEXT(cap, f); -} - +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "clip.h" +#include "context.h" +#include "macros.h" +#include "mtypes.h" + +#include "math/m_matrix.h" + + + +/**********************************************************************/ +/* Get/Set User clip-planes. */ +/**********************************************************************/ + + + +void GLAPIENTRY +_mesa_ClipPlane( GLenum plane, const GLdouble *eq ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint p; + GLfloat equation[4]; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + p = (GLint) plane - (GLint) GL_CLIP_PLANE0; + if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { + _mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" ); + return; + } + + equation[0] = (GLfloat) eq[0]; + equation[1] = (GLfloat) eq[1]; + equation[2] = (GLfloat) eq[2]; + equation[3] = (GLfloat) eq[3]; + + /* + * The equation is transformed by the transpose of the inverse of the + * current modelview matrix and stored in the resulting eye coordinates. + * + * KW: Eqn is then transformed to the current clip space, where user + * clipping now takes place. The clip-space equations are recalculated + * whenever the projection matrix changes. + */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + + _mesa_transform_vector( equation, equation, + ctx->ModelviewMatrixStack.Top->inv ); + + if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation)) + return; + + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + COPY_4FV(ctx->Transform.EyeUserPlane[p], equation); + + /* Update derived state. This state also depends on the projection + * matrix, and is recalculated on changes to the projection matrix by + * code in _mesa_update_state(). + */ + if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { + if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) + _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); + + _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], + ctx->Transform.EyeUserPlane[p], + ctx->ProjectionMatrixStack.Top->inv ); + } + + if (ctx->Driver.ClipPlane) + ctx->Driver.ClipPlane( ctx, plane, equation ); +} + + +void GLAPIENTRY +_mesa_GetClipPlane( GLenum plane, GLdouble *equation ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint p; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + p = (GLint) (plane - GL_CLIP_PLANE0); + if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" ); + return; + } + + equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0]; + equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1]; + equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2]; + equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3]; +} diff --git a/mesalib/src/mesa/main/clip.h b/mesalib/src/mesa/main/clip.h index ac472d66e..bba16e11c 100644 --- a/mesalib/src/mesa/main/clip.h +++ b/mesalib/src/mesa/main/clip.h @@ -1,49 +1,42 @@ -/** - * \file clip.h - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef CLIP_H -#define CLIP_H - -#include "glheader.h" - -extern void GLAPIENTRY -_mesa_ClipPlane( GLenum plane, const GLdouble *equation ); - -extern void GLAPIENTRY -_mesa_GetClipPlane( GLenum plane, GLdouble *equation ); - -extern void GLAPIENTRY -_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v); - -extern void GLAPIENTRY -_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v); - - -#endif +/** + * \file clip.h + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef CLIP_H +#define CLIP_H + +#include "glheader.h" + +extern void GLAPIENTRY +_mesa_ClipPlane( GLenum plane, const GLdouble *equation ); + +extern void GLAPIENTRY +_mesa_GetClipPlane( GLenum plane, GLdouble *equation ); + +#endif diff --git a/mesalib/src/mesa/main/colormac.h b/mesalib/src/mesa/main/colormac.h index 245fb658b..995183aeb 100644 --- a/mesalib/src/mesa/main/colormac.h +++ b/mesalib/src/mesa/main/colormac.h @@ -1,228 +1,235 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file colormac.h - * Color-related macros - */ - - -#ifndef COLORMAC_H -#define COLORMAC_H - - -#include "config.h" -#include "macros.h" -#include "mtypes.h" - - -/** \def BYTE_TO_CHAN - * Convert from GLbyte to GLchan */ - -/** \def UBYTE_TO_CHAN - * Convert from GLubyte to GLchan */ - -/** \def SHORT_TO_CHAN - * Convert from GLshort to GLchan */ - -/** \def USHORT_TO_CHAN - * Convert from GLushort to GLchan */ - -/** \def INT_TO_CHAN - * Convert from GLint to GLchan */ - -/** \def UINT_TO_CHAN - * Convert from GLuint to GLchan */ - -/** \def CHAN_TO_UBYTE - * Convert from GLchan to GLubyte */ - -/** \def CHAN_TO_FLOAT - * Convert from GLchan to GLfloat */ - -/** \def CLAMPED_FLOAT_TO_CHAN - * Convert from GLclampf to GLchan */ - -/** \def UNCLAMPED_FLOAT_TO_CHAN - * Convert from GLfloat to GLchan */ - -/** \def COPY_CHAN4 - * Copy a GLchan[4] array */ - -#if CHAN_BITS == 8 - -#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b)) -#define UBYTE_TO_CHAN(b) (b) -#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7)) -#define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8)) -#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23)) -#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24)) - -#define CHAN_TO_UBYTE(c) (c) -#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) - -#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) - -#elif CHAN_BITS == 16 - -#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516)) -#define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b))) -#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s)) -#define USHORT_TO_CHAN(s) (s) -#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15)) -#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16)) - -#define CHAN_TO_UBYTE(c) ((c) >> 8) -#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f) - -#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) - -#elif CHAN_BITS == 32 - -/* XXX floating-point color channels not fully thought-out */ -#define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F))) -#define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F))) -#define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F))) -#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F))) -#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F))) -#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F))) - -#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c) -#define CHAN_TO_FLOAT(c) (c) - -#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) -#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) - -#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) - -#else - -#error unexpected CHAN_BITS size - -#endif - - -/** - * Convert 3 channels at once. - * - * \param dst pointer to destination GLchan[3] array. - * \param f pointer to source GLfloat[3] array. - * - * \sa #UNCLAMPED_FLOAT_TO_CHAN. - */ -#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \ -do { \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ -} while (0) - - -/** - * Convert 4 channels at once. - * - * \param dst pointer to destination GLchan[4] array. - * \param f pointer to source GLfloat[4] array. - * - * \sa #UNCLAMPED_FLOAT_TO_CHAN. - */ -#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \ -do { \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ - UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \ -} while (0) - - - -/** - * \name Generic color packing macros. All inputs should be GLubytes. - * - * \todo We may move these into texstore.h at some point. - */ -/*@{*/ - -#define PACK_COLOR_8888( X, Y, Z, W ) \ - (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) - -#define PACK_COLOR_8888_REV( X, Y, Z, W ) \ - (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X)) - -#define PACK_COLOR_888( X, Y, Z ) \ - (((X) << 16) | ((Y) << 8) | (Z)) - -#define PACK_COLOR_565( X, Y, Z ) \ - ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) - -#define PACK_COLOR_565_REV( X, Y, Z ) \ - (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5)) - -#define PACK_COLOR_5551( R, G, B, A ) \ - ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \ - ((A) ? 1 : 0)) - -#define PACK_COLOR_1555( A, B, G, R ) \ - ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ - ((A) ? 0x8000 : 0)) - -#define PACK_COLOR_1555_REV( A, B, G, R ) \ - ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \ - ((A) ? 0x80 : 0)) - -#define PACK_COLOR_4444( R, G, B, A ) \ - ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) - -#define PACK_COLOR_4444_REV( R, G, B, A ) \ - ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4)) - -#define PACK_COLOR_88( L, A ) \ - (((L) << 8) | (A)) - -#define PACK_COLOR_88_REV( L, A ) \ - (((A) << 8) | (L)) - -#define PACK_COLOR_1616( L, A ) \ - (((L) << 16) | (A)) - -#define PACK_COLOR_1616_REV( L, A ) \ - (((A) << 16) | (L)) - -#define PACK_COLOR_332( R, G, B ) \ - (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6)) - -#define PACK_COLOR_233( B, G, R ) \ - (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5)) - -/*@}*/ - - -#endif /* COLORMAC_H */ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file colormac.h + * Color-related macros + */ + + +#ifndef COLORMAC_H +#define COLORMAC_H + + +#include "config.h" +#include "macros.h" +#include "mtypes.h" + + +/** \def BYTE_TO_CHAN + * Convert from GLbyte to GLchan */ + +/** \def UBYTE_TO_CHAN + * Convert from GLubyte to GLchan */ + +/** \def SHORT_TO_CHAN + * Convert from GLshort to GLchan */ + +/** \def USHORT_TO_CHAN + * Convert from GLushort to GLchan */ + +/** \def INT_TO_CHAN + * Convert from GLint to GLchan */ + +/** \def UINT_TO_CHAN + * Convert from GLuint to GLchan */ + +/** \def CHAN_TO_UBYTE + * Convert from GLchan to GLubyte */ + +/** \def CHAN_TO_FLOAT + * Convert from GLchan to GLfloat */ + +/** \def CLAMPED_FLOAT_TO_CHAN + * Convert from GLclampf to GLchan */ + +/** \def UNCLAMPED_FLOAT_TO_CHAN + * Convert from GLfloat to GLchan */ + +/** \def COPY_CHAN4 + * Copy a GLchan[4] array */ + +#if CHAN_BITS == 8 + +#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b)) +#define UBYTE_TO_CHAN(b) (b) +#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7)) +#define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8)) +#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23)) +#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24)) + +#define CHAN_TO_UBYTE(c) (c) +#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c) + +#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f) + +#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC) + +#elif CHAN_BITS == 16 + +#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516)) +#define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b))) +#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s)) +#define USHORT_TO_CHAN(s) (s) +#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15)) +#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16)) + +#define CHAN_TO_UBYTE(c) ((c) >> 8) +#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF))) + +#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f) + +#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) + +#elif CHAN_BITS == 32 + +/* XXX floating-point color channels not fully thought-out */ +#define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F))) +#define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F))) +#define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F))) +#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F))) +#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F))) +#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F))) + +#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c) +#define CHAN_TO_FLOAT(c) (c) + +#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f) +#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f) + +#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC) + +#else + +#error unexpected CHAN_BITS size + +#endif + + +/** + * Convert 3 channels at once. + * + * \param dst pointer to destination GLchan[3] array. + * \param f pointer to source GLfloat[3] array. + * + * \sa #UNCLAMPED_FLOAT_TO_CHAN. + */ +#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \ +do { \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ +} while (0) + + +/** + * Convert 4 channels at once. + * + * \param dst pointer to destination GLchan[4] array. + * \param f pointer to source GLfloat[4] array. + * + * \sa #UNCLAMPED_FLOAT_TO_CHAN. + */ +#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \ +do { \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \ + UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \ +} while (0) + + + +/** + * \name Generic color packing macros. All inputs should be GLubytes. + * + * \todo We may move these into texstore.h at some point. + */ +/*@{*/ + +#define PACK_COLOR_8888( X, Y, Z, W ) \ + (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W)) + +#define PACK_COLOR_8888_REV( X, Y, Z, W ) \ + (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X)) + +#define PACK_COLOR_888( X, Y, Z ) \ + (((X) << 16) | ((Y) << 8) | (Z)) + +#define PACK_COLOR_565( X, Y, Z ) \ + ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3)) + +#define PACK_COLOR_565_REV( X, Y, Z ) \ + (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5)) + +#define PACK_COLOR_5551( R, G, B, A ) \ + ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \ + ((A) ? 1 : 0)) + +#define PACK_COLOR_1555( A, B, G, R ) \ + ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ + ((A) ? 0x8000 : 0)) + +#define PACK_COLOR_1555_REV( A, B, G, R ) \ + ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \ + ((A) ? 0x80 : 0)) + +#define PACK_COLOR_2101010( A, B, G, R ) \ + (((B) << 22) | ((G) << 12) | ((R) << 2) | \ + (((A) & 0xc0) << 24)) + +#define PACK_COLOR_4444( R, G, B, A ) \ + ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) + +#define PACK_COLOR_4444_REV( R, G, B, A ) \ + ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4)) + +#define PACK_COLOR_44( L, A ) \ + (((L) & 0xf0) | (((A) & 0xf0) >> 4)) + +#define PACK_COLOR_88( L, A ) \ + (((L) << 8) | (A)) + +#define PACK_COLOR_88_REV( L, A ) \ + (((A) << 8) | (L)) + +#define PACK_COLOR_1616( L, A ) \ + (((L) << 16) | (A)) + +#define PACK_COLOR_1616_REV( L, A ) \ + (((A) << 16) | (L)) + +#define PACK_COLOR_332( R, G, B ) \ + (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6)) + +#define PACK_COLOR_233( B, G, R ) \ + (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5)) + +/*@}*/ + + +#endif /* COLORMAC_H */ diff --git a/mesalib/src/mesa/main/colortab.c b/mesalib/src/mesa/main/colortab.c index 52d5badf3..a18a67ce2 100644 --- a/mesalib/src/mesa/main/colortab.c +++ b/mesalib/src/mesa/main/colortab.c @@ -1,1133 +1,932 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colortab.h" -#include "context.h" -#include "image.h" -#include "macros.h" -#include "state.h" -#include "teximage.h" -#include "texstate.h" -#include "main/dispatch.h" - - -#if FEATURE_colortable - - -/** - * Given an internalFormat token passed to glColorTable, - * return the corresponding base format. - * Return -1 if invalid token. - */ -static GLint -base_colortab_format( GLenum format ) -{ - switch (format) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - return -1; /* error */ - } -} - - - -/** - * Examine table's format and set the component sizes accordingly. - */ -static void -set_component_sizes( struct gl_color_table *table ) -{ - /* assuming the ubyte table */ - const GLubyte sz = 8; - - switch (table->_BaseFormat) { - case GL_ALPHA: - table->RedSize = 0; - table->GreenSize = 0; - table->BlueSize = 0; - table->AlphaSize = sz; - table->IntensitySize = 0; - table->LuminanceSize = 0; - break; - case GL_LUMINANCE: - table->RedSize = 0; - table->GreenSize = 0; - table->BlueSize = 0; - table->AlphaSize = 0; - table->IntensitySize = 0; - table->LuminanceSize = sz; - break; - case GL_LUMINANCE_ALPHA: - table->RedSize = 0; - table->GreenSize = 0; - table->BlueSize = 0; - table->AlphaSize = sz; - table->IntensitySize = 0; - table->LuminanceSize = sz; - break; - case GL_INTENSITY: - table->RedSize = 0; - table->GreenSize = 0; - table->BlueSize = 0; - table->AlphaSize = 0; - table->IntensitySize = sz; - table->LuminanceSize = 0; - break; - case GL_RGB: - table->RedSize = sz; - table->GreenSize = sz; - table->BlueSize = sz; - table->AlphaSize = 0; - table->IntensitySize = 0; - table->LuminanceSize = 0; - break; - case GL_RGBA: - table->RedSize = sz; - table->GreenSize = sz; - table->BlueSize = sz; - table->AlphaSize = sz; - table->IntensitySize = 0; - table->LuminanceSize = 0; - break; - default: - _mesa_problem(NULL, "unexpected format in set_component_sizes"); - } -} - - - -/** - * Update/replace all or part of a color table. Helper function - * used by _mesa_ColorTable() and _mesa_ColorSubTable(). - * The table->Table buffer should already be allocated. - * \param start first entry to update - * \param count number of entries to update - * \param format format of user-provided table data - * \param type datatype of user-provided table data - * \param data user-provided table data - * \param [rgba]Scale - RGBA scale factors - * \param [rgba]Bias - RGBA bias factors - */ -static void -store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, - GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid *data, - GLfloat rScale, GLfloat rBias, - GLfloat gScale, GLfloat gBias, - GLfloat bScale, GLfloat bBias, - GLfloat aScale, GLfloat aBias) -{ - data = _mesa_map_validate_pbo_source(ctx, - 1, &ctx->Unpack, count, 1, 1, - format, type, data, - "glColor[Sub]Table"); - if (!data) - return; - - { - /* convert user-provided data to GLfloat values */ - GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4]; - GLfloat *tableF; - GLint i; - - _mesa_unpack_color_span_float(ctx, - count, /* number of pixels */ - table->_BaseFormat, /* dest format */ - tempTab, /* dest address */ - format, type, /* src format/type */ - data, /* src data */ - &ctx->Unpack, - IMAGE_CLAMP_BIT); /* transfer ops */ - - /* the destination */ - tableF = table->TableF; - - /* Apply scale & bias & clamp now */ - switch (table->_BaseFormat) { - case GL_INTENSITY: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F); - } - break; - case GL_LUMINANCE: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F); - } - break; - case GL_ALPHA: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F); - } - break; - case GL_LUMINANCE_ALPHA: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F); - tableF[j*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F); - } - break; - case GL_RGB: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F); - tableF[j*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F); - tableF[j*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F); - } - break; - case GL_RGBA: - for (i = 0; i < count; i++) { - GLuint j = start + i; - tableF[j*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F); - tableF[j*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F); - tableF[j*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F); - tableF[j*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F); - } - break; - default: - _mesa_problem(ctx, "Bad format in store_colortable_entries"); - return; - } - } - - /* update the ubyte table */ - { - const GLint comps = _mesa_components_in_format(table->_BaseFormat); - const GLfloat *tableF = table->TableF + start * comps; - GLubyte *tableUB = table->TableUB + start * comps; - GLint i; - for (i = 0; i < count * comps; i++) { - CLAMPED_FLOAT_TO_UBYTE(tableUB[i], tableF[i]); - } - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); -} - - - -void GLAPIENTRY -_mesa_ColorTable( GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid *data ) -{ - static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; - static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = NULL; - struct gl_color_table *table = NULL; - GLboolean proxy = GL_FALSE; - GLint baseFormat; - const GLfloat *scale = one, *bias = zero; - GLint comps; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ - - switch (target) { - case GL_SHARED_TEXTURE_PALETTE_EXT: - table = &ctx->Texture.Palette; - break; - case GL_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; - break; - case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; - proxy = GL_TRUE; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; - } - table = &(texUnit->ColorTable); - scale = ctx->Pixel.TextureColorTableScale; - bias = ctx->Pixel.TextureColorTableBias; - break; - case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; - } - table = &(texUnit->ProxyColorTable); - proxy = GL_TRUE; - break; - case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; - proxy = GL_TRUE; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; - break; - case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; - proxy = GL_TRUE; - break; - default: - /* try texture targets */ - { - struct gl_texture_object *texobj - = _mesa_select_tex_object(ctx, texUnit, target); - if (texobj) { - table = &texobj->Palette; - proxy = _mesa_is_proxy_texture(target); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; - } - } - } - - assert(table); - - if (!_mesa_is_legal_format_and_type(ctx, format, type) || - format == GL_INTENSITY) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)"); - return; - } - - baseFormat = base_colortab_format(internalFormat); - if (baseFormat < 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)"); - return; - } - - if (width < 0 || (width != 0 && !_mesa_is_pow_two(width))) { - /* error */ - if (proxy) { - table->Size = 0; - table->InternalFormat = (GLenum) 0; - table->_BaseFormat = (GLenum) 0; - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorTable(width=%d)", width); - } - return; - } - - if (width > (GLsizei) ctx->Const.MaxColorTableSize) { - if (proxy) { - table->Size = 0; - table->InternalFormat = (GLenum) 0; - table->_BaseFormat = (GLenum) 0; - } - else { - _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)"); - } - return; - } - - table->Size = width; - table->InternalFormat = internalFormat; - table->_BaseFormat = (GLenum) baseFormat; - - comps = _mesa_components_in_format(table->_BaseFormat); - assert(comps > 0); /* error should have been caught sooner */ - - if (!proxy) { - _mesa_free_colortable_data(table); - - if (width > 0) { - table->TableF = (GLfloat *) malloc(comps * width * sizeof(GLfloat)); - table->TableUB = (GLubyte *) malloc(comps * width * sizeof(GLubyte)); - - if (!table->TableF || !table->TableUB) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); - return; - } - - store_colortable_entries(ctx, table, - 0, width, /* start, count */ - format, type, data, - scale[0], bias[0], - scale[1], bias[1], - scale[2], bias[2], - scale[3], bias[3]); - } - } /* proxy */ - - /* do this after the table's Type and Format are set */ - set_component_sizes(table); - - if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { - /* texture object palette, texObj==NULL means the shared palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); - } - } - - ctx->NewState |= _NEW_PIXEL; -} - - - -void GLAPIENTRY -_mesa_ColorSubTable( GLenum target, GLsizei start, - GLsizei count, GLenum format, GLenum type, - const GLvoid *data ) -{ - static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; - static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = NULL; - struct gl_color_table *table = NULL; - const GLfloat *scale = one, *bias = zero; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_SHARED_TEXTURE_PALETTE_EXT: - table = &ctx->Texture.Palette; - break; - case GL_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); - return; - } - table = &(texUnit->ColorTable); - scale = ctx->Pixel.TextureColorTableScale; - bias = ctx->Pixel.TextureColorTableBias; - break; - case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; - break; - default: - /* try texture targets */ - texObj = _mesa_select_tex_object(ctx, texUnit, target); - if (texObj && !_mesa_is_proxy_texture(target)) { - table = &texObj->Palette; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); - return; - } - } - - assert(table); - - if (!_mesa_is_legal_format_and_type(ctx, format, type) || - format == GL_INTENSITY) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)"); - return; - } - - if (count < 1) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); - return; - } - - /* error should have been caught sooner */ - assert(_mesa_components_in_format(table->_BaseFormat) > 0); - - if (start + count > (GLint) table->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); - return; - } - - if (!table->TableF || !table->TableUB) { - /* a GL_OUT_OF_MEMORY error would have been recorded previously */ - return; - } - - store_colortable_entries(ctx, table, start, count, - format, type, data, - scale[0], bias[0], - scale[1], bias[1], - scale[2], bias[2], - scale[3], bias[3]); - - if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { - /* per-texture object palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); - } - } - - ctx->NewState |= _NEW_PIXEL; -} - - - -static void GLAPIENTRY -_mesa_CopyColorTable(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyColorTable( ctx, target, internalformat, x, y, width ); -} - - - -static void GLAPIENTRY -_mesa_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyColorSubTable( ctx, target, start, x, y, width ); -} - - - -static void GLAPIENTRY -_mesa_GetColorTable( GLenum target, GLenum format, - GLenum type, GLvoid *data ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_color_table *table = NULL; - GLfloat rgba[MAX_COLOR_TABLE_SIZE][4]; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - switch (target) { - case GL_SHARED_TEXTURE_PALETTE_EXT: - table = &ctx->Texture.Palette; - break; - case GL_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); - return; - } - table = &(texUnit->ColorTable); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; - break; - default: - /* try texture targets */ - { - struct gl_texture_object *texobj - = _mesa_select_tex_object(ctx, texUnit, target); - if (texobj && !_mesa_is_proxy_texture(target)) { - table = &texobj->Palette; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); - return; - } - } - } - - ASSERT(table); - - if (table->Size <= 0) { - return; - } - - switch (table->_BaseFormat) { - case GL_ALPHA: - { - GLuint i; - for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = 0; - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = table->TableF[i]; - } - } - break; - case GL_LUMINANCE: - { - GLuint i; - for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = table->TableF[i]; - rgba[i][ACOMP] = 1.0F; - } - } - break; - case GL_LUMINANCE_ALPHA: - { - GLuint i; - for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = table->TableF[i*2+0]; - rgba[i][ACOMP] = table->TableF[i*2+1]; - } - } - break; - case GL_INTENSITY: - { - GLuint i; - for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = - rgba[i][ACOMP] = table->TableF[i]; - } - } - break; - case GL_RGB: - { - GLuint i; - for (i = 0; i < table->Size; i++) { - rgba[i][RCOMP] = table->TableF[i*3+0]; - rgba[i][GCOMP] = table->TableF[i*3+1]; - rgba[i][BCOMP] = table->TableF[i*3+2]; - rgba[i][ACOMP] = 1.0F; - } - } - break; - case GL_RGBA: - memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat)); - break; - default: - _mesa_problem(ctx, "bad table format in glGetColorTable"); - return; - } - - data = _mesa_map_validate_pbo_dest(ctx, - 1, &ctx->Pack, table->Size, 1, 1, - format, type, data, - "glGetColorTable"); - if (!data) - return; - - _mesa_pack_rgba_span_float(ctx, table->Size, rgba, - format, type, data, &ctx->Pack, 0x0); - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - - -static void GLAPIENTRY -_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GLfloat *scale, *bias; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_COLOR_TABLE_SGI: - scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - scale = ctx->Pixel.TextureColorTableScale; - bias = ctx->Pixel.TextureColorTableBias; - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; - bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); - return; - } - - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(scale, params); - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(bias, params); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; -} - - - -static void GLAPIENTRY -_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLfloat fparams[4]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { - /* four values */ - fparams[0] = (GLfloat) params[0]; - fparams[1] = (GLfloat) params[1]; - fparams[2] = (GLfloat) params[2]; - fparams[3] = (GLfloat) params[3]; - } - else { - /* one values */ - fparams[0] = (GLfloat) params[0]; - } - _mesa_ColorTableParameterfv(target, pname, fparams); -} - - - -static void GLAPIENTRY -_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_color_table *table = NULL; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_SHARED_TEXTURE_PALETTE_EXT: - table = &ctx->Texture.Palette; - break; - case GL_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]); - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]); - return; - } - break; - case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); - return; - } - table = &(texUnit->ColorTable); - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(params, ctx->Pixel.TextureColorTableScale); - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(params, ctx->Pixel.TextureColorTableBias); - return; - } - break; - case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); - return; - } - table = &(texUnit->ProxyColorTable); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]); - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]); - return; - } - break; - case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]); - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(params, ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]); - return; - } - break; - case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; - break; - default: - /* try texture targets */ - { - struct gl_texture_object *texobj - = _mesa_select_tex_object(ctx, texUnit, target); - if (texobj) { - table = &texobj->Palette; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameterfv(target)"); - return; - } - } - } - - assert(table); - - switch (pname) { - case GL_COLOR_TABLE_FORMAT: - *params = (GLfloat) table->InternalFormat; - break; - case GL_COLOR_TABLE_WIDTH: - *params = (GLfloat) table->Size; - break; - case GL_COLOR_TABLE_RED_SIZE: - *params = (GLfloat) table->RedSize; - break; - case GL_COLOR_TABLE_GREEN_SIZE: - *params = (GLfloat) table->GreenSize; - break; - case GL_COLOR_TABLE_BLUE_SIZE: - *params = (GLfloat) table->BlueSize; - break; - case GL_COLOR_TABLE_ALPHA_SIZE: - *params = (GLfloat) table->AlphaSize; - break; - case GL_COLOR_TABLE_LUMINANCE_SIZE: - *params = (GLfloat) table->LuminanceSize; - break; - case GL_COLOR_TABLE_INTENSITY_SIZE: - *params = (GLfloat) table->IntensitySize; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" ); - return; - } -} - - - -static void GLAPIENTRY -_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_color_table *table = NULL; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_SHARED_TEXTURE_PALETTE_EXT: - table = &ctx->Texture.Palette; - break; - case GL_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_PRECONVOLUTION]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; - params[0] = (GLint) scale[0]; - params[1] = (GLint) scale[1]; - params[2] = (GLint) scale[2]; - params[3] = (GLint) scale[3]; - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; - params[0] = (GLint) bias[0]; - params[1] = (GLint) bias[1]; - params[2] = (GLint) bias[2]; - params[3] = (GLint) bias[3]; - return; - } - break; - case GL_PROXY_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_PRECONVOLUTION]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); - return; - } - table = &(texUnit->ColorTable); - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0]; - params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1]; - params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2]; - params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3]; - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0]; - params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1]; - params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2]; - params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3]; - return; - } - break; - case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); - return; - } - table = &(texUnit->ProxyColorTable); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCONVOLUTION]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; - params[0] = (GLint) scale[0]; - params[1] = (GLint) scale[1]; - params[2] = (GLint) scale[2]; - params[3] = (GLint) scale[3]; - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - GLfloat *bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; - params[0] = (GLint) bias[0]; - params[1] = (GLint) bias[1]; - params[2] = (GLint) bias[2]; - params[3] = (GLint) bias[3]; - return; - } - break; - case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - GLfloat *scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; - params[0] = (GLint) scale[0]; - params[0] = (GLint) scale[1]; - params[0] = (GLint) scale[2]; - params[0] = (GLint) scale[3]; - return; - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - GLfloat *bias = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; - params[0] = (GLint) bias[0]; - params[1] = (GLint) bias[1]; - params[2] = (GLint) bias[2]; - params[3] = (GLint) bias[3]; - return; - } - break; - case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: - table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; - break; - default: - /* Try texture targets */ - { - struct gl_texture_object *texobj - = _mesa_select_tex_object(ctx, texUnit, target); - if (texobj) { - table = &texobj->Palette; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameteriv(target)"); - return; - } - } - } - - assert(table); - - switch (pname) { - case GL_COLOR_TABLE_FORMAT: - *params = table->InternalFormat; - break; - case GL_COLOR_TABLE_WIDTH: - *params = table->Size; - break; - case GL_COLOR_TABLE_RED_SIZE: - *params = table->RedSize; - break; - case GL_COLOR_TABLE_GREEN_SIZE: - *params = table->GreenSize; - break; - case GL_COLOR_TABLE_BLUE_SIZE: - *params = table->BlueSize; - break; - case GL_COLOR_TABLE_ALPHA_SIZE: - *params = table->AlphaSize; - break; - case GL_COLOR_TABLE_LUMINANCE_SIZE: - *params = table->LuminanceSize; - break; - case GL_COLOR_TABLE_INTENSITY_SIZE: - *params = table->IntensitySize; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); - return; - } -} - - -void -_mesa_init_colortable_dispatch(struct _glapi_table *disp) -{ - SET_ColorSubTable(disp, _mesa_ColorSubTable); - SET_ColorTable(disp, _mesa_ColorTable); - SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv); - SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv); - SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable); - SET_CopyColorTable(disp, _mesa_CopyColorTable); - SET_GetColorTable(disp, _mesa_GetColorTable); - SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv); - SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv); -} - - -#endif /* FEATURE_colortable */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - - -void -_mesa_init_colortable( struct gl_color_table *p ) -{ - p->TableF = NULL; - p->TableUB = NULL; - p->Size = 0; - p->InternalFormat = GL_RGBA; -} - - - -void -_mesa_free_colortable_data( struct gl_color_table *p ) -{ - if (p->TableF) { - free(p->TableF); - p->TableF = NULL; - } - if (p->TableUB) { - free(p->TableUB); - p->TableUB = NULL; - } -} - - -/* - * Initialize all colortables for a context. - */ -void -_mesa_init_colortables( GLcontext * ctx ) -{ - GLuint i; - for (i = 0; i < COLORTABLE_MAX; i++) { - _mesa_init_colortable(&ctx->ColorTable[i]); - _mesa_init_colortable(&ctx->ProxyColorTable[i]); - } -} - - -/* - * Free all colortable data for a context - */ -void -_mesa_free_colortables_data( GLcontext *ctx ) -{ - GLuint i; - for (i = 0; i < COLORTABLE_MAX; i++) { - _mesa_free_colortable_data(&ctx->ColorTable[i]); - _mesa_free_colortable_data(&ctx->ProxyColorTable[i]); - } -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colortab.h" +#include "context.h" +#include "image.h" +#include "macros.h" +#include "pack.h" +#include "state.h" +#include "teximage.h" +#include "texstate.h" +#include "main/dispatch.h" + + +#if FEATURE_colortable + + +/** + * Given an internalFormat token passed to glColorTable, + * return the corresponding base format. + * Return -1 if invalid token. + */ +static GLint +base_colortab_format( GLenum format ) +{ + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + return -1; /* error */ + } +} + + + +/** + * Examine table's format and set the component sizes accordingly. + */ +static void +set_component_sizes( struct gl_color_table *table ) +{ + /* assuming the ubyte table */ + const GLubyte sz = 8; + + switch (table->_BaseFormat) { + case GL_ALPHA: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = sz; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + case GL_LUMINANCE: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = sz; + break; + case GL_LUMINANCE_ALPHA: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = sz; + table->IntensitySize = 0; + table->LuminanceSize = sz; + break; + case GL_INTENSITY: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = sz; + table->LuminanceSize = 0; + break; + case GL_RGB: + table->RedSize = sz; + table->GreenSize = sz; + table->BlueSize = sz; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + case GL_RGBA: + table->RedSize = sz; + table->GreenSize = sz; + table->BlueSize = sz; + table->AlphaSize = sz; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + default: + _mesa_problem(NULL, "unexpected format in set_component_sizes"); + } +} + + + +/** + * Update/replace all or part of a color table. Helper function + * used by _mesa_ColorTable() and _mesa_ColorSubTable(). + * The table->Table buffer should already be allocated. + * \param start first entry to update + * \param count number of entries to update + * \param format format of user-provided table data + * \param type datatype of user-provided table data + * \param data user-provided table data + * \param [rgba]Scale - RGBA scale factors + * \param [rgba]Bias - RGBA bias factors + */ +static void +store_colortable_entries(struct gl_context *ctx, struct gl_color_table *table, + GLsizei start, GLsizei count, + GLenum format, GLenum type, const GLvoid *data, + GLfloat rScale, GLfloat rBias, + GLfloat gScale, GLfloat gBias, + GLfloat bScale, GLfloat bBias, + GLfloat aScale, GLfloat aBias) +{ + data = _mesa_map_validate_pbo_source(ctx, + 1, &ctx->Unpack, count, 1, 1, + format, type, data, + "glColor[Sub]Table"); + if (!data) + return; + + { + /* convert user-provided data to GLfloat values */ + GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4]; + GLfloat *tableF; + GLint i; + + _mesa_unpack_color_span_float(ctx, + count, /* number of pixels */ + table->_BaseFormat, /* dest format */ + tempTab, /* dest address */ + format, type, /* src format/type */ + data, /* src data */ + &ctx->Unpack, + IMAGE_CLAMP_BIT); /* transfer ops */ + + /* the destination */ + tableF = table->TableF; + + /* Apply scale & bias & clamp now */ + switch (table->_BaseFormat) { + case GL_INTENSITY: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F); + } + break; + case GL_LUMINANCE: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F); + } + break; + case GL_ALPHA: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F); + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F); + tableF[j*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F); + } + break; + case GL_RGB: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F); + tableF[j*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F); + tableF[j*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F); + } + break; + case GL_RGBA: + for (i = 0; i < count; i++) { + GLuint j = start + i; + tableF[j*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F); + tableF[j*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F); + tableF[j*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F); + tableF[j*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F); + } + break; + default: + _mesa_problem(ctx, "Bad format in store_colortable_entries"); + return; + } + } + + /* update the ubyte table */ + { + const GLint comps = _mesa_components_in_format(table->_BaseFormat); + const GLfloat *tableF = table->TableF + start * comps; + GLubyte *tableUB = table->TableUB + start * comps; + GLint i; + for (i = 0; i < count * comps; i++) { + CLAMPED_FLOAT_TO_UBYTE(tableUB[i], tableF[i]); + } + } + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); +} + + + +void GLAPIENTRY +_mesa_ColorTable( GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *data ) +{ + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; + GLboolean proxy = GL_FALSE; + GLint baseFormat; + const GLfloat *scale = one, *bias = zero; + GLint comps; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ + + switch (target) { + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + table = &(texUnit->ColorTable); + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; + break; + case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + table = &(texUnit->ProxyColorTable); + proxy = GL_TRUE; + break; + default: + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + proxy = _mesa_is_proxy_texture(target); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + } + } + + assert(table); + + if (!_mesa_is_legal_format_and_type(ctx, format, type) || + format == GL_INTENSITY) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)"); + return; + } + + baseFormat = base_colortab_format(internalFormat); + if (baseFormat < 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)"); + return; + } + + if (width < 0 || (width != 0 && !_mesa_is_pow_two(width))) { + /* error */ + if (proxy) { + table->Size = 0; + table->InternalFormat = (GLenum) 0; + table->_BaseFormat = (GLenum) 0; + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorTable(width=%d)", width); + } + return; + } + + if (width > (GLsizei) ctx->Const.MaxColorTableSize) { + if (proxy) { + table->Size = 0; + table->InternalFormat = (GLenum) 0; + table->_BaseFormat = (GLenum) 0; + } + else { + _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)"); + } + return; + } + + table->Size = width; + table->InternalFormat = internalFormat; + table->_BaseFormat = (GLenum) baseFormat; + + comps = _mesa_components_in_format(table->_BaseFormat); + assert(comps > 0); /* error should have been caught sooner */ + + if (!proxy) { + _mesa_free_colortable_data(table); + + if (width > 0) { + table->TableF = (GLfloat *) malloc(comps * width * sizeof(GLfloat)); + table->TableUB = (GLubyte *) malloc(comps * width * sizeof(GLubyte)); + + if (!table->TableF || !table->TableUB) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); + return; + } + + store_colortable_entries(ctx, table, + 0, width, /* start, count */ + format, type, data, + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); + } + } /* proxy */ + + /* do this after the table's Type and Format are set */ + set_component_sizes(table); + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* texture object palette, texObj==NULL means the shared palette */ + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + } + } + + ctx->NewState |= _NEW_PIXEL; +} + + + +void GLAPIENTRY +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *data ) +{ + static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 }; + static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 }; + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; + const GLfloat *scale = one, *bias = zero; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + switch (target) { + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); + return; + } + table = &(texUnit->ColorTable); + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; + break; + default: + /* try texture targets */ + texObj = _mesa_select_tex_object(ctx, texUnit, target); + if (texObj && !_mesa_is_proxy_texture(target)) { + table = &texObj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); + return; + } + } + + assert(table); + + if (!_mesa_is_legal_format_and_type(ctx, format, type) || + format == GL_INTENSITY) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)"); + return; + } + + if (count < 1) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); + return; + } + + /* error should have been caught sooner */ + assert(_mesa_components_in_format(table->_BaseFormat) > 0); + + if (start + count > (GLint) table->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); + return; + } + + if (!table->TableF || !table->TableUB) { + /* a GL_OUT_OF_MEMORY error would have been recorded previously */ + return; + } + + store_colortable_entries(ctx, table, start, count, + format, type, data, + scale[0], bias[0], + scale[1], bias[1], + scale[2], bias[2], + scale[3], bias[3]); + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* per-texture object palette */ + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + } + } + + ctx->NewState |= _NEW_PIXEL; +} + + + +static void GLAPIENTRY +_mesa_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->ReadBuffer->_ColorReadBuffer) { + return; /* no readbuffer - OK */ + } + + ctx->Driver.CopyColorTable( ctx, target, internalformat, x, y, width ); +} + + + +static void GLAPIENTRY +_mesa_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->ReadBuffer->_ColorReadBuffer) { + return; /* no readbuffer - OK */ + } + + ctx->Driver.CopyColorSubTable( ctx, target, start, x, y, width ); +} + + + +static void GLAPIENTRY +_mesa_GetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *data ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_color_table *table = NULL; + GLfloat rgba[MAX_COLOR_TABLE_SIZE][4]; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->NewState) { + _mesa_update_state(ctx); + } + + switch (target) { + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); + return; + } + table = &(texUnit->ColorTable); + break; + default: + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj && !_mesa_is_proxy_texture(target)) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); + return; + } + } + } + + ASSERT(table); + + if (table->Size <= 0) { + return; + } + + switch (table->_BaseFormat) { + case GL_ALPHA: + { + GLuint i; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = table->TableF[i]; + } + } + break; + case GL_LUMINANCE: + { + GLuint i; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = table->TableF[i]; + rgba[i][ACOMP] = 1.0F; + } + } + break; + case GL_LUMINANCE_ALPHA: + { + GLuint i; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = table->TableF[i*2+0]; + rgba[i][ACOMP] = table->TableF[i*2+1]; + } + } + break; + case GL_INTENSITY: + { + GLuint i; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = + rgba[i][ACOMP] = table->TableF[i]; + } + } + break; + case GL_RGB: + { + GLuint i; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = table->TableF[i*3+0]; + rgba[i][GCOMP] = table->TableF[i*3+1]; + rgba[i][BCOMP] = table->TableF[i*3+2]; + rgba[i][ACOMP] = 1.0F; + } + } + break; + case GL_RGBA: + memcpy(rgba, table->TableF, 4 * table->Size * sizeof(GLfloat)); + break; + default: + _mesa_problem(ctx, "bad table format in glGetColorTable"); + return; + } + + data = _mesa_map_validate_pbo_dest(ctx, + 1, &ctx->Pack, table->Size, 1, 1, + format, type, data, + "glGetColorTable"); + if (!data) + return; + + _mesa_pack_rgba_span_float(ctx, table->Size, rgba, + format, type, data, &ctx->Pack, 0x0); + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + + +static void GLAPIENTRY +_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GLfloat *scale, *bias; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + switch (target) { + case GL_TEXTURE_COLOR_TABLE_SGI: + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); + return; + } + + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + COPY_4V(scale, params); + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + COPY_4V(bias, params); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + + ctx->NewState |= _NEW_PIXEL; +} + + + +static void GLAPIENTRY +_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLfloat fparams[4]; + if (pname == GL_TEXTURE_COLOR_TABLE_SGI) { + /* four values */ + fparams[0] = (GLfloat) params[0]; + fparams[1] = (GLfloat) params[1]; + fparams[2] = (GLfloat) params[2]; + fparams[3] = (GLfloat) params[3]; + } + else { + /* one values */ + fparams[0] = (GLfloat) params[0]; + } + _mesa_ColorTableParameterfv(target, pname, fparams); +} + + + +static void GLAPIENTRY +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_color_table *table = NULL; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (target) { + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + return; + } + table = &(texUnit->ColorTable); + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + COPY_4V(params, ctx->Pixel.TextureColorTableScale); + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + COPY_4V(params, ctx->Pixel.TextureColorTableBias); + return; + } + break; + case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + return; + } + table = &(texUnit->ProxyColorTable); + break; + default: + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetColorTableParameterfv(target)"); + return; + } + } + } + + assert(table); + + switch (pname) { + case GL_COLOR_TABLE_FORMAT: + *params = (GLfloat) table->InternalFormat; + break; + case GL_COLOR_TABLE_WIDTH: + *params = (GLfloat) table->Size; + break; + case GL_COLOR_TABLE_RED_SIZE: + *params = (GLfloat) table->RedSize; + break; + case GL_COLOR_TABLE_GREEN_SIZE: + *params = (GLfloat) table->GreenSize; + break; + case GL_COLOR_TABLE_BLUE_SIZE: + *params = (GLfloat) table->BlueSize; + break; + case GL_COLOR_TABLE_ALPHA_SIZE: + *params = (GLfloat) table->AlphaSize; + break; + case GL_COLOR_TABLE_LUMINANCE_SIZE: + *params = (GLfloat) table->LuminanceSize; + break; + case GL_COLOR_TABLE_INTENSITY_SIZE: + *params = (GLfloat) table->IntensitySize; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" ); + return; + } +} + + + +static void GLAPIENTRY +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_color_table *table = NULL; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (target) { + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + return; + } + table = &(texUnit->ColorTable); + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0]; + params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1]; + params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2]; + params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0]; + params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1]; + params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2]; + params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3]; + return; + } + break; + case GL_PROXY_TEXTURE_COLOR_TABLE_SGI: + if (!ctx->Extensions.SGI_texture_color_table) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + return; + } + table = &(texUnit->ProxyColorTable); + break; + default: + /* Try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetColorTableParameteriv(target)"); + return; + } + } + } + + assert(table); + + switch (pname) { + case GL_COLOR_TABLE_FORMAT: + *params = table->InternalFormat; + break; + case GL_COLOR_TABLE_WIDTH: + *params = table->Size; + break; + case GL_COLOR_TABLE_RED_SIZE: + *params = table->RedSize; + break; + case GL_COLOR_TABLE_GREEN_SIZE: + *params = table->GreenSize; + break; + case GL_COLOR_TABLE_BLUE_SIZE: + *params = table->BlueSize; + break; + case GL_COLOR_TABLE_ALPHA_SIZE: + *params = table->AlphaSize; + break; + case GL_COLOR_TABLE_LUMINANCE_SIZE: + *params = table->LuminanceSize; + break; + case GL_COLOR_TABLE_INTENSITY_SIZE: + *params = table->IntensitySize; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); + return; + } +} + + +void +_mesa_init_colortable_dispatch(struct _glapi_table *disp) +{ + SET_ColorSubTable(disp, _mesa_ColorSubTable); + SET_ColorTable(disp, _mesa_ColorTable); + SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv); + SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv); + SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable); + SET_CopyColorTable(disp, _mesa_CopyColorTable); + SET_GetColorTable(disp, _mesa_GetColorTable); + SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv); + SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv); +} + + +#endif /* FEATURE_colortable */ + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + + +void +_mesa_init_colortable( struct gl_color_table *p ) +{ + p->TableF = NULL; + p->TableUB = NULL; + p->Size = 0; + p->InternalFormat = GL_RGBA; +} + + + +void +_mesa_free_colortable_data( struct gl_color_table *p ) +{ + if (p->TableF) { + free(p->TableF); + p->TableF = NULL; + } + if (p->TableUB) { + free(p->TableUB); + p->TableUB = NULL; + } +} diff --git a/mesalib/src/mesa/main/colortab.h b/mesalib/src/mesa/main/colortab.h index 303c9fb30..81b4e008b 100644 --- a/mesalib/src/mesa/main/colortab.h +++ b/mesalib/src/mesa/main/colortab.h @@ -1,88 +1,84 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef COLORTAB_H -#define COLORTAB_H - - -#include "main/mtypes.h" - -#if FEATURE_colortable - -extern void GLAPIENTRY -_mesa_ColorTable( GLenum target, GLenum internalformat, - GLsizei width, GLenum format, GLenum type, - const GLvoid *table ); - -extern void GLAPIENTRY -_mesa_ColorSubTable( GLenum target, GLsizei start, - GLsizei count, GLenum format, GLenum type, - const GLvoid *table ); - -extern void -_mesa_init_colortable_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_colortable */ - -#include "main/compiler.h" - -static INLINE void GLAPIENTRY -_mesa_ColorTable( GLenum target, GLenum internalformat, - GLsizei width, GLenum format, GLenum type, - const GLvoid *table ) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void GLAPIENTRY -_mesa_ColorSubTable( GLenum target, GLsizei start, - GLsizei count, GLenum format, GLenum type, - const GLvoid *table ) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_init_colortable_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_colortable */ - - -extern void -_mesa_init_colortable( struct gl_color_table *table ); - -extern void -_mesa_free_colortable_data( struct gl_color_table *table ); - -extern void -_mesa_init_colortables( GLcontext *ctx ); - -extern void -_mesa_free_colortables_data( GLcontext *ctx ); - - -#endif /* COLORTAB_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef COLORTAB_H +#define COLORTAB_H + + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct gl_color_table; + +#if FEATURE_colortable + +extern void GLAPIENTRY +_mesa_ColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ); + +extern void GLAPIENTRY +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *table ); + +extern void +_mesa_init_colortable_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_colortable */ + +static INLINE void GLAPIENTRY +_mesa_ColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void GLAPIENTRY +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *table ) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_init_colortable_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_colortable */ + + +extern void +_mesa_init_colortable( struct gl_color_table *table ); + +extern void +_mesa_free_colortable_data( struct gl_color_table *table ); + +#endif /* COLORTAB_H */ diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h index 800eb8390..41cd48bc6 100644 --- a/mesalib/src/mesa/main/compiler.h +++ b/mesalib/src/mesa/main/compiler.h @@ -1,512 +1,516 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file compiler.h - * Compiler-related stuff. - */ - - -#ifndef COMPILER_H -#define COMPILER_H - - -#include -#include -#if defined(__alpha__) && defined(CCPML) -#include /* use Compaq's Fast Math Library on Alpha */ -#else -#include -#endif -#include -#include -#include -#include -#if defined(__linux__) && defined(__i386__) -#include -#endif -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Get standard integer types - */ -#if defined(_MSC_VER) - typedef __int8 int8_t; - typedef unsigned __int8 uint8_t; - typedef __int16 int16_t; - typedef unsigned __int16 uint16_t; - typedef __int32 int32_t; - typedef unsigned __int32 uint32_t; - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - -# if defined(_WIN64) - typedef __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -# else - typedef __int32 intptr_t; - typedef unsigned __int32 uintptr_t; -# endif - -# define INT64_C(__val) __val##i64 -# define UINT64_C(__val) __val##ui64 -#else -# include -#endif - - -/** - * Sun compilers define __i386 instead of the gcc-style __i386__ - */ -#ifdef __SUNPRO_C -# if !defined(__i386__) && defined(__i386) -# define __i386__ -# elif !defined(__amd64__) && defined(__amd64) -# define __amd64__ -# elif !defined(__sparc__) && defined(__sparc) -# define __sparc__ -# endif -# if !defined(__volatile) -# define __volatile volatile -# endif -#endif - - -/** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#elif defined(__WATCOMC__) -# define finite _finite -#endif - - -/** - * Disable assorted warnings - */ -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if !defined(__GNUC__) /* mingw environment */ -# pragma warning( disable : 4068 ) /* unknown pragma */ -# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ -# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ -# pragma warning( disable : 4127 ) /* conditional expression is constant */ -# if defined(MESA_MINWARN) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# endif -# endif -#endif -#if defined(__WATCOMC__) -# pragma disable_message(201) /* Disable unreachable code warnings */ -#endif - - - -/** - * Function inlining - */ -#if defined(__GNUC__) -# define INLINE __inline__ -#elif defined(__MSC__) -# define INLINE __inline -#elif defined(_MSC_VER) -# define INLINE __inline -#elif defined(__ICL) -# define INLINE __inline -#elif defined(__INTEL_COMPILER) -# define INLINE inline -#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) -# define INLINE __inline -#elif defined(__SUNPRO_C) && defined(__C99FEATURES__) -# define INLINE inline -# define __inline inline -# define __inline__ inline -#elif (__STDC_VERSION__ >= 199901L) /* C99 */ -# define INLINE inline -#else -# define INLINE -#endif - - -/** - * PUBLIC/USED macros - * - * If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -#else -# define PUBLIC -# define USED -#endif - - -/** - * Some compilers don't like some of Mesa's const usage. In those places use - * CONST instead of const. Pass -DNO_CONST to compilers where this matters. - */ -#ifdef NO_CONST -# define CONST -#else -# define CONST const -#endif - - -/** - * __builtin_expect macros - */ -#if !defined(__GNUC__) -# define __builtin_expect(x, y) x -#endif - -#ifdef __GNUC__ -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#else -#define likely(x) !!(x) -#define unlikely(x) !!(x) -#endif - -/** - * The __FUNCTION__ gcc variable is generally only used for debugging. - * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. - * Don't define it if using a newer Windows compiler. - */ -#ifndef __FUNCTION__ -# if defined(__VMS) -# define __FUNCTION__ "VMS$NL:" -# elif !defined(__GNUC__) && !defined(__xlC__) && \ - (!defined(_MSC_VER) || _MSC_VER < 1300) -# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) -# define __FUNCTION__ __func__ -# else -# define __FUNCTION__ "" -# endif -# endif -#endif -#ifndef __func__ -# if (__STDC_VERSION__ >= 199901L) || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) - /* __func__ is part of C99 */ -# elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -# endif -#endif - - -/** - * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. - * Do not use these unless absolutely necessary! - * Try to use a runtime test instead. - * For now, only used by some DRI hardware drivers for color/texel packing. - */ -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -#if defined(__linux__) -#include -#define CPU_TO_LE32( x ) bswap_32( x ) -#elif defined(__APPLE__) -#include -#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) -#elif (defined(_AIX) || defined(__blrts)) -static INLINE GLuint CPU_TO_LE32(GLuint x) -{ - return (((x & 0x000000ff) << 24) | - ((x & 0x0000ff00) << 8) | - ((x & 0x00ff0000) >> 8) | - ((x & 0xff000000) >> 24)); -} -#else /*__linux__ */ -#include -#define CPU_TO_LE32( x ) bswap32( x ) -#endif /*__linux__*/ -#define MESA_BIG_ENDIAN 1 -#else -#define CPU_TO_LE32( x ) ( x ) -#define MESA_LITTLE_ENDIAN 1 -#endif -#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) - - - -#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) -#define CAPI _cdecl -#endif - - -/** - * Create a macro so that asm functions can be linked into compilers other - * than GNU C - */ -#ifndef _ASMAPI -#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ -#define _ASMAPI __cdecl -#else -#define _ASMAPI -#endif -#ifdef PTR_DECL_IN_FRONT -#define _ASMAPIP * _ASMAPI -#else -#define _ASMAPIP _ASMAPI * -#endif -#endif - -#ifdef USE_X86_ASM -#define _NORMAPI _ASMAPI -#define _NORMAPIP _ASMAPIP -#else -#define _NORMAPI -#define _NORMAPIP * -#endif - - -/* This is a macro on IRIX */ -#ifdef _P -#undef _P -#endif - - -/* Turn off macro checking systems used by other libraries */ -#ifdef CHECK -#undef CHECK -#endif - - -/** - * ASSERT macro - */ -#if !defined(_WIN32_WCE) -#if defined(BUILD_FOR_SNAP) && defined(CHECKED) -# define ASSERT(X) _CHECK(X) -#elif defined(DEBUG) -# define ASSERT(X) assert(X) -#else -# define ASSERT(X) -#endif -#endif - -#if (__GNUC__ >= 3) -#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) -#else -#define PRINTFLIKE(f, a) -#endif - -#ifndef NULL -#define NULL 0 -#endif - - -/** - * LONGSTRING macro - * gcc -pedantic warns about long string literals, LONGSTRING silences that. - */ -#if !defined(__GNUC__) -# define LONGSTRING -#else -# define LONGSTRING __extension__ -#endif - - -#ifndef M_PI -#define M_PI (3.1415926536) -#endif - -#ifndef M_E -#define M_E (2.7182818284590452354) -#endif - -#ifndef ONE_DIV_LN2 -#define ONE_DIV_LN2 (1.442695040888963456) -#endif - -#ifndef ONE_DIV_SQRT_LN2 -#define ONE_DIV_SQRT_LN2 (1.201122408786449815) -#endif - -#ifndef FLT_MAX_EXP -#define FLT_MAX_EXP 128 -#endif - - -/** - * USE_IEEE: Determine if we're using IEEE floating point - */ -#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ - defined(__s390x__) || defined(__powerpc__) || \ - defined(__x86_64__) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__hppa__) || defined(hpux) || \ - defined(__mips) || defined(_MIPS_ARCH) || \ - defined(__arm__) || \ - defined(__sh__) || defined(__m32r__) || \ - (defined(__sun) && defined(_IEEE_754)) || \ - (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) -#define USE_IEEE -#define IEEE_ONE 0x3f800000 -#endif - - -/** - * START/END_FAST_MATH macros: - * - * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save - * original mode to a temporary). - * END_FAST_MATH: Restore x86 FPU to original mode. - */ -#if defined(__GNUC__) && defined(__i386__) -/* - * Set the x86 FPU control word to guarentee only 32 bits of precision - * are stored in registers. Allowing the FPU to store more introduces - * differences between situations where numbers are pulled out of memory - * vs. situations where the compiler is able to optimize register usage. - * - * In the worst case, we force the compiler to use a memory access to - * truncate the float, by specifying the 'volatile' keyword. - */ -/* Hardware default: All exceptions masked, extended double precision, - * round to nearest (IEEE compliant): - */ -#define DEFAULT_X86_FPU 0x037f -/* All exceptions masked, single precision, round to nearest: - */ -#define FAST_X86_FPU 0x003f -/* The fldcw instruction will cause any pending FP exceptions to be - * raised prior to entering the block, and we clear any pending - * exceptions before exiting the block. Hence, asm code has free - * reign over the FPU while in the fast math block. - */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = DEFAULT_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = FAST_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#endif -/* Restore original FPU mode, and clear any exceptions that may have - * occurred in the FAST_MATH block. - */ -#define END_FAST_MATH(x) \ -do { \ - __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ -} while (0) - -#elif defined(__WATCOMC__) && defined(__386__) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); -#pragma aux _watcom_start_fast_math = \ - "fnstcw word ptr [eax]" \ - "fldcw word ptr [ecx]" \ - parm [eax] [ecx] \ - modify exact []; -void _watcom_end_fast_math(unsigned short *x); -#pragma aux _watcom_end_fast_math = \ - "fnclex" \ - "fldcw word ptr [eax]" \ - parm [eax] \ - modify exact []; -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = DEFAULT_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = FAST_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#endif -#define END_FAST_MATH(x) _watcom_end_fast_math(&x) - -#elif defined(_MSC_VER) && defined(_M_IX86) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) do {\ - static GLuint mask = DEFAULT_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#else -#define START_FAST_MATH(x) do {\ - static GLuint mask = FAST_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#endif -#define END_FAST_MATH(x) do {\ - __asm fnclex\ - __asm fldcw word ptr [x]\ -} while(0) - -#else -#define START_FAST_MATH(x) x = 0 -#define END_FAST_MATH(x) (void)(x) -#endif - - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - - - -#ifdef __cplusplus -} -#endif - - -#endif /* COMPILER_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file compiler.h + * Compiler-related stuff. + */ + + +#ifndef COMPILER_H +#define COMPILER_H + + +#include +#include +#if defined(__alpha__) && defined(CCPML) +#include /* use Compaq's Fast Math Library on Alpha */ +#else +#include +#endif +#include +#include +#include +#include +#if defined(__linux__) && defined(__i386__) +#include +#endif +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Get standard integer types + */ +#if defined(_MSC_VER) + typedef __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; + +# if defined(_WIN64) + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +# else + typedef __int32 intptr_t; + typedef unsigned __int32 uintptr_t; +# endif + +# define INT64_C(__val) __val##i64 +# define UINT64_C(__val) __val##ui64 +#else +# include +#endif + + +/** + * Sun compilers define __i386 instead of the gcc-style __i386__ + */ +#ifdef __SUNPRO_C +# if !defined(__i386__) && defined(__i386) +# define __i386__ +# elif !defined(__amd64__) && defined(__amd64) +# define __amd64__ +# elif !defined(__sparc__) && defined(__sparc) +# define __sparc__ +# endif +# if !defined(__volatile) +# define __volatile volatile +# endif +#endif + + +/** + * finite macro. + */ +#if defined(_MSC_VER) +# define finite _finite +#elif defined(__WATCOMC__) +# define finite _finite +#endif + + +/** + * Disable assorted warnings + */ +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if !defined(__GNUC__) /* mingw environment */ +# pragma warning( disable : 4068 ) /* unknown pragma */ +# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ +# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ +# pragma warning( disable : 4127 ) /* conditional expression is constant */ +# if defined(MESA_MINWARN) +# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ +# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ +# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ +# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ +# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ +# endif +# endif +#endif +#if defined(__WATCOMC__) +# pragma disable_message(201) /* Disable unreachable code warnings */ +#endif + + + +/** + * Function inlining + */ +#if defined(__GNUC__) +# define INLINE __inline__ +#elif defined(__MSC__) +# define INLINE __inline +#elif defined(_MSC_VER) +# define INLINE __inline +#elif defined(__ICL) +# define INLINE __inline +#elif defined(__INTEL_COMPILER) +# define INLINE inline +#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +# define INLINE __inline +#elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +# define INLINE inline +# define __inline inline +# define __inline__ inline +#elif (__STDC_VERSION__ >= 199901L) /* C99 */ +# define INLINE inline +#else +# define INLINE +#endif + + +/** + * PUBLIC/USED macros + * + * If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +#else +# define PUBLIC +# define USED +#endif + + +/** + * Some compilers don't like some of Mesa's const usage. In those places use + * CONST instead of const. Pass -DNO_CONST to compilers where this matters. + */ +#ifdef NO_CONST +# define CONST +#else +# define CONST const +#endif + + +/** + * __builtin_expect macros + */ +#if !defined(__GNUC__) +# define __builtin_expect(x, y) x +#endif + +#ifdef __GNUC__ +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define likely(x) !!(x) +#define unlikely(x) !!(x) +#endif + +/** + * The __FUNCTION__ gcc variable is generally only used for debugging. + * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. + * Don't define it if using a newer Windows compiler. + */ +#ifndef __FUNCTION__ +# if defined(__VMS) +# define __FUNCTION__ "VMS$NL:" +# elif !defined(__GNUC__) && !defined(__xlC__) && \ + (!defined(_MSC_VER) || _MSC_VER < 1300) +# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +# define __FUNCTION__ __func__ +# else +# define __FUNCTION__ "" +# endif +# endif +#endif +#ifndef __func__ +# if (__STDC_VERSION__ >= 199901L) || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) + /* __func__ is part of C99 */ +# elif defined(_MSC_VER) +# if _MSC_VER >= 1300 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# endif +#endif + + +/** + * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. + * Do not use these unless absolutely necessary! + * Try to use a runtime test instead. + * For now, only used by some DRI hardware drivers for color/texel packing. + */ +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN +#if defined(__linux__) +#include +#define CPU_TO_LE32( x ) bswap_32( x ) +#elif defined(__APPLE__) +#include +#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) +#elif (defined(_AIX) || defined(__blrts)) +static INLINE GLuint CPU_TO_LE32(GLuint x) +{ + return (((x & 0x000000ff) << 24) | + ((x & 0x0000ff00) << 8) | + ((x & 0x00ff0000) >> 8) | + ((x & 0xff000000) >> 24)); +} +#else /*__linux__ */ +#include +#define CPU_TO_LE32( x ) bswap32( x ) +#endif /*__linux__*/ +#define MESA_BIG_ENDIAN 1 +#else +#define CPU_TO_LE32( x ) ( x ) +#define MESA_LITTLE_ENDIAN 1 +#endif +#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) + + + +#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) +#define CAPI _cdecl +#endif + + +/** + * Create a macro so that asm functions can be linked into compilers other + * than GNU C + */ +#ifndef _ASMAPI +#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ +#define _ASMAPI __cdecl +#else +#define _ASMAPI +#endif +#ifdef PTR_DECL_IN_FRONT +#define _ASMAPIP * _ASMAPI +#else +#define _ASMAPIP _ASMAPI * +#endif +#endif + +#ifdef USE_X86_ASM +#define _NORMAPI _ASMAPI +#define _NORMAPIP _ASMAPIP +#else +#define _NORMAPI +#define _NORMAPIP * +#endif + + +/* This is a macro on IRIX */ +#ifdef _P +#undef _P +#endif + + +/* Turn off macro checking systems used by other libraries */ +#ifdef CHECK +#undef CHECK +#endif + + +/** + * ASSERT macro + */ +#if !defined(_WIN32_WCE) +#if defined(BUILD_FOR_SNAP) && defined(CHECKED) +# define ASSERT(X) _CHECK(X) +#elif defined(DEBUG) +# define ASSERT(X) assert(X) +#else +# define ASSERT(X) +#endif +#endif + +#if (__GNUC__ >= 3) +#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) +#else +#define PRINTFLIKE(f, a) +#endif + +#ifndef NULL +#define NULL 0 +#endif + + +/** + * LONGSTRING macro + * gcc -pedantic warns about long string literals, LONGSTRING silences that. + */ +#if !defined(__GNUC__) +# define LONGSTRING +#else +# define LONGSTRING __extension__ +#endif + + +#ifndef M_PI +#define M_PI (3.1415926536) +#endif + +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif + +#ifndef M_LOG2E +#define M_LOG2E (1.4426950408889634074) +#endif + +#ifndef ONE_DIV_LN2 +#define ONE_DIV_LN2 (1.442695040888963456) +#endif + +#ifndef ONE_DIV_SQRT_LN2 +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) +#endif + +#ifndef FLT_MAX_EXP +#define FLT_MAX_EXP 128 +#endif + + +/** + * USE_IEEE: Determine if we're using IEEE floating point + */ +#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ + defined(__s390x__) || defined(__powerpc__) || \ + defined(__x86_64__) || \ + defined(ia64) || defined(__ia64__) || \ + defined(__hppa__) || defined(hpux) || \ + defined(__mips) || defined(_MIPS_ARCH) || \ + defined(__arm__) || \ + defined(__sh__) || defined(__m32r__) || \ + (defined(__sun) && defined(_IEEE_754)) || \ + (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) +#define USE_IEEE +#define IEEE_ONE 0x3f800000 +#endif + + +/** + * START/END_FAST_MATH macros: + * + * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save + * original mode to a temporary). + * END_FAST_MATH: Restore x86 FPU to original mode. + */ +#if defined(__GNUC__) && defined(__i386__) +/* + * Set the x86 FPU control word to guarentee only 32 bits of precision + * are stored in registers. Allowing the FPU to store more introduces + * differences between situations where numbers are pulled out of memory + * vs. situations where the compiler is able to optimize register usage. + * + * In the worst case, we force the compiler to use a memory access to + * truncate the float, by specifying the 'volatile' keyword. + */ +/* Hardware default: All exceptions masked, extended double precision, + * round to nearest (IEEE compliant): + */ +#define DEFAULT_X86_FPU 0x037f +/* All exceptions masked, single precision, round to nearest: + */ +#define FAST_X86_FPU 0x003f +/* The fldcw instruction will cause any pending FP exceptions to be + * raised prior to entering the block, and we clear any pending + * exceptions before exiting the block. Hence, asm code has free + * reign over the FPU while in the fast math block. + */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = DEFAULT_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = FAST_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#endif +/* Restore original FPU mode, and clear any exceptions that may have + * occurred in the FAST_MATH block. + */ +#define END_FAST_MATH(x) \ +do { \ + __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ +} while (0) + +#elif defined(__WATCOMC__) && defined(__386__) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); +#pragma aux _watcom_start_fast_math = \ + "fnstcw word ptr [eax]" \ + "fldcw word ptr [ecx]" \ + parm [eax] [ecx] \ + modify exact []; +void _watcom_end_fast_math(unsigned short *x); +#pragma aux _watcom_end_fast_math = \ + "fnclex" \ + "fldcw word ptr [eax]" \ + parm [eax] \ + modify exact []; +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = DEFAULT_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = FAST_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#endif +#define END_FAST_MATH(x) _watcom_end_fast_math(&x) + +#elif defined(_MSC_VER) && defined(_M_IX86) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) do {\ + static GLuint mask = DEFAULT_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#else +#define START_FAST_MATH(x) do {\ + static GLuint mask = FAST_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#endif +#define END_FAST_MATH(x) do {\ + __asm fnclex\ + __asm fldcw word ptr [x]\ +} while(0) + +#else +#define START_FAST_MATH(x) x = 0 +#define END_FAST_MATH(x) (void)(x) +#endif + + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + + + +#ifdef __cplusplus +} +#endif + + +#endif /* COMPILER_H */ diff --git a/mesalib/src/mesa/main/condrender.c b/mesalib/src/mesa/main/condrender.c index 8d9a91d54..250397854 100644 --- a/mesalib/src/mesa/main/condrender.c +++ b/mesalib/src/mesa/main/condrender.c @@ -1,147 +1,147 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -/** - * \file condrender.c - * Conditional rendering functions - * - * \author Brian Paul - */ - -#include "glheader.h" -#include "condrender.h" -#include "enums.h" -#include "queryobj.h" - - -void GLAPIENTRY -_mesa_BeginConditionalRender(GLuint queryId, GLenum mode) -{ - struct gl_query_object *q; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); - return; - } - - ASSERT(ctx->Query.CondRenderMode == GL_NONE); - - switch (mode) { - case GL_QUERY_WAIT: - case GL_QUERY_NO_WAIT: - case GL_QUERY_BY_REGION_WAIT: - case GL_QUERY_BY_REGION_NO_WAIT: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBeginConditionalRender(mode=%s)", - _mesa_lookup_enum_by_nr(mode)); - return; - } - - q = _mesa_lookup_query_object(ctx, queryId); - if (!q) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glBeginConditionalRender(bad queryId=%u)", queryId); - return; - } - ASSERT(q->Id == queryId); - - if (q->Target != GL_SAMPLES_PASSED) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); - return; - } - - ctx->Query.CondRenderQuery = q; - ctx->Query.CondRenderMode = mode; - - if (ctx->Driver.BeginConditionalRender) - ctx->Driver.BeginConditionalRender(ctx, q, mode); -} - - -void APIENTRY -_mesa_EndConditionalRender(void) -{ - GET_CURRENT_CONTEXT(ctx); - - FLUSH_VERTICES(ctx, 0x0); - - if (!ctx->Extensions.NV_conditional_render || !ctx->Query.CondRenderQuery) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndConditionalRender()"); - return; - } - - if (ctx->Driver.EndConditionalRender) - ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery); - - ctx->Query.CondRenderQuery = NULL; - ctx->Query.CondRenderMode = GL_NONE; -} - - -/** - * This function is called by software rendering commands (all point, - * line triangle drawing, glClear, glDrawPixels, glCopyPixels, and - * glBitmap, glBlitFramebuffer) to determine if subsequent drawing - * commands should be - * executed or discarded depending on the current conditional - * rendering state. Ideally, this check would be implemented by the - * GPU when doing hardware rendering. XXX should this function be - * called via a new driver hook? - * - * \return GL_TRUE if we should render, GL_FALSE if we should discard - */ -GLboolean -_mesa_check_conditional_render(GLcontext *ctx) -{ - struct gl_query_object *q = ctx->Query.CondRenderQuery; - - if (!q) { - /* no query in progress - draw normally */ - return GL_TRUE; - } - - switch (ctx->Query.CondRenderMode) { - case GL_QUERY_BY_REGION_WAIT: - /* fall-through */ - case GL_QUERY_WAIT: - if (!q->Ready) { - ctx->Driver.WaitQuery(ctx, q); - } - return q->Result > 0; - case GL_QUERY_BY_REGION_NO_WAIT: - /* fall-through */ - case GL_QUERY_NO_WAIT: - return q->Ready ? (q->Result > 0) : GL_TRUE; - default: - _mesa_problem(ctx, "Bad cond render mode %s in " - " _mesa_check_conditional_render()", - _mesa_lookup_enum_by_nr(ctx->Query.CondRenderMode)); - return GL_TRUE; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +/** + * \file condrender.c + * Conditional rendering functions + * + * \author Brian Paul + */ + +#include "glheader.h" +#include "condrender.h" +#include "enums.h" +#include "queryobj.h" + + +void GLAPIENTRY +_mesa_BeginConditionalRender(GLuint queryId, GLenum mode) +{ + struct gl_query_object *q; + GET_CURRENT_CONTEXT(ctx); + + if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); + return; + } + + ASSERT(ctx->Query.CondRenderMode == GL_NONE); + + switch (mode) { + case GL_QUERY_WAIT: + case GL_QUERY_NO_WAIT: + case GL_QUERY_BY_REGION_WAIT: + case GL_QUERY_BY_REGION_NO_WAIT: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBeginConditionalRender(mode=%s)", + _mesa_lookup_enum_by_nr(mode)); + return; + } + + q = _mesa_lookup_query_object(ctx, queryId); + if (!q) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBeginConditionalRender(bad queryId=%u)", queryId); + return; + } + ASSERT(q->Id == queryId); + + if (q->Target != GL_SAMPLES_PASSED) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()"); + return; + } + + ctx->Query.CondRenderQuery = q; + ctx->Query.CondRenderMode = mode; + + if (ctx->Driver.BeginConditionalRender) + ctx->Driver.BeginConditionalRender(ctx, q, mode); +} + + +void APIENTRY +_mesa_EndConditionalRender(void) +{ + GET_CURRENT_CONTEXT(ctx); + + FLUSH_VERTICES(ctx, 0x0); + + if (!ctx->Extensions.NV_conditional_render || !ctx->Query.CondRenderQuery) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndConditionalRender()"); + return; + } + + if (ctx->Driver.EndConditionalRender) + ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery); + + ctx->Query.CondRenderQuery = NULL; + ctx->Query.CondRenderMode = GL_NONE; +} + + +/** + * This function is called by software rendering commands (all point, + * line triangle drawing, glClear, glDrawPixels, glCopyPixels, and + * glBitmap, glBlitFramebuffer) to determine if subsequent drawing + * commands should be + * executed or discarded depending on the current conditional + * rendering state. Ideally, this check would be implemented by the + * GPU when doing hardware rendering. XXX should this function be + * called via a new driver hook? + * + * \return GL_TRUE if we should render, GL_FALSE if we should discard + */ +GLboolean +_mesa_check_conditional_render(struct gl_context *ctx) +{ + struct gl_query_object *q = ctx->Query.CondRenderQuery; + + if (!q) { + /* no query in progress - draw normally */ + return GL_TRUE; + } + + switch (ctx->Query.CondRenderMode) { + case GL_QUERY_BY_REGION_WAIT: + /* fall-through */ + case GL_QUERY_WAIT: + if (!q->Ready) { + ctx->Driver.WaitQuery(ctx, q); + } + return q->Result > 0; + case GL_QUERY_BY_REGION_NO_WAIT: + /* fall-through */ + case GL_QUERY_NO_WAIT: + return q->Ready ? (q->Result > 0) : GL_TRUE; + default: + _mesa_problem(ctx, "Bad cond render mode %s in " + " _mesa_check_conditional_render()", + _mesa_lookup_enum_by_nr(ctx->Query.CondRenderMode)); + return GL_TRUE; + } +} diff --git a/mesalib/src/mesa/main/condrender.h b/mesalib/src/mesa/main/condrender.h index d55e9805f..49e9953be 100644 --- a/mesalib/src/mesa/main/condrender.h +++ b/mesalib/src/mesa/main/condrender.h @@ -1,45 +1,45 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -#ifndef CONDRENDER_H -#define CONDRENDER_H - - -#include "glheader.h" -#include "context.h" - - -extern void GLAPIENTRY -_mesa_BeginConditionalRender(GLuint queryId, GLenum mode); - -extern void APIENTRY -_mesa_EndConditionalRender(void); - -extern GLboolean -_mesa_check_conditional_render(GLcontext *ctx); - - -#endif /* CONDRENDER_H */ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +#ifndef CONDRENDER_H +#define CONDRENDER_H + + +#include "glheader.h" +#include "context.h" + + +extern void GLAPIENTRY +_mesa_BeginConditionalRender(GLuint queryId, GLenum mode); + +extern void APIENTRY +_mesa_EndConditionalRender(void); + +extern GLboolean +_mesa_check_conditional_render(struct gl_context *ctx); + + +#endif /* CONDRENDER_H */ diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h index 0f2d1a8f8..a12f7f4f3 100644 --- a/mesalib/src/mesa/main/config.h +++ b/mesalib/src/mesa/main/config.h @@ -1,338 +1,358 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file config.h - * Tunable configuration parameters. - */ - -#ifndef MESA_CONFIG_H_INCLUDED -#define MESA_CONFIG_H_INCLUDED - - -/** - * \name OpenGL implementation limits - */ -/*@{*/ - -/** Maximum modelview matrix stack depth */ -#define MAX_MODELVIEW_STACK_DEPTH 32 - -/** Maximum projection matrix stack depth */ -#define MAX_PROJECTION_STACK_DEPTH 32 - -/** Maximum texture matrix stack depth */ -#define MAX_TEXTURE_STACK_DEPTH 10 - -/** Maximum color matrix stack depth */ -#define MAX_COLOR_STACK_DEPTH 4 - -/** Maximum attribute stack depth */ -#define MAX_ATTRIB_STACK_DEPTH 16 - -/** Maximum client attribute stack depth */ -#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16 - -/** Maximum recursion depth of display list calls */ -#define MAX_LIST_NESTING 64 - -/** Maximum number of lights */ -#define MAX_LIGHTS 8 - -/** Maximum user-defined clipping planes */ -#define MAX_CLIP_PLANES 6 - -/** Maximum pixel map lookup table size */ -#define MAX_PIXEL_MAP_TABLE 256 - -/** Maximum number of auxillary color buffers */ -#define MAX_AUX_BUFFERS 1 - -/** Maximum order (degree) of curves */ -#ifdef AMIGA -# define MAX_EVAL_ORDER 12 -#else -# define MAX_EVAL_ORDER 30 -#endif - -/** Maximum Name stack depth */ -#define MAX_NAME_STACK_DEPTH 64 - -/** Minimum point size */ -#define MIN_POINT_SIZE 1.0 -/** Maximum point size */ -#define MAX_POINT_SIZE 60.0 -/** Point size granularity */ -#define POINT_SIZE_GRANULARITY 0.1 - -/** Minimum line width */ -#define MIN_LINE_WIDTH 1.0 -/** Maximum line width */ -#define MAX_LINE_WIDTH 10.0 -/** Line width granularity */ -#define LINE_WIDTH_GRANULARITY 0.1 - -/** Max texture palette / color table size */ -#define MAX_COLOR_TABLE_SIZE 256 - -/** Number of 1D/2D texture mipmap levels */ -#define MAX_TEXTURE_LEVELS 13 - -/** Number of 3D texture mipmap levels */ -#define MAX_3D_TEXTURE_LEVELS 9 - -/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */ -#define MAX_CUBE_TEXTURE_LEVELS 13 - -/** Maximum rectangular texture size - GL_NV_texture_rectangle */ -#define MAX_TEXTURE_RECT_SIZE 4096 - -/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */ -#define MAX_ARRAY_TEXTURE_LAYERS 64 - -/** - * Max number of texture coordinate units. This mainly just applies to - * the fixed-function vertex code. This will be difficult to raise above - * eight because of various vertex attribute bitvectors. - */ -#define MAX_TEXTURE_COORD_UNITS 8 - -/** - * Max number of texture image units. Also determines number of texture - * samplers in shaders. - */ -#define MAX_TEXTURE_IMAGE_UNITS 16 - -/** - * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS. - * This value is only used for dimensioning arrays. - * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the - * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be - * used almost everywhere else. - */ -#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) - - -/** - * Maximum viewport/image width. Must accomodate all texture sizes too. - */ - -#ifndef MAX_WIDTH -# define MAX_WIDTH 4096 -#endif -/** Maximum viewport/image height */ -#ifndef MAX_HEIGHT -# define MAX_HEIGHT 4096 -#endif - -/** Maxmimum size for CVA. May be overridden by the drivers. */ -#define MAX_ARRAY_LOCK_SIZE 3000 - -/** Subpixel precision for antialiasing, window coordinate snapping */ -#define SUB_PIXEL_BITS 4 - -/** Size of histogram tables */ -#define HISTOGRAM_TABLE_SIZE 256 - -/** Max convolution filter width */ -#define MAX_CONVOLUTION_WIDTH 9 -/** Max convolution filter height */ -#define MAX_CONVOLUTION_HEIGHT 9 - -/** For GL_ARB_texture_compression */ -#define MAX_COMPRESSED_TEXTURE_FORMATS 25 - -/** For GL_EXT_texture_filter_anisotropic */ -#define MAX_TEXTURE_MAX_ANISOTROPY 16.0 - -/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */ -#define MAX_TEXTURE_LOD_BIAS 12.0 - -/** For any program target/extension */ -/*@{*/ -#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) - -/** - * Per-program constants (power of two) - * - * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader - * and GLSL shader names for the same thing. They should \b always have the - * same value. Each refers to the number of vec4 values supplied as - * per-program parameters. - */ -/*@{*/ -#define MAX_PROGRAM_LOCAL_PARAMS 1024 -#define MAX_UNIFORMS 1024 -/*@}*/ - -/** - * Per-context constants (power of two) - * - * \note - * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS - * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make - * incorrect assumptions. - */ -#define MAX_PROGRAM_ENV_PARAMS 256 - -#define MAX_PROGRAM_MATRICES 8 -#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4 -#define MAX_PROGRAM_CALL_DEPTH 8 -#define MAX_PROGRAM_TEMPS 256 -#define MAX_PROGRAM_ADDRESS_REGS 2 -#define MAX_VARYING 16 /**< number of float[4] vectors */ -#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS -#define MAX_PROGRAM_INPUTS 32 -#define MAX_PROGRAM_OUTPUTS 64 -/*@}*/ - -/** For GL_ARB_vertex_program */ -/*@{*/ -#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 -#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS -/*@}*/ - -/** For GL_ARB_fragment_program */ -/*@{*/ -#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0 -/*@}*/ - -/** For GL_NV_vertex_program */ -/*@{*/ -#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 -#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 -#define MAX_NV_VERTEX_PROGRAM_PARAMS 96 -#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 -#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 -/*@}*/ - -/** For GL_NV_fragment_program */ -/*@{*/ -#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ -#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 -#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 -#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 -#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 -#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 -/*@}*/ - - -/** For GL_ARB_vertex_shader */ -/*@{*/ -#define MAX_VERTEX_GENERIC_ATTRIBS 16 -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS -#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \ - MAX_TEXTURE_IMAGE_UNITS) -/*@}*/ - - -/** For GL_ARB_draw_buffers */ -/*@{*/ -#define MAX_DRAW_BUFFERS 8 -/*@}*/ - - -/** For GL_EXT_framebuffer_object */ -/*@{*/ -#define MAX_COLOR_ATTACHMENTS 8 -/*@}*/ - -/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */ -#define SUPPORTED_ATI_BUMP_UNITS 0xff - -/** For GL_EXT_transform_feedback */ -#define MAX_FEEDBACK_ATTRIBS 32 - -/** For GL_ARB_geometry_shader4 */ -/*@{*/ -#define MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 8 -#define MAX_GEOMETRY_VARYING_COMPONENTS 32 -#define MAX_VERTEX_VARYING_COMPONENTS 32 -#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512 -#define MAX_GEOMETRY_OUTPUT_VERTICES 256 -#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024 -/*@}*/ - - -/** - * \name Mesa-specific parameters - */ -/*@{*/ - - -/** - * If non-zero use GLdouble for walking triangle edges, for better accuracy. - */ -#define TRIANGLE_WALK_DOUBLE 0 - - -/** - * Bits per depth buffer value (max is 32). - */ -#ifndef DEFAULT_SOFTWARE_DEPTH_BITS -#define DEFAULT_SOFTWARE_DEPTH_BITS 16 -#endif -/** Depth buffer data type */ -#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 -#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort -#else -#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint -#endif - - -/** - * Bits per stencil value: 8 - */ -#define STENCIL_BITS 8 - - -/** - * Bits per color channel: 8, 16 or 32 - */ -#ifndef CHAN_BITS -#define CHAN_BITS 8 -#endif - - -/* - * Color channel component order - * - * \note Changes will almost certainly cause problems at this time. - */ -#define RCOMP 0 -#define GCOMP 1 -#define BCOMP 2 -#define ACOMP 3 - - -/** - * Maximum number of temporary vertices required for clipping. - * - * Used in array_cache and tnl modules. - */ -#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) - - -#endif /* MESA_CONFIG_H_INCLUDED */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file config.h + * Tunable configuration parameters. + */ + +#ifndef MESA_CONFIG_H_INCLUDED +#define MESA_CONFIG_H_INCLUDED + + +/** + * \name OpenGL implementation limits + */ +/*@{*/ + +/** Maximum modelview matrix stack depth */ +#define MAX_MODELVIEW_STACK_DEPTH 32 + +/** Maximum projection matrix stack depth */ +#define MAX_PROJECTION_STACK_DEPTH 32 + +/** Maximum texture matrix stack depth */ +#define MAX_TEXTURE_STACK_DEPTH 10 + +/** Maximum color matrix stack depth */ +#define MAX_COLOR_STACK_DEPTH 4 + +/** Maximum attribute stack depth */ +#define MAX_ATTRIB_STACK_DEPTH 16 + +/** Maximum client attribute stack depth */ +#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16 + +/** Maximum recursion depth of display list calls */ +#define MAX_LIST_NESTING 64 + +/** Maximum number of lights */ +#define MAX_LIGHTS 8 + +/** Maximum user-defined clipping planes */ +#define MAX_CLIP_PLANES 6 + +/** Maximum pixel map lookup table size */ +#define MAX_PIXEL_MAP_TABLE 256 + +/** Maximum number of auxillary color buffers */ +#define MAX_AUX_BUFFERS 1 + +/** Maximum order (degree) of curves */ +#ifdef AMIGA +# define MAX_EVAL_ORDER 12 +#else +# define MAX_EVAL_ORDER 30 +#endif + +/** Maximum Name stack depth */ +#define MAX_NAME_STACK_DEPTH 64 + +/** Minimum point size */ +#define MIN_POINT_SIZE 1.0 +/** Maximum point size */ +#define MAX_POINT_SIZE 60.0 +/** Point size granularity */ +#define POINT_SIZE_GRANULARITY 0.1 + +/** Minimum line width */ +#define MIN_LINE_WIDTH 1.0 +/** Maximum line width */ +#define MAX_LINE_WIDTH 10.0 +/** Line width granularity */ +#define LINE_WIDTH_GRANULARITY 0.1 + +/** Max texture palette / color table size */ +#define MAX_COLOR_TABLE_SIZE 256 + +/** Max memory to allow for a single texture image (in megabytes) */ +#define MAX_TEXTURE_MBYTES 1024 + +/** Number of 1D/2D texture mipmap levels */ +#define MAX_TEXTURE_LEVELS 15 + +/** Number of 3D texture mipmap levels */ +#define MAX_3D_TEXTURE_LEVELS 15 + +/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */ +#define MAX_CUBE_TEXTURE_LEVELS 15 + +/** Maximum rectangular texture size - GL_NV_texture_rectangle */ +#define MAX_TEXTURE_RECT_SIZE 16384 + +/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */ +#define MAX_ARRAY_TEXTURE_LAYERS 64 + +/** + * Max number of texture coordinate units. This mainly just applies to + * the fixed-function vertex code. This will be difficult to raise above + * eight because of various vertex attribute bitvectors. + */ +#define MAX_TEXTURE_COORD_UNITS 8 + +/** + * Max number of texture image units. Also determines number of texture + * samplers in shaders. + */ +#define MAX_TEXTURE_IMAGE_UNITS 16 + +/** + * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS. + * This value is only used for dimensioning arrays. + * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the + * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be + * used almost everywhere else. + */ +#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) + + +/** + * Maximum viewport/image width. Must accomodate all texture sizes too. + */ + +#ifndef MAX_WIDTH +# define MAX_WIDTH 16384 +#endif +/** Maximum viewport/image height */ +#ifndef MAX_HEIGHT +# define MAX_HEIGHT 16384 +#endif + +/* XXX: hack to prevent stack overflow on windows until all temporary arrays + * [MAX_WIDTH] are allocated from the heap */ +#ifdef WIN32 +#undef MAX_TEXTURE_LEVELS +#undef MAX_3D_TEXTURE_LEVELS +#undef MAX_CUBE_TEXTURE_LEVELS +#undef MAX_TEXTURE_RECT_SIZE +#undef MAX_WIDTH +#undef MAX_HEIGHT +#define MAX_TEXTURE_LEVELS 13 +#define MAX_3D_TEXTURE_LEVELS 9 +#define MAX_CUBE_TEXTURE_LEVELS 13 +#define MAX_TEXTURE_RECT_SIZE 4096 +#define MAX_WIDTH 4096 +#define MAX_HEIGHT 4096 +#endif + +/** Maxmimum size for CVA. May be overridden by the drivers. */ +#define MAX_ARRAY_LOCK_SIZE 3000 + +/** Subpixel precision for antialiasing, window coordinate snapping */ +#define SUB_PIXEL_BITS 4 + +/** Size of histogram tables */ +#define HISTOGRAM_TABLE_SIZE 256 + +/** Max convolution filter width */ +#define MAX_CONVOLUTION_WIDTH 9 +/** Max convolution filter height */ +#define MAX_CONVOLUTION_HEIGHT 9 + +/** For GL_ARB_texture_compression */ +#define MAX_COMPRESSED_TEXTURE_FORMATS 25 + +/** For GL_EXT_texture_filter_anisotropic */ +#define MAX_TEXTURE_MAX_ANISOTROPY 16.0 + +/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */ +#define MAX_TEXTURE_LOD_BIAS 14.0 + +/** For any program target/extension */ +/*@{*/ +#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) + +/** + * Per-program constants (power of two) + * + * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader + * and GLSL shader names for the same thing. They should \b always have the + * same value. Each refers to the number of vec4 values supplied as + * per-program parameters. + */ +/*@{*/ +#define MAX_PROGRAM_LOCAL_PARAMS 1024 +#define MAX_UNIFORMS 1024 +/*@}*/ + +/** + * Per-context constants (power of two) + * + * \note + * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS + * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make + * incorrect assumptions. + */ +#define MAX_PROGRAM_ENV_PARAMS 256 + +#define MAX_PROGRAM_MATRICES 8 +#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4 +#define MAX_PROGRAM_CALL_DEPTH 8 +#define MAX_PROGRAM_TEMPS 256 +#define MAX_PROGRAM_ADDRESS_REGS 2 +#define MAX_VARYING 16 /**< number of float[4] vectors */ +#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS +#define MAX_PROGRAM_INPUTS 32 +#define MAX_PROGRAM_OUTPUTS 64 +/*@}*/ + +/** For GL_ARB_vertex_program */ +/*@{*/ +#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 +#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS +/*@}*/ + +/** For GL_ARB_fragment_program */ +/*@{*/ +#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0 +/*@}*/ + +/** For GL_NV_vertex_program */ +/*@{*/ +#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 +#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 +#define MAX_NV_VERTEX_PROGRAM_PARAMS 96 +#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 +#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 +/*@}*/ + +/** For GL_NV_fragment_program */ +/*@{*/ +#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ +#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 +#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 +#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 +#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 +#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 +/*@}*/ + + +/** For GL_ARB_vertex_shader */ +/*@{*/ +#define MAX_VERTEX_GENERIC_ATTRIBS 16 +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS +#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \ + MAX_TEXTURE_IMAGE_UNITS) +/*@}*/ + + +/** For GL_ARB_draw_buffers */ +/*@{*/ +#define MAX_DRAW_BUFFERS 8 +/*@}*/ + + +/** For GL_EXT_framebuffer_object */ +/*@{*/ +#define MAX_COLOR_ATTACHMENTS 8 +/*@}*/ + +/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */ +#define SUPPORTED_ATI_BUMP_UNITS 0xff + +/** For GL_EXT_transform_feedback */ +#define MAX_FEEDBACK_ATTRIBS 32 + +/** For GL_ARB_geometry_shader4 */ +/*@{*/ +#define MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 8 +#define MAX_GEOMETRY_VARYING_COMPONENTS 32 +#define MAX_VERTEX_VARYING_COMPONENTS 32 +#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512 +#define MAX_GEOMETRY_OUTPUT_VERTICES 256 +#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024 +/*@}*/ + + +/** + * \name Mesa-specific parameters + */ +/*@{*/ + + +/** + * If non-zero use GLdouble for walking triangle edges, for better accuracy. + */ +#define TRIANGLE_WALK_DOUBLE 0 + + +/** + * Bits per depth buffer value (max is 32). + */ +#ifndef DEFAULT_SOFTWARE_DEPTH_BITS +#define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#endif +/** Depth buffer data type */ +#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16 +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort +#else +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint +#endif + + +/** + * Bits per stencil value: 8 + */ +#define STENCIL_BITS 8 + + +/** + * Bits per color channel: 8, 16 or 32 + */ +#ifndef CHAN_BITS +#define CHAN_BITS 8 +#endif + + +/* + * Color channel component order + * + * \note Changes will almost certainly cause problems at this time. + */ +#define RCOMP 0 +#define GCOMP 1 +#define BCOMP 2 +#define ACOMP 3 + + +/** + * Maximum number of temporary vertices required for clipping. + * + * Used in array_cache and tnl modules. + */ +#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) + + +#endif /* MESA_CONFIG_H_INCLUDED */ diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 3bddf2570..a18af86a3 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -1,1782 +1,1885 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file context.c - * Mesa context/visual/framebuffer management functions. - * \author Brian Paul - */ - -/** - * \mainpage Mesa Main Module - * - * \section MainIntroduction Introduction - * - * The Mesa Main module consists of all the files in the main/ directory. - * Among the features of this module are: - *
    - *
  • Structures to represent most GL state
  • - *
  • State set/get functions
  • - *
  • Display lists
  • - *
  • Texture unit, object and image handling
  • - *
  • Matrix and attribute stacks
  • - *
- * - * Other modules are responsible for API dispatch, vertex transformation, - * point/line/triangle setup, rasterization, vertex array caching, - * vertex/fragment programs/shaders, etc. - * - * - * \section AboutDoxygen About Doxygen - * - * If you're viewing this information as Doxygen-generated HTML you'll - * see the documentation index at the top of this page. - * - * The first line lists the Mesa source code modules. - * The second line lists the indexes available for viewing the documentation - * for each module. - * - * Selecting the Main page link will display a summary of the module - * (this page). - * - * Selecting Data Structures will list all C structures. - * - * Selecting the File List link will list all the source files in - * the module. - * Selecting a filename will show a list of all functions defined in that file. - * - * Selecting the Data Fields link will display a list of all - * documented structure members. - * - * Selecting the Globals link will display a list - * of all functions, structures, global variables and macros in the module. - * - */ - - -#include "glheader.h" -#include "mfeatures.h" -#include "imports.h" -#include "accum.h" -#include "api_exec.h" -#include "arrayobj.h" -#include "attrib.h" -#include "blend.h" -#include "buffers.h" -#include "bufferobj.h" -#include "colortab.h" -#include "context.h" -#include "cpuinfo.h" -#include "debug.h" -#include "depth.h" -#include "dlist.h" -#include "eval.h" -#include "extensions.h" -#include "fbobject.h" -#include "feedback.h" -#include "fog.h" -#include "framebuffer.h" -#include "histogram.h" -#include "hint.h" -#include "hash.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "multisample.h" -#include "pixel.h" -#include "pixelstore.h" -#include "points.h" -#include "polygon.h" -#include "queryobj.h" -#include "syncobj.h" -#include "rastpos.h" -#include "remap.h" -#include "scissor.h" -#include "shared.h" -#include "shaderobj.h" -#include "simple_list.h" -#include "state.h" -#include "stencil.h" -#include "texcompress_s3tc.h" -#include "texstate.h" -#include "transformfeedback.h" -#include "mtypes.h" -#include "varray.h" -#include "version.h" -#include "viewport.h" -#include "vtxfmt.h" -#include "program/program.h" -#include "program/prog_print.h" -#if _HAVE_FULL_GL -#include "math/m_matrix.h" -#endif - -#ifdef USE_SPARC_ASM -#include "sparc/sparc.h" -#endif - -#include "glsl_parser_extras.h" - - - -#ifndef MESA_VERBOSE -int MESA_VERBOSE = 0; -#endif - -#ifndef MESA_DEBUG_FLAGS -int MESA_DEBUG_FLAGS = 0; -#endif - - -/* ubyte -> float conversion */ -GLfloat _mesa_ubyte_to_float_color_tab[256]; - - - -/** - * Swap buffers notification callback. - * - * \param ctx GL context. - * - * Called by window system just before swapping buffers. - * We have to finish any pending rendering. - */ -void -_mesa_notifySwapBuffers(__GLcontext *ctx) -{ - if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS) - _mesa_debug(ctx, "SwapBuffers\n"); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } -} - - -/**********************************************************************/ -/** \name GL Visual allocation/destruction */ -/**********************************************************************/ -/*@{*/ - -/** - * Allocates a GLvisual structure and initializes it via - * _mesa_initialize_visual(). - * - * \param dbFlag double buffering - * \param stereoFlag stereo buffer - * \param depthBits requested bits per depth buffer value. Any value in [0, 32] - * is acceptable but the actual depth type will be GLushort or GLuint as - * needed. - * \param stencilBits requested minimum bits per stencil buffer value - * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number of bits per color component in accum buffer. - * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE - * \param redBits number of bits per color component in frame buffer for RGB(A) - * mode. We always use 8 in core Mesa though. - * \param greenBits same as above. - * \param blueBits same as above. - * \param alphaBits same as above. - * \param numSamples not really used. - * - * \return pointer to new GLvisual or NULL if requested parameters can't be - * met. - * - * \note Need to add params for level and numAuxBuffers (at least) - */ -GLvisual * -_mesa_create_visual( GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits, - GLint numSamples ) -{ - GLvisual *vis = (GLvisual *) calloc(1, sizeof(GLvisual)); - if (vis) { - if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag, - redBits, greenBits, blueBits, alphaBits, - depthBits, stencilBits, - accumRedBits, accumGreenBits, - accumBlueBits, accumAlphaBits, - numSamples)) { - free(vis); - return NULL; - } - } - return vis; -} - -/** - * Makes some sanity checks and fills in the fields of the - * GLvisual object with the given parameters. If the caller needs - * to set additional fields, he should just probably init the whole GLvisual - * object himself. - * \return GL_TRUE on success, or GL_FALSE on failure. - * - * \sa _mesa_create_visual() above for the parameter description. - */ -GLboolean -_mesa_initialize_visual( GLvisual *vis, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits, - GLint numSamples ) -{ - assert(vis); - - if (depthBits < 0 || depthBits > 32) { - return GL_FALSE; - } - if (stencilBits < 0 || stencilBits > STENCIL_BITS) { - return GL_FALSE; - } - assert(accumRedBits >= 0); - assert(accumGreenBits >= 0); - assert(accumBlueBits >= 0); - assert(accumAlphaBits >= 0); - - vis->rgbMode = GL_TRUE; - vis->doubleBufferMode = dbFlag; - vis->stereoMode = stereoFlag; - - vis->redBits = redBits; - vis->greenBits = greenBits; - vis->blueBits = blueBits; - vis->alphaBits = alphaBits; - vis->rgbBits = redBits + greenBits + blueBits; - - vis->indexBits = 0; - vis->depthBits = depthBits; - vis->stencilBits = stencilBits; - - vis->accumRedBits = accumRedBits; - vis->accumGreenBits = accumGreenBits; - vis->accumBlueBits = accumBlueBits; - vis->accumAlphaBits = accumAlphaBits; - - vis->haveAccumBuffer = accumRedBits > 0; - vis->haveDepthBuffer = depthBits > 0; - vis->haveStencilBuffer = stencilBits > 0; - - vis->numAuxBuffers = 0; - vis->level = 0; - vis->pixmapMode = 0; - vis->sampleBuffers = numSamples > 0 ? 1 : 0; - vis->samples = numSamples; - - return GL_TRUE; -} - - -/** - * Destroy a visual and free its memory. - * - * \param vis visual. - * - * Frees the visual structure. - */ -void -_mesa_destroy_visual( GLvisual *vis ) -{ - free(vis); -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Context allocation, initialization, destroying - * - * The purpose of the most initialization functions here is to provide the - * default state values according to the OpenGL specification. - */ -/**********************************************************************/ -/*@{*/ - - -/** - * This is lame. gdb only seems to recognize enum types that are - * actually used somewhere. We want to be able to print/use enum - * values such as TEXTURE_2D_INDEX in gdb. But we don't actually use - * the gl_texture_index type anywhere. Thus, this lame function. - */ -static void -dummy_enum_func(void) -{ - gl_buffer_index bi = BUFFER_FRONT_LEFT; - gl_colortable_index ci = COLORTABLE_PRECONVOLUTION; - gl_face_index fi = FACE_POS_X; - gl_frag_attrib fa = FRAG_ATTRIB_WPOS; - gl_frag_result fr = FRAG_RESULT_DEPTH; - gl_texture_index ti = TEXTURE_2D_ARRAY_INDEX; - gl_vert_attrib va = VERT_ATTRIB_POS; - gl_vert_result vr = VERT_RESULT_HPOS; - gl_geom_attrib ga = GEOM_ATTRIB_POSITION; - gl_geom_result gr = GEOM_RESULT_POS; - - (void) bi; - (void) ci; - (void) fi; - (void) fa; - (void) fr; - (void) ti; - (void) va; - (void) vr; - (void) ga; - (void) gr; -} - - -/** - * One-time initialization mutex lock. - * - * \sa Used by one_time_init(). - */ -_glthread_DECLARE_STATIC_MUTEX(OneTimeLock); - -/** - * Calls all the various one-time-init functions in Mesa. - * - * While holding a global mutex lock, calls several initialization functions, - * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is - * defined. - * - * \sa _math_init(). - */ -static void -one_time_init( GLcontext *ctx ) -{ - static GLboolean alreadyCalled = GL_FALSE; - (void) ctx; - _glthread_LOCK_MUTEX(OneTimeLock); - if (!alreadyCalled) { - GLuint i; - - /* do some implementation tests */ - assert( sizeof(GLbyte) == 1 ); - assert( sizeof(GLubyte) == 1 ); - assert( sizeof(GLshort) == 2 ); - assert( sizeof(GLushort) == 2 ); - assert( sizeof(GLint) == 4 ); - assert( sizeof(GLuint) == 4 ); - - _mesa_get_cpu_features(); - - switch (ctx->API) { -#if FEATURE_GL - case API_OPENGL: - _mesa_init_remap_table(); - break; -#endif -#if FEATURE_ES1 - case API_OPENGLES: - _mesa_init_remap_table_es1(); - break; -#endif -#if FEATURE_ES2 - case API_OPENGLES2: - _mesa_init_remap_table_es2(); - break; -#endif - default: - break; - } - - _mesa_init_sqrt_table(); - _mesa_init_get_hash(ctx); - - for (i = 0; i < 256; i++) { - _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; - } - -#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__) - _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n", - MESA_VERSION_STRING, __DATE__, __TIME__); -#endif - - alreadyCalled = GL_TRUE; - } - _glthread_UNLOCK_MUTEX(OneTimeLock); - - /* Hopefully atexit() is widely available. If not, we may need some - * #ifdef tests here. - */ - atexit(_mesa_destroy_shader_compiler); - - dummy_enum_func(); -} - - -/** - * Initialize fields of gl_current_attrib (aka ctx->Current.*) - */ -static void -_mesa_init_current(GLcontext *ctx) -{ - GLuint i; - - /* Init all to (0,0,0,1) */ - for (i = 0; i < Elements(ctx->Current.Attrib); i++) { - ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 ); - } - - /* redo special cases: */ - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 ); -} - - -/** - * Init vertex/fragment/geometry program limits. - * Important: drivers should override these with actual limits. - */ -static void -init_program_limits(GLenum type, struct gl_program_constants *prog) -{ - prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTemps = MAX_PROGRAM_TEMPS; - prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; - prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; - prog->MaxUniformComponents = 4 * MAX_UNIFORMS; - - switch (type) { - case GL_VERTEX_PROGRAM_ARB: - prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS; - prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; - prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; - break; - case GL_FRAGMENT_PROGRAM_ARB: - prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS; - prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS; - prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; - break; - case MESA_GEOMETRY_PROGRAM: - prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS; - prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; - prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; - - prog->MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS; - prog->MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS; - prog->MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS; - prog->MaxGeometryUniformComponents = MAX_GEOMETRY_UNIFORM_COMPONENTS; - prog->MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES; - prog->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS; - break; - default: - assert(0 && "Bad program type in init_program_limits()"); - } - - /* Set the native limits to zero. This implies that there is no native - * support for shaders. Let the drivers fill in the actual values. - */ - prog->MaxNativeInstructions = 0; - prog->MaxNativeAluInstructions = 0; - prog->MaxNativeTexInstructions = 0; - prog->MaxNativeTexIndirections = 0; - prog->MaxNativeAttribs = 0; - prog->MaxNativeTemps = 0; - prog->MaxNativeAddressRegs = 0; - prog->MaxNativeParameters = 0; -} - - -/** - * Initialize fields of gl_constants (aka ctx->Const.*). - * Use defaults from config.h. The device drivers will often override - * some of these values (such as number of texture units). - */ -static void -_mesa_init_constants(GLcontext *ctx) -{ - assert(ctx); - - /* Constants, may be overriden (usually only reduced) by device drivers */ - ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; - ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; - ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; - ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE; - ctx->Const.MaxArrayTextureLayers = MAX_ARRAY_TEXTURE_LAYERS; - ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS; - ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits, - ctx->Const.MaxTextureImageUnits); - ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY; - ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS; - ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; - ctx->Const.SubPixelBits = SUB_PIXEL_BITS; - ctx->Const.MinPointSize = MIN_POINT_SIZE; - ctx->Const.MaxPointSize = MAX_POINT_SIZE; - ctx->Const.MinPointSizeAA = MIN_POINT_SIZE; - ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE; - ctx->Const.PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY; - ctx->Const.MinLineWidth = MIN_LINE_WIDTH; - ctx->Const.MaxLineWidth = MAX_LINE_WIDTH; - ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH; - ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; - ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY; - ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE; - ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH; - ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT; - ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES; - ctx->Const.MaxLights = MAX_LIGHTS; - ctx->Const.MaxShininess = 128.0; - ctx->Const.MaxSpotExponent = 128.0; - ctx->Const.MaxViewportWidth = MAX_WIDTH; - ctx->Const.MaxViewportHeight = MAX_HEIGHT; -#if FEATURE_ARB_vertex_program - init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram); -#endif -#if FEATURE_ARB_fragment_program - init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram); -#endif -#if FEATURE_ARB_geometry_shader4 - init_program_limits(MESA_GEOMETRY_PROGRAM, &ctx->Const.GeometryProgram); -#endif - ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; - ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; - - /* CheckArrayBounds is overriden by drivers/x11 for X server */ - ctx->Const.CheckArrayBounds = GL_FALSE; - - /* GL_ARB_draw_buffers */ - ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS; - -#if FEATURE_EXT_framebuffer_object - ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS; - ctx->Const.MaxRenderbufferSize = MAX_WIDTH; -#endif - -#if FEATURE_ARB_vertex_shader - ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxVarying = MAX_VARYING; -#endif - - /* Shading language version */ - if (ctx->API == API_OPENGL) { -#if FEATURE_ARB_shading_language_120 - ctx->Const.GLSLVersion = 120; -#else - ctx->Const.GLSLVersion = 110; -#endif - } - else if (ctx->API == API_OPENGLES2) { - ctx->Const.GLSLVersion = 100; - } - else if (ctx->API == API_OPENGLES) { - ctx->Const.GLSLVersion = 0; /* GLSL not supported */ - } - - /* GL_ARB_framebuffer_object */ - ctx->Const.MaxSamples = 0; - - /* GL_ARB_sync */ - ctx->Const.MaxServerWaitTimeout = (GLuint64) ~0; - - /* GL_ATI_envmap_bumpmap */ - ctx->Const.SupportedBumpUnits = SUPPORTED_ATI_BUMP_UNITS; - - /* GL_EXT_provoking_vertex */ - ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE; - - /* GL_EXT_transform_feedback */ - ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS; - ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS; - ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS; - - /* GL 3.2: hard-coded for now: */ - ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; -} - - -/** - * Do some sanity checks on the limits/constants for the given context. - * Only called the first time a context is bound. - */ -static void -check_context_limits(GLcontext *ctx) -{ - /* check that we don't exceed the size of various bitfields */ - assert(VERT_RESULT_MAX <= - (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); - assert(FRAG_ATTRIB_MAX <= - (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead))); - - assert(MAX_COMBINED_TEXTURE_IMAGE_UNITS <= 8 * sizeof(GLbitfield)); - - /* shader-related checks */ - assert(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); - assert(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); - - assert(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); - assert(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); - assert(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX); - assert(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX); - - /* Texture unit checks */ - assert(ctx->Const.MaxTextureImageUnits > 0); - assert(ctx->Const.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureCoordUnits > 0); - assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS); - assert(ctx->Const.MaxTextureUnits > 0); - assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS); - assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.MaxTextureImageUnits, - ctx->Const.MaxTextureCoordUnits)); - assert(ctx->Const.MaxCombinedTextureImageUnits > 0); - assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); - /* number of coord units cannot be greater than number of image units */ - assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits); - - - /* Texture size checks */ - assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS); - assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS); - assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS); - assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE); - - /* make sure largest texture image is <= MAX_WIDTH in size */ - assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= MAX_WIDTH); - assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= MAX_WIDTH); - - /* Texture level checks */ - assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); - assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); - - /* Max texture size should be <= max viewport size (render to texture) */ - assert((1 << (MAX_TEXTURE_LEVELS - 1)) <= MAX_WIDTH); - - assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); - assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); - - assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS); - - /* if this fails, add more enum values to gl_buffer_index */ - assert(BUFFER_COLOR0 + MAX_DRAW_BUFFERS <= BUFFER_COUNT); - - /* XXX probably add more tests */ -} - - -/** - * Initialize the attribute groups in a GL context. - * - * \param ctx GL context. - * - * Initializes all the attributes, calling the respective init* - * functions for the more complex data structures. - */ -static GLboolean -init_attrib_groups(GLcontext *ctx) -{ - assert(ctx); - - /* Constants */ - _mesa_init_constants( ctx ); - - /* Extensions */ - _mesa_init_extensions( ctx ); - - /* Attribute Groups */ - _mesa_init_accum( ctx ); - _mesa_init_attrib( ctx ); - _mesa_init_buffer_objects( ctx ); - _mesa_init_color( ctx ); - _mesa_init_colortables( ctx ); - _mesa_init_current( ctx ); - _mesa_init_depth( ctx ); - _mesa_init_debug( ctx ); - _mesa_init_display_list( ctx ); - _mesa_init_eval( ctx ); - _mesa_init_fbobjects( ctx ); - _mesa_init_feedback( ctx ); - _mesa_init_fog( ctx ); - _mesa_init_histogram( ctx ); - _mesa_init_hint( ctx ); - _mesa_init_line( ctx ); - _mesa_init_lighting( ctx ); - _mesa_init_matrix( ctx ); - _mesa_init_multisample( ctx ); - _mesa_init_pixel( ctx ); - _mesa_init_pixelstore( ctx ); - _mesa_init_point( ctx ); - _mesa_init_polygon( ctx ); - _mesa_init_program( ctx ); - _mesa_init_queryobj( ctx ); - _mesa_init_sync( ctx ); - _mesa_init_rastpos( ctx ); - _mesa_init_scissor( ctx ); - _mesa_init_shader_state( ctx ); - _mesa_init_stencil( ctx ); - _mesa_init_transform( ctx ); - _mesa_init_transform_feedback( ctx ); - _mesa_init_varray( ctx ); - _mesa_init_viewport( ctx ); - - if (!_mesa_init_texture( ctx )) - return GL_FALSE; - - _mesa_init_texture_s3tc( ctx ); - - /* Miscellaneous */ - ctx->NewState = _NEW_ALL; - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - ctx->varying_vp_inputs = ~0; - - return GL_TRUE; -} - - -/** - * Update default objects in a GL context with respect to shared state. - * - * \param ctx GL context. - * - * Removes references to old default objects, (texture objects, program - * objects, etc.) and changes to reference those from the current shared - * state. - */ -static GLboolean -update_default_objects(GLcontext *ctx) -{ - assert(ctx); - - _mesa_update_default_objects_program(ctx); - _mesa_update_default_objects_texture(ctx); - _mesa_update_default_objects_buffer_objects(ctx); - - return GL_TRUE; -} - - -/** - * This is the default function we plug into all dispatch table slots - * This helps prevents a segfault when someone calls a GL function without - * first checking if the extension's supported. - */ -static int -generic_nop(void) -{ - _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)"); - return 0; -} - - -/** - * Allocate and initialize a new dispatch table. - */ -struct _glapi_table * -_mesa_alloc_dispatch_table(int size) -{ - /* Find the larger of Mesa's dispatch table and libGL's dispatch table. - * In practice, this'll be the same for stand-alone Mesa. But for DRI - * Mesa we do this to accomodate different versions of libGL and various - * DRI drivers. - */ - GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), - size / sizeof(_glapi_proc)); - struct _glapi_table *table = - (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc)); - if (table) { - _glapi_proc *entry = (_glapi_proc *) table; - GLint i; - for (i = 0; i < numEntries; i++) { - entry[i] = (_glapi_proc) generic_nop; - } - } - return table; -} - - -/** - * Initialize a GLcontext struct (rendering context). - * - * This includes allocating all the other structs and arrays which hang off of - * the context by pointers. - * Note that the driver needs to pass in its dd_function_table here since - * we need to at least call driverFunctions->NewTextureObject to create the - * default texture objects. - * - * Called by _mesa_create_context(). - * - * Performs the imports and exports callback tables initialization, and - * miscellaneous one-time initializations. If no shared context is supplied one - * is allocated, and increase its reference count. Setups the GL API dispatch - * tables. Initialize the TNL module. Sets the maximum Z buffer depth. - * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables - * for debug flags. - * - * \param ctx the context to initialize - * \param api the GL API type to create the context for - * \param visual describes the visual attributes for this context - * \param share_list points to context to share textures, display lists, - * etc with, or NULL - * \param driverFunctions table of device driver functions for this context - * to use - * \param driverContext pointer to driver-specific context data - */ -GLboolean -_mesa_initialize_context_for_api(GLcontext *ctx, - gl_api api, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - struct gl_shared_state *shared; - int i; - - /*ASSERT(driverContext);*/ - assert(driverFunctions->NewTextureObject); - assert(driverFunctions->FreeTexImageData); - - ctx->API = api; - ctx->Visual = *visual; - ctx->DrawBuffer = NULL; - ctx->ReadBuffer = NULL; - ctx->WinSysDrawBuffer = NULL; - ctx->WinSysReadBuffer = NULL; - - /* misc one-time initializations */ - one_time_init(ctx); - - /* Plug in driver functions and context pointer here. - * This is important because when we call alloc_shared_state() below - * we'll call ctx->Driver.NewTextureObject() to create the default - * textures. - */ - ctx->Driver = *driverFunctions; - ctx->DriverCtx = driverContext; - - if (share_list) { - /* share state with another context */ - shared = share_list->Shared; - } - else { - /* allocate new, unshared state */ - shared = _mesa_alloc_shared_state(ctx); - if (!shared) - return GL_FALSE; - } - - _glthread_LOCK_MUTEX(shared->Mutex); - ctx->Shared = shared; - shared->RefCount++; - _glthread_UNLOCK_MUTEX(shared->Mutex); - - if (!init_attrib_groups( ctx )) { - _mesa_release_shared_state(ctx, ctx->Shared); - return GL_FALSE; - } - -#if FEATURE_dispatch - /* setup the API dispatch tables */ - switch (ctx->API) { -#if FEATURE_GL - case API_OPENGL: - ctx->Exec = _mesa_create_exec_table(); - break; -#endif -#if FEATURE_ES1 - case API_OPENGLES: - ctx->Exec = _mesa_create_exec_table_es1(); - break; -#endif -#if FEATURE_ES2 - case API_OPENGLES2: - ctx->Exec = _mesa_create_exec_table_es2(); - break; -#endif - default: - _mesa_problem(ctx, "unknown or unsupported API"); - break; - } - - if (!ctx->Exec) { - _mesa_release_shared_state(ctx, ctx->Shared); - return GL_FALSE; - } -#endif - ctx->CurrentDispatch = ctx->Exec; - - ctx->FragmentProgram._MaintainTexEnvProgram - = (_mesa_getenv("MESA_TEX_PROG") != NULL); - - ctx->VertexProgram._MaintainTnlProgram - = (_mesa_getenv("MESA_TNL_PROG") != NULL); - if (ctx->VertexProgram._MaintainTnlProgram) { - /* this is required... */ - ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; - } - - switch (ctx->API) { - case API_OPENGL: - /* Neutral tnl module stuff */ - _mesa_init_exec_vtxfmt( ctx ); - ctx->TnlModule.Current = NULL; - ctx->TnlModule.SwapCount = 0; - -#if FEATURE_dlist - ctx->Save = _mesa_create_save_table(); - if (!ctx->Save) { - _mesa_release_shared_state(ctx, ctx->Shared); - free(ctx->Exec); - return GL_FALSE; - } - - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); -#endif - break; - case API_OPENGLES: - /** - * GL_OES_texture_cube_map says - * "Initially all texture generation modes are set to REFLECTION_MAP_OES" - */ - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; - texUnit->GenS.Mode = GL_REFLECTION_MAP_NV; - texUnit->GenT.Mode = GL_REFLECTION_MAP_NV; - texUnit->GenR.Mode = GL_REFLECTION_MAP_NV; - texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV; - texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV; - texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV; - } - break; - case API_OPENGLES2: - ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; - ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; - ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */ - break; - } - - ctx->FirstTimeCurrent = GL_TRUE; - - return GL_TRUE; -} - -GLboolean -_mesa_initialize_context(GLcontext *ctx, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - return _mesa_initialize_context_for_api(ctx, - API_OPENGL, - visual, - share_list, - driverFunctions, - driverContext); -} - -/** - * Allocate and initialize a GLcontext structure. - * Note that the driver needs to pass in its dd_function_table here since - * we need to at least call driverFunctions->NewTextureObject to initialize - * the rendering context. - * - * \param api the GL API type to create the context for - * \param visual a GLvisual pointer (we copy the struct contents) - * \param share_list another context to share display lists with or NULL - * \param driverFunctions points to the dd_function_table into which the - * driver has plugged in all its special functions. - * \param driverContext points to the device driver's private context state - * - * \return pointer to a new __GLcontextRec or NULL if error. - */ -GLcontext * -_mesa_create_context_for_api(gl_api api, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - GLcontext *ctx; - - ASSERT(visual); - /*ASSERT(driverContext);*/ - - ctx = (GLcontext *) calloc(1, sizeof(GLcontext)); - if (!ctx) - return NULL; - - if (_mesa_initialize_context_for_api(ctx, api, visual, share_list, - driverFunctions, driverContext)) { - return ctx; - } - else { - free(ctx); - return NULL; - } -} - -GLcontext * -_mesa_create_context(const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) -{ - return _mesa_create_context_for_api(API_OPENGL, visual, - share_list, - driverFunctions, - driverContext); -} - -/** - * Free the data associated with the given context. - * - * But doesn't free the GLcontext struct itself. - * - * \sa _mesa_initialize_context() and init_attrib_groups(). - */ -void -_mesa_free_context_data( GLcontext *ctx ) -{ - if (!_mesa_get_current_context()){ - /* No current context, but we may need one in order to delete - * texture objs, etc. So temporarily bind the context now. - */ - _mesa_make_current(ctx, NULL, NULL); - } - - /* unreference WinSysDraw/Read buffers */ - _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); - _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); - _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL); - _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL); - - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL); - - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); - - _mesa_free_attrib_data(ctx); - _mesa_free_buffer_objects(ctx); - _mesa_free_lighting_data( ctx ); - _mesa_free_eval_data( ctx ); - _mesa_free_texture_data( ctx ); - _mesa_free_matrix_data( ctx ); - _mesa_free_viewport_data( ctx ); - _mesa_free_colortables_data( ctx ); - _mesa_free_program_data(ctx); - _mesa_free_shader_state(ctx); - _mesa_free_queryobj_data(ctx); - _mesa_free_sync_data(ctx); - _mesa_free_varray_data(ctx); - _mesa_free_transform_feedback(ctx); - - _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj); - -#if FEATURE_ARB_pixel_buffer_object - _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL); - _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL); -#endif - -#if FEATURE_ARB_vertex_buffer_object - _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL); - _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL); -#endif - - /* free dispatch tables */ - free(ctx->Exec); - free(ctx->Save); - - /* Shared context state (display lists, textures, etc) */ - _mesa_release_shared_state( ctx, ctx->Shared ); - - /* needs to be after freeing shared state */ - _mesa_free_display_list_data(ctx); - - if (ctx->Extensions.String) - free((void *) ctx->Extensions.String); - - if (ctx->VersionString) - free(ctx->VersionString); - - /* unbind the context if it's currently bound */ - if (ctx == _mesa_get_current_context()) { - _mesa_make_current(NULL, NULL, NULL); - } -} - - -/** - * Destroy a GLcontext structure. - * - * \param ctx GL context. - * - * Calls _mesa_free_context_data() and frees the GLcontext structure itself. - */ -void -_mesa_destroy_context( GLcontext *ctx ) -{ - if (ctx) { - _mesa_free_context_data(ctx); - free( (void *) ctx ); - } -} - - -#if _HAVE_FULL_GL -/** - * Copy attribute groups from one context to another. - * - * \param src source context - * \param dst destination context - * \param mask bitwise OR of GL_*_BIT flags - * - * According to the bits specified in \p mask, copies the corresponding - * attributes from \p src into \p dst. For many of the attributes a simple \c - * memcpy is not enough due to the existence of internal pointers in their data - * structures. - */ -void -_mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) -{ - if (mask & GL_ACCUM_BUFFER_BIT) { - /* OK to memcpy */ - dst->Accum = src->Accum; - } - if (mask & GL_COLOR_BUFFER_BIT) { - /* OK to memcpy */ - dst->Color = src->Color; - } - if (mask & GL_CURRENT_BIT) { - /* OK to memcpy */ - dst->Current = src->Current; - } - if (mask & GL_DEPTH_BUFFER_BIT) { - /* OK to memcpy */ - dst->Depth = src->Depth; - } - if (mask & GL_ENABLE_BIT) { - /* no op */ - } - if (mask & GL_EVAL_BIT) { - /* OK to memcpy */ - dst->Eval = src->Eval; - } - if (mask & GL_FOG_BIT) { - /* OK to memcpy */ - dst->Fog = src->Fog; - } - if (mask & GL_HINT_BIT) { - /* OK to memcpy */ - dst->Hint = src->Hint; - } - if (mask & GL_LIGHTING_BIT) { - GLuint i; - /* begin with memcpy */ - dst->Light = src->Light; - /* fixup linked lists to prevent pointer insanity */ - make_empty_list( &(dst->Light.EnabledList) ); - for (i = 0; i < MAX_LIGHTS; i++) { - if (dst->Light.Light[i].Enabled) { - insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i])); - } - } - } - if (mask & GL_LINE_BIT) { - /* OK to memcpy */ - dst->Line = src->Line; - } - if (mask & GL_LIST_BIT) { - /* OK to memcpy */ - dst->List = src->List; - } - if (mask & GL_PIXEL_MODE_BIT) { - /* OK to memcpy */ - dst->Pixel = src->Pixel; - } - if (mask & GL_POINT_BIT) { - /* OK to memcpy */ - dst->Point = src->Point; - } - if (mask & GL_POLYGON_BIT) { - /* OK to memcpy */ - dst->Polygon = src->Polygon; - } - if (mask & GL_POLYGON_STIPPLE_BIT) { - /* Use loop instead of memcpy due to problem with Portland Group's - * C compiler. Reported by John Stone. - */ - GLuint i; - for (i = 0; i < 32; i++) { - dst->PolygonStipple[i] = src->PolygonStipple[i]; - } - } - if (mask & GL_SCISSOR_BIT) { - /* OK to memcpy */ - dst->Scissor = src->Scissor; - } - if (mask & GL_STENCIL_BUFFER_BIT) { - /* OK to memcpy */ - dst->Stencil = src->Stencil; - } - if (mask & GL_TEXTURE_BIT) { - /* Cannot memcpy because of pointers */ - _mesa_copy_texture_state(src, dst); - } - if (mask & GL_TRANSFORM_BIT) { - /* OK to memcpy */ - dst->Transform = src->Transform; - } - if (mask & GL_VIEWPORT_BIT) { - /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */ - dst->Viewport.X = src->Viewport.X; - dst->Viewport.Y = src->Viewport.Y; - dst->Viewport.Width = src->Viewport.Width; - dst->Viewport.Height = src->Viewport.Height; - dst->Viewport.Near = src->Viewport.Near; - dst->Viewport.Far = src->Viewport.Far; - _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap); - } - - /* XXX FIXME: Call callbacks? - */ - dst->NewState = _NEW_ALL; -} -#endif - - -/** - * Check if the given context can render into the given framebuffer - * by checking visual attributes. - * - * Most of these tests could go away because Mesa is now pretty flexible - * in terms of mixing rendering contexts with framebuffers. As long - * as RGB vs. CI mode agree, we're probably good. - * - * \return GL_TRUE if compatible, GL_FALSE otherwise. - */ -static GLboolean -check_compatible(const GLcontext *ctx, const GLframebuffer *buffer) -{ - const GLvisual *ctxvis = &ctx->Visual; - const GLvisual *bufvis = &buffer->Visual; - - if (ctxvis == bufvis) - return GL_TRUE; - - if (buffer == _mesa_get_incomplete_framebuffer()) - return GL_TRUE; - -#if 0 - /* disabling this fixes the fgl_glxgears pbuffer demo */ - if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode) - return GL_FALSE; -#endif - if (ctxvis->stereoMode && !bufvis->stereoMode) - return GL_FALSE; - if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer) - return GL_FALSE; - if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer) - return GL_FALSE; - if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer) - return GL_FALSE; - if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask) - return GL_FALSE; - if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask) - return GL_FALSE; - if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask) - return GL_FALSE; -#if 0 - /* disabled (see bug 11161) */ - if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits) - return GL_FALSE; -#endif - if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Do one-time initialization for the given framebuffer. Specifically, - * ask the driver for the window's current size and update the framebuffer - * object to match. - * Really, the device driver should totally take care of this. - */ -static void -initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb) -{ - GLuint width, height; - if (ctx->Driver.GetBufferSize) { - ctx->Driver.GetBufferSize(fb, &width, &height); - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, fb, width, height); - fb->Initialized = GL_TRUE; - } -} - - -/** - * Check if the viewport/scissor size has not yet been initialized. - * Initialize the size if the given width and height are non-zero. - */ -void -_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height) -{ - if (!ctx->ViewportInitialized && width > 0 && height > 0) { - /* Note: set flag here, before calling _mesa_set_viewport(), to prevent - * potential infinite recursion. - */ - ctx->ViewportInitialized = GL_TRUE; - _mesa_set_viewport(ctx, 0, 0, width, height); - _mesa_set_scissor(ctx, 0, 0, width, height); - } -} - - -/** - * Bind the given context to the given drawBuffer and readBuffer and - * make it the current context for the calling thread. - * We'll render into the drawBuffer and read pixels from the - * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc). - * - * We check that the context's and framebuffer's visuals are compatible - * and return immediately if they're not. - * - * \param newCtx the new GL context. If NULL then there will be no current GL - * context. - * \param drawBuffer the drawing framebuffer - * \param readBuffer the reading framebuffer - */ -GLboolean -_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, - GLframebuffer *readBuffer ) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(newCtx, "_mesa_make_current()\n"); - - /* Check that the context's and framebuffer's visuals are compatible. - */ - if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) { - if (!check_compatible(newCtx, drawBuffer)) { - _mesa_warning(newCtx, - "MakeCurrent: incompatible visuals for context and drawbuffer"); - return GL_FALSE; - } - } - if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) { - if (!check_compatible(newCtx, readBuffer)) { - _mesa_warning(newCtx, - "MakeCurrent: incompatible visuals for context and readbuffer"); - return GL_FALSE; - } - } - - /* We used to call _glapi_check_multithread() here. Now do it in drivers */ - _glapi_set_context((void *) newCtx); - ASSERT(_mesa_get_current_context() == newCtx); - - if (!newCtx) { - _glapi_set_dispatch(NULL); /* none current */ - } - else { - _glapi_set_dispatch(newCtx->CurrentDispatch); - - if (drawBuffer && readBuffer) { - /* TODO: check if newCtx and buffer's visual match??? */ - - ASSERT(drawBuffer->Name == 0); - ASSERT(readBuffer->Name == 0); - _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); - _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); - - /* - * Only set the context's Draw/ReadBuffer fields if they're NULL - * or not bound to a user-created FBO. - */ - if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { - /* KW: merge conflict here, revisit. - */ - /* fix up the fb fields - these will end up wrong otherwise - * if the DRIdrawable changes, and everything relies on them. - * This is a bit messy (same as needed in _mesa_BindFramebufferEXT) - */ - unsigned int i; - GLenum buffers[MAX_DRAW_BUFFERS]; - - _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); - - for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { - buffers[i] = newCtx->Color.DrawBuffer[i]; - } - - _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL); - } - if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { - _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); - } - - /* XXX only set this flag if we're really changing the draw/read - * framebuffer bindings. - */ - newCtx->NewState |= _NEW_BUFFERS; - -#if 1 - /* We want to get rid of these lines: */ - -#if _HAVE_FULL_GL - if (!drawBuffer->Initialized) { - initialize_framebuffer_size(newCtx, drawBuffer); - } - if (readBuffer != drawBuffer && !readBuffer->Initialized) { - initialize_framebuffer_size(newCtx, readBuffer); - } - - _mesa_resizebuffers(newCtx); -#endif - -#else - /* We want the drawBuffer and readBuffer to be initialized by - * the driver. - * This generally means the Width and Height match the actual - * window size and the renderbuffers (both hardware and software - * based) are allocated to match. The later can generally be - * done with a call to _mesa_resize_framebuffer(). - * - * It's theoretically possible for a buffer to have zero width - * or height, but for now, assert check that the driver did what's - * expected of it. - */ - ASSERT(drawBuffer->Width > 0); - ASSERT(drawBuffer->Height > 0); -#endif - - if (drawBuffer) { - _mesa_check_init_viewport(newCtx, - drawBuffer->Width, drawBuffer->Height); - } - } - - if (newCtx->FirstTimeCurrent) { - _mesa_compute_version(newCtx); - - newCtx->Extensions.String = _mesa_make_extension_string(newCtx); - - check_context_limits(newCtx); - - /* We can use this to help debug user's problems. Tell them to set - * the MESA_INFO env variable before running their app. Then the - * first time each context is made current we'll print some useful - * information. - */ - if (_mesa_getenv("MESA_INFO")) { - _mesa_print_info(); - } - - newCtx->FirstTimeCurrent = GL_FALSE; - } - } - - return GL_TRUE; -} - - -/** - * Make context 'ctx' share the display lists, textures and programs - * that are associated with 'ctxToShare'. - * Any display lists, textures or programs associated with 'ctx' will - * be deleted if nobody else is sharing them. - */ -GLboolean -_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare) -{ - if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { - struct gl_shared_state *oldSharedState = ctx->Shared; - - ctx->Shared = ctxToShare->Shared; - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - ctx->Shared->RefCount++; - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - update_default_objects(ctx); - - _mesa_release_shared_state(ctx, oldSharedState); - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/** - * \return pointer to the current GL context for this thread. - * - * Calls _glapi_get_context(). This isn't the fastest way to get the current - * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in - * context.h. - */ -GLcontext * -_mesa_get_current_context( void ) -{ - return (GLcontext *) _glapi_get_context(); -} - - -/** - * Get context's current API dispatch table. - * - * It'll either be the immediate-mode execute dispatcher or the display list - * compile dispatcher. - * - * \param ctx GL context. - * - * \return pointer to dispatch_table. - * - * Simply returns __GLcontextRec::CurrentDispatch. - */ -struct _glapi_table * -_mesa_get_dispatch(GLcontext *ctx) -{ - return ctx->CurrentDispatch; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Miscellaneous functions */ -/**********************************************************************/ -/*@{*/ - -/** - * Record an error. - * - * \param ctx GL context. - * \param error error code. - * - * Records the given error code and call the driver's dd_function_table::Error - * function if defined. - * - * \sa - * This is called via _mesa_error(). - */ -void -_mesa_record_error(GLcontext *ctx, GLenum error) -{ - if (!ctx) - return; - - if (ctx->ErrorValue == GL_NO_ERROR) { - ctx->ErrorValue = error; - } - - /* Call device driver's error handler, if any. This is used on the Mac. */ - if (ctx->Driver.Error) { - ctx->Driver.Error(ctx); - } -} - - -/** - * Flush commands and wait for completion. - */ -void -_mesa_finish(GLcontext *ctx) -{ - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Finish) { - ctx->Driver.Finish(ctx); - } -} - - -/** - * Flush commands. - */ -void -_mesa_flush(GLcontext *ctx) -{ - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } -} - - - -/** - * Execute glFinish(). - * - * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the - * dd_function_table::Finish driver callback, if not NULL. - */ -void GLAPIENTRY -_mesa_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_finish(ctx); -} - - -/** - * Execute glFlush(). - * - * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the - * dd_function_table::Flush driver callback, if not NULL. - */ -void GLAPIENTRY -_mesa_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_flush(ctx); -} - - -/** - * Set mvp_with_dp4 flag. If a driver has a preference for DP4 over - * MUL/MAD, or vice versa, call this function to register that. - * Otherwise we default to MUL/MAD. - */ -void -_mesa_set_mvp_with_dp4( GLcontext *ctx, - GLboolean flag ) -{ - ctx->mvp_with_dp4 = flag; -} - - - -/** - * Prior to drawing anything with glBegin, glDrawArrays, etc. this function - * is called to see if it's valid to render. This involves checking that - * the current shader is valid and the framebuffer is complete. - * If an error is detected it'll be recorded here. - * \return GL_TRUE if OK to render, GL_FALSE if not - */ -GLboolean -_mesa_valid_to_render(GLcontext *ctx, const char *where) -{ - /* This depends on having up to date derived state (shaders) */ - if (ctx->NewState) - _mesa_update_state(ctx); - - if (ctx->Shader.CurrentProgram) { - /* using shaders */ - if (!ctx->Shader.CurrentProgram->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(shader not linked)", where); - return GL_FALSE; - } -#if 0 /* not normally enabled */ - { - char errMsg[100]; - if (!_mesa_validate_shader_program(ctx, ctx->Shader.CurrentProgram, - errMsg)) { - _mesa_warning(ctx, "Shader program %u is invalid: %s", - ctx->Shader.CurrentProgram->Name, errMsg); - } - } -#endif - } - else { - if (ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(vertex program not valid)", where); - return GL_FALSE; - } - if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(fragment program not valid)", where); - return GL_FALSE; - } - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "%s(incomplete framebuffer)", where); - return GL_FALSE; - } - -#ifdef DEBUG - if (ctx->Shader.Flags & GLSL_LOG) { - struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; - if (shProg) { - if (!shProg->_Used) { - /* This is the first time this shader is being used. - * Append shader's constants/uniforms to log file. - */ - GLuint i; - for (i = 0; i < shProg->NumShaders; i++) { - struct gl_shader *sh = shProg->Shaders[i]; - if (sh->Type == GL_VERTEX_SHADER) { - _mesa_append_uniforms_to_file(sh, - &shProg->VertexProgram->Base); - } - else if (sh->Type == GL_FRAGMENT_SHADER) { - _mesa_append_uniforms_to_file(sh, - &shProg->FragmentProgram->Base); - } - } - shProg->_Used = GL_TRUE; - } - } - } -#endif - - return GL_TRUE; -} - - -/*@}*/ +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file context.c + * Mesa context/visual/framebuffer management functions. + * \author Brian Paul + */ + +/** + * \mainpage Mesa Main Module + * + * \section MainIntroduction Introduction + * + * The Mesa Main module consists of all the files in the main/ directory. + * Among the features of this module are: + *
    + *
  • Structures to represent most GL state
  • + *
  • State set/get functions
  • + *
  • Display lists
  • + *
  • Texture unit, object and image handling
  • + *
  • Matrix and attribute stacks
  • + *
+ * + * Other modules are responsible for API dispatch, vertex transformation, + * point/line/triangle setup, rasterization, vertex array caching, + * vertex/fragment programs/shaders, etc. + * + * + * \section AboutDoxygen About Doxygen + * + * If you're viewing this information as Doxygen-generated HTML you'll + * see the documentation index at the top of this page. + * + * The first line lists the Mesa source code modules. + * The second line lists the indexes available for viewing the documentation + * for each module. + * + * Selecting the Main page link will display a summary of the module + * (this page). + * + * Selecting Data Structures will list all C structures. + * + * Selecting the File List link will list all the source files in + * the module. + * Selecting a filename will show a list of all functions defined in that file. + * + * Selecting the Data Fields link will display a list of all + * documented structure members. + * + * Selecting the Globals link will display a list + * of all functions, structures, global variables and macros in the module. + * + */ + + +#include "glheader.h" +#include "mfeatures.h" +#include "imports.h" +#include "accum.h" +#include "api_exec.h" +#include "arrayobj.h" +#include "attrib.h" +#include "blend.h" +#include "buffers.h" +#include "bufferobj.h" +#include "context.h" +#include "cpuinfo.h" +#include "debug.h" +#include "depth.h" +#include "dlist.h" +#include "eval.h" +#include "extensions.h" +#include "fbobject.h" +#include "feedback.h" +#include "fog.h" +#include "framebuffer.h" +#include "hint.h" +#include "hash.h" +#include "light.h" +#include "lines.h" +#include "macros.h" +#include "matrix.h" +#include "multisample.h" +#include "pixel.h" +#include "pixelstore.h" +#include "points.h" +#include "polygon.h" +#include "queryobj.h" +#include "syncobj.h" +#include "rastpos.h" +#include "remap.h" +#include "scissor.h" +#include "shared.h" +#include "shaderobj.h" +#include "simple_list.h" +#include "state.h" +#include "stencil.h" +#include "texcompress_s3tc.h" +#include "texstate.h" +#include "transformfeedback.h" +#include "mtypes.h" +#include "varray.h" +#include "version.h" +#include "viewport.h" +#include "vtxfmt.h" +#include "program/program.h" +#include "program/prog_print.h" +#if _HAVE_FULL_GL +#include "math/m_matrix.h" +#endif +#include "main/dispatch.h" /* for _gloffset_COUNT */ + +#ifdef USE_SPARC_ASM +#include "sparc/sparc.h" +#endif + +#include "glsl_parser_extras.h" +#include + + +#ifndef MESA_VERBOSE +int MESA_VERBOSE = 0; +#endif + +#ifndef MESA_DEBUG_FLAGS +int MESA_DEBUG_FLAGS = 0; +#endif + + +/* ubyte -> float conversion */ +GLfloat _mesa_ubyte_to_float_color_tab[256]; + + + +/** + * Swap buffers notification callback. + * + * \param ctx GL context. + * + * Called by window system just before swapping buffers. + * We have to finish any pending rendering. + */ +void +_mesa_notifySwapBuffers(struct gl_context *ctx) +{ + if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS) + _mesa_debug(ctx, "SwapBuffers\n"); + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Flush) { + ctx->Driver.Flush(ctx); + } +} + + +/**********************************************************************/ +/** \name GL Visual allocation/destruction */ +/**********************************************************************/ +/*@{*/ + +/** + * Allocates a struct gl_config structure and initializes it via + * _mesa_initialize_visual(). + * + * \param dbFlag double buffering + * \param stereoFlag stereo buffer + * \param depthBits requested bits per depth buffer value. Any value in [0, 32] + * is acceptable but the actual depth type will be GLushort or GLuint as + * needed. + * \param stencilBits requested minimum bits per stencil buffer value + * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number of bits per color component in accum buffer. + * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE + * \param redBits number of bits per color component in frame buffer for RGB(A) + * mode. We always use 8 in core Mesa though. + * \param greenBits same as above. + * \param blueBits same as above. + * \param alphaBits same as above. + * \param numSamples not really used. + * + * \return pointer to new struct gl_config or NULL if requested parameters can't be + * met. + * + * \note Need to add params for level and numAuxBuffers (at least) + */ +struct gl_config * +_mesa_create_visual( GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ) +{ + struct gl_config *vis = CALLOC_STRUCT(gl_config); + if (vis) { + if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag, + redBits, greenBits, blueBits, alphaBits, + depthBits, stencilBits, + accumRedBits, accumGreenBits, + accumBlueBits, accumAlphaBits, + numSamples)) { + free(vis); + return NULL; + } + } + return vis; +} + + +/** + * Makes some sanity checks and fills in the fields of the struct + * gl_config object with the given parameters. If the caller needs to + * set additional fields, he should just probably init the whole + * gl_config object himself. + * + * \return GL_TRUE on success, or GL_FALSE on failure. + * + * \sa _mesa_create_visual() above for the parameter description. + */ +GLboolean +_mesa_initialize_visual( struct gl_config *vis, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ) +{ + assert(vis); + + if (depthBits < 0 || depthBits > 32) { + return GL_FALSE; + } + if (stencilBits < 0 || stencilBits > STENCIL_BITS) { + return GL_FALSE; + } + assert(accumRedBits >= 0); + assert(accumGreenBits >= 0); + assert(accumBlueBits >= 0); + assert(accumAlphaBits >= 0); + + vis->rgbMode = GL_TRUE; + vis->doubleBufferMode = dbFlag; + vis->stereoMode = stereoFlag; + + vis->redBits = redBits; + vis->greenBits = greenBits; + vis->blueBits = blueBits; + vis->alphaBits = alphaBits; + vis->rgbBits = redBits + greenBits + blueBits; + + vis->indexBits = 0; + vis->depthBits = depthBits; + vis->stencilBits = stencilBits; + + vis->accumRedBits = accumRedBits; + vis->accumGreenBits = accumGreenBits; + vis->accumBlueBits = accumBlueBits; + vis->accumAlphaBits = accumAlphaBits; + + vis->haveAccumBuffer = accumRedBits > 0; + vis->haveDepthBuffer = depthBits > 0; + vis->haveStencilBuffer = stencilBits > 0; + + vis->numAuxBuffers = 0; + vis->level = 0; + vis->sampleBuffers = numSamples > 0 ? 1 : 0; + vis->samples = numSamples; + + return GL_TRUE; +} + + +/** + * Destroy a visual and free its memory. + * + * \param vis visual. + * + * Frees the visual structure. + */ +void +_mesa_destroy_visual( struct gl_config *vis ) +{ + free(vis); +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Context allocation, initialization, destroying + * + * The purpose of the most initialization functions here is to provide the + * default state values according to the OpenGL specification. + */ +/**********************************************************************/ +/*@{*/ + + +/** + * This is lame. gdb only seems to recognize enum types that are + * actually used somewhere. We want to be able to print/use enum + * values such as TEXTURE_2D_INDEX in gdb. But we don't actually use + * the gl_texture_index type anywhere. Thus, this lame function. + */ +static void +dummy_enum_func(void) +{ + gl_buffer_index bi = BUFFER_FRONT_LEFT; + gl_face_index fi = FACE_POS_X; + gl_frag_attrib fa = FRAG_ATTRIB_WPOS; + gl_frag_result fr = FRAG_RESULT_DEPTH; + gl_texture_index ti = TEXTURE_2D_ARRAY_INDEX; + gl_vert_attrib va = VERT_ATTRIB_POS; + gl_vert_result vr = VERT_RESULT_HPOS; + gl_geom_attrib ga = GEOM_ATTRIB_POSITION; + gl_geom_result gr = GEOM_RESULT_POS; + + (void) bi; + (void) fi; + (void) fa; + (void) fr; + (void) ti; + (void) va; + (void) vr; + (void) ga; + (void) gr; +} + + +/** + * One-time initialization mutex lock. + * + * \sa Used by one_time_init(). + */ +_glthread_DECLARE_STATIC_MUTEX(OneTimeLock); + + + +/** + * Calls all the various one-time-init functions in Mesa. + * + * While holding a global mutex lock, calls several initialization functions, + * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is + * defined. + * + * \sa _math_init(). + */ +static void +one_time_init( struct gl_context *ctx ) +{ + static GLbitfield api_init_mask = 0x0; + + _glthread_LOCK_MUTEX(OneTimeLock); + + /* truly one-time init */ + if (!api_init_mask) { + GLuint i; + + /* do some implementation tests */ + assert( sizeof(GLbyte) == 1 ); + assert( sizeof(GLubyte) == 1 ); + assert( sizeof(GLshort) == 2 ); + assert( sizeof(GLushort) == 2 ); + assert( sizeof(GLint) == 4 ); + assert( sizeof(GLuint) == 4 ); + + _mesa_get_cpu_features(); + + _mesa_init_sqrt_table(); + + /* context dependence is never a one-time thing... */ + _mesa_init_get_hash(ctx); + + for (i = 0; i < 256; i++) { + _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; + } + +#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__) + if (MESA_VERBOSE != 0) { + _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n", + MESA_VERSION_STRING, __DATE__, __TIME__); + } +#endif + } + + /* per-API one-time init */ + if (!(api_init_mask & (1 << ctx->API))) { + /* + * This is fine as ES does not use the remap table, but it may not be + * future-proof. We cannot always initialize the remap table because + * when an app is linked to libGLES*, there are not enough dynamic + * entries. + */ + if (ctx->API == API_OPENGL) + _mesa_init_remap_table(); + } + + api_init_mask |= 1 << ctx->API; + + _glthread_UNLOCK_MUTEX(OneTimeLock); + + /* Hopefully atexit() is widely available. If not, we may need some + * #ifdef tests here. + */ + atexit(_mesa_destroy_shader_compiler); + + dummy_enum_func(); +} + + +/** + * Initialize fields of gl_current_attrib (aka ctx->Current.*) + */ +static void +_mesa_init_current(struct gl_context *ctx) +{ + GLuint i; + + /* Init all to (0,0,0,1) */ + for (i = 0; i < Elements(ctx->Current.Attrib); i++) { + ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 ); + } + + /* redo special cases: */ + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 ); + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 ); + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 ); +} + + +/** + * Init vertex/fragment/geometry program limits. + * Important: drivers should override these with actual limits. + */ +static void +init_program_limits(GLenum type, struct gl_program_constants *prog) +{ + prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS; + prog->MaxTemps = MAX_PROGRAM_TEMPS; + prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; + prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; + prog->MaxUniformComponents = 4 * MAX_UNIFORMS; + + switch (type) { + case GL_VERTEX_PROGRAM_ARB: + prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS; + prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; + prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; + break; + case GL_FRAGMENT_PROGRAM_ARB: + prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS; + prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS; + prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; + break; + case MESA_GEOMETRY_PROGRAM: + prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS; + prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; + prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; + + prog->MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS; + prog->MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS; + prog->MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS; + prog->MaxGeometryUniformComponents = MAX_GEOMETRY_UNIFORM_COMPONENTS; + prog->MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES; + prog->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS; + break; + default: + assert(0 && "Bad program type in init_program_limits()"); + } + + /* Set the native limits to zero. This implies that there is no native + * support for shaders. Let the drivers fill in the actual values. + */ + prog->MaxNativeInstructions = 0; + prog->MaxNativeAluInstructions = 0; + prog->MaxNativeTexInstructions = 0; + prog->MaxNativeTexIndirections = 0; + prog->MaxNativeAttribs = 0; + prog->MaxNativeTemps = 0; + prog->MaxNativeAddressRegs = 0; + prog->MaxNativeParameters = 0; +} + + +/** + * Initialize fields of gl_constants (aka ctx->Const.*). + * Use defaults from config.h. The device drivers will often override + * some of these values (such as number of texture units). + */ +static void +_mesa_init_constants(struct gl_context *ctx) +{ + assert(ctx); + + /* Constants, may be overriden (usually only reduced) by device drivers */ + ctx->Const.MaxTextureMbytes = MAX_TEXTURE_MBYTES; + ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; + ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; + ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; + ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE; + ctx->Const.MaxArrayTextureLayers = MAX_ARRAY_TEXTURE_LAYERS; + ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS; + ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; + ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits, + ctx->Const.MaxTextureImageUnits); + ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY; + ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS; + ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; + ctx->Const.SubPixelBits = SUB_PIXEL_BITS; + ctx->Const.MinPointSize = MIN_POINT_SIZE; + ctx->Const.MaxPointSize = MAX_POINT_SIZE; + ctx->Const.MinPointSizeAA = MIN_POINT_SIZE; + ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE; + ctx->Const.PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY; + ctx->Const.MinLineWidth = MIN_LINE_WIDTH; + ctx->Const.MaxLineWidth = MAX_LINE_WIDTH; + ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH; + ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; + ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY; + ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE; + ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES; + ctx->Const.MaxLights = MAX_LIGHTS; + ctx->Const.MaxShininess = 128.0; + ctx->Const.MaxSpotExponent = 128.0; + ctx->Const.MaxViewportWidth = MAX_WIDTH; + ctx->Const.MaxViewportHeight = MAX_HEIGHT; +#if FEATURE_ARB_vertex_program + init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram); +#endif +#if FEATURE_ARB_fragment_program + init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram); +#endif +#if FEATURE_ARB_geometry_shader4 + init_program_limits(MESA_GEOMETRY_PROGRAM, &ctx->Const.GeometryProgram); +#endif + ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; + ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; + + /* CheckArrayBounds is overriden by drivers/x11 for X server */ + ctx->Const.CheckArrayBounds = GL_FALSE; + + /* GL_ARB_draw_buffers */ + ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS; + +#if FEATURE_EXT_framebuffer_object + ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS; + ctx->Const.MaxRenderbufferSize = MAX_WIDTH; +#endif + +#if FEATURE_ARB_vertex_shader + ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; + ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; + ctx->Const.MaxVarying = MAX_VARYING; +#endif + + /* Shading language version */ + if (ctx->API == API_OPENGL) { + ctx->Const.GLSLVersion = 120; + } + else if (ctx->API == API_OPENGLES2) { + ctx->Const.GLSLVersion = 100; + } + else if (ctx->API == API_OPENGLES) { + ctx->Const.GLSLVersion = 0; /* GLSL not supported */ + } + + /* GL_ARB_framebuffer_object */ + ctx->Const.MaxSamples = 0; + + /* GL_ARB_sync */ + ctx->Const.MaxServerWaitTimeout = (GLuint64) ~0; + + /* GL_ATI_envmap_bumpmap */ + ctx->Const.SupportedBumpUnits = SUPPORTED_ATI_BUMP_UNITS; + + /* GL_EXT_provoking_vertex */ + ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE; + + /* GL_EXT_transform_feedback */ + ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS; + ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS; + ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS; + + /* GL 3.2: hard-coded for now: */ + ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; + + /** GL_EXT_gpu_shader4 */ + ctx->Const.MinProgramTexelOffset = -8; + ctx->Const.MaxProgramTexelOffset = 7; +} + + +/** + * Do some sanity checks on the limits/constants for the given context. + * Only called the first time a context is bound. + */ +static void +check_context_limits(struct gl_context *ctx) +{ + /* check that we don't exceed the size of various bitfields */ + assert(VERT_RESULT_MAX <= + (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); + assert(FRAG_ATTRIB_MAX <= + (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead))); + + assert(MAX_COMBINED_TEXTURE_IMAGE_UNITS <= 8 * sizeof(GLbitfield)); + + /* shader-related checks */ + assert(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); + assert(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); + + assert(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); + assert(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); + assert(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX); + assert(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX); + + /* Texture unit checks */ + assert(ctx->Const.MaxTextureImageUnits > 0); + assert(ctx->Const.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS); + assert(ctx->Const.MaxTextureCoordUnits > 0); + assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS); + assert(ctx->Const.MaxTextureUnits > 0); + assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS); + assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS); + assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.MaxTextureImageUnits, + ctx->Const.MaxTextureCoordUnits)); + assert(ctx->Const.MaxCombinedTextureImageUnits > 0); + assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); + assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); + /* number of coord units cannot be greater than number of image units */ + assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits); + + + /* Texture size checks */ + assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS); + assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS); + assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS); + assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE); + + /* make sure largest texture image is <= MAX_WIDTH in size */ + assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= MAX_WIDTH); + assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= MAX_WIDTH); + assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= MAX_WIDTH); + + /* Texture level checks */ + assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); + assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); + + /* Max texture size should be <= max viewport size (render to texture) */ + assert((1 << (MAX_TEXTURE_LEVELS - 1)) <= MAX_WIDTH); + + assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); + assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); + + assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS); + + /* if this fails, add more enum values to gl_buffer_index */ + assert(BUFFER_COLOR0 + MAX_DRAW_BUFFERS <= BUFFER_COUNT); + + /* XXX probably add more tests */ +} + + +/** + * Initialize the attribute groups in a GL context. + * + * \param ctx GL context. + * + * Initializes all the attributes, calling the respective init* + * functions for the more complex data structures. + */ +static GLboolean +init_attrib_groups(struct gl_context *ctx) +{ + assert(ctx); + + /* Constants */ + _mesa_init_constants( ctx ); + + /* Extensions */ + _mesa_init_extensions( ctx ); + + /* Attribute Groups */ + _mesa_init_accum( ctx ); + _mesa_init_attrib( ctx ); + _mesa_init_buffer_objects( ctx ); + _mesa_init_color( ctx ); + _mesa_init_current( ctx ); + _mesa_init_depth( ctx ); + _mesa_init_debug( ctx ); + _mesa_init_display_list( ctx ); + _mesa_init_eval( ctx ); + _mesa_init_fbobjects( ctx ); + _mesa_init_feedback( ctx ); + _mesa_init_fog( ctx ); + _mesa_init_hint( ctx ); + _mesa_init_line( ctx ); + _mesa_init_lighting( ctx ); + _mesa_init_matrix( ctx ); + _mesa_init_multisample( ctx ); + _mesa_init_pixel( ctx ); + _mesa_init_pixelstore( ctx ); + _mesa_init_point( ctx ); + _mesa_init_polygon( ctx ); + _mesa_init_program( ctx ); + _mesa_init_queryobj( ctx ); + _mesa_init_sync( ctx ); + _mesa_init_rastpos( ctx ); + _mesa_init_scissor( ctx ); + _mesa_init_shader_state( ctx ); + _mesa_init_stencil( ctx ); + _mesa_init_transform( ctx ); + _mesa_init_transform_feedback( ctx ); + _mesa_init_varray( ctx ); + _mesa_init_viewport( ctx ); + + if (!_mesa_init_texture( ctx )) + return GL_FALSE; + + _mesa_init_texture_s3tc( ctx ); + + /* Miscellaneous */ + ctx->NewState = _NEW_ALL; + ctx->ErrorValue = (GLenum) GL_NO_ERROR; + ctx->varying_vp_inputs = ~0; + + return GL_TRUE; +} + + +/** + * Update default objects in a GL context with respect to shared state. + * + * \param ctx GL context. + * + * Removes references to old default objects, (texture objects, program + * objects, etc.) and changes to reference those from the current shared + * state. + */ +static GLboolean +update_default_objects(struct gl_context *ctx) +{ + assert(ctx); + + _mesa_update_default_objects_program(ctx); + _mesa_update_default_objects_texture(ctx); + _mesa_update_default_objects_buffer_objects(ctx); + + return GL_TRUE; +} + + +/** + * This is the default function we plug into all dispatch table slots + * This helps prevents a segfault when someone calls a GL function without + * first checking if the extension's supported. + */ +static int +generic_nop(void) +{ + _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)"); + return 0; +} + + +/** + * Allocate and initialize a new dispatch table. + */ +struct _glapi_table * +_mesa_alloc_dispatch_table(int size) +{ + /* Find the larger of Mesa's dispatch table and libGL's dispatch table. + * In practice, this'll be the same for stand-alone Mesa. But for DRI + * Mesa we do this to accomodate different versions of libGL and various + * DRI drivers. + */ + GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT); + struct _glapi_table *table; + + /* should never happen, but just in case */ + numEntries = MAX2(numEntries, size); + + table = (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc)); + if (table) { + _glapi_proc *entry = (_glapi_proc *) table; + GLint i; + for (i = 0; i < numEntries; i++) { + entry[i] = (_glapi_proc) generic_nop; + } + } + return table; +} + + +/** + * Initialize a struct gl_context struct (rendering context). + * + * This includes allocating all the other structs and arrays which hang off of + * the context by pointers. + * Note that the driver needs to pass in its dd_function_table here since + * we need to at least call driverFunctions->NewTextureObject to create the + * default texture objects. + * + * Called by _mesa_create_context(). + * + * Performs the imports and exports callback tables initialization, and + * miscellaneous one-time initializations. If no shared context is supplied one + * is allocated, and increase its reference count. Setups the GL API dispatch + * tables. Initialize the TNL module. Sets the maximum Z buffer depth. + * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables + * for debug flags. + * + * \param ctx the context to initialize + * \param api the GL API type to create the context for + * \param visual describes the visual attributes for this context + * \param share_list points to context to share textures, display lists, + * etc with, or NULL + * \param driverFunctions table of device driver functions for this context + * to use + * \param driverContext pointer to driver-specific context data + */ +GLboolean +_mesa_initialize_context_for_api(struct gl_context *ctx, + gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + struct gl_shared_state *shared; + int i; + + /*ASSERT(driverContext);*/ + assert(driverFunctions->NewTextureObject); + assert(driverFunctions->FreeTexImageData); + + ctx->API = api; + ctx->Visual = *visual; + ctx->DrawBuffer = NULL; + ctx->ReadBuffer = NULL; + ctx->WinSysDrawBuffer = NULL; + ctx->WinSysReadBuffer = NULL; + + /* misc one-time initializations */ + one_time_init(ctx); + + /* Plug in driver functions and context pointer here. + * This is important because when we call alloc_shared_state() below + * we'll call ctx->Driver.NewTextureObject() to create the default + * textures. + */ + ctx->Driver = *driverFunctions; + ctx->DriverCtx = driverContext; + + if (share_list) { + /* share state with another context */ + shared = share_list->Shared; + } + else { + /* allocate new, unshared state */ + shared = _mesa_alloc_shared_state(ctx); + if (!shared) + return GL_FALSE; + } + + _glthread_LOCK_MUTEX(shared->Mutex); + ctx->Shared = shared; + shared->RefCount++; + _glthread_UNLOCK_MUTEX(shared->Mutex); + + if (!init_attrib_groups( ctx )) { + _mesa_release_shared_state(ctx, ctx->Shared); + return GL_FALSE; + } + +#if FEATURE_dispatch + /* setup the API dispatch tables */ + switch (ctx->API) { +#if FEATURE_GL + case API_OPENGL: + ctx->Exec = _mesa_create_exec_table(); + break; +#endif +#if FEATURE_ES1 + case API_OPENGLES: + ctx->Exec = _mesa_create_exec_table_es1(); + break; +#endif +#if FEATURE_ES2 + case API_OPENGLES2: + ctx->Exec = _mesa_create_exec_table_es2(); + break; +#endif + default: + _mesa_problem(ctx, "unknown or unsupported API"); + break; + } + + if (!ctx->Exec) { + _mesa_release_shared_state(ctx, ctx->Shared); + return GL_FALSE; + } +#endif + ctx->CurrentDispatch = ctx->Exec; + + ctx->FragmentProgram._MaintainTexEnvProgram + = (_mesa_getenv("MESA_TEX_PROG") != NULL); + + ctx->VertexProgram._MaintainTnlProgram + = (_mesa_getenv("MESA_TNL_PROG") != NULL); + if (ctx->VertexProgram._MaintainTnlProgram) { + /* this is required... */ + ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + } + + switch (ctx->API) { + case API_OPENGL: +#if FEATURE_dlist + ctx->Save = _mesa_create_save_table(); + if (!ctx->Save) { + _mesa_release_shared_state(ctx, ctx->Shared); + free(ctx->Exec); + return GL_FALSE; + } + + _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); +#endif + break; + case API_OPENGLES: + /** + * GL_OES_texture_cube_map says + * "Initially all texture generation modes are set to REFLECTION_MAP_OES" + */ + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + texUnit->GenS.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenT.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenR.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV; + } + break; + case API_OPENGLES2: + ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; + ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */ + break; + } + + ctx->FirstTimeCurrent = GL_TRUE; + + return GL_TRUE; +} + + +/** + * Initialize an OpenGL context. + */ +GLboolean +_mesa_initialize_context(struct gl_context *ctx, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + return _mesa_initialize_context_for_api(ctx, + API_OPENGL, + visual, + share_list, + driverFunctions, + driverContext); +} + + +/** + * Allocate and initialize a struct gl_context structure. + * Note that the driver needs to pass in its dd_function_table here since + * we need to at least call driverFunctions->NewTextureObject to initialize + * the rendering context. + * + * \param api the GL API type to create the context for + * \param visual a struct gl_config pointer (we copy the struct contents) + * \param share_list another context to share display lists with or NULL + * \param driverFunctions points to the dd_function_table into which the + * driver has plugged in all its special functions. + * \param driverContext points to the device driver's private context state + * + * \return pointer to a new __struct gl_contextRec or NULL if error. + */ +struct gl_context * +_mesa_create_context_for_api(gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + struct gl_context *ctx; + + ASSERT(visual); + /*ASSERT(driverContext);*/ + + ctx = (struct gl_context *) calloc(1, sizeof(struct gl_context)); + if (!ctx) + return NULL; + + if (_mesa_initialize_context_for_api(ctx, api, visual, share_list, + driverFunctions, driverContext)) { + return ctx; + } + else { + free(ctx); + return NULL; + } +} + + +/** + * Create an OpenGL context. + */ +struct gl_context * +_mesa_create_context(const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + return _mesa_create_context_for_api(API_OPENGL, visual, + share_list, + driverFunctions, + driverContext); +} + + +/** + * Free the data associated with the given context. + * + * But doesn't free the struct gl_context struct itself. + * + * \sa _mesa_initialize_context() and init_attrib_groups(). + */ +void +_mesa_free_context_data( struct gl_context *ctx ) +{ + if (!_mesa_get_current_context()){ + /* No current context, but we may need one in order to delete + * texture objs, etc. So temporarily bind the context now. + */ + _mesa_make_current(ctx, NULL, NULL); + } + + /* unreference WinSysDraw/Read buffers */ + _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL); + _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL); + _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL); + _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL); + + _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL); + + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); + + _mesa_free_attrib_data(ctx); + _mesa_free_buffer_objects(ctx); + _mesa_free_lighting_data( ctx ); + _mesa_free_eval_data( ctx ); + _mesa_free_texture_data( ctx ); + _mesa_free_matrix_data( ctx ); + _mesa_free_viewport_data( ctx ); + _mesa_free_program_data(ctx); + _mesa_free_shader_state(ctx); + _mesa_free_queryobj_data(ctx); + _mesa_free_sync_data(ctx); + _mesa_free_varray_data(ctx); + _mesa_free_transform_feedback(ctx); + + _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj); + +#if FEATURE_ARB_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL); + _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL); +#endif + +#if FEATURE_ARB_vertex_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL); + _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL); +#endif + + /* free dispatch tables */ + free(ctx->Exec); + free(ctx->Save); + + /* Shared context state (display lists, textures, etc) */ + _mesa_release_shared_state( ctx, ctx->Shared ); + + /* needs to be after freeing shared state */ + _mesa_free_display_list_data(ctx); + + if (ctx->Extensions.String) + free((void *) ctx->Extensions.String); + + if (ctx->VersionString) + free(ctx->VersionString); + + /* unbind the context if it's currently bound */ + if (ctx == _mesa_get_current_context()) { + _mesa_make_current(NULL, NULL, NULL); + } +} + + +/** + * Destroy a struct gl_context structure. + * + * \param ctx GL context. + * + * Calls _mesa_free_context_data() and frees the gl_context object itself. + */ +void +_mesa_destroy_context( struct gl_context *ctx ) +{ + if (ctx) { + _mesa_free_context_data(ctx); + free( (void *) ctx ); + } +} + + +#if _HAVE_FULL_GL +/** + * Copy attribute groups from one context to another. + * + * \param src source context + * \param dst destination context + * \param mask bitwise OR of GL_*_BIT flags + * + * According to the bits specified in \p mask, copies the corresponding + * attributes from \p src into \p dst. For many of the attributes a simple \c + * memcpy is not enough due to the existence of internal pointers in their data + * structures. + */ +void +_mesa_copy_context( const struct gl_context *src, struct gl_context *dst, GLuint mask ) +{ + if (mask & GL_ACCUM_BUFFER_BIT) { + /* OK to memcpy */ + dst->Accum = src->Accum; + } + if (mask & GL_COLOR_BUFFER_BIT) { + /* OK to memcpy */ + dst->Color = src->Color; + } + if (mask & GL_CURRENT_BIT) { + /* OK to memcpy */ + dst->Current = src->Current; + } + if (mask & GL_DEPTH_BUFFER_BIT) { + /* OK to memcpy */ + dst->Depth = src->Depth; + } + if (mask & GL_ENABLE_BIT) { + /* no op */ + } + if (mask & GL_EVAL_BIT) { + /* OK to memcpy */ + dst->Eval = src->Eval; + } + if (mask & GL_FOG_BIT) { + /* OK to memcpy */ + dst->Fog = src->Fog; + } + if (mask & GL_HINT_BIT) { + /* OK to memcpy */ + dst->Hint = src->Hint; + } + if (mask & GL_LIGHTING_BIT) { + GLuint i; + /* begin with memcpy */ + dst->Light = src->Light; + /* fixup linked lists to prevent pointer insanity */ + make_empty_list( &(dst->Light.EnabledList) ); + for (i = 0; i < MAX_LIGHTS; i++) { + if (dst->Light.Light[i].Enabled) { + insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i])); + } + } + } + if (mask & GL_LINE_BIT) { + /* OK to memcpy */ + dst->Line = src->Line; + } + if (mask & GL_LIST_BIT) { + /* OK to memcpy */ + dst->List = src->List; + } + if (mask & GL_PIXEL_MODE_BIT) { + /* OK to memcpy */ + dst->Pixel = src->Pixel; + } + if (mask & GL_POINT_BIT) { + /* OK to memcpy */ + dst->Point = src->Point; + } + if (mask & GL_POLYGON_BIT) { + /* OK to memcpy */ + dst->Polygon = src->Polygon; + } + if (mask & GL_POLYGON_STIPPLE_BIT) { + /* Use loop instead of memcpy due to problem with Portland Group's + * C compiler. Reported by John Stone. + */ + GLuint i; + for (i = 0; i < 32; i++) { + dst->PolygonStipple[i] = src->PolygonStipple[i]; + } + } + if (mask & GL_SCISSOR_BIT) { + /* OK to memcpy */ + dst->Scissor = src->Scissor; + } + if (mask & GL_STENCIL_BUFFER_BIT) { + /* OK to memcpy */ + dst->Stencil = src->Stencil; + } + if (mask & GL_TEXTURE_BIT) { + /* Cannot memcpy because of pointers */ + _mesa_copy_texture_state(src, dst); + } + if (mask & GL_TRANSFORM_BIT) { + /* OK to memcpy */ + dst->Transform = src->Transform; + } + if (mask & GL_VIEWPORT_BIT) { + /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */ + dst->Viewport.X = src->Viewport.X; + dst->Viewport.Y = src->Viewport.Y; + dst->Viewport.Width = src->Viewport.Width; + dst->Viewport.Height = src->Viewport.Height; + dst->Viewport.Near = src->Viewport.Near; + dst->Viewport.Far = src->Viewport.Far; + _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap); + } + + /* XXX FIXME: Call callbacks? + */ + dst->NewState = _NEW_ALL; +} +#endif + + +/** + * Check if the given context can render into the given framebuffer + * by checking visual attributes. + * + * Most of these tests could go away because Mesa is now pretty flexible + * in terms of mixing rendering contexts with framebuffers. As long + * as RGB vs. CI mode agree, we're probably good. + * + * \return GL_TRUE if compatible, GL_FALSE otherwise. + */ +static GLboolean +check_compatible(const struct gl_context *ctx, + const struct gl_framebuffer *buffer) +{ + const struct gl_config *ctxvis = &ctx->Visual; + const struct gl_config *bufvis = &buffer->Visual; + + if (buffer == _mesa_get_incomplete_framebuffer()) + return GL_TRUE; + +#if 0 + /* disabling this fixes the fgl_glxgears pbuffer demo */ + if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode) + return GL_FALSE; +#endif + if (ctxvis->stereoMode && !bufvis->stereoMode) + return GL_FALSE; + if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer) + return GL_FALSE; + if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer) + return GL_FALSE; + if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer) + return GL_FALSE; + if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask) + return GL_FALSE; + if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask) + return GL_FALSE; + if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask) + return GL_FALSE; +#if 0 + /* disabled (see bug 11161) */ + if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits) + return GL_FALSE; +#endif + if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Do one-time initialization for the given framebuffer. Specifically, + * ask the driver for the window's current size and update the framebuffer + * object to match. + * Really, the device driver should totally take care of this. + */ +static void +initialize_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint width, height; + if (ctx->Driver.GetBufferSize) { + ctx->Driver.GetBufferSize(fb, &width, &height); + if (ctx->Driver.ResizeBuffers) + ctx->Driver.ResizeBuffers(ctx, fb, width, height); + fb->Initialized = GL_TRUE; + } +} + + +/** + * Check if the viewport/scissor size has not yet been initialized. + * Initialize the size if the given width and height are non-zero. + */ +void +_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height) +{ + if (!ctx->ViewportInitialized && width > 0 && height > 0) { + /* Note: set flag here, before calling _mesa_set_viewport(), to prevent + * potential infinite recursion. + */ + ctx->ViewportInitialized = GL_TRUE; + _mesa_set_viewport(ctx, 0, 0, width, height); + _mesa_set_scissor(ctx, 0, 0, width, height); + } +} + + +/** + * Bind the given context to the given drawBuffer and readBuffer and + * make it the current context for the calling thread. + * We'll render into the drawBuffer and read pixels from the + * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc). + * + * We check that the context's and framebuffer's visuals are compatible + * and return immediately if they're not. + * + * \param newCtx the new GL context. If NULL then there will be no current GL + * context. + * \param drawBuffer the drawing framebuffer + * \param readBuffer the reading framebuffer + */ +GLboolean +_mesa_make_current( struct gl_context *newCtx, + struct gl_framebuffer *drawBuffer, + struct gl_framebuffer *readBuffer ) +{ + GET_CURRENT_CONTEXT(curCtx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(newCtx, "_mesa_make_current()\n"); + + /* Check that the context's and framebuffer's visuals are compatible. + */ + if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) { + if (!check_compatible(newCtx, drawBuffer)) { + _mesa_warning(newCtx, + "MakeCurrent: incompatible visuals for context and drawbuffer"); + return GL_FALSE; + } + } + if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) { + if (!check_compatible(newCtx, readBuffer)) { + _mesa_warning(newCtx, + "MakeCurrent: incompatible visuals for context and readbuffer"); + return GL_FALSE; + } + } + + if (curCtx && + (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */ + curCtx != newCtx) + _mesa_flush(curCtx); + + /* We used to call _glapi_check_multithread() here. Now do it in drivers */ + _glapi_set_context((void *) newCtx); + ASSERT(_mesa_get_current_context() == newCtx); + + if (!newCtx) { + _glapi_set_dispatch(NULL); /* none current */ + } + else { + _glapi_set_dispatch(newCtx->CurrentDispatch); + + if (drawBuffer && readBuffer) { + /* TODO: check if newCtx and buffer's visual match??? */ + + ASSERT(drawBuffer->Name == 0); + ASSERT(readBuffer->Name == 0); + _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); + _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); + + /* + * Only set the context's Draw/ReadBuffer fields if they're NULL + * or not bound to a user-created FBO. + */ + if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { + /* KW: merge conflict here, revisit. + */ + /* fix up the fb fields - these will end up wrong otherwise + * if the DRIdrawable changes, and everything relies on them. + * This is a bit messy (same as needed in _mesa_BindFramebufferEXT) + */ + unsigned int i; + GLenum buffers[MAX_DRAW_BUFFERS]; + + _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); + + for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { + buffers[i] = newCtx->Color.DrawBuffer[i]; + } + + _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, + buffers, NULL); + } + if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { + _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); + } + + /* XXX only set this flag if we're really changing the draw/read + * framebuffer bindings. + */ + newCtx->NewState |= _NEW_BUFFERS; + +#if 1 + /* We want to get rid of these lines: */ + +#if _HAVE_FULL_GL + if (!drawBuffer->Initialized) { + initialize_framebuffer_size(newCtx, drawBuffer); + } + if (readBuffer != drawBuffer && !readBuffer->Initialized) { + initialize_framebuffer_size(newCtx, readBuffer); + } + + _mesa_resizebuffers(newCtx); +#endif + +#else + /* We want the drawBuffer and readBuffer to be initialized by + * the driver. + * This generally means the Width and Height match the actual + * window size and the renderbuffers (both hardware and software + * based) are allocated to match. The later can generally be + * done with a call to _mesa_resize_framebuffer(). + * + * It's theoretically possible for a buffer to have zero width + * or height, but for now, assert check that the driver did what's + * expected of it. + */ + ASSERT(drawBuffer->Width > 0); + ASSERT(drawBuffer->Height > 0); +#endif + + if (drawBuffer) { + _mesa_check_init_viewport(newCtx, + drawBuffer->Width, drawBuffer->Height); + } + } + + if (newCtx->FirstTimeCurrent) { + _mesa_compute_version(newCtx); + + newCtx->Extensions.String = _mesa_make_extension_string(newCtx); + + check_context_limits(newCtx); + + /* We can use this to help debug user's problems. Tell them to set + * the MESA_INFO env variable before running their app. Then the + * first time each context is made current we'll print some useful + * information. + */ + if (_mesa_getenv("MESA_INFO")) { + _mesa_print_info(); + } + + newCtx->FirstTimeCurrent = GL_FALSE; + } + } + + return GL_TRUE; +} + + +/** + * Make context 'ctx' share the display lists, textures and programs + * that are associated with 'ctxToShare'. + * Any display lists, textures or programs associated with 'ctx' will + * be deleted if nobody else is sharing them. + */ +GLboolean +_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare) +{ + if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { + struct gl_shared_state *oldSharedState = ctx->Shared; + + ctx->Shared = ctxToShare->Shared; + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + ctx->Shared->RefCount++; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + update_default_objects(ctx); + + _mesa_release_shared_state(ctx, oldSharedState); + + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/** + * \return pointer to the current GL context for this thread. + * + * Calls _glapi_get_context(). This isn't the fastest way to get the current + * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in + * context.h. + */ +struct gl_context * +_mesa_get_current_context( void ) +{ + return (struct gl_context *) _glapi_get_context(); +} + + +/** + * Get context's current API dispatch table. + * + * It'll either be the immediate-mode execute dispatcher or the display list + * compile dispatcher. + * + * \param ctx GL context. + * + * \return pointer to dispatch_table. + * + * Simply returns __struct gl_contextRec::CurrentDispatch. + */ +struct _glapi_table * +_mesa_get_dispatch(struct gl_context *ctx) +{ + return ctx->CurrentDispatch; +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Miscellaneous functions */ +/**********************************************************************/ +/*@{*/ + +/** + * Record an error. + * + * \param ctx GL context. + * \param error error code. + * + * Records the given error code and call the driver's dd_function_table::Error + * function if defined. + * + * \sa + * This is called via _mesa_error(). + */ +void +_mesa_record_error(struct gl_context *ctx, GLenum error) +{ + if (!ctx) + return; + + if (ctx->ErrorValue == GL_NO_ERROR) { + ctx->ErrorValue = error; + } + + /* Call device driver's error handler, if any. This is used on the Mac. */ + if (ctx->Driver.Error) { + ctx->Driver.Error(ctx); + } +} + + +/** + * Flush commands and wait for completion. + */ +void +_mesa_finish(struct gl_context *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Finish) { + ctx->Driver.Finish(ctx); + } +} + + +/** + * Flush commands. + */ +void +_mesa_flush(struct gl_context *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Flush) { + ctx->Driver.Flush(ctx); + } +} + + + +/** + * Execute glFinish(). + * + * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the + * dd_function_table::Finish driver callback, if not NULL. + */ +void GLAPIENTRY +_mesa_Finish(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_finish(ctx); +} + + +/** + * Execute glFlush(). + * + * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the + * dd_function_table::Flush driver callback, if not NULL. + */ +void GLAPIENTRY +_mesa_Flush(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_flush(ctx); +} + + +/** + * Set mvp_with_dp4 flag. If a driver has a preference for DP4 over + * MUL/MAD, or vice versa, call this function to register that. + * Otherwise we default to MUL/MAD. + */ +void +_mesa_set_mvp_with_dp4( struct gl_context *ctx, + GLboolean flag ) +{ + ctx->mvp_with_dp4 = flag; +} + + + +/** + * Prior to drawing anything with glBegin, glDrawArrays, etc. this function + * is called to see if it's valid to render. This involves checking that + * the current shader is valid and the framebuffer is complete. + * If an error is detected it'll be recorded here. + * \return GL_TRUE if OK to render, GL_FALSE if not + */ +GLboolean +_mesa_valid_to_render(struct gl_context *ctx, const char *where) +{ + bool vert_from_glsl_shader = false; + bool geom_from_glsl_shader = false; + bool frag_from_glsl_shader = false; + + /* This depends on having up to date derived state (shaders) */ + if (ctx->NewState) + _mesa_update_state(ctx); + + if (ctx->Shader.CurrentVertexProgram) { + vert_from_glsl_shader = true; + + if (!ctx->Shader.CurrentVertexProgram->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(shader not linked)", where); + return GL_FALSE; + } +#if 0 /* not normally enabled */ + { + char errMsg[100]; + if (!_mesa_validate_shader_program(ctx, + ctx->Shader.CurrentVertexProgram, + errMsg)) { + _mesa_warning(ctx, "Shader program %u is invalid: %s", + ctx->Shader.CurrentVertexProgram->Name, errMsg); + } + } +#endif + } + + if (ctx->Shader.CurrentGeometryProgram) { + geom_from_glsl_shader = true; + + if (!ctx->Shader.CurrentGeometryProgram->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(shader not linked)", where); + return GL_FALSE; + } +#if 0 /* not normally enabled */ + { + char errMsg[100]; + if (!_mesa_validate_shader_program(ctx, + ctx->Shader.CurrentGeometryProgram, + errMsg)) { + _mesa_warning(ctx, "Shader program %u is invalid: %s", + ctx->Shader.CurrentGeometryProgram->Name, errMsg); + } + } +#endif + } + + if (ctx->Shader.CurrentFragmentProgram) { + frag_from_glsl_shader = true; + + if (!ctx->Shader.CurrentFragmentProgram->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(shader not linked)", where); + return GL_FALSE; + } +#if 0 /* not normally enabled */ + { + char errMsg[100]; + if (!_mesa_validate_shader_program(ctx, + ctx->Shader.CurrentFragmentProgram, + errMsg)) { + _mesa_warning(ctx, "Shader program %u is invalid: %s", + ctx->Shader.CurrentFragmentProgram->Name, errMsg); + } + } +#endif + } + + /* Any shader stages that are not supplied by the GLSL shader and have + * assembly shaders enabled must now be validated. + */ + if (!vert_from_glsl_shader + && ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(vertex program not valid)", where); + return GL_FALSE; + } + + /* FINISHME: If GL_NV_geometry_program4 is ever supported, the current + * FINISHME: geometry program should validated here. + */ + (void) geom_from_glsl_shader; + + if (!frag_from_glsl_shader) { + if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(fragment program not valid)", where); + return GL_FALSE; + } + + /* If drawing to integer-valued color buffers, there must be an + * active fragment shader (GL_EXT_texture_integer). + */ + if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(integer format but no fragment shader)", where); + return GL_FALSE; + } + } + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "%s(incomplete framebuffer)", where); + return GL_FALSE; + } + +#ifdef DEBUG + if (ctx->Shader.Flags & GLSL_LOG) { + struct gl_shader_program *shProg[MESA_SHADER_TYPES]; + gl_shader_type i; + + shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram; + shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram; + shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram; + + for (i = 0; i < MESA_SHADER_TYPES; i++) { + struct gl_shader *sh; + + if (shProg[i] == NULL || shProg[i]->_Used + || shProg[i]->_LinkedShaders[i] == NULL) + continue; + + /* This is the first time this shader is being used. + * Append shader's constants/uniforms to log file. + * + * The logic is a little odd here. We only want to log data for each + * shader target that will actually be used, and we only want to log + * it once. It's possible to have a program bound to the vertex + * shader target that also supplied a fragment shader. If that + * program isn't also bound to the fragment shader target we don't + * want to log its fragment data. + */ + sh = shProg[i]->_LinkedShaders[i]; + switch (sh->Type) { + case GL_VERTEX_SHADER: + _mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base); + break; + + case GL_GEOMETRY_SHADER_ARB: + _mesa_append_uniforms_to_file(sh, + &shProg[i]->GeometryProgram->Base); + break; + + case GL_FRAGMENT_SHADER: + _mesa_append_uniforms_to_file(sh, + &shProg[i]->FragmentProgram->Base); + break; + } + } + + for (i = 0; i < MESA_SHADER_TYPES; i++) { + if (shProg[i] != NULL) + shProg[i]->_Used = GL_TRUE; + } + } +#endif + + return GL_TRUE; +} + + +/*@}*/ diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h index c61da6282..ab689f429 100644 --- a/mesalib/src/mesa/main/context.h +++ b/mesalib/src/mesa/main/context.h @@ -1,326 +1,326 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file context.h - * Mesa context and visual-related functions. - * - * There are three large Mesa data types/classes which are meant to be - * used by device drivers: - * - GLcontext: this contains the Mesa rendering state - * - GLvisual: this describes the color buffer (RGB vs. ci), whether or not - * there's a depth buffer, stencil buffer, etc. - * - GLframebuffer: contains pointers to the depth buffer, stencil buffer, - * accum buffer and alpha buffers. - * - * These types should be encapsulated by corresponding device driver - * data types. See xmesa.h and xmesaP.h for an example. - * - * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes - * which the device driver must derive from. - * - * The following functions create and destroy these data types. - */ - - -#ifndef CONTEXT_H -#define CONTEXT_H - - -#include "imports.h" -#include "mtypes.h" - - -struct _glapi_table; - - -/** \name Visual-related functions */ -/*@{*/ - -extern GLvisual * -_mesa_create_visual( GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits, - GLint numSamples ); - -extern GLboolean -_mesa_initialize_visual( GLvisual *v, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits, - GLint depthBits, - GLint stencilBits, - GLint accumRedBits, - GLint accumGreenBits, - GLint accumBlueBits, - GLint accumAlphaBits, - GLint numSamples ); - -extern void -_mesa_destroy_visual( GLvisual *vis ); - -/*@}*/ - - -/** \name Context-related functions */ -/*@{*/ - -extern GLcontext * -_mesa_create_context( const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext ); - -extern GLboolean -_mesa_initialize_context( GLcontext *ctx, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext ); - -extern GLcontext * -_mesa_create_context_for_api(gl_api api, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext); - -extern GLboolean -_mesa_initialize_context_for_api(GLcontext *ctx, - gl_api api, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext); - -extern void -_mesa_free_context_data( GLcontext *ctx ); - -extern void -_mesa_destroy_context( GLcontext *ctx ); - - -extern void -_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); - - -extern void -_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height); - -extern GLboolean -_mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer, - GLframebuffer *readBuffer ); - -extern GLboolean -_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare); - -extern GLcontext * -_mesa_get_current_context(void); - -/*@}*/ - -extern void -_mesa_init_get_hash(GLcontext *ctx); - -extern void -_mesa_notifySwapBuffers(__GLcontext *gc); - - -extern struct _glapi_table * -_mesa_get_dispatch(GLcontext *ctx); - - -void -_mesa_set_mvp_with_dp4( GLcontext *ctx, - GLboolean flag ); - - -extern GLboolean -_mesa_valid_to_render(GLcontext *ctx, const char *where); - - - -/** \name Miscellaneous */ -/*@{*/ - -extern void -_mesa_record_error( GLcontext *ctx, GLenum error ); - - -extern void -_mesa_finish(GLcontext *ctx); - -extern void -_mesa_flush(GLcontext *ctx); - - -extern void GLAPIENTRY -_mesa_Finish( void ); - -extern void GLAPIENTRY -_mesa_Flush( void ); - -/*@}*/ - - -/** - * \name Macros for flushing buffered rendering commands before state changes, - * checking if inside glBegin/glEnd, etc. - */ -/*@{*/ - -/** - * Flush vertices. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, - * and calls dd_function_table::FlushVertices if so. Marks - * __GLcontextRec::NewState with \p newstate. - */ -#define FLUSH_VERTICES(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ - if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ - ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Flush current state. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush current state, - * and calls dd_function_table::FlushVertices if so. Marks - * __GLcontextRec::NewState with \p newstate. - */ -#define FLUSH_CURRENT(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ - ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END(ctx); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/*@}*/ - - - -/** - * Is the secondary color needed? - */ -#define NEED_SECONDARY_COLOR(CTX) \ - (((CTX)->Light.Enabled && \ - (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ - || (CTX)->Fog.ColorSumEnabled \ - || ((CTX)->VertexProgram._Current && \ - ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) && \ - ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \ - || ((CTX)->FragmentProgram._Current && \ - ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) && \ - ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \ - ) - - -/** - * Is RGBA LogicOp enabled? - */ -#define RGBA_LOGICOP_ENABLED(CTX) \ - ((CTX)->Color.ColorLogicOpEnabled || \ - ((CTX)->Color.BlendEnabled && (CTX)->Color.BlendEquationRGB == GL_LOGIC_OP)) - - -#endif /* CONTEXT_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file context.h + * Mesa context and visual-related functions. + * + * There are three large Mesa data types/classes which are meant to be + * used by device drivers: + * - struct gl_context: this contains the Mesa rendering state + * - struct gl_config: this describes the color buffer (RGB vs. ci), whether or not + * there's a depth buffer, stencil buffer, etc. + * - struct gl_framebuffer: contains pointers to the depth buffer, stencil buffer, + * accum buffer and alpha buffers. + * + * These types should be encapsulated by corresponding device driver + * data types. See xmesa.h and xmesaP.h for an example. + * + * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer are base classes + * which the device driver must derive from. + * + * The following functions create and destroy these data types. + */ + + +#ifndef CONTEXT_H +#define CONTEXT_H + + +#include "imports.h" +#include "mtypes.h" + + +struct _glapi_table; + + +/** \name Visual-related functions */ +/*@{*/ + +extern struct gl_config * +_mesa_create_visual( GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +extern GLboolean +_mesa_initialize_visual( struct gl_config *v, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +extern void +_mesa_destroy_visual( struct gl_config *vis ); + +/*@}*/ + + +/** \name Context-related functions */ +/*@{*/ + +extern struct gl_context * +_mesa_create_context( const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext ); + +extern GLboolean +_mesa_initialize_context( struct gl_context *ctx, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext ); + +extern struct gl_context * +_mesa_create_context_for_api(gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + +extern GLboolean +_mesa_initialize_context_for_api(struct gl_context *ctx, + gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + +extern void +_mesa_free_context_data( struct gl_context *ctx ); + +extern void +_mesa_destroy_context( struct gl_context *ctx ); + + +extern void +_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask); + + +extern void +_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height); + +extern GLboolean +_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer, + struct gl_framebuffer *readBuffer ); + +extern GLboolean +_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare); + +extern struct gl_context * +_mesa_get_current_context(void); + +/*@}*/ + +extern void +_mesa_init_get_hash(struct gl_context *ctx); + +extern void +_mesa_notifySwapBuffers(struct gl_context *gc); + + +extern struct _glapi_table * +_mesa_get_dispatch(struct gl_context *ctx); + + +void +_mesa_set_mvp_with_dp4( struct gl_context *ctx, + GLboolean flag ); + + +extern GLboolean +_mesa_valid_to_render(struct gl_context *ctx, const char *where); + + + +/** \name Miscellaneous */ +/*@{*/ + +extern void +_mesa_record_error( struct gl_context *ctx, GLenum error ); + + +extern void +_mesa_finish(struct gl_context *ctx); + +extern void +_mesa_flush(struct gl_context *ctx); + + +extern void GLAPIENTRY +_mesa_Finish( void ); + +extern void GLAPIENTRY +_mesa_Flush( void ); + +/*@}*/ + + +/** + * \name Macros for flushing buffered rendering commands before state changes, + * checking if inside glBegin/glEnd, etc. + */ +/*@{*/ + +/** + * Flush vertices. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_VERTICES(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ + if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ + ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Flush current state. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush current state, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_CURRENT(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ + if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ + ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END(ctx); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/*@}*/ + + + +/** + * Is the secondary color needed? + */ +#define NEED_SECONDARY_COLOR(CTX) \ + (((CTX)->Light.Enabled && \ + (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ + || (CTX)->Fog.ColorSumEnabled \ + || ((CTX)->VertexProgram._Current && \ + ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) && \ + ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \ + || ((CTX)->FragmentProgram._Current && \ + ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) && \ + ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \ + ) + + +/** + * Is RGBA LogicOp enabled? + */ +#define RGBA_LOGICOP_ENABLED(CTX) \ + ((CTX)->Color.ColorLogicOpEnabled || \ + ((CTX)->Color.BlendEnabled && (CTX)->Color.BlendEquationRGB == GL_LOGIC_OP)) + + +#endif /* CONTEXT_H */ diff --git a/mesalib/src/mesa/main/convolve.c b/mesalib/src/mesa/main/convolve.c index f63bddc44..cd725bb01 100644 --- a/mesalib/src/mesa/main/convolve.c +++ b/mesalib/src/mesa/main/convolve.c @@ -1,1461 +1,181 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Image convolution functions. - * - * Notes: filter kernel elements are indexed by and as in - * the GL spec. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "convolve.h" -#include "context.h" -#include "image.h" -#include "macros.h" -#include "mtypes.h" -#include "state.h" -#include "main/dispatch.h" - - -#if FEATURE_convolve - - -/* - * Given an internalFormat token passed to glConvolutionFilter - * or glSeparableFilter, return the corresponding base format. - * Return -1 if invalid token. - */ -static GLint -base_filter_format( GLenum format ) -{ - switch (format) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - return -1; /* error */ - } -} - - -void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) -{ - GLint baseFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter1D(width)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(format or type)"); - return; - } - - ctx->Convolution1D.Format = format; - ctx->Convolution1D.InternalFormat = internalFormat; - ctx->Convolution1D.Width = width; - ctx->Convolution1D.Height = 1; - - image = _mesa_map_validate_pbo_source(ctx, - 1, &ctx->Unpack, width, 1, 1, - format, type, image, - "glConvolutionFilter1D"); - if (!image) - return; - - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, - ctx->Convolution1D.Filter, - format, type, image, &ctx->Unpack, - 0); /* transferOps */ - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - _mesa_scale_and_bias_rgba(width, - (GLfloat (*)[4]) ctx->Convolution1D.Filter, - ctx->Pixel.ConvolutionFilterScale[0][0], - ctx->Pixel.ConvolutionFilterScale[0][1], - ctx->Pixel.ConvolutionFilterScale[0][2], - ctx->Pixel.ConvolutionFilterScale[0][3], - ctx->Pixel.ConvolutionFilterBias[0][0], - ctx->Pixel.ConvolutionFilterBias[0][1], - ctx->Pixel.ConvolutionFilterBias[0][2], - ctx->Pixel.ConvolutionFilterBias[0][3]); - - ctx->NewState |= _NEW_PIXEL; -} - - -void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) -{ - GLint baseFormat; - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(height)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(format or type)"); - return; - } - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(format or type)"); - return; - } - - /* this should have been caught earlier */ - assert(_mesa_components_in_format(format)); - - ctx->Convolution2D.Format = format; - ctx->Convolution2D.InternalFormat = internalFormat; - ctx->Convolution2D.Width = width; - ctx->Convolution2D.Height = height; - - image = _mesa_map_validate_pbo_source(ctx, - 2, &ctx->Unpack, width, height, 1, - format, type, image, - "glConvolutionFilter2D"); - if (!image) - return; - - /* Unpack filter image. We always store filters in RGBA format. */ - for (i = 0; i < height; i++) { - const GLvoid *src = _mesa_image_address2d(&ctx->Unpack, image, width, - height, format, type, i, 0); - GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4; - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst, - format, type, src, &ctx->Unpack, - 0); /* transferOps */ - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - _mesa_scale_and_bias_rgba(width * height, - (GLfloat (*)[4]) ctx->Convolution2D.Filter, - ctx->Pixel.ConvolutionFilterScale[1][0], - ctx->Pixel.ConvolutionFilterScale[1][1], - ctx->Pixel.ConvolutionFilterScale[1][2], - ctx->Pixel.ConvolutionFilterScale[1][3], - ctx->Pixel.ConvolutionFilterBias[1][0], - ctx->Pixel.ConvolutionFilterBias[1][1], - ctx->Pixel.ConvolutionFilterBias[1][2], - ctx->Pixel.ConvolutionFilterBias[1][3]); - - ctx->NewState |= _NEW_PIXEL; -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_MODE: - if (param == (GLfloat) GL_REDUCE || - param == (GLfloat) GL_CONSTANT_BORDER || - param == (GLfloat) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(params)"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - COPY_4V(ctx->Pixel.ConvolutionBorderColor[c], params); - break; - case GL_CONVOLUTION_BORDER_MODE: - if (params[0] == (GLfloat) GL_REDUCE || - params[0] == (GLfloat) GL_CONSTANT_BORDER || - params[0] == (GLfloat) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(params)"); - return; - } - break; - case GL_CONVOLUTION_FILTER_SCALE: - COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); - break; - case GL_CONVOLUTION_FILTER_BIAS: - COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_MODE: - if (param == (GLint) GL_REDUCE || - param == (GLint) GL_CONSTANT_BORDER || - param == (GLint) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(params)"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint c; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - break; - case GL_CONVOLUTION_2D: - c = 1; - break; - case GL_SEPARABLE_2D: - c = 2; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - ctx->Pixel.ConvolutionBorderColor[c][0] = INT_TO_FLOAT(params[0]); - ctx->Pixel.ConvolutionBorderColor[c][1] = INT_TO_FLOAT(params[1]); - ctx->Pixel.ConvolutionBorderColor[c][2] = INT_TO_FLOAT(params[2]); - ctx->Pixel.ConvolutionBorderColor[c][3] = INT_TO_FLOAT(params[3]); - break; - case GL_CONVOLUTION_BORDER_MODE: - if (params[0] == (GLint) GL_REDUCE || - params[0] == (GLint) GL_CONSTANT_BORDER || - params[0] == (GLint) GL_REPLICATE_BORDER) { - ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(params)"); - return; - } - break; - case GL_CONVOLUTION_FILTER_SCALE: - /* COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); */ - /* need cast to prevent compiler warnings */ - ctx->Pixel.ConvolutionFilterScale[c][0] = (GLfloat) params[0]; - ctx->Pixel.ConvolutionFilterScale[c][1] = (GLfloat) params[1]; - ctx->Pixel.ConvolutionFilterScale[c][2] = (GLfloat) params[2]; - ctx->Pixel.ConvolutionFilterScale[c][3] = (GLfloat) params[3]; - break; - case GL_CONVOLUTION_FILTER_BIAS: - /* COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); */ - /* need cast to prevent compiler warnings */ - ctx->Pixel.ConvolutionFilterBias[c][0] = (GLfloat) params[0]; - ctx->Pixel.ConvolutionFilterBias[c][1] = (GLfloat) params[1]; - ctx->Pixel.ConvolutionFilterBias[c][2] = (GLfloat) params[2]; - ctx->Pixel.ConvolutionFilterBias[c][3] = (GLfloat) params[3]; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(pname)"); - return; - } - - ctx->NewState |= _NEW_PIXEL; -} - - -static void GLAPIENTRY -_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) -{ - GLint baseFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_1D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter1D(width)"); - return; - } - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyConvolutionFilter1D( ctx, target, - internalFormat, x, y, width); -} - - -static void GLAPIENTRY -_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) -{ - GLint baseFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_CONVOLUTION_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(height)"); - return; - } - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - return; /* no readbuffer - OK */ - } - - ctx->Driver.CopyConvolutionFilter2D( ctx, target, internalFormat, x, y, - width, height ); -} - - -static void GLAPIENTRY -_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid *image) -{ - struct gl_convolution_attrib *filter; - GLuint row; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); - return; - } - - switch (target) { - case GL_CONVOLUTION_1D: - filter = &(ctx->Convolution1D); - break; - case GL_CONVOLUTION_2D: - filter = &(ctx->Convolution2D); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(target)"); - return; - } - - image = _mesa_map_validate_pbo_dest(ctx, 2, &ctx->Pack, - filter->Width, filter->Height, 1, - format, type, image, - "glGetConvolutionFilter"); - if (!image) - return; - - for (row = 0; row < filter->Height; row++) { - GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width, - filter->Height, format, type, - row, 0); - GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + row * filter->Width * 4); - _mesa_pack_rgba_span_float(ctx, filter->Width, src, - format, type, dst, &ctx->Pack, 0x0); - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - const struct gl_convolution_attrib *conv; - GLuint c; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - conv = &ctx->Convolution1D; - break; - case GL_CONVOLUTION_2D: - c = 1; - conv = &ctx->Convolution2D; - break; - case GL_SEPARABLE_2D: - c = 2; - conv = &ctx->Separable2D; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - COPY_4V(params, ctx->Pixel.ConvolutionBorderColor[c]); - break; - case GL_CONVOLUTION_BORDER_MODE: - *params = (GLfloat) ctx->Pixel.ConvolutionBorderMode[c]; - break; - case GL_CONVOLUTION_FILTER_SCALE: - COPY_4V(params, ctx->Pixel.ConvolutionFilterScale[c]); - break; - case GL_CONVOLUTION_FILTER_BIAS: - COPY_4V(params, ctx->Pixel.ConvolutionFilterBias[c]); - break; - case GL_CONVOLUTION_FORMAT: - *params = (GLfloat) conv->Format; - break; - case GL_CONVOLUTION_WIDTH: - *params = (GLfloat) conv->Width; - break; - case GL_CONVOLUTION_HEIGHT: - *params = (GLfloat) conv->Height; - break; - case GL_MAX_CONVOLUTION_WIDTH: - *params = (GLfloat) ctx->Const.MaxConvolutionWidth; - break; - case GL_MAX_CONVOLUTION_HEIGHT: - *params = (GLfloat) ctx->Const.MaxConvolutionHeight; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(pname)"); - return; - } -} - - -static void GLAPIENTRY -_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - const struct gl_convolution_attrib *conv; - GLuint c; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_CONVOLUTION_1D: - c = 0; - conv = &ctx->Convolution1D; - break; - case GL_CONVOLUTION_2D: - c = 1; - conv = &ctx->Convolution2D; - break; - case GL_SEPARABLE_2D: - c = 2; - conv = &ctx->Separable2D; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(target)"); - return; - } - - switch (pname) { - case GL_CONVOLUTION_BORDER_COLOR: - params[0] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][0]); - params[1] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][1]); - params[2] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][2]); - params[3] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][3]); - break; - case GL_CONVOLUTION_BORDER_MODE: - *params = (GLint) ctx->Pixel.ConvolutionBorderMode[c]; - break; - case GL_CONVOLUTION_FILTER_SCALE: - params[0] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][0]; - params[1] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][1]; - params[2] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][2]; - params[3] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][3]; - break; - case GL_CONVOLUTION_FILTER_BIAS: - params[0] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][0]; - params[1] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][1]; - params[2] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][2]; - params[3] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][3]; - break; - case GL_CONVOLUTION_FORMAT: - *params = (GLint) conv->Format; - break; - case GL_CONVOLUTION_WIDTH: - *params = (GLint) conv->Width; - break; - case GL_CONVOLUTION_HEIGHT: - *params = (GLint) conv->Height; - break; - case GL_MAX_CONVOLUTION_WIDTH: - *params = (GLint) ctx->Const.MaxConvolutionWidth; - break; - case GL_MAX_CONVOLUTION_HEIGHT: - *params = (GLint) ctx->Const.MaxConvolutionHeight; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(pname)"); - return; - } -} - - -static void GLAPIENTRY -_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid *row, GLvoid *column, GLvoid *span) -{ - const GLint colStart = MAX_CONVOLUTION_WIDTH * 4; - struct gl_convolution_attrib *filter; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (target != GL_SEPARABLE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter(target)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetConvolutionFilter(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); - return; - } - - filter = &ctx->Separable2D; - - /* Get row filter */ - row = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, - filter->Width, 1, 1, - format, type, row, - "glGetConvolutionFilter"); - if (row) { - GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width, - format, type, 0); - _mesa_pack_rgba_span_float(ctx, filter->Width, - (GLfloat (*)[4]) filter->Filter, - format, type, dst, &ctx->Pack, 0x0); - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - } - - /* get column filter */ - column = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, - filter->Height, 1, 1, - format, type, column, - "glGetConvolutionFilter"); - if (column) { - GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height, - format, type, 0); - GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + colStart); - _mesa_pack_rgba_span_float(ctx, filter->Height, src, - format, type, dst, &ctx->Pack, 0x0); - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - } - - (void) span; /* unused at this time */ -} - - -static void GLAPIENTRY -_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) -{ - const GLint colStart = MAX_CONVOLUTION_WIDTH * 4; - GLint baseFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (target != GL_SEPARABLE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(target)"); - return; - } - - baseFormat = base_filter_format(internalFormat); - if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(internalFormat)"); - return; - } - - if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(width)"); - return; - } - if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(height)"); - return; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glSeparableFilter2D(format or type)"); - return; - } - - if (format == GL_COLOR_INDEX || - format == GL_STENCIL_INDEX || - format == GL_DEPTH_COMPONENT || - format == GL_INTENSITY || - type == GL_BITMAP) { - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(format or type)"); - return; - } - - ctx->Separable2D.Format = format; - ctx->Separable2D.InternalFormat = internalFormat; - ctx->Separable2D.Width = width; - ctx->Separable2D.Height = height; - - /* unpack row filter */ - row = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, - width, 1, 1, - format, type, row, - "glSeparableFilter2D"); - if (row) { - _mesa_unpack_color_span_float(ctx, width, GL_RGBA, - ctx->Separable2D.Filter, - format, type, row, &ctx->Unpack, - 0x0); /* transferOps */ - _mesa_scale_and_bias_rgba(width, - (GLfloat (*)[4]) ctx->Separable2D.Filter, - ctx->Pixel.ConvolutionFilterScale[2][0], - ctx->Pixel.ConvolutionFilterScale[2][1], - ctx->Pixel.ConvolutionFilterScale[2][2], - ctx->Pixel.ConvolutionFilterScale[2][3], - ctx->Pixel.ConvolutionFilterBias[2][0], - ctx->Pixel.ConvolutionFilterBias[2][1], - ctx->Pixel.ConvolutionFilterBias[2][2], - ctx->Pixel.ConvolutionFilterBias[2][3]); - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - } - - /* unpack column filter */ - column = _mesa_map_validate_pbo_source(ctx, 1, &ctx->Unpack, - height, 1, 1, - format, type, column, - "glSeparableFilter2D"); - if (column) { - _mesa_unpack_color_span_float(ctx, height, GL_RGBA, - &ctx->Separable2D.Filter[colStart], - format, type, column, &ctx->Unpack, - 0); /* transferOps */ - - _mesa_scale_and_bias_rgba(height, - (GLfloat (*)[4]) (ctx->Separable2D.Filter + colStart), - ctx->Pixel.ConvolutionFilterScale[2][0], - ctx->Pixel.ConvolutionFilterScale[2][1], - ctx->Pixel.ConvolutionFilterScale[2][2], - ctx->Pixel.ConvolutionFilterScale[2][3], - ctx->Pixel.ConvolutionFilterBias[2][0], - ctx->Pixel.ConvolutionFilterBias[2][1], - ctx->Pixel.ConvolutionFilterBias[2][2], - ctx->Pixel.ConvolutionFilterBias[2][3]); - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - } - - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } - - ctx->NewState |= _NEW_PIXEL; -} - - -/**********************************************************************/ -/*** image convolution functions ***/ -/**********************************************************************/ - -static void -convolve_1d_reduce(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4]) -{ - GLint dstWidth; - GLint i, n; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (dstWidth <= 0) - return; /* null result */ - - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - sumR += src[i + n][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n][ACOMP] * filter[n][ACOMP]; - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_1d_constant(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - GLint i, n; - - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - if (i + n < halfFilterWidth || i + n - halfFilterWidth >= srcWidth) { - sumR += borderColor[RCOMP] * filter[n][RCOMP]; - sumG += borderColor[GCOMP] * filter[n][GCOMP]; - sumB += borderColor[BCOMP] * filter[n][BCOMP]; - sumA += borderColor[ACOMP] * filter[n][ACOMP]; - } - else { - sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP]; - } - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_1d_replicate(GLint srcWidth, const GLfloat src[][4], - GLint filterWidth, const GLfloat filter[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - GLint i, n; - - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (n = 0; n < filterWidth; n++) { - if (i + n < halfFilterWidth) { - sumR += src[0][RCOMP] * filter[n][RCOMP]; - sumG += src[0][GCOMP] * filter[n][GCOMP]; - sumB += src[0][BCOMP] * filter[n][BCOMP]; - sumA += src[0][ACOMP] * filter[n][ACOMP]; - } - else if (i + n - halfFilterWidth >= srcWidth) { - sumR += src[srcWidth - 1][RCOMP] * filter[n][RCOMP]; - sumG += src[srcWidth - 1][GCOMP] * filter[n][GCOMP]; - sumB += src[srcWidth - 1][BCOMP] * filter[n][BCOMP]; - sumA += src[srcWidth - 1][ACOMP] * filter[n][ACOMP]; - } - else { - sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP]; - sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP]; - sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP]; - sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP]; - } - } - dest[i][RCOMP] = sumR; - dest[i][GCOMP] = sumG; - dest[i][BCOMP] = sumB; - dest[i][ACOMP] = sumA; - } -} - - -static void -convolve_2d_reduce(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4]) -{ - GLint dstWidth, dstHeight; - GLint i, j, n, m; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (filterHeight >= 1) - dstHeight = srcHeight - (filterHeight - 1); - else - dstHeight = srcHeight; - - if (dstWidth <= 0 || dstHeight <= 0) - return; - - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint k = (j + m) * srcWidth + i + n; - const GLint f = m * filterWidth + n; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - dest[j * dstWidth + i][RCOMP] = sumR; - dest[j * dstWidth + i][GCOMP] = sumG; - dest[j * dstWidth + i][BCOMP] = sumB; - dest[j * dstWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_2d_constant(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint f = m * filterWidth + n; - const GLint is = i + n - halfFilterWidth; - const GLint js = j + m - halfFilterHeight; - if (is < 0 || is >= srcWidth || - js < 0 || js >= srcHeight) { - sumR += borderColor[RCOMP] * filter[f][RCOMP]; - sumG += borderColor[GCOMP] * filter[f][GCOMP]; - sumB += borderColor[BCOMP] * filter[f][BCOMP]; - sumA += borderColor[ACOMP] * filter[f][ACOMP]; - } - else { - const GLint k = js * srcWidth + is; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_2d_replicate(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat filter[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint f = m * filterWidth + n; - GLint is = i + n - halfFilterWidth; - GLint js = j + m - halfFilterHeight; - GLint k; - if (is < 0) - is = 0; - else if (is >= srcWidth) - is = srcWidth - 1; - if (js < 0) - js = 0; - else if (js >= srcHeight) - js = srcHeight - 1; - k = js * srcWidth + is; - sumR += src[k][RCOMP] * filter[f][RCOMP]; - sumG += src[k][GCOMP] * filter[f][GCOMP]; - sumB += src[k][BCOMP] * filter[f][BCOMP]; - sumA += src[k][ACOMP] * filter[f][ACOMP]; - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_reduce(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4]) -{ - GLint dstWidth, dstHeight; - GLint i, j, n, m; - - if (filterWidth >= 1) - dstWidth = srcWidth - (filterWidth - 1); - else - dstWidth = srcWidth; - - if (filterHeight >= 1) - dstHeight = srcHeight - (filterHeight - 1); - else - dstHeight = srcHeight; - - if (dstWidth <= 0 || dstHeight <= 0) - return; - - for (j = 0; j < dstHeight; j++) { - for (i = 0; i < dstWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - GLint k = (j + m) * srcWidth + i + n; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - } - dest[j * dstWidth + i][RCOMP] = sumR; - dest[j * dstWidth + i][GCOMP] = sumG; - dest[j * dstWidth + i][BCOMP] = sumB; - dest[j * dstWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_constant(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4], - const GLfloat borderColor[4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - const GLint is = i + n - halfFilterWidth; - const GLint js = j + m - halfFilterHeight; - if (is < 0 || is >= srcWidth || - js < 0 || js >= srcHeight) { - sumR += borderColor[RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += borderColor[GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += borderColor[BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += borderColor[ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - else { - GLint k = js * srcWidth + is; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - -static void -convolve_sep_replicate(GLint srcWidth, GLint srcHeight, - const GLfloat src[][4], - GLint filterWidth, GLint filterHeight, - const GLfloat rowFilt[][4], - const GLfloat colFilt[][4], - GLfloat dest[][4]) -{ - const GLint halfFilterWidth = filterWidth / 2; - const GLint halfFilterHeight = filterHeight / 2; - GLint i, j, n, m; - - for (j = 0; j < srcHeight; j++) { - for (i = 0; i < srcWidth; i++) { - GLfloat sumR = 0.0; - GLfloat sumG = 0.0; - GLfloat sumB = 0.0; - GLfloat sumA = 0.0; - for (m = 0; m < filterHeight; m++) { - for (n = 0; n < filterWidth; n++) { - GLint is = i + n - halfFilterWidth; - GLint js = j + m - halfFilterHeight; - GLint k; - if (is < 0) - is = 0; - else if (is >= srcWidth) - is = srcWidth - 1; - if (js < 0) - js = 0; - else if (js >= srcHeight) - js = srcHeight - 1; - k = js * srcWidth + is; - sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP]; - sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP]; - sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP]; - sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP]; - } - } - dest[j * srcWidth + i][RCOMP] = sumR; - dest[j * srcWidth + i][GCOMP] = sumG; - dest[j * srcWidth + i][BCOMP] = sumB; - dest[j * srcWidth + i][ACOMP] = sumA; - } - } -} - - - -void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage) -{ - switch (ctx->Pixel.ConvolutionBorderMode[0]) { - case GL_REDUCE: - convolve_1d_reduce(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_1d_constant(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[0]); - break; - case GL_REPLICATE_BORDER: - convolve_1d_replicate(*width, (const GLfloat (*)[4]) srcImage, - ctx->Convolution1D.Width, - (const GLfloat (*)[4]) ctx->Convolution1D.Filter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } -} - - -void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - switch (ctx->Pixel.ConvolutionBorderMode[1]) { - case GL_REDUCE: - convolve_2d_reduce(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4]) ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_2d_constant(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4]) ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[1]); - break; - case GL_REPLICATE_BORDER: - convolve_2d_replicate(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Convolution2D.Width, - ctx->Convolution2D.Height, - (const GLfloat (*)[4])ctx->Convolution2D.Filter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } -} - - -void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - const GLfloat *rowFilter = ctx->Separable2D.Filter; - const GLfloat *colFilter = rowFilter + 4 * MAX_CONVOLUTION_WIDTH; - - switch (ctx->Pixel.ConvolutionBorderMode[2]) { - case GL_REDUCE: - convolve_sep_reduce(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage); - *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); - break; - case GL_CONSTANT_BORDER: - convolve_sep_constant(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage, - ctx->Pixel.ConvolutionBorderColor[2]); - break; - case GL_REPLICATE_BORDER: - convolve_sep_replicate(*width, *height, - (const GLfloat (*)[4]) srcImage, - ctx->Separable2D.Width, - ctx->Separable2D.Height, - (const GLfloat (*)[4]) rowFilter, - (const GLfloat (*)[4]) colFilter, - (GLfloat (*)[4]) dstImage); - break; - default: - ; - } -} - - - -/* - * This function computes an image's size after convolution. - * If the convolution border mode is GL_REDUCE, the post-convolution - * image will be smaller than the original. - */ -void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height) -{ - if (ctx->Pixel.Convolution1DEnabled - && dimensions == 1 - && ctx->Pixel.ConvolutionBorderMode[0] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1); - } - else if (ctx->Pixel.Convolution2DEnabled - && dimensions > 1 - && ctx->Pixel.ConvolutionBorderMode[1] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1); - } - else if (ctx->Pixel.Separable2DEnabled - && dimensions > 1 - && ctx->Pixel.ConvolutionBorderMode[2] == GL_REDUCE) { - *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1); - *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); - } -} - - -void -_mesa_init_convolve_dispatch(struct _glapi_table *disp) -{ - SET_ConvolutionFilter1D(disp, _mesa_ConvolutionFilter1D); - SET_ConvolutionFilter2D(disp, _mesa_ConvolutionFilter2D); - SET_ConvolutionParameterf(disp, _mesa_ConvolutionParameterf); - SET_ConvolutionParameterfv(disp, _mesa_ConvolutionParameterfv); - SET_ConvolutionParameteri(disp, _mesa_ConvolutionParameteri); - SET_ConvolutionParameteriv(disp, _mesa_ConvolutionParameteriv); - SET_CopyConvolutionFilter1D(disp, _mesa_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(disp, _mesa_CopyConvolutionFilter2D); - SET_GetConvolutionFilter(disp, _mesa_GetConvolutionFilter); - SET_GetConvolutionParameterfv(disp, _mesa_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(disp, _mesa_GetConvolutionParameteriv); - SET_SeparableFilter2D(disp, _mesa_SeparableFilter2D); - SET_GetSeparableFilter(disp, _mesa_GetSeparableFilter); -} - - -#endif /* FEATURE_convolve */ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* + * Image convolution functions. + * + * Notes: filter kernel elements are indexed by and as in + * the GL spec. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "convolve.h" +#include "macros.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_convolve + +static void GLAPIENTRY +_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D"); +} + +static void GLAPIENTRY +_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv"); +} + + +static void GLAPIENTRY +_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D"); +} + + +static void GLAPIENTRY +_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D"); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter"); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv"); +} + + +static void GLAPIENTRY +_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid *row, GLvoid *column, GLvoid *span) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter"); +} + + +static void GLAPIENTRY +_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D"); +} + +void +_mesa_init_convolve_dispatch(struct _glapi_table *disp) +{ + SET_ConvolutionFilter1D(disp, _mesa_ConvolutionFilter1D); + SET_ConvolutionFilter2D(disp, _mesa_ConvolutionFilter2D); + SET_ConvolutionParameterf(disp, _mesa_ConvolutionParameterf); + SET_ConvolutionParameterfv(disp, _mesa_ConvolutionParameterfv); + SET_ConvolutionParameteri(disp, _mesa_ConvolutionParameteri); + SET_ConvolutionParameteriv(disp, _mesa_ConvolutionParameteriv); + SET_CopyConvolutionFilter1D(disp, _mesa_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(disp, _mesa_CopyConvolutionFilter2D); + SET_GetConvolutionFilter(disp, _mesa_GetConvolutionFilter); + SET_GetConvolutionParameterfv(disp, _mesa_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(disp, _mesa_GetConvolutionParameteriv); + SET_SeparableFilter2D(disp, _mesa_SeparableFilter2D); + SET_GetSeparableFilter(disp, _mesa_GetSeparableFilter); +} + + +#endif /* FEATURE_convolve */ diff --git a/mesalib/src/mesa/main/convolve.h b/mesalib/src/mesa/main/convolve.h index 80caf942f..7ecfcd6b1 100644 --- a/mesalib/src/mesa/main/convolve.h +++ b/mesalib/src/mesa/main/convolve.h @@ -1,120 +1,51 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef CONVOLVE_H -#define CONVOLVE_H - - -#include "main/mtypes.h" - - -#if FEATURE_convolve - -extern void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, - GLenum format, GLenum type, const GLvoid *image); - -extern void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, - GLsizei height, GLenum format, GLenum type, - const GLvoid *image); - -extern void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage); - -extern void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height); - -extern void -_mesa_init_convolve_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_convolve */ - -#include "main/compiler.h" - -static INLINE void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, - GLenum format, GLenum type, const GLvoid *image) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, - GLsizei height, GLenum format, GLenum type, - const GLvoid *image) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - - -static INLINE void -_mesa_convolve_sep_image(const GLcontext *ctx, - GLsizei *width, GLsizei *height, - const GLfloat *srcImage, GLfloat *dstImage) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, - GLsizei *width, GLsizei *height) -{ -} - -static INLINE void -_mesa_init_convolve_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_convolve */ - -#endif /* CONVOLVE_H */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef CONVOLVE_H +#define CONVOLVE_H + + +#include "compiler.h" +#include "mfeatures.h" + +struct _glapi_table; + + +#if FEATURE_convolve + +extern void +_mesa_init_convolve_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_convolve */ + +static INLINE void +_mesa_init_convolve_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_convolve */ + +#endif /* CONVOLVE_H */ diff --git a/mesalib/src/mesa/main/core.h b/mesalib/src/mesa/main/core.h index ea6e6bf11..ee3e91593 100644 --- a/mesalib/src/mesa/main/core.h +++ b/mesalib/src/mesa/main/core.h @@ -1,66 +1,64 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - * - * Authors: - * Chia-I Wu - */ - - -/** - * \file core.h - * The public header of core mesa. - * - * This file is the (only) public header of core mesa. It is supposed to be - * used by GLX, WGL, and GLSL. It is important that headers directly or - * indirectly included here do not perform feature tests (#if FEATURE_xxx). - */ - - -#ifndef CORE_H -#define CORE_H - - -#include "main/glheader.h" -#include "main/compiler.h" -#include "main/imports.h" -#include "main/macros.h" - -#include "main/version.h" /* for MESA_VERSION_STRING */ -#include "main/context.h" /* for _mesa_share_state */ -#include "main/mtypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* for GLSL */ -#include "program/prog_parameter.h" -#include "program/prog_uniform.h" - -#ifdef __cplusplus -} -#endif - - -#endif /* CORE_H */ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + * + * Authors: + * Chia-I Wu + */ + + +/** + * \file core.h + * The public header of core mesa. + * + * This file is the (only) public header of core mesa. It is supposed to be + * used by GLX, WGL, and GLSL. It is important that headers directly or + * indirectly included here do not perform feature tests (#if FEATURE_xxx). + */ + + +#ifndef CORE_H +#define CORE_H + + +#include "main/glheader.h" +#include "main/compiler.h" +#include "main/imports.h" +#include "main/macros.h" + +#include "main/mtypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* for GLSL */ +#include "program/prog_parameter.h" +#include "program/prog_uniform.h" + +#ifdef __cplusplus +} +#endif + + +#endif /* CORE_H */ diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 8a20a6636..15600ba93 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -1,1174 +1,1196 @@ -/** - * \file dd.h - * Device driver interfaces. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DD_INCLUDED -#define DD_INCLUDED - -/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ - -struct gl_pixelstore_attrib; -struct gl_display_list; - -/* GL_ARB_vertex_buffer_object */ -/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return - * NULL) if buffer is unavailable for immediate mapping. - * - * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it - * would require more book-keeping in the driver than seems necessary - * at this point. - * - * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't - * want to provoke the driver to throw away the old storage, we will - * respect the contents of already referenced data. - */ -#define MESA_MAP_NOWAIT_BIT 0x0040 - - -/** - * Device driver function table. - * Core Mesa uses these function pointers to call into device drivers. - * Most of these functions directly correspond to OpenGL state commands. - * Core Mesa will call these functions after error checking has been done - * so that the drivers don't have to worry about error testing. - * - * Vertex transformation/clipping/lighting is patched into the T&L module. - * Rasterization functions are patched into the swrast module. - * - * Note: when new functions are added here, the drivers/common/driverfuncs.c - * file should be updated too!!! - */ -struct dd_function_table { - /** - * Return a string as needed by glGetString(). - * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be - * returned. - */ - const GLubyte * (*GetString)( GLcontext *ctx, GLenum name ); - - /** - * Notify the driver after Mesa has made some internal state changes. - * - * This is in addition to any state change callbacks Mesa may already have - * made. - */ - void (*UpdateState)( GLcontext *ctx, GLbitfield new_state ); - - /** - * Get the width and height of the named buffer/window. - * - * Mesa uses this to determine when the driver's window size has changed. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*GetBufferSize)( GLframebuffer *buffer, - GLuint *width, GLuint *height ); - - /** - * Resize the given framebuffer to the given size. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*ResizeBuffers)( GLcontext *ctx, GLframebuffer *fb, - GLuint width, GLuint height); - - /** - * Called whenever an error is generated. - * __GLcontextRec::ErrorValue contains the error value. - */ - void (*Error)( GLcontext *ctx ); - - /** - * This is called whenever glFinish() is called. - */ - void (*Finish)( GLcontext *ctx ); - - /** - * This is called whenever glFlush() is called. - */ - void (*Flush)( GLcontext *ctx ); - - /** - * Clear the color/depth/stencil/accum buffer(s). - * \param buffers a bitmask of BUFFER_BIT_* flags indicating which - * renderbuffers need to be cleared. - */ - void (*Clear)( GLcontext *ctx, GLbitfield buffers ); - - /** - * Execute glAccum command. - */ - void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value ); - - - /** - * Execute glRasterPos, updating the ctx->Current.Raster fields - */ - void (*RasterPos)( GLcontext *ctx, const GLfloat v[4] ); - - /** - * \name Image-related functions - */ - /*@{*/ - - /** - * Called by glDrawPixels(). - * \p unpack describes how to unpack the source image data. - */ - void (*DrawPixels)( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); - - /** - * Called by glReadPixels(). - */ - void (*ReadPixels)( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - GLvoid *dest ); - - /** - * Called by glCopyPixels(). - */ - void (*CopyPixels)( GLcontext *ctx, GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, GLenum type ); - - /** - * Called by glBitmap(). - */ - void (*Bitmap)( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - /*@}*/ - - - /** - * \name Texture image functions - */ - /*@{*/ - - /** - * Choose texture format. - * - * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback - * functions. The driver should examine \p internalFormat and return a - * gl_format value. - */ - GLuint (*ChooseTextureFormat)( GLcontext *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ); - - /** - * Called by glTexImage1D(). - * - * \param target user specified. - * \param format user specified. - * \param type user specified. - * \param pixels user specified. - * \param packing indicates the image packing of pixels. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - * - * \p retainInternalCopy is returned by this function and indicates whether - * core Mesa should keep an internal copy of the texture image. - * - * Drivers should call a fallback routine from texstore.c if needed. - */ - void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexImage2D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexImage3D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage1D(). - * - * \param target user specified. - * \param level user specified. - * \param xoffset user specified. - * \param yoffset user specified. - * \param zoffset user specified. - * \param width user specified. - * \param height user specified. - * \param depth user specified. - * \param format user specified. - * \param type user specified. - * \param pixels user specified. - * \param packing indicates the image packing of pixels. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p border and \p internalFormat information. - * - * The driver should use a fallback routine from texstore.c if needed. - */ - void (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage2D(). - * - * \sa dd_function_table::TexSubImage1D. - */ - void (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage3D(). - * - * \sa dd_function_table::TexSubImage1D. - */ - void (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLint depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glGetTexImage(). - */ - void (*GetTexImage)( GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glCopyTexImage1D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, GLint x, GLint y, - GLsizei width, GLint border ); - - /** - * Called by glCopyTexImage2D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, GLint x, GLint y, - GLsizei width, GLsizei height, GLint border ); - - /** - * Called by glCopyTexSubImage1D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, - GLint x, GLint y, GLsizei width ); - /** - * Called by glCopyTexSubImage2D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - /** - * Called by glCopyTexSubImage3D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - - /** - * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled. - */ - void (*GenerateMipmap)(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj); - - /** - * Called by glTexImage[123]D when user specifies a proxy texture - * target. - * - * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. - */ - GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); - /*@}*/ - - - /** - * \name Compressed texture functions - */ - /*@{*/ - - /** - * Called by glCompressedTexImage1D(). - * - * \param target user specified. - * \param format user specified. - * \param type user specified. - * \param pixels user specified. - * \param packing indicates the image packing of pixels. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - * - * \a retainInternalCopy is returned by this function and indicates whether - * core Mesa should keep an internal copy of the texture image. - */ - void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - /** - * Called by glCompressedTexImage2D(). - * - * \sa dd_function_table::CompressedTexImage1D. - */ - void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - /** - * Called by glCompressedTexImage3D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glCompressedTexSubImage1D(). - * - * \param target user specified. - * \param level user specified. - * \param xoffset user specified. - * \param yoffset user specified. - * \param zoffset user specified. - * \param width user specified. - * \param height user specified. - * \param depth user specified. - * \param imageSize user specified. - * \param data user specified. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - */ - void (*CompressedTexSubImage1D)(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - /** - * Called by glCompressedTexSubImage2D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexSubImage2D)(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - /** - * Called by glCompressedTexSubImage3D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexSubImage3D)(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLint height, GLint depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - - /** - * Called by glGetCompressedTexImage. - */ - void (*GetCompressedTexImage)(GLcontext *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - /*@}*/ - - /** - * \name Texture object functions - */ - /*@{*/ - - /** - * Called by glBindTexture(). - */ - void (*BindTexture)( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj ); - - /** - * Called to allocate a new texture object. - * A new gl_texture_object should be returned. The driver should - * attach to it any device-specific info it needs. - */ - struct gl_texture_object * (*NewTextureObject)( GLcontext *ctx, GLuint name, - GLenum target ); - /** - * Called when a texture object is about to be deallocated. - * - * Driver should delete the gl_texture_object object and anything - * hanging off of it. - */ - void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); - - /** - * Called to allocate a new texture image object. - */ - struct gl_texture_image * (*NewTextureImage)( GLcontext *ctx ); - - /** - * Called to free tImage->Data. - */ - void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage ); - - /** Map texture image data into user space */ - void (*MapTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); - /** Unmap texture images from user space */ - void (*UnmapTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); - - /** - * Note: no context argument. This function doesn't initially look - * like it belongs here, except that the driver is the only entity - * that knows for sure how the texture memory is allocated - via - * the above callbacks. There is then an argument that the driver - * knows what memcpy paths might be fast. Typically this is invoked with - * - * to -- a pointer into texture memory allocated by NewTextureImage() above. - * from -- a pointer into client memory or a mesa temporary. - * sz -- nr bytes to copy. - */ - void* (*TextureMemCpy)( void *to, const void *from, size_t sz ); - - /** - * Called by glAreTextureResident(). - */ - GLboolean (*IsTextureResident)( GLcontext *ctx, - struct gl_texture_object *t ); - - /** - * Called when the texture's color lookup table is changed. - * - * If \p tObj is NULL then the shared texture palette - * gl_texture_object::Palette is to be updated. - */ - void (*UpdateTexturePalette)( GLcontext *ctx, - struct gl_texture_object *tObj ); - /*@}*/ - - - /** - * \name Imaging functionality - */ - /*@{*/ - void (*CopyColorTable)( GLcontext *ctx, - GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width ); - - void (*CopyColorSubTable)( GLcontext *ctx, - GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width ); - - void (*CopyConvolutionFilter1D)( GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width ); - - void (*CopyConvolutionFilter2D)( GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLsizei height ); - /*@}*/ - - - /** - * \name Vertex/fragment program functions - */ - /*@{*/ - /** Bind a vertex/fragment program */ - void (*BindProgram)(GLcontext *ctx, GLenum target, struct gl_program *prog); - /** Allocate a new program */ - struct gl_program * (*NewProgram)(GLcontext *ctx, GLenum target, GLuint id); - /** Delete a program */ - void (*DeleteProgram)(GLcontext *ctx, struct gl_program *prog); - /** - * Notify driver that a program string (and GPU code) has been specified - * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is - * supported by the driver. - */ - GLboolean (*ProgramStringNotify)(GLcontext *ctx, GLenum target, - struct gl_program *prog); - - /** Query if program can be loaded onto hardware */ - GLboolean (*IsProgramNative)(GLcontext *ctx, GLenum target, - struct gl_program *prog); - - /*@}*/ - - /** - * \name GLSL shader/program functions. - */ - /*@{*/ - /** - * Called when a shader is compiled. - * - * Note that not all shader objects get ShaderCompile called on - * them. Notably, the shaders containing builtin functions do not - * have CompileShader() called, so if lowering passes are done they - * need to also be performed in LinkShader(). - */ - GLboolean (*CompileShader)(GLcontext *ctx, struct gl_shader *shader); - /** - * Called when a shader program is linked. - * - * This gives drivers an opportunity to clone the IR and make their - * own transformations on it for the purposes of code generation. - */ - GLboolean (*LinkShader)(GLcontext *ctx, struct gl_shader_program *shader); - /*@}*/ - - /** - * \name State-changing functions. - * - * \note drawing functions are above. - * - * These functions are called by their corresponding OpenGL API functions. - * They are \e also called by the gl_PopAttrib() function!!! - * May add more functions like these to the device driver in the future. - */ - /*@{*/ - /** Specify the alpha test function */ - void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLfloat ref); - /** Set the blend color */ - void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]); - /** Set the blend equation */ - void (*BlendEquationSeparate)(GLcontext *ctx, GLenum modeRGB, GLenum modeA); - /** Specify pixel arithmetic */ - void (*BlendFuncSeparate)(GLcontext *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA); - /** Specify clear values for the color buffers */ - void (*ClearColor)(GLcontext *ctx, const GLfloat color[4]); - /** Specify the clear value for the depth buffer */ - void (*ClearDepth)(GLcontext *ctx, GLclampd d); - /** Specify the clear value for the stencil buffer */ - void (*ClearStencil)(GLcontext *ctx, GLint s); - /** Specify a plane against which all geometry is clipped */ - void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation ); - /** Enable and disable writing of frame buffer color components */ - void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask, - GLboolean bmask, GLboolean amask ); - void (*ColorMaskIndexed)(GLcontext *ctx, GLuint buf, GLboolean rmask, - GLboolean gmask, GLboolean bmask, GLboolean amask); - /** Cause a material color to track the current color */ - void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode); - /** Specify whether front- or back-facing facets can be culled */ - void (*CullFace)(GLcontext *ctx, GLenum mode); - /** Define front- and back-facing polygons */ - void (*FrontFace)(GLcontext *ctx, GLenum mode); - /** Specify the value used for depth buffer comparisons */ - void (*DepthFunc)(GLcontext *ctx, GLenum func); - /** Enable or disable writing into the depth buffer */ - void (*DepthMask)(GLcontext *ctx, GLboolean flag); - /** Specify mapping of depth values from NDC to window coordinates */ - void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval); - /** Specify the current buffer for writing */ - void (*DrawBuffer)( GLcontext *ctx, GLenum buffer ); - /** Specify the buffers for writing for fragment programs*/ - void (*DrawBuffers)( GLcontext *ctx, GLsizei n, const GLenum *buffers ); - /** Enable or disable server-side gl capabilities */ - void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state); - /** Specify fog parameters */ - void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); - /** Specify implementation-specific hints */ - void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode); - /** Set light source parameters. - * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already - * been transformed to eye-space. - */ - void (*Lightfv)(GLcontext *ctx, GLenum light, - GLenum pname, const GLfloat *params ); - /** Set the lighting model parameters */ - void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); - /** Specify the line stipple pattern */ - void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern ); - /** Specify the width of rasterized lines */ - void (*LineWidth)(GLcontext *ctx, GLfloat width); - /** Specify a logical pixel operation for color index rendering */ - void (*LogicOpcode)(GLcontext *ctx, GLenum opcode); - void (*PointParameterfv)(GLcontext *ctx, GLenum pname, - const GLfloat *params); - /** Specify the diameter of rasterized points */ - void (*PointSize)(GLcontext *ctx, GLfloat size); - /** Select a polygon rasterization mode */ - void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode); - /** Set the scale and units used to calculate depth values */ - void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units); - /** Set the polygon stippling pattern */ - void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask ); - /* Specifies the current buffer for reading */ - void (*ReadBuffer)( GLcontext *ctx, GLenum buffer ); - /** Set rasterization mode */ - void (*RenderMode)(GLcontext *ctx, GLenum mode ); - /** Define the scissor box */ - void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /** Select flat or smooth shading */ - void (*ShadeModel)(GLcontext *ctx, GLenum mode); - /** OpenGL 2.0 two-sided StencilFunc */ - void (*StencilFuncSeparate)(GLcontext *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask); - /** OpenGL 2.0 two-sided StencilMask */ - void (*StencilMaskSeparate)(GLcontext *ctx, GLenum face, GLuint mask); - /** OpenGL 2.0 two-sided StencilOp */ - void (*StencilOpSeparate)(GLcontext *ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass); - /** Control the generation of texture coordinates */ - void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname, - const GLfloat *params); - /** Set texture environment parameters */ - void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname, - const GLfloat *param); - /** Set texture parameters */ - void (*TexParameter)(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params); - /** Set the viewport */ - void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /*@}*/ - - - /** - * \name Vertex/pixel buffer object functions - */ - /*@{*/ - void (*BindBuffer)( GLcontext *ctx, GLenum target, - struct gl_buffer_object *obj ); - - struct gl_buffer_object * (*NewBufferObject)( GLcontext *ctx, GLuint buffer, - GLenum target ); - - void (*DeleteBuffer)( GLcontext *ctx, struct gl_buffer_object *obj ); - - GLboolean (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid *data, GLenum usage, - struct gl_buffer_object *obj ); - - void (*BufferSubData)( GLcontext *ctx, GLenum target, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid *data, - struct gl_buffer_object *obj ); - - void (*GetBufferSubData)( GLcontext *ctx, GLenum target, - GLintptrARB offset, GLsizeiptrARB size, - GLvoid *data, struct gl_buffer_object *obj ); - - void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access, - struct gl_buffer_object *obj ); - - void (*CopyBufferSubData)( GLcontext *ctx, - struct gl_buffer_object *src, - struct gl_buffer_object *dst, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size ); - - /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: - */ - void * (*MapBufferRange)( GLcontext *ctx, GLenum target, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *obj); - - void (*FlushMappedBufferRange)(GLcontext *ctx, GLenum target, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj); - - GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target, - struct gl_buffer_object *obj ); - /*@}*/ - - /** - * \name Functions for GL_APPLE_object_purgeable - */ - /*@{*/ - /* variations on ObjectPurgeable */ - GLenum (*BufferObjectPurgeable)( GLcontext *ctx, struct gl_buffer_object *obj, GLenum option ); - GLenum (*RenderObjectPurgeable)( GLcontext *ctx, struct gl_renderbuffer *obj, GLenum option ); - GLenum (*TextureObjectPurgeable)( GLcontext *ctx, struct gl_texture_object *obj, GLenum option ); - - /* variations on ObjectUnpurgeable */ - GLenum (*BufferObjectUnpurgeable)( GLcontext *ctx, struct gl_buffer_object *obj, GLenum option ); - GLenum (*RenderObjectUnpurgeable)( GLcontext *ctx, struct gl_renderbuffer *obj, GLenum option ); - GLenum (*TextureObjectUnpurgeable)( GLcontext *ctx, struct gl_texture_object *obj, GLenum option ); - /*@}*/ - - /** - * \name Functions for GL_EXT_framebuffer_{object,blit}. - */ - /*@{*/ - struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name); - struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name); - void (*BindFramebuffer)(GLcontext *ctx, GLenum target, - struct gl_framebuffer *drawFb, - struct gl_framebuffer *readFb); - void (*FramebufferRenderbuffer)(GLcontext *ctx, - struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb); - void (*RenderTexture)(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att); - void (*FinishRenderTexture)(GLcontext *ctx, - struct gl_renderbuffer_attachment *att); - void (*ValidateFramebuffer)(GLcontext *ctx, - struct gl_framebuffer *fb); - /*@}*/ - void (*BlitFramebuffer)(GLcontext *ctx, - GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); - - /** - * \name Query objects - */ - /*@{*/ - struct gl_query_object * (*NewQueryObject)(GLcontext *ctx, GLuint id); - void (*DeleteQuery)(GLcontext *ctx, struct gl_query_object *q); - void (*BeginQuery)(GLcontext *ctx, struct gl_query_object *q); - void (*EndQuery)(GLcontext *ctx, struct gl_query_object *q); - void (*CheckQuery)(GLcontext *ctx, struct gl_query_object *q); - void (*WaitQuery)(GLcontext *ctx, struct gl_query_object *q); - /*@}*/ - - - /** - * \name Vertex Array objects - */ - /*@{*/ - struct gl_array_object * (*NewArrayObject)(GLcontext *ctx, GLuint id); - void (*DeleteArrayObject)(GLcontext *ctx, struct gl_array_object *obj); - void (*BindArrayObject)(GLcontext *ctx, struct gl_array_object *obj); - /*@}*/ - - /** - * \name GLSL-related functions (ARB extensions and OpenGL 2.x) - */ - /*@{*/ - struct gl_shader *(*NewShader)(GLcontext *ctx, GLuint name, GLenum type); - void (*DeleteShader)(GLcontext *ctx, struct gl_shader *shader); - struct gl_shader_program *(*NewShaderProgram)(GLcontext *ctx, GLuint name); - void (*DeleteShaderProgram)(GLcontext *ctx, - struct gl_shader_program *shProg); - void (*UseProgram)(GLcontext *ctx, struct gl_shader_program *shProg); - /*@}*/ - - - /** - * \name Support for multiple T&L engines - */ - /*@{*/ - - /** - * Bitmask of state changes that require the current T&L module to be - * validated, using ValidateTnlModule() below. - */ - GLuint NeedValidate; - - /** - * Validate the current T&L module. - * - * This is called directly after UpdateState() when a state change that has - * occurred matches the dd_function_table::NeedValidate bitmask above. This - * ensures all computed values are up to date, thus allowing the driver to - * decide if the current T&L module needs to be swapped out. - * - * This must be non-NULL if a driver installs a custom T&L module and sets - * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise. - */ - void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state ); - - -#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) -#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) -#define PRIM_UNKNOWN (GL_POLYGON+3) - - /** - * Set by the driver-supplied T&L engine. - * - * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). - */ - GLuint CurrentExecPrimitive; - - /** - * Current state of an in-progress compilation. - * - * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, - * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. - */ - GLuint CurrentSavePrimitive; - - -#define FLUSH_STORED_VERTICES 0x1 -#define FLUSH_UPDATE_CURRENT 0x2 - /** - * Set by the driver-supplied T&L engine whenever vertices are buffered - * between glBegin()/glEnd() objects or __GLcontextRec::Current is not - * updated. - * - * The dd_function_table::FlushVertices call below may be used to resolve - * these conditions. - */ - GLuint NeedFlush; - GLuint SaveNeedFlush; - - - /* Called prior to any of the GLvertexformat functions being - * called. Paired with Driver.FlushVertices(). - */ - void (*BeginVertices)( GLcontext *ctx ); - - /** - * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if - * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered - * vertices, if FLUSH_UPDATE_CURRENT bit is set updates - * __GLcontextRec::Current and gl_light_attrib::Material - * - * Note that the default T&L engine never clears the - * FLUSH_UPDATE_CURRENT bit, even after performing the update. - */ - void (*FlushVertices)( GLcontext *ctx, GLuint flags ); - void (*SaveFlushVertices)( GLcontext *ctx ); - - /** - * Give the driver the opportunity to hook in its own vtxfmt for - * compiling optimized display lists. This is called on each valid - * glBegin() during list compilation. - */ - GLboolean (*NotifySaveBegin)( GLcontext *ctx, GLenum mode ); - - /** - * Notify driver that the special derived value _NeedEyeCoords has - * changed. - */ - void (*LightingSpaceChange)( GLcontext *ctx ); - - /** - * Called by glNewList(). - * - * Let the T&L component know what is going on with display lists - * in time to make changes to dispatch tables, etc. - */ - void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode ); - /** - * Called by glEndList(). - * - * \sa dd_function_table::NewList. - */ - void (*EndList)( GLcontext *ctx ); - - /** - * Called by glCallList(s). - * - * Notify the T&L component before and after calling a display list. - */ - void (*BeginCallList)( GLcontext *ctx, - struct gl_display_list *dlist ); - /** - * Called by glEndCallList(). - * - * \sa dd_function_table::BeginCallList. - */ - void (*EndCallList)( GLcontext *ctx ); - - - /** - * \name GL_ARB_sync interfaces - */ - /*@{*/ - struct gl_sync_object * (*NewSyncObject)(GLcontext *, GLenum); - void (*FenceSync)(GLcontext *, struct gl_sync_object *, GLenum, GLbitfield); - void (*DeleteSyncObject)(GLcontext *, struct gl_sync_object *); - void (*CheckSync)(GLcontext *, struct gl_sync_object *); - void (*ClientWaitSync)(GLcontext *, struct gl_sync_object *, - GLbitfield, GLuint64); - void (*ServerWaitSync)(GLcontext *, struct gl_sync_object *, - GLbitfield, GLuint64); - /*@}*/ - - /** GL_NV_conditional_render */ - void (*BeginConditionalRender)(GLcontext *ctx, struct gl_query_object *q, - GLenum mode); - void (*EndConditionalRender)(GLcontext *ctx, struct gl_query_object *q); - - /** - * \name GL_OES_draw_texture interface - */ - /*@{*/ - void (*DrawTex)(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height); - /*@}*/ - - /** - * \name GL_OES_EGL_image interface - */ - void (*EGLImageTargetTexture2D)(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLeglImageOES image_handle); - void (*EGLImageTargetRenderbufferStorage)(GLcontext *ctx, - struct gl_renderbuffer *rb, - void *image_handle); - - /** - * \name GL_EXT_transform_feedback interface - */ - struct gl_transform_feedback_object * - (*NewTransformFeedback)(GLcontext *ctx, GLuint name); - void (*DeleteTransformFeedback)(GLcontext *ctx, - struct gl_transform_feedback_object *obj); - void (*BeginTransformFeedback)(GLcontext *ctx, GLenum mode, - struct gl_transform_feedback_object *obj); - void (*EndTransformFeedback)(GLcontext *ctx, - struct gl_transform_feedback_object *obj); - void (*PauseTransformFeedback)(GLcontext *ctx, - struct gl_transform_feedback_object *obj); - void (*ResumeTransformFeedback)(GLcontext *ctx, - struct gl_transform_feedback_object *obj); - void (*DrawTransformFeedback)(GLcontext *ctx, GLenum mode, - struct gl_transform_feedback_object *obj); -}; - - -/** - * Transform/Clip/Lighting interface - * - * Drivers present a reduced set of the functions possible in - * glBegin()/glEnd() objects. Core mesa provides translation stubs for the - * remaining functions to map down to these entry points. - * - * These are the initial values to be installed into dispatch by - * mesa. If the T&L driver wants to modify the dispatch table - * while installed, it must do so itself. It would be possible for - * the vertexformat to install its own initial values for these - * functions, but this way there is an obvious list of what is - * expected of the driver. - * - * If the driver wants to hook in entry points other than those - * listed, it must restore them to their original values in - * the disable() callback, below. - */ -typedef struct { - /** - * \name Vertex - */ - /*@{*/ - void (GLAPIENTRYP ArrayElement)( GLint ); - void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color3fv)( const GLfloat * ); - void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color4fv)( const GLfloat * ); - void (GLAPIENTRYP EdgeFlag)( GLboolean ); - void (GLAPIENTRYP EvalCoord1f)( GLfloat ); - void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP EvalPoint1)( GLint ); - void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); - void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); - void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); - void (GLAPIENTRYP Indexf)( GLfloat ); - void (GLAPIENTRYP Indexfv)( const GLfloat * ); - void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); - void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Normal3fv)( const GLfloat * ); - void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * ); - void (GLAPIENTRYP TexCoord1f)( GLfloat ); - void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); - void (GLAPIENTRYP CallList)( GLuint ); - void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); - void (GLAPIENTRYP Begin)( GLenum ); - void (GLAPIENTRYP End)( void ); - /* GL_NV_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); - /* GL_ARB_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); - /*@}*/ - - void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); - - /** - * \name Array - */ - /*@{*/ - void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); - void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices ); - void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, const GLvoid *indices ); - void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount); - void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex ); - void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex); - void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode, - const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex); - void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first, - GLsizei count, GLsizei primcount); - void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices, - GLsizei primcount); - /*@}*/ - - /** - * \name Eval - * - * If you don't support eval, fallback to the default vertex format - * on receiving an eval call and use the pipeline mechanism to - * provide partial T&L acceleration. - * - * Mesa will provide a set of helper functions to do eval within - * accelerated vertex formats, eventually... - */ - /*@{*/ - void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); - void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); - /*@}*/ - -} GLvertexformat; - - -#endif /* DD_INCLUDED */ +/** + * \file dd.h + * Device driver interfaces. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef DD_INCLUDED +#define DD_INCLUDED + +/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ + +#include "glheader.h" + +struct gl_buffer_object; +struct gl_context; +struct gl_display_list; +struct gl_framebuffer; +struct gl_pixelstore_attrib; +struct gl_program; +struct gl_renderbuffer; +struct gl_renderbuffer_attachment; +struct gl_shader; +struct gl_shader_program; +struct gl_texture_image; +struct gl_texture_object; + +/* GL_ARB_vertex_buffer_object */ +/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return + * NULL) if buffer is unavailable for immediate mapping. + * + * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it + * would require more book-keeping in the driver than seems necessary + * at this point. + * + * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't + * want to provoke the driver to throw away the old storage, we will + * respect the contents of already referenced data. + */ +#define MESA_MAP_NOWAIT_BIT 0x0040 + + +/** + * Device driver function table. + * Core Mesa uses these function pointers to call into device drivers. + * Most of these functions directly correspond to OpenGL state commands. + * Core Mesa will call these functions after error checking has been done + * so that the drivers don't have to worry about error testing. + * + * Vertex transformation/clipping/lighting is patched into the T&L module. + * Rasterization functions are patched into the swrast module. + * + * Note: when new functions are added here, the drivers/common/driverfuncs.c + * file should be updated too!!! + */ +struct dd_function_table { + /** + * Return a string as needed by glGetString(). + * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be + * returned. + */ + const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name ); + + /** + * Notify the driver after Mesa has made some internal state changes. + * + * This is in addition to any state change callbacks Mesa may already have + * made. + */ + void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); + + /** + * Get the width and height of the named buffer/window. + * + * Mesa uses this to determine when the driver's window size has changed. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*GetBufferSize)( struct gl_framebuffer *buffer, + GLuint *width, GLuint *height ); + + /** + * Resize the given framebuffer to the given size. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height); + + /** + * Called whenever an error is generated. + * __struct gl_contextRec::ErrorValue contains the error value. + */ + void (*Error)( struct gl_context *ctx ); + + /** + * This is called whenever glFinish() is called. + */ + void (*Finish)( struct gl_context *ctx ); + + /** + * This is called whenever glFlush() is called. + */ + void (*Flush)( struct gl_context *ctx ); + + /** + * Clear the color/depth/stencil/accum buffer(s). + * \param buffers a bitmask of BUFFER_BIT_* flags indicating which + * renderbuffers need to be cleared. + */ + void (*Clear)( struct gl_context *ctx, GLbitfield buffers ); + + /** + * Execute glAccum command. + */ + void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value ); + + + /** + * Execute glRasterPos, updating the ctx->Current.Raster fields + */ + void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] ); + + /** + * \name Image-related functions + */ + /*@{*/ + + /** + * Called by glDrawPixels(). + * \p unpack describes how to unpack the source image data. + */ + void (*DrawPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels ); + + /** + * Called by glReadPixels(). + */ + void (*ReadPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + GLvoid *dest ); + + /** + * Called by glCopyPixels(). + */ + void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type ); + + /** + * Called by glBitmap(). + */ + void (*Bitmap)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ); + /*@}*/ + + + /** + * \name Texture image functions + */ + /*@{*/ + + /** + * Choose texture format. + * + * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback + * functions. The driver should examine \p internalFormat and return a + * gl_format value. + */ + GLuint (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, + GLenum srcFormat, GLenum srcType ); + + /** + * Called by glTexImage1D(). + * + * \param target user specified. + * \param format user specified. + * \param type user specified. + * \param pixels user specified. + * \param packing indicates the image packing of pixels. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + * + * \p retainInternalCopy is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + * + * Drivers should call a fallback routine from texstore.c if needed. + */ + void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage2D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage3D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage1D(). + * + * \param target user specified. + * \param level user specified. + * \param xoffset user specified. + * \param yoffset user specified. + * \param zoffset user specified. + * \param width user specified. + * \param height user specified. + * \param depth user specified. + * \param format user specified. + * \param type user specified. + * \param pixels user specified. + * \param packing indicates the image packing of pixels. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p border and \p internalFormat information. + * + * The driver should use a fallback routine from texstore.c if needed. + */ + void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage2D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage3D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLint depth, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glGetTexImage(). + */ + void (*GetTexImage)( struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCopyTexImage1D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLint border ); + + /** + * Called by glCopyTexImage2D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ); + + /** + * Called by glCopyTexSubImage1D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, + GLint x, GLint y, GLsizei width ); + /** + * Called by glCopyTexSubImage2D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + /** + * Called by glCopyTexSubImage3D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + /** + * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled. + */ + void (*GenerateMipmap)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj); + + /** + * Called by glTexImage[123]D when user specifies a proxy texture + * target. + * + * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. + */ + GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border); + /*@}*/ + + + /** + * \name Compressed texture functions + */ + /*@{*/ + + /** + * Called by glCompressedTexImage1D(). + * + * \param target user specified. + * \param format user specified. + * \param type user specified. + * \param pixels user specified. + * \param packing indicates the image packing of pixels. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + * + * \a retainInternalCopy is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + */ + void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage2D(). + * + * \sa dd_function_table::CompressedTexImage1D. + */ + void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCompressedTexSubImage1D(). + * + * \param target user specified. + * \param level user specified. + * \param xoffset user specified. + * \param yoffset user specified. + * \param zoffset user specified. + * \param width user specified. + * \param height user specified. + * \param depth user specified. + * \param imageSize user specified. + * \param data user specified. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + */ + void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage2D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + + /** + * Called by glGetCompressedTexImage. + */ + void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + /*@}*/ + + /** + * \name Texture object functions + */ + /*@{*/ + + /** + * Called by glBindTexture(). + */ + void (*BindTexture)( struct gl_context *ctx, GLenum target, + struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture object. + * A new gl_texture_object should be returned. The driver should + * attach to it any device-specific info it needs. + */ + struct gl_texture_object * (*NewTextureObject)( struct gl_context *ctx, GLuint name, + GLenum target ); + /** + * Called when a texture object is about to be deallocated. + * + * Driver should delete the gl_texture_object object and anything + * hanging off of it. + */ + void (*DeleteTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture image object. + */ + struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx ); + + /** + * Called to free tImage->Data. + */ + void (*FreeTexImageData)( struct gl_context *ctx, struct gl_texture_image *tImage ); + + /** Map texture image data into user space */ + void (*MapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + /** Unmap texture images from user space */ + void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Note: no context argument. This function doesn't initially look + * like it belongs here, except that the driver is the only entity + * that knows for sure how the texture memory is allocated - via + * the above callbacks. There is then an argument that the driver + * knows what memcpy paths might be fast. Typically this is invoked with + * + * to -- a pointer into texture memory allocated by NewTextureImage() above. + * from -- a pointer into client memory or a mesa temporary. + * sz -- nr bytes to copy. + */ + void* (*TextureMemCpy)( void *to, const void *from, size_t sz ); + + /** + * Called by glAreTextureResident(). + */ + GLboolean (*IsTextureResident)( struct gl_context *ctx, + struct gl_texture_object *t ); + + /** + * Called when the texture's color lookup table is changed. + * + * If \p tObj is NULL then the shared texture palette + * gl_texture_object::Palette is to be updated. + */ + void (*UpdateTexturePalette)( struct gl_context *ctx, + struct gl_texture_object *tObj ); + /*@}*/ + + + /** + * \name Imaging functionality + */ + /*@{*/ + void (*CopyColorTable)( struct gl_context *ctx, + GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + + void (*CopyColorSubTable)( struct gl_context *ctx, + GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + /*@}*/ + + + /** + * \name Vertex/fragment program functions + */ + /*@{*/ + /** Bind a vertex/fragment program */ + void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog); + /** Allocate a new program */ + struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id); + /** Delete a program */ + void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog); + /** + * Notify driver that a program string (and GPU code) has been specified + * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is + * supported by the driver. + */ + GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /** Query if program can be loaded onto hardware */ + GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /*@}*/ + + /** + * \name GLSL shader/program functions. + */ + /*@{*/ + /** + * Called when a shader is compiled. + * + * Note that not all shader objects get ShaderCompile called on + * them. Notably, the shaders containing builtin functions do not + * have CompileShader() called, so if lowering passes are done they + * need to also be performed in LinkShader(). + */ + GLboolean (*CompileShader)(struct gl_context *ctx, struct gl_shader *shader); + /** + * Called when a shader program is linked. + * + * This gives drivers an opportunity to clone the IR and make their + * own transformations on it for the purposes of code generation. + */ + GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader); + /*@}*/ + + /** + * \name State-changing functions. + * + * \note drawing functions are above. + * + * These functions are called by their corresponding OpenGL API functions. + * They are \e also called by the gl_PopAttrib() function!!! + * May add more functions like these to the device driver in the future. + */ + /*@{*/ + /** Specify the alpha test function */ + void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref); + /** Set the blend color */ + void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Set the blend equation */ + void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA); + /** Specify pixel arithmetic */ + void (*BlendFuncSeparate)(struct gl_context *ctx, + GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA); + /** Specify clear values for the color buffers */ + void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Specify the clear value for the depth buffer */ + void (*ClearDepth)(struct gl_context *ctx, GLclampd d); + /** Specify the clear value for the stencil buffer */ + void (*ClearStencil)(struct gl_context *ctx, GLint s); + /** Specify a plane against which all geometry is clipped */ + void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation ); + /** Enable and disable writing of frame buffer color components */ + void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, + GLboolean bmask, GLboolean amask ); + void (*ColorMaskIndexed)(struct gl_context *ctx, GLuint buf, GLboolean rmask, + GLboolean gmask, GLboolean bmask, GLboolean amask); + /** Cause a material color to track the current color */ + void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Specify whether front- or back-facing facets can be culled */ + void (*CullFace)(struct gl_context *ctx, GLenum mode); + /** Define front- and back-facing polygons */ + void (*FrontFace)(struct gl_context *ctx, GLenum mode); + /** Specify the value used for depth buffer comparisons */ + void (*DepthFunc)(struct gl_context *ctx, GLenum func); + /** Enable or disable writing into the depth buffer */ + void (*DepthMask)(struct gl_context *ctx, GLboolean flag); + /** Specify mapping of depth values from NDC to window coordinates */ + void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); + /** Specify the current buffer for writing */ + void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Specify the buffers for writing for fragment programs*/ + void (*DrawBuffers)( struct gl_context *ctx, GLsizei n, const GLenum *buffers ); + /** Enable or disable server-side gl capabilities */ + void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state); + /** Specify fog parameters */ + void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify implementation-specific hints */ + void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode); + /** Set light source parameters. + * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already + * been transformed to eye-space. + */ + void (*Lightfv)(struct gl_context *ctx, GLenum light, + GLenum pname, const GLfloat *params ); + /** Set the lighting model parameters */ + void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify the line stipple pattern */ + void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern ); + /** Specify the width of rasterized lines */ + void (*LineWidth)(struct gl_context *ctx, GLfloat width); + /** Specify a logical pixel operation for color index rendering */ + void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode); + void (*PointParameterfv)(struct gl_context *ctx, GLenum pname, + const GLfloat *params); + /** Specify the diameter of rasterized points */ + void (*PointSize)(struct gl_context *ctx, GLfloat size); + /** Select a polygon rasterization mode */ + void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Set the scale and units used to calculate depth values */ + void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units); + /** Set the polygon stippling pattern */ + void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask ); + /* Specifies the current buffer for reading */ + void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Set rasterization mode */ + void (*RenderMode)(struct gl_context *ctx, GLenum mode ); + /** Define the scissor box */ + void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /** Select flat or smooth shading */ + void (*ShadeModel)(struct gl_context *ctx, GLenum mode); + /** OpenGL 2.0 two-sided StencilFunc */ + void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func, + GLint ref, GLuint mask); + /** OpenGL 2.0 two-sided StencilMask */ + void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask); + /** OpenGL 2.0 two-sided StencilOp */ + void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail, + GLenum zfail, GLenum zpass); + /** Control the generation of texture coordinates */ + void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname, + const GLfloat *params); + /** Set texture environment parameters */ + void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname, + const GLfloat *param); + /** Set texture parameters */ + void (*TexParameter)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params); + /** Set the viewport */ + void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /*@}*/ + + + /** + * \name Vertex/pixel buffer object functions + */ + /*@{*/ + void (*BindBuffer)( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *obj ); + + struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer, + GLenum target ); + + void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); + + GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, + const GLvoid *data, GLenum usage, + struct gl_buffer_object *obj ); + + void (*BufferSubData)( struct gl_context *ctx, GLenum target, GLintptrARB offset, + GLsizeiptrARB size, const GLvoid *data, + struct gl_buffer_object *obj ); + + void (*GetBufferSubData)( struct gl_context *ctx, GLenum target, + GLintptrARB offset, GLsizeiptrARB size, + GLvoid *data, struct gl_buffer_object *obj ); + + void * (*MapBuffer)( struct gl_context *ctx, GLenum target, GLenum access, + struct gl_buffer_object *obj ); + + void (*CopyBufferSubData)( struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size ); + + /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: + */ + void * (*MapBufferRange)( struct gl_context *ctx, GLenum target, GLintptr offset, + GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *obj); + + void (*FlushMappedBufferRange)(struct gl_context *ctx, GLenum target, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj); + + GLboolean (*UnmapBuffer)( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *obj ); + /*@}*/ + + /** + * \name Functions for GL_APPLE_object_purgeable + */ + /*@{*/ + /* variations on ObjectPurgeable */ + GLenum (*BufferObjectPurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectPurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectPurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + + /* variations on ObjectUnpurgeable */ + GLenum (*BufferObjectUnpurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectUnpurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectUnpurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + /*@}*/ + + /** + * \name Functions for GL_EXT_framebuffer_{object,blit}. + */ + /*@{*/ + struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name); + struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx, GLuint name); + void (*BindFramebuffer)(struct gl_context *ctx, GLenum target, + struct gl_framebuffer *drawFb, + struct gl_framebuffer *readFb); + void (*FramebufferRenderbuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum attachment, + struct gl_renderbuffer *rb); + void (*RenderTexture)(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att); + void (*FinishRenderTexture)(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + void (*ValidateFramebuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb); + /*@}*/ + void (*BlitFramebuffer)(struct gl_context *ctx, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + + /** + * \name Query objects + */ + /*@{*/ + struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id); + void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q); + /*@}*/ + + + /** + * \name Vertex Array objects + */ + /*@{*/ + struct gl_array_object * (*NewArrayObject)(struct gl_context *ctx, GLuint id); + void (*DeleteArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + /*@}*/ + + /** + * \name GLSL-related functions (ARB extensions and OpenGL 2.x) + */ + /*@{*/ + struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type); + void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader); + struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name); + void (*DeleteShaderProgram)(struct gl_context *ctx, + struct gl_shader_program *shProg); + void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg); + /*@}*/ + + + /** + * \name Support for multiple T&L engines + */ + /*@{*/ + + /** + * Bitmask of state changes that require the current T&L module to be + * validated, using ValidateTnlModule() below. + */ + GLuint NeedValidate; + + /** + * Validate the current T&L module. + * + * This is called directly after UpdateState() when a state change that has + * occurred matches the dd_function_table::NeedValidate bitmask above. This + * ensures all computed values are up to date, thus allowing the driver to + * decide if the current T&L module needs to be swapped out. + * + * This must be non-NULL if a driver installs a custom T&L module and sets + * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise. + */ + void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state ); + + +#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) +#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) +#define PRIM_UNKNOWN (GL_POLYGON+3) + + /** + * Set by the driver-supplied T&L engine. + * + * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). + */ + GLuint CurrentExecPrimitive; + + /** + * Current state of an in-progress compilation. + * + * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, + * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. + */ + GLuint CurrentSavePrimitive; + + +#define FLUSH_STORED_VERTICES 0x1 +#define FLUSH_UPDATE_CURRENT 0x2 + /** + * Set by the driver-supplied T&L engine whenever vertices are buffered + * between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not + * updated. + * + * The dd_function_table::FlushVertices call below may be used to resolve + * these conditions. + */ + GLuint NeedFlush; + GLuint SaveNeedFlush; + + + /* Called prior to any of the GLvertexformat functions being + * called. Paired with Driver.FlushVertices(). + */ + void (*BeginVertices)( struct gl_context *ctx ); + + /** + * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if + * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered + * vertices, if FLUSH_UPDATE_CURRENT bit is set updates + * __struct gl_contextRec::Current and gl_light_attrib::Material + * + * Note that the default T&L engine never clears the + * FLUSH_UPDATE_CURRENT bit, even after performing the update. + */ + void (*FlushVertices)( struct gl_context *ctx, GLuint flags ); + void (*SaveFlushVertices)( struct gl_context *ctx ); + + /** + * Give the driver the opportunity to hook in its own vtxfmt for + * compiling optimized display lists. This is called on each valid + * glBegin() during list compilation. + */ + GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode ); + + /** + * Notify driver that the special derived value _NeedEyeCoords has + * changed. + */ + void (*LightingSpaceChange)( struct gl_context *ctx ); + + /** + * Called by glNewList(). + * + * Let the T&L component know what is going on with display lists + * in time to make changes to dispatch tables, etc. + */ + void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode ); + /** + * Called by glEndList(). + * + * \sa dd_function_table::NewList. + */ + void (*EndList)( struct gl_context *ctx ); + + /** + * Called by glCallList(s). + * + * Notify the T&L component before and after calling a display list. + */ + void (*BeginCallList)( struct gl_context *ctx, + struct gl_display_list *dlist ); + /** + * Called by glEndCallList(). + * + * \sa dd_function_table::BeginCallList. + */ + void (*EndCallList)( struct gl_context *ctx ); + + + /** + * \name GL_ARB_sync interfaces + */ + /*@{*/ + struct gl_sync_object * (*NewSyncObject)(struct gl_context *, GLenum); + void (*FenceSync)(struct gl_context *, struct gl_sync_object *, GLenum, GLbitfield); + void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *); + void (*CheckSync)(struct gl_context *, struct gl_sync_object *); + void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + /*@}*/ + + /** GL_NV_conditional_render */ + void (*BeginConditionalRender)(struct gl_context *ctx, struct gl_query_object *q, + GLenum mode); + void (*EndConditionalRender)(struct gl_context *ctx, struct gl_query_object *q); + + /** + * \name GL_OES_draw_texture interface + */ + /*@{*/ + void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height); + /*@}*/ + + /** + * \name GL_OES_EGL_image interface + */ + void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle); + void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx, + struct gl_renderbuffer *rb, + void *image_handle); + + /** + * \name GL_EXT_transform_feedback interface + */ + struct gl_transform_feedback_object * + (*NewTransformFeedback)(struct gl_context *ctx, GLuint name); + void (*DeleteTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + void (*EndTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*PauseTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*ResumeTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*DrawTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); +}; + + +/** + * Transform/Clip/Lighting interface + * + * Drivers present a reduced set of the functions possible in + * glBegin()/glEnd() objects. Core mesa provides translation stubs for the + * remaining functions to map down to these entry points. + * + * These are the initial values to be installed into dispatch by + * mesa. If the T&L driver wants to modify the dispatch table + * while installed, it must do so itself. It would be possible for + * the vertexformat to install its own initial values for these + * functions, but this way there is an obvious list of what is + * expected of the driver. + * + * If the driver wants to hook in entry points other than those + * listed, it must restore them to their original values in + * the disable() callback, below. + */ +typedef struct { + /** + * \name Vertex + */ + /*@{*/ + void (GLAPIENTRYP ArrayElement)( GLint ); + void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color3fv)( const GLfloat * ); + void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color4fv)( const GLfloat * ); + void (GLAPIENTRYP EdgeFlag)( GLboolean ); + void (GLAPIENTRYP EvalCoord1f)( GLfloat ); + void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP EvalPoint1)( GLint ); + void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); + void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); + void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); + void (GLAPIENTRYP Indexf)( GLfloat ); + void (GLAPIENTRYP Indexfv)( const GLfloat * ); + void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); + void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Normal3fv)( const GLfloat * ); + void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * ); + void (GLAPIENTRYP TexCoord1f)( GLfloat ); + void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); + void (GLAPIENTRYP CallList)( GLuint ); + void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); + void (GLAPIENTRYP Begin)( GLenum ); + void (GLAPIENTRYP End)( void ); + void (GLAPIENTRYP PrimitiveRestartNV)( void ); + /* GL_NV_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); + /* GL_ARB_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x); + void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y); + void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z); + void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w); + void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v); + + void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x); + void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y); + void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z); + void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v); + + /*@}*/ + + void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); + + /** + * \name Array + */ + /*@{*/ + void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); + void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices ); + void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, const GLvoid *indices ); + void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount); + void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex ); + void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex); + void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode, + const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex); + void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first, + GLsizei count, GLsizei primcount); + void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices, + GLsizei primcount); + /*@}*/ + + /** + * \name Eval + * + * If you don't support eval, fallback to the default vertex format + * on receiving an eval call and use the pipeline mechanism to + * provide partial T&L acceleration. + * + * Mesa will provide a set of helper functions to do eval within + * accelerated vertex formats, eventually... + */ + /*@{*/ + void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); + void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + /*@}*/ + +} GLvertexformat; + + +#endif /* DD_INCLUDED */ diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c index 526145aec..f0752d1a3 100644 --- a/mesalib/src/mesa/main/debug.c +++ b/mesalib/src/mesa/main/debug.c @@ -1,636 +1,633 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "mtypes.h" -#include "attrib.h" -#include "colormac.h" -#include "enums.h" -#include "formats.h" -#include "hash.h" -#include "imports.h" -#include "debug.h" -#include "get.h" -#include "pixelstore.h" -#include "readpix.h" -#include "texobj.h" - - -/** - * Primitive names - */ -const char *_mesa_prim_name[GL_POLYGON+4] = { - "GL_POINTS", - "GL_LINES", - "GL_LINE_LOOP", - "GL_LINE_STRIP", - "GL_TRIANGLES", - "GL_TRIANGLE_STRIP", - "GL_TRIANGLE_FAN", - "GL_QUADS", - "GL_QUAD_STRIP", - "GL_POLYGON", - "outside begin/end", - "inside unknown primitive", - "unknown state" -}; - - -static const char * -tex_target_name(GLenum tgt) -{ - static const struct { - GLenum target; - const char *name; - } tex_targets[] = { - { GL_TEXTURE_1D, "GL_TEXTURE_1D" }, - { GL_TEXTURE_2D, "GL_TEXTURE_2D" }, - { GL_TEXTURE_3D, "GL_TEXTURE_3D" }, - { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" }, - { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" }, - { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" }, - { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" } - }; - GLuint i; - for (i = 0; i < Elements(tex_targets); i++) { - if (tex_targets[i].target == tgt) - return tex_targets[i].name; - } - return "UNKNOWN TEX TARGET"; -} - - -void -_mesa_print_state( const char *msg, GLuint state ) -{ - _mesa_debug(NULL, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - msg, - state, - (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "", - (state & _NEW_PROJECTION) ? "ctx->Projection, " : "", - (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "", - (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "", - (state & _NEW_ACCUM) ? "ctx->Accum, " : "", - (state & _NEW_COLOR) ? "ctx->Color, " : "", - (state & _NEW_DEPTH) ? "ctx->Depth, " : "", - (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "", - (state & _NEW_FOG) ? "ctx->Fog, " : "", - (state & _NEW_HINT) ? "ctx->Hint, " : "", - (state & _NEW_LIGHT) ? "ctx->Light, " : "", - (state & _NEW_LINE) ? "ctx->Line, " : "", - (state & _NEW_PIXEL) ? "ctx->Pixel, " : "", - (state & _NEW_POINT) ? "ctx->Point, " : "", - (state & _NEW_POLYGON) ? "ctx->Polygon, " : "", - (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "", - (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "", - (state & _NEW_STENCIL) ? "ctx->Stencil, " : "", - (state & _NEW_TEXTURE) ? "ctx->Texture, " : "", - (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "", - (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "", - (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "", - (state & _NEW_ARRAY) ? "ctx->Array, " : "", - (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "", - (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : ""); -} - - - -void -_mesa_print_tri_caps( const char *name, GLuint flags ) -{ - _mesa_debug(NULL, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - name, - flags, - (flags & DD_FLATSHADE) ? "flat-shade, " : "", - (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "", - (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "", - (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "", - (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "", - (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "", - (flags & DD_TRI_OFFSET) ? "tri-offset, " : "", - (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "", - (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "", - (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "", - (flags & DD_LINE_WIDTH) ? "line-wide, " : "", - (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "", - (flags & DD_POINT_SIZE) ? "point-size, " : "", - (flags & DD_POINT_ATTEN) ? "point-atten, " : "", - (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : "" - ); -} - - -/** - * Print information about this Mesa version and build options. - */ -void _mesa_print_info( void ) -{ - _mesa_debug(NULL, "Mesa GL_VERSION = %s\n", - (char *) _mesa_GetString(GL_VERSION)); - _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n", - (char *) _mesa_GetString(GL_RENDERER)); - _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n", - (char *) _mesa_GetString(GL_VENDOR)); - _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", - (char *) _mesa_GetString(GL_EXTENSIONS)); -#if defined(THREADS) - _mesa_debug(NULL, "Mesa thread-safe: YES\n"); -#else - _mesa_debug(NULL, "Mesa thread-safe: NO\n"); -#endif -#if defined(USE_X86_ASM) - _mesa_debug(NULL, "Mesa x86-optimized: YES\n"); -#else - _mesa_debug(NULL, "Mesa x86-optimized: NO\n"); -#endif -#if defined(USE_SPARC_ASM) - _mesa_debug(NULL, "Mesa sparc-optimized: YES\n"); -#else - _mesa_debug(NULL, "Mesa sparc-optimized: NO\n"); -#endif -} - - -/** - * Set the debugging flags. - * - * \param debug debug string - * - * If compiled with debugging support then search for keywords in \p debug and - * enables the verbose debug output of the respective feature. - */ -static void add_debug_flags( const char *debug ) -{ -#ifdef DEBUG - struct debug_option { - const char *name; - GLbitfield flag; - }; - static const struct debug_option debug_opt[] = { - { "varray", VERBOSE_VARRAY }, - { "tex", VERBOSE_TEXTURE }, - { "mat", VERBOSE_MATERIAL }, - { "pipe", VERBOSE_PIPELINE }, - { "driver", VERBOSE_DRIVER }, - { "state", VERBOSE_STATE }, - { "api", VERBOSE_API }, - { "list", VERBOSE_DISPLAY_LIST }, - { "lighting", VERBOSE_LIGHTING }, - { "disassem", VERBOSE_DISASSEM }, - { "draw", VERBOSE_DRAW }, - { "swap", VERBOSE_SWAPBUFFERS } - }; - GLuint i; - - MESA_VERBOSE = 0x0; - for (i = 0; i < Elements(debug_opt); i++) { - if (strstr(debug, debug_opt[i].name)) - MESA_VERBOSE |= debug_opt[i].flag; - } - - /* Debug flag: - */ - if (strstr(debug, "flush")) - MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH; - -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - if (strstr(debug, "fpexceptions")) { - /* raise FP exceptions */ - fpu_control_t mask; - _FPU_GETCW(mask); - mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM - | _FPU_MASK_OM | _FPU_MASK_UM); - _FPU_SETCW(mask); - } -#endif - -#else - (void) debug; -#endif -} - - -void -_mesa_init_debug( GLcontext *ctx ) -{ - char *c; - - /* Dither disable */ - ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE; - if (ctx->NoDither) { - if (_mesa_getenv("MESA_DEBUG")) { - _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n"); - } - ctx->Color.DitherFlag = GL_FALSE; - } - - c = _mesa_getenv("MESA_DEBUG"); - if (c) - add_debug_flags(c); - - c = _mesa_getenv("MESA_VERBOSE"); - if (c) - add_debug_flags(c); -} - - -/* - * Write ppm file - */ -static void -write_ppm(const char *filename, const GLubyte *buffer, int width, int height, - int comps, int rcomp, int gcomp, int bcomp, GLboolean invert) -{ - FILE *f = fopen( filename, "w" ); - if (f) { - int x, y; - const GLubyte *ptr = buffer; - fprintf(f,"P6\n"); - fprintf(f,"# ppm-file created by osdemo.c\n"); - fprintf(f,"%i %i\n", width,height); - fprintf(f,"255\n"); - fclose(f); - f = fopen( filename, "ab" ); /* reopen in binary append mode */ - for (y=0; y < height; y++) { - for (x = 0; x < width; x++) { - int yy = invert ? (height - 1 - y) : y; - int i = (yy * width + x) * comps; - fputc(ptr[i+rcomp], f); /* write red */ - fputc(ptr[i+gcomp], f); /* write green */ - fputc(ptr[i+bcomp], f); /* write blue */ - } - } - fclose(f); - } -} - - -/** - * Write a texture image to a ppm file. - * \param face cube face in [0,5] - * \param level mipmap level - */ -static void -write_texture_image(struct gl_texture_object *texObj, - GLuint face, GLuint level) -{ - struct gl_texture_image *img = texObj->Image[face][level]; - if (img) { - GET_CURRENT_CONTEXT(ctx); - struct gl_pixelstore_attrib store; - GLubyte *buffer; - char s[100]; - - buffer = (GLubyte *) malloc(img->Width * img->Height - * img->Depth * 4); - - store = ctx->Pack; /* save */ - ctx->Pack = ctx->DefaultPacking; - - ctx->Driver.GetTexImage(ctx, texObj->Target, level, - GL_RGBA, GL_UNSIGNED_BYTE, - buffer, texObj, img); - - /* make filename */ - _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); - - printf(" Writing image level %u to %s\n", level, s); - write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE); - - ctx->Pack = store; /* restore */ - - free(buffer); - } -} - - -/** - * Write renderbuffer image to a ppm file. - */ -static void -write_renderbuffer_image(const struct gl_renderbuffer *rb) -{ - GET_CURRENT_CONTEXT(ctx); - GLubyte *buffer; - char s[100]; - GLenum format, type; - - if (rb->_BaseFormat == GL_RGB || - rb->_BaseFormat == GL_RGBA) { - format = GL_RGBA; - type = GL_UNSIGNED_BYTE; - } - else if (rb->_BaseFormat == GL_DEPTH_STENCIL) { - format = GL_DEPTH_STENCIL; - type = GL_UNSIGNED_INT_24_8; - } - else { - return; - } - - buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4); - - ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height, - format, type, &ctx->DefaultPacking, buffer); - - /* make filename */ - _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name); - - printf(" Writing renderbuffer image to %s\n", s); - write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE); - - free(buffer); -} - - -/** How many texture images (mipmap levels, faces) to write to files */ -#define WRITE_NONE 0 -#define WRITE_ONE 1 -#define WRITE_ALL 2 - -static GLuint WriteImages; - - -static void -dump_texture(struct gl_texture_object *texObj, GLuint writeImages) -{ - const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; - GLboolean written = GL_FALSE; - GLuint i, j; - - printf("Texture %u\n", texObj->Name); - printf(" Target %s\n", tex_target_name(texObj->Target)); - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - for (j = 0; j < numFaces; j++) { - struct gl_texture_image *texImg = texObj->Image[j][i]; - if (texImg) { - printf(" Face %u level %u: %d x %d x %d, format %s at %p\n", - j, i, - texImg->Width, texImg->Height, texImg->Depth, - _mesa_get_format_name(texImg->TexFormat), - texImg->Data); - if (writeImages == WRITE_ALL || - (writeImages == WRITE_ONE && !written)) { - write_texture_image(texObj, j, i); - written = GL_TRUE; - } - } - } - } -} - - -/** - * Dump a single texture. - */ -void -_mesa_dump_texture(GLuint texture, GLuint writeImages) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture); - if (texObj) { - dump_texture(texObj, writeImages); - } -} - - -static void -dump_texture_cb(GLuint id, void *data, void *userData) -{ - struct gl_texture_object *texObj = (struct gl_texture_object *) data; - (void) userData; - dump_texture(texObj, WriteImages); -} - - -/** - * Print basic info about all texture objext to stdout. - * If dumpImages is true, write PPM of level[0] image to a file. - */ -void -_mesa_dump_textures(GLuint writeImages) -{ - GET_CURRENT_CONTEXT(ctx); - WriteImages = writeImages; - _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx); -} - - -static void -dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage) -{ - printf("Renderbuffer %u: %u x %u IntFormat = %s\n", - rb->Name, rb->Width, rb->Height, - _mesa_lookup_enum_by_nr(rb->InternalFormat)); - if (writeImage) { - write_renderbuffer_image(rb); - } -} - - -static void -dump_renderbuffer_cb(GLuint id, void *data, void *userData) -{ - const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data; - (void) userData; - dump_renderbuffer(rb, WriteImages); -} - - -/** - * Print basic info about all renderbuffers to stdout. - * If dumpImages is true, write PPM of level[0] image to a file. - */ -void -_mesa_dump_renderbuffers(GLboolean writeImages) -{ - GET_CURRENT_CONTEXT(ctx); - WriteImages = writeImages; - _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx); -} - - - -void -_mesa_dump_color_buffer(const char *filename) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint w = ctx->DrawBuffer->Width; - const GLuint h = ctx->DrawBuffer->Height; - GLubyte *buf; - - buf = (GLubyte *) malloc(w * h * 4); - - _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); - _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); - - _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf); - - printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n", - (void *) ctx->ReadBuffer->_ColorReadBuffer, - ctx->ReadBuffer->ColorReadBuffer, - (void *) ctx->DrawBuffer->_ColorDrawBuffers[0], - ctx->DrawBuffer->ColorDrawBuffer[0]); - printf("Writing %d x %d color buffer to %s\n", w, h, filename); - write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE); - - _mesa_PopClientAttrib(); - - free(buf); -} - - -void -_mesa_dump_depth_buffer(const char *filename) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint w = ctx->DrawBuffer->Width; - const GLuint h = ctx->DrawBuffer->Height; - GLuint *buf; - GLubyte *buf2; - GLuint i; - - buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */ - buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ - - _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); - _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); - - _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf); - - /* spread 24 bits of Z across R, G, B */ - for (i = 0; i < w * h; i++) { - buf2[i*3+0] = (buf[i] >> 24) & 0xff; - buf2[i*3+1] = (buf[i] >> 16) & 0xff; - buf2[i*3+2] = (buf[i] >> 8) & 0xff; - } - - printf("Writing %d x %d depth buffer to %s\n", w, h, filename); - write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); - - _mesa_PopClientAttrib(); - - free(buf); - free(buf2); -} - - -void -_mesa_dump_stencil_buffer(const char *filename) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint w = ctx->DrawBuffer->Width; - const GLuint h = ctx->DrawBuffer->Height; - GLubyte *buf; - GLubyte *buf2; - GLuint i; - - buf = (GLubyte *) malloc(w * h); /* 1 bpp */ - buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ - - _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); - _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); - - _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf); - - for (i = 0; i < w * h; i++) { - buf2[i*3+0] = buf[i]; - buf2[i*3+1] = (buf[i] & 127) * 2; - buf2[i*3+2] = (buf[i] - 128) * 2; - } - - printf("Writing %d x %d stencil buffer to %s\n", w, h, filename); - write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); - - _mesa_PopClientAttrib(); - - free(buf); - free(buf2); -} - - -/** - * Quick and dirty function to "print" a texture to stdout. - */ -void -_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img) -{ -#if CHAN_TYPE != GL_UNSIGNED_BYTE - _mesa_problem(NULL, "PrintTexture not supported"); -#else - GLuint i, j, c; - const GLubyte *data = (const GLubyte *) img->Data; - - if (!data) { - printf("No texture data\n"); - return; - } - - /* XXX add more formats or make into a new format utility function */ - switch (img->TexFormat) { - case MESA_FORMAT_A8: - case MESA_FORMAT_L8: - case MESA_FORMAT_I8: - case MESA_FORMAT_CI8: - c = 1; - break; - case MESA_FORMAT_AL88: - case MESA_FORMAT_AL88_REV: - c = 2; - break; - case MESA_FORMAT_RGB888: - case MESA_FORMAT_BGR888: - c = 3; - break; - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ARGB8888: - c = 4; - break; - default: - _mesa_problem(NULL, "error in PrintTexture\n"); - return; - } - - for (i = 0; i < img->Height; i++) { - for (j = 0; j < img->Width; j++) { - if (c==1) - printf("%02x ", data[0]); - else if (c==2) - printf("%02x%02x ", data[0], data[1]); - else if (c==3) - printf("%02x%02x%02x ", data[0], data[1], data[2]); - else if (c==4) - printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); - data += (img->RowStride - img->Width) * c; - } - /* XXX use img->ImageStride here */ - printf("\n"); - } -#endif -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "mtypes.h" +#include "attrib.h" +#include "colormac.h" +#include "enums.h" +#include "formats.h" +#include "hash.h" +#include "imports.h" +#include "debug.h" +#include "get.h" +#include "pixelstore.h" +#include "readpix.h" +#include "texobj.h" + + +/** + * Primitive names + */ +const char *_mesa_prim_name[GL_POLYGON+4] = { + "GL_POINTS", + "GL_LINES", + "GL_LINE_LOOP", + "GL_LINE_STRIP", + "GL_TRIANGLES", + "GL_TRIANGLE_STRIP", + "GL_TRIANGLE_FAN", + "GL_QUADS", + "GL_QUAD_STRIP", + "GL_POLYGON", + "outside begin/end", + "inside unknown primitive", + "unknown state" +}; + + +static const char * +tex_target_name(GLenum tgt) +{ + static const struct { + GLenum target; + const char *name; + } tex_targets[] = { + { GL_TEXTURE_1D, "GL_TEXTURE_1D" }, + { GL_TEXTURE_2D, "GL_TEXTURE_2D" }, + { GL_TEXTURE_3D, "GL_TEXTURE_3D" }, + { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" }, + { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" }, + { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" }, + { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" } + }; + GLuint i; + for (i = 0; i < Elements(tex_targets); i++) { + if (tex_targets[i].target == tgt) + return tex_targets[i].name; + } + return "UNKNOWN TEX TARGET"; +} + + +void +_mesa_print_state( const char *msg, GLuint state ) +{ + _mesa_debug(NULL, + "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + msg, + state, + (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "", + (state & _NEW_PROJECTION) ? "ctx->Projection, " : "", + (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "", + (state & _NEW_ACCUM) ? "ctx->Accum, " : "", + (state & _NEW_COLOR) ? "ctx->Color, " : "", + (state & _NEW_DEPTH) ? "ctx->Depth, " : "", + (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "", + (state & _NEW_FOG) ? "ctx->Fog, " : "", + (state & _NEW_HINT) ? "ctx->Hint, " : "", + (state & _NEW_LIGHT) ? "ctx->Light, " : "", + (state & _NEW_LINE) ? "ctx->Line, " : "", + (state & _NEW_PIXEL) ? "ctx->Pixel, " : "", + (state & _NEW_POINT) ? "ctx->Point, " : "", + (state & _NEW_POLYGON) ? "ctx->Polygon, " : "", + (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "", + (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "", + (state & _NEW_STENCIL) ? "ctx->Stencil, " : "", + (state & _NEW_TEXTURE) ? "ctx->Texture, " : "", + (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "", + (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "", + (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "", + (state & _NEW_ARRAY) ? "ctx->Array, " : "", + (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "", + (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : ""); +} + + + +void +_mesa_print_tri_caps( const char *name, GLuint flags ) +{ + _mesa_debug(NULL, + "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n", + name, + flags, + (flags & DD_FLATSHADE) ? "flat-shade, " : "", + (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "", + (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "", + (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "", + (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "", + (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "", + (flags & DD_TRI_OFFSET) ? "tri-offset, " : "", + (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "", + (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "", + (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "", + (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "", + (flags & DD_POINT_ATTEN) ? "point-atten, " : "", + (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : "" + ); +} + + +/** + * Print information about this Mesa version and build options. + */ +void _mesa_print_info( void ) +{ + _mesa_debug(NULL, "Mesa GL_VERSION = %s\n", + (char *) _mesa_GetString(GL_VERSION)); + _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n", + (char *) _mesa_GetString(GL_RENDERER)); + _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n", + (char *) _mesa_GetString(GL_VENDOR)); + _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", + (char *) _mesa_GetString(GL_EXTENSIONS)); +#if defined(THREADS) + _mesa_debug(NULL, "Mesa thread-safe: YES\n"); +#else + _mesa_debug(NULL, "Mesa thread-safe: NO\n"); +#endif +#if defined(USE_X86_ASM) + _mesa_debug(NULL, "Mesa x86-optimized: YES\n"); +#else + _mesa_debug(NULL, "Mesa x86-optimized: NO\n"); +#endif +#if defined(USE_SPARC_ASM) + _mesa_debug(NULL, "Mesa sparc-optimized: YES\n"); +#else + _mesa_debug(NULL, "Mesa sparc-optimized: NO\n"); +#endif +} + + +/** + * Set the debugging flags. + * + * \param debug debug string + * + * If compiled with debugging support then search for keywords in \p debug and + * enables the verbose debug output of the respective feature. + */ +static void add_debug_flags( const char *debug ) +{ +#ifdef DEBUG + struct debug_option { + const char *name; + GLbitfield flag; + }; + static const struct debug_option debug_opt[] = { + { "varray", VERBOSE_VARRAY }, + { "tex", VERBOSE_TEXTURE }, + { "mat", VERBOSE_MATERIAL }, + { "pipe", VERBOSE_PIPELINE }, + { "driver", VERBOSE_DRIVER }, + { "state", VERBOSE_STATE }, + { "api", VERBOSE_API }, + { "list", VERBOSE_DISPLAY_LIST }, + { "lighting", VERBOSE_LIGHTING }, + { "disassem", VERBOSE_DISASSEM }, + { "draw", VERBOSE_DRAW }, + { "swap", VERBOSE_SWAPBUFFERS } + }; + GLuint i; + + MESA_VERBOSE = 0x0; + for (i = 0; i < Elements(debug_opt); i++) { + if (strstr(debug, debug_opt[i].name)) + MESA_VERBOSE |= debug_opt[i].flag; + } + + /* Debug flag: + */ + if (strstr(debug, "flush")) + MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH; + +#if defined(_FPU_GETCW) && defined(_FPU_SETCW) + if (strstr(debug, "fpexceptions")) { + /* raise FP exceptions */ + fpu_control_t mask; + _FPU_GETCW(mask); + mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM + | _FPU_MASK_OM | _FPU_MASK_UM); + _FPU_SETCW(mask); + } +#endif + +#else + (void) debug; +#endif +} + + +void +_mesa_init_debug( struct gl_context *ctx ) +{ + char *c; + + /* Dither disable */ + ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE; + if (ctx->NoDither) { + if (_mesa_getenv("MESA_DEBUG")) { + _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n"); + } + ctx->Color.DitherFlag = GL_FALSE; + } + + c = _mesa_getenv("MESA_DEBUG"); + if (c) + add_debug_flags(c); + + c = _mesa_getenv("MESA_VERBOSE"); + if (c) + add_debug_flags(c); +} + + +/* + * Write ppm file + */ +static void +write_ppm(const char *filename, const GLubyte *buffer, int width, int height, + int comps, int rcomp, int gcomp, int bcomp, GLboolean invert) +{ + FILE *f = fopen( filename, "w" ); + if (f) { + int x, y; + const GLubyte *ptr = buffer; + fprintf(f,"P6\n"); + fprintf(f,"# ppm-file created by osdemo.c\n"); + fprintf(f,"%i %i\n", width,height); + fprintf(f,"255\n"); + fclose(f); + f = fopen( filename, "ab" ); /* reopen in binary append mode */ + for (y=0; y < height; y++) { + for (x = 0; x < width; x++) { + int yy = invert ? (height - 1 - y) : y; + int i = (yy * width + x) * comps; + fputc(ptr[i+rcomp], f); /* write red */ + fputc(ptr[i+gcomp], f); /* write green */ + fputc(ptr[i+bcomp], f); /* write blue */ + } + } + fclose(f); + } +} + + +/** + * Write a texture image to a ppm file. + * \param face cube face in [0,5] + * \param level mipmap level + */ +static void +write_texture_image(struct gl_texture_object *texObj, + GLuint face, GLuint level) +{ + struct gl_texture_image *img = texObj->Image[face][level]; + if (img) { + GET_CURRENT_CONTEXT(ctx); + struct gl_pixelstore_attrib store; + GLubyte *buffer; + char s[100]; + + buffer = (GLubyte *) malloc(img->Width * img->Height + * img->Depth * 4); + + store = ctx->Pack; /* save */ + ctx->Pack = ctx->DefaultPacking; + + ctx->Driver.GetTexImage(ctx, texObj->Target, level, + GL_RGBA, GL_UNSIGNED_BYTE, + buffer, texObj, img); + + /* make filename */ + _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); + + printf(" Writing image level %u to %s\n", level, s); + write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE); + + ctx->Pack = store; /* restore */ + + free(buffer); + } +} + + +/** + * Write renderbuffer image to a ppm file. + */ +static void +write_renderbuffer_image(const struct gl_renderbuffer *rb) +{ + GET_CURRENT_CONTEXT(ctx); + GLubyte *buffer; + char s[100]; + GLenum format, type; + + if (rb->_BaseFormat == GL_RGB || + rb->_BaseFormat == GL_RGBA) { + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + } + else if (rb->_BaseFormat == GL_DEPTH_STENCIL) { + format = GL_DEPTH_STENCIL; + type = GL_UNSIGNED_INT_24_8; + } + else { + return; + } + + buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4); + + ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height, + format, type, &ctx->DefaultPacking, buffer); + + /* make filename */ + _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name); + + printf(" Writing renderbuffer image to %s\n", s); + write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE); + + free(buffer); +} + + +/** How many texture images (mipmap levels, faces) to write to files */ +#define WRITE_NONE 0 +#define WRITE_ONE 1 +#define WRITE_ALL 2 + +static GLuint WriteImages; + + +static void +dump_texture(struct gl_texture_object *texObj, GLuint writeImages) +{ + const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + GLboolean written = GL_FALSE; + GLuint i, j; + + printf("Texture %u\n", texObj->Name); + printf(" Target %s\n", tex_target_name(texObj->Target)); + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + for (j = 0; j < numFaces; j++) { + struct gl_texture_image *texImg = texObj->Image[j][i]; + if (texImg) { + printf(" Face %u level %u: %d x %d x %d, format %s at %p\n", + j, i, + texImg->Width, texImg->Height, texImg->Depth, + _mesa_get_format_name(texImg->TexFormat), + texImg->Data); + if (writeImages == WRITE_ALL || + (writeImages == WRITE_ONE && !written)) { + write_texture_image(texObj, j, i); + written = GL_TRUE; + } + } + } + } +} + + +/** + * Dump a single texture. + */ +void +_mesa_dump_texture(GLuint texture, GLuint writeImages) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture); + if (texObj) { + dump_texture(texObj, writeImages); + } +} + + +static void +dump_texture_cb(GLuint id, void *data, void *userData) +{ + struct gl_texture_object *texObj = (struct gl_texture_object *) data; + (void) userData; + dump_texture(texObj, WriteImages); +} + + +/** + * Print basic info about all texture objext to stdout. + * If dumpImages is true, write PPM of level[0] image to a file. + */ +void +_mesa_dump_textures(GLuint writeImages) +{ + GET_CURRENT_CONTEXT(ctx); + WriteImages = writeImages; + _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx); +} + + +static void +dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage) +{ + printf("Renderbuffer %u: %u x %u IntFormat = %s\n", + rb->Name, rb->Width, rb->Height, + _mesa_lookup_enum_by_nr(rb->InternalFormat)); + if (writeImage) { + write_renderbuffer_image(rb); + } +} + + +static void +dump_renderbuffer_cb(GLuint id, void *data, void *userData) +{ + const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data; + (void) userData; + dump_renderbuffer(rb, WriteImages); +} + + +/** + * Print basic info about all renderbuffers to stdout. + * If dumpImages is true, write PPM of level[0] image to a file. + */ +void +_mesa_dump_renderbuffers(GLboolean writeImages) +{ + GET_CURRENT_CONTEXT(ctx); + WriteImages = writeImages; + _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx); +} + + + +void +_mesa_dump_color_buffer(const char *filename) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint w = ctx->DrawBuffer->Width; + const GLuint h = ctx->DrawBuffer->Height; + GLubyte *buf; + + buf = (GLubyte *) malloc(w * h * 4); + + _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); + _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); + + _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n", + (void *) ctx->ReadBuffer->_ColorReadBuffer, + ctx->ReadBuffer->ColorReadBuffer, + (void *) ctx->DrawBuffer->_ColorDrawBuffers[0], + ctx->DrawBuffer->ColorDrawBuffer[0]); + printf("Writing %d x %d color buffer to %s\n", w, h, filename); + write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE); + + _mesa_PopClientAttrib(); + + free(buf); +} + + +void +_mesa_dump_depth_buffer(const char *filename) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint w = ctx->DrawBuffer->Width; + const GLuint h = ctx->DrawBuffer->Height; + GLuint *buf; + GLubyte *buf2; + GLuint i; + + buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */ + buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ + + _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); + _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); + + _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf); + + /* spread 24 bits of Z across R, G, B */ + for (i = 0; i < w * h; i++) { + buf2[i*3+0] = (buf[i] >> 24) & 0xff; + buf2[i*3+1] = (buf[i] >> 16) & 0xff; + buf2[i*3+2] = (buf[i] >> 8) & 0xff; + } + + printf("Writing %d x %d depth buffer to %s\n", w, h, filename); + write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); + + _mesa_PopClientAttrib(); + + free(buf); + free(buf2); +} + + +void +_mesa_dump_stencil_buffer(const char *filename) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint w = ctx->DrawBuffer->Width; + const GLuint h = ctx->DrawBuffer->Height; + GLubyte *buf; + GLubyte *buf2; + GLuint i; + + buf = (GLubyte *) malloc(w * h); /* 1 bpp */ + buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ + + _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); + _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); + _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); + + _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf); + + for (i = 0; i < w * h; i++) { + buf2[i*3+0] = buf[i]; + buf2[i*3+1] = (buf[i] & 127) * 2; + buf2[i*3+2] = (buf[i] - 128) * 2; + } + + printf("Writing %d x %d stencil buffer to %s\n", w, h, filename); + write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); + + _mesa_PopClientAttrib(); + + free(buf); + free(buf2); +} + + +/** + * Quick and dirty function to "print" a texture to stdout. + */ +void +_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img) +{ +#if CHAN_TYPE != GL_UNSIGNED_BYTE + _mesa_problem(NULL, "PrintTexture not supported"); +#else + GLuint i, j, c; + const GLubyte *data = (const GLubyte *) img->Data; + + if (!data) { + printf("No texture data\n"); + return; + } + + /* XXX add more formats or make into a new format utility function */ + switch (img->TexFormat) { + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + c = 1; + break; + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + c = 2; + break; + case MESA_FORMAT_RGB888: + case MESA_FORMAT_BGR888: + c = 3; + break; + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_ARGB8888: + c = 4; + break; + default: + _mesa_problem(NULL, "error in PrintTexture\n"); + return; + } + + for (i = 0; i < img->Height; i++) { + for (j = 0; j < img->Width; j++) { + if (c==1) + printf("%02x ", data[0]); + else if (c==2) + printf("%02x%02x ", data[0], data[1]); + else if (c==3) + printf("%02x%02x%02x ", data[0], data[1], data[2]); + else if (c==4) + printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); + data += (img->RowStride - img->Width) * c; + } + /* XXX use img->ImageStride here */ + printf("\n"); + } +#endif +} diff --git a/mesalib/src/mesa/main/debug.h b/mesalib/src/mesa/main/debug.h index b517cc825..ea397b72b 100644 --- a/mesalib/src/mesa/main/debug.h +++ b/mesalib/src/mesa/main/debug.h @@ -1,84 +1,87 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file debug.h - * Debugging functions. - * - * \if subset - * (No-op) - * - * \endif - */ - - -#ifndef _DEBUG_H -#define _DEBUG_H - -#include "glheader.h" -#include "mtypes.h" - -#if _HAVE_FULL_GL - -extern void _mesa_print_tri_caps( const char *name, GLuint flags ); -extern void _mesa_print_enable_flags( const char *msg, GLuint flags ); -extern void _mesa_print_state( const char *msg, GLuint state ); -extern void _mesa_print_info( void ); -extern void _mesa_init_debug( GLcontext *ctx ); - -#else - -/** No-op */ -#define _mesa_print_state( m, s ) ((void)0) - -/** No-op */ -#define _mesa_print_info() ((void)0) - -/** No-op */ -#define _mesa_init_debug( c ) ((void)0) - -#endif - -extern void -_mesa_dump_texture(GLuint texture, GLuint writeImages); - -extern void -_mesa_dump_textures(GLuint writeImages); - -extern void -_mesa_dump_renderbuffers(GLboolean writeImages); - -extern void -_mesa_dump_color_buffer(const char *filename); - -extern void -_mesa_dump_depth_buffer(const char *filename); - -extern void -_mesa_dump_stencil_buffer(const char *filename); - -extern void -_mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img); - -#endif +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file debug.h + * Debugging functions. + * + * \if subset + * (No-op) + * + * \endif + */ + + +#ifndef _DEBUG_H +#define _DEBUG_H + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; +struct gl_texture_image; + +#if _HAVE_FULL_GL + +extern void _mesa_print_tri_caps( const char *name, GLuint flags ); +extern void _mesa_print_enable_flags( const char *msg, GLuint flags ); +extern void _mesa_print_state( const char *msg, GLuint state ); +extern void _mesa_print_info( void ); +extern void _mesa_init_debug( struct gl_context *ctx ); + +#else + +/** No-op */ +#define _mesa_print_state( m, s ) ((void)0) + +/** No-op */ +#define _mesa_print_info() ((void)0) + +/** No-op */ +#define _mesa_init_debug( c ) ((void)0) + +#endif + +extern void +_mesa_dump_texture(GLuint texture, GLuint writeImages); + +extern void +_mesa_dump_textures(GLuint writeImages); + +extern void +_mesa_dump_renderbuffers(GLboolean writeImages); + +extern void +_mesa_dump_color_buffer(const char *filename); + +extern void +_mesa_dump_depth_buffer(const char *filename); + +extern void +_mesa_dump_stencil_buffer(const char *filename); + +extern void +_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img); + +#endif diff --git a/mesalib/src/mesa/main/depth.c b/mesalib/src/mesa/main/depth.c index f187205b9..9ab08df29 100644 --- a/mesalib/src/mesa/main/depth.c +++ b/mesalib/src/mesa/main/depth.c @@ -1,162 +1,162 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "depth.h" -#include "enums.h" -#include "macros.h" -#include "mtypes.h" - - -/**********************************************************************/ -/***** API Functions *****/ -/**********************************************************************/ - - - -void GLAPIENTRY -_mesa_ClearDepth( GLclampd depth ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - depth = CLAMP( depth, 0.0, 1.0 ); - - if (ctx->Depth.Clear == depth) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Clear = depth; - if (ctx->Driver.ClearDepth) - (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); -} - - - -void GLAPIENTRY -_mesa_DepthFunc( GLenum func ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); - - switch (func) { - case GL_LESS: /* (default) pass if incoming z < stored z */ - case GL_GEQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_EQUAL: - case GL_ALWAYS: - case GL_NEVER: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); - return; - } - - if (ctx->Depth.Func == func) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Func = func; - - if (ctx->Driver.DepthFunc) - ctx->Driver.DepthFunc( ctx, func ); -} - - - -void GLAPIENTRY -_mesa_DepthMask( GLboolean flag ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthMask %d\n", flag); - - /* - * GL_TRUE indicates depth buffer writing is enabled (default) - * GL_FALSE indicates depth buffer writing is disabled - */ - if (ctx->Depth.Mask == flag) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Mask = flag; - - if (ctx->Driver.DepthMask) - ctx->Driver.DepthMask( ctx, flag ); -} - - - -/** - * Specified by the GL_EXT_depth_bounds_test extension. - */ -void GLAPIENTRY -_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (zmin > zmax) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); - return; - } - - zmin = CLAMP(zmin, 0.0, 1.0); - zmax = CLAMP(zmax, 0.0, 1.0); - - if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsMin = (GLfloat) zmin; - ctx->Depth.BoundsMax = (GLfloat) zmax; -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - - -/** - * Initialize the depth buffer attribute group in the given context. - */ -void -_mesa_init_depth(GLcontext *ctx) -{ - ctx->Depth.Test = GL_FALSE; - ctx->Depth.Clear = 1.0; - ctx->Depth.Func = GL_LESS; - ctx->Depth.Mask = GL_TRUE; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "depth.h" +#include "enums.h" +#include "macros.h" +#include "mtypes.h" + + +/**********************************************************************/ +/***** API Functions *****/ +/**********************************************************************/ + + + +void GLAPIENTRY +_mesa_ClearDepth( GLclampd depth ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + depth = CLAMP( depth, 0.0, 1.0 ); + + if (ctx->Depth.Clear == depth) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Clear = depth; + if (ctx->Driver.ClearDepth) + (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); +} + + + +void GLAPIENTRY +_mesa_DepthFunc( GLenum func ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); + + switch (func) { + case GL_LESS: /* (default) pass if incoming z < stored z */ + case GL_GEQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_EQUAL: + case GL_ALWAYS: + case GL_NEVER: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); + return; + } + + if (ctx->Depth.Func == func) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Func = func; + + if (ctx->Driver.DepthFunc) + ctx->Driver.DepthFunc( ctx, func ); +} + + + +void GLAPIENTRY +_mesa_DepthMask( GLboolean flag ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDepthMask %d\n", flag); + + /* + * GL_TRUE indicates depth buffer writing is enabled (default) + * GL_FALSE indicates depth buffer writing is disabled + */ + if (ctx->Depth.Mask == flag) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Mask = flag; + + if (ctx->Driver.DepthMask) + ctx->Driver.DepthMask( ctx, flag ); +} + + + +/** + * Specified by the GL_EXT_depth_bounds_test extension. + */ +void GLAPIENTRY +_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (zmin > zmax) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); + return; + } + + zmin = CLAMP(zmin, 0.0, 1.0); + zmax = CLAMP(zmax, 0.0, 1.0); + + if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.BoundsMin = (GLfloat) zmin; + ctx->Depth.BoundsMax = (GLfloat) zmax; +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + + +/** + * Initialize the depth buffer attribute group in the given context. + */ +void +_mesa_init_depth(struct gl_context *ctx) +{ + ctx->Depth.Test = GL_FALSE; + ctx->Depth.Clear = 1.0; + ctx->Depth.Func = GL_LESS; + ctx->Depth.Mask = GL_TRUE; +} diff --git a/mesalib/src/mesa/main/depth.h b/mesalib/src/mesa/main/depth.h index dcc0b4637..2a0bc81a6 100644 --- a/mesalib/src/mesa/main/depth.h +++ b/mesalib/src/mesa/main/depth.h @@ -1,62 +1,65 @@ -/** - * \file depth.h - * Depth buffer operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DEPTH_H -#define DEPTH_H - - -#include "mtypes.h" - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_ClearDepth( GLclampd depth ); - -extern void GLAPIENTRY -_mesa_DepthFunc( GLenum func ); - -extern void GLAPIENTRY -_mesa_DepthMask( GLboolean flag ); - -extern void GLAPIENTRY -_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ); - -extern void -_mesa_init_depth( GLcontext * ctx ); - -#else - -/** No-op */ -#define _mesa_init_depth( c ) ((void)0) - -#endif - -#endif +/** + * \file depth.h + * Depth buffer operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef DEPTH_H +#define DEPTH_H + + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + + +#if _HAVE_FULL_GL + +extern void GLAPIENTRY +_mesa_ClearDepth( GLclampd depth ); + +extern void GLAPIENTRY +_mesa_DepthFunc( GLenum func ); + +extern void GLAPIENTRY +_mesa_DepthMask( GLboolean flag ); + +extern void GLAPIENTRY +_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ); + +extern void +_mesa_init_depth( struct gl_context * ctx ); + +#else + +/** No-op */ +#define _mesa_init_depth( c ) ((void)0) + +#endif + +#endif diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c index dbaa84164..a1f206b9c 100644 --- a/mesalib/src/mesa/main/depthstencil.c +++ b/mesalib/src/mesa/main/depthstencil.c @@ -1,832 +1,832 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "formats.h" -#include "mtypes.h" -#include "depthstencil.h" -#include "renderbuffer.h" - - -/** - * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. - * - * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we - * want to treat it as a stencil buffer, other times we want to treat it - * as a depth/z buffer and still other times when we want to treat it as - * a combined Z+stencil buffer! That implies we need three different sets - * of Get/Put functions. - * - * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and - * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. - */ - - -static void * -nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - (void) ctx; - (void) rb; - (void) x; - (void) y; - return NULL; -} - - -/** - * Delete a depth or stencil wrapper renderbuffer. - */ -static void -delete_wrapper(struct gl_renderbuffer *rb) -{ - ASSERT(rb->Format == MESA_FORMAT_S8 || - rb->Format == MESA_FORMAT_X8_Z24); - _mesa_reference_renderbuffer(&rb->Wrapped, NULL); - free(rb); -} - - -/** - * Realloc storage for wrapper. - */ -static GLboolean -alloc_wrapper_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - /* just pass this on to the wrapped renderbuffer */ - struct gl_renderbuffer *dsrb = rb->Wrapped; - GLboolean retVal; - - (void) internalFormat; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - - retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); - if (retVal) { - rb->Width = width; - rb->Height = height; - } - return retVal; -} - - - - -/*====================================================================== - * Depth wrapper around depth/stencil renderbuffer - */ - -static void -get_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xffffff; - } - } -} - -static void -get_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xffffff; - } - } -} - -static void -put_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] << 8) | (dst[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] << 8) | (*dst & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a depth renderbuffer. - * \return new depth renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx, - struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *z24rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!z24rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - z24rb->Wrapped = dsrb; - dsrb->RefCount++; - - z24rb->Name = dsrb->Name; - z24rb->RefCount = 0; - z24rb->Width = dsrb->Width; - z24rb->Height = dsrb->Height; - z24rb->InternalFormat = GL_DEPTH_COMPONENT24; - z24rb->Format = MESA_FORMAT_X8_Z24; - z24rb->_BaseFormat = GL_DEPTH_COMPONENT; - z24rb->DataType = GL_UNSIGNED_INT; - z24rb->Data = NULL; - z24rb->Delete = delete_wrapper; - z24rb->AllocStorage = alloc_wrapper_storage; - z24rb->GetPointer = nop_get_pointer; - z24rb->GetRow = get_row_z24; - z24rb->GetValues = get_values_z24; - z24rb->PutRow = put_row_z24; - z24rb->PutRowRGB = NULL; - z24rb->PutMonoRow = put_mono_row_z24; - z24rb->PutValues = put_values_z24; - z24rb->PutMonoValues = put_mono_values_z24; - - return z24rb; -} - - -/*====================================================================== - * Stencil wrapper around depth/stencil renderbuffer - */ - -static void -get_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLubyte *dst = (GLubyte *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 24; - } - } -} - -static void -get_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLubyte *dst = (GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 24; - } - } -} - -static void -put_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte val = *((GLubyte *) value); - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (val << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_s8(GLcontext *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - const GLubyte val = *((GLubyte *) value); - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a stencil renderbuffer. - * \return new stencil renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *s8rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_S8_Z24); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!s8rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - s8rb->Wrapped = dsrb; - dsrb->RefCount++; - - s8rb->Name = dsrb->Name; - s8rb->RefCount = 0; - s8rb->Width = dsrb->Width; - s8rb->Height = dsrb->Height; - s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; - s8rb->Format = MESA_FORMAT_S8; - s8rb->_BaseFormat = GL_STENCIL_INDEX; - s8rb->DataType = GL_UNSIGNED_BYTE; - s8rb->Data = NULL; - s8rb->Delete = delete_wrapper; - s8rb->AllocStorage = alloc_wrapper_storage; - s8rb->GetPointer = nop_get_pointer; - s8rb->GetRow = get_row_s8; - s8rb->GetValues = get_values_s8; - s8rb->PutRow = put_row_s8; - s8rb->PutRowRGB = NULL; - s8rb->PutMonoRow = put_mono_row_s8; - s8rb->PutValues = put_values_s8; - s8rb->PutMonoValues = put_mono_values_s8; - - return s8rb; -} - - - -/** - ** The following functions are useful for hardware drivers that only - ** implement combined depth/stencil buffers. - ** The GL_EXT_framebuffer_object extension allows indepedent depth and - ** stencil buffers to be used in any combination. - ** Therefore, we sometimes have to merge separate depth and stencil - ** renderbuffers into a single depth+stencil renderbuffer. And sometimes - ** we have to split combined depth+stencil renderbuffers into separate - ** renderbuffers. - **/ - - -/** - * Extract stencil values from the combined depth/stencil renderbuffer, storing - * the values into a separate stencil renderbuffer. - * \param dsRb the source depth/stencil renderbuffer - * \param stencilRb the destination stencil renderbuffer - * (either 8-bit or 32-bit) - */ -void -_mesa_extract_stencil(GLcontext *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb) -{ - GLuint row, width, height; - - ASSERT(dsRb); - ASSERT(stencilRb); - - ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || - stencilRb->Format == MESA_FORMAT_S8); - ASSERT(dsRb->Width == stencilRb->Width); - ASSERT(dsRb->Height == stencilRb->Height); - - width = dsRb->Width; - height = dsRb->Height; - - for (row = 0; row < height; row++) { - GLuint depthStencil[MAX_WIDTH]; - dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); - if (stencilRb->Format == MESA_FORMAT_S8) { - /* 8bpp stencil */ - GLubyte stencil[MAX_WIDTH]; - GLuint i; - for (i = 0; i < width; i++) { - stencil[i] = depthStencil[i] & 0xff; - } - stencilRb->PutRow(ctx, stencilRb, width, 0, row, stencil, NULL); - } - else { - /* 32bpp stencil */ - /* the 24 depth bits will be ignored */ - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL); - } - } -} - - -/** - * Copy stencil values from a stencil renderbuffer into a combined - * depth/stencil renderbuffer. - * \param dsRb the destination depth/stencil renderbuffer - * \param stencilRb the source stencil buffer (either 8-bit or 32-bit) - */ -void -_mesa_insert_stencil(GLcontext *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb) -{ - GLuint row, width, height; - - ASSERT(dsRb); - ASSERT(stencilRb); - - ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || - stencilRb->Format == MESA_FORMAT_S8); - - ASSERT(dsRb->Width == stencilRb->Width); - ASSERT(dsRb->Height == stencilRb->Height); - - width = dsRb->Width; - height = dsRb->Height; - - for (row = 0; row < height; row++) { - GLuint depthStencil[MAX_WIDTH]; - - dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); - - if (stencilRb->Format == MESA_FORMAT_S8) { - /* 8bpp stencil */ - GLubyte stencil[MAX_WIDTH]; - GLuint i; - stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); - for (i = 0; i < width; i++) { - depthStencil[i] = (depthStencil[i] & 0xffffff00) | stencil[i]; - } - } - else { - /* 32bpp stencil buffer */ - GLuint stencil[MAX_WIDTH], i; - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); - for (i = 0; i < width; i++) { - depthStencil[i] - = (depthStencil[i] & 0xffffff00) | (stencil[i] & 0xff); - } - } - - dsRb->PutRow(ctx, dsRb, width, 0, row, depthStencil, NULL); - } -} - - -/** - * Convert the stencil buffer from 8bpp to 32bpp depth/stencil. - * \param stencilRb the stencil renderbuffer to promote - */ -void -_mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb) -{ - const GLsizei width = stencilRb->Width; - const GLsizei height = stencilRb->Height; - GLubyte *data; - GLint i, j, k; - - ASSERT(stencilRb->Format == MESA_FORMAT_S8); - ASSERT(stencilRb->Data); - - data = (GLubyte *) stencilRb->Data; - stencilRb->Data = NULL; - stencilRb->AllocStorage(ctx, stencilRb, GL_DEPTH24_STENCIL8_EXT, - width, height); - - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - k = 0; - for (i = 0; i < height; i++) { - GLuint depthStencil[MAX_WIDTH]; - for (j = 0; j < width; j++) { - depthStencil[j] = data[k++]; - } - stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL); - } - free(data); -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "formats.h" +#include "mtypes.h" +#include "depthstencil.h" +#include "renderbuffer.h" + + +/** + * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. + * + * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we + * want to treat it as a stencil buffer, other times we want to treat it + * as a depth/z buffer and still other times when we want to treat it as + * a combined Z+stencil buffer! That implies we need three different sets + * of Get/Put functions. + * + * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and + * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. + */ + + +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + (void) ctx; + (void) rb; + (void) x; + (void) y; + return NULL; +} + + +/** + * Delete a depth or stencil wrapper renderbuffer. + */ +static void +delete_wrapper(struct gl_renderbuffer *rb) +{ + ASSERT(rb->Format == MESA_FORMAT_S8 || + rb->Format == MESA_FORMAT_X8_Z24); + _mesa_reference_renderbuffer(&rb->Wrapped, NULL); + free(rb); +} + + +/** + * Realloc storage for wrapper. + */ +static GLboolean +alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) +{ + /* just pass this on to the wrapped renderbuffer */ + struct gl_renderbuffer *dsrb = rb->Wrapped; + GLboolean retVal; + + (void) internalFormat; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + + retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); + if (retVal) { + rb->Width = width; + rb->Height = height; + } + return retVal; +} + + + + +/*====================================================================== + * Depth wrapper around depth/stencil renderbuffer + */ + +static void +get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xffffff; + } + } +} + +static void +get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xffffff; + } + } +} + +static void +put_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] << 8) | (dst[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] << 8) | (*dst & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a depth renderbuffer. + * \return new depth renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *z24rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!z24rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + z24rb->Wrapped = dsrb; + dsrb->RefCount++; + + z24rb->Name = dsrb->Name; + z24rb->RefCount = 0; + z24rb->Width = dsrb->Width; + z24rb->Height = dsrb->Height; + z24rb->InternalFormat = GL_DEPTH_COMPONENT24; + z24rb->Format = MESA_FORMAT_X8_Z24; + z24rb->_BaseFormat = GL_DEPTH_COMPONENT; + z24rb->DataType = GL_UNSIGNED_INT; + z24rb->Data = NULL; + z24rb->Delete = delete_wrapper; + z24rb->AllocStorage = alloc_wrapper_storage; + z24rb->GetPointer = nop_get_pointer; + z24rb->GetRow = get_row_z24; + z24rb->GetValues = get_values_z24; + z24rb->PutRow = put_row_z24; + z24rb->PutRowRGB = NULL; + z24rb->PutMonoRow = put_mono_row_z24; + z24rb->PutValues = put_values_z24; + z24rb->PutMonoValues = put_mono_values_z24; + + return z24rb; +} + + +/*====================================================================== + * Stencil wrapper around depth/stencil renderbuffer + */ + +static void +get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLubyte *dst = (GLubyte *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 24; + } + } +} + +static void +get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLubyte *dst = (GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 24; + } + } +} + +static void +put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte val = *((GLubyte *) value); + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (val << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + const GLubyte val = *((GLubyte *) value); + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a stencil renderbuffer. + * \return new stencil renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *s8rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_S8_Z24); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!s8rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + s8rb->Wrapped = dsrb; + dsrb->RefCount++; + + s8rb->Name = dsrb->Name; + s8rb->RefCount = 0; + s8rb->Width = dsrb->Width; + s8rb->Height = dsrb->Height; + s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; + s8rb->Format = MESA_FORMAT_S8; + s8rb->_BaseFormat = GL_STENCIL_INDEX; + s8rb->DataType = GL_UNSIGNED_BYTE; + s8rb->Data = NULL; + s8rb->Delete = delete_wrapper; + s8rb->AllocStorage = alloc_wrapper_storage; + s8rb->GetPointer = nop_get_pointer; + s8rb->GetRow = get_row_s8; + s8rb->GetValues = get_values_s8; + s8rb->PutRow = put_row_s8; + s8rb->PutRowRGB = NULL; + s8rb->PutMonoRow = put_mono_row_s8; + s8rb->PutValues = put_values_s8; + s8rb->PutMonoValues = put_mono_values_s8; + + return s8rb; +} + + + +/** + ** The following functions are useful for hardware drivers that only + ** implement combined depth/stencil buffers. + ** The GL_EXT_framebuffer_object extension allows indepedent depth and + ** stencil buffers to be used in any combination. + ** Therefore, we sometimes have to merge separate depth and stencil + ** renderbuffers into a single depth+stencil renderbuffer. And sometimes + ** we have to split combined depth+stencil renderbuffers into separate + ** renderbuffers. + **/ + + +/** + * Extract stencil values from the combined depth/stencil renderbuffer, storing + * the values into a separate stencil renderbuffer. + * \param dsRb the source depth/stencil renderbuffer + * \param stencilRb the destination stencil renderbuffer + * (either 8-bit or 32-bit) + */ +void +_mesa_extract_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb) +{ + GLuint row, width, height; + + ASSERT(dsRb); + ASSERT(stencilRb); + + ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || + stencilRb->Format == MESA_FORMAT_S8); + ASSERT(dsRb->Width == stencilRb->Width); + ASSERT(dsRb->Height == stencilRb->Height); + + width = dsRb->Width; + height = dsRb->Height; + + for (row = 0; row < height; row++) { + GLuint depthStencil[MAX_WIDTH]; + dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); + if (stencilRb->Format == MESA_FORMAT_S8) { + /* 8bpp stencil */ + GLubyte stencil[MAX_WIDTH]; + GLuint i; + for (i = 0; i < width; i++) { + stencil[i] = depthStencil[i] & 0xff; + } + stencilRb->PutRow(ctx, stencilRb, width, 0, row, stencil, NULL); + } + else { + /* 32bpp stencil */ + /* the 24 depth bits will be ignored */ + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL); + } + } +} + + +/** + * Copy stencil values from a stencil renderbuffer into a combined + * depth/stencil renderbuffer. + * \param dsRb the destination depth/stencil renderbuffer + * \param stencilRb the source stencil buffer (either 8-bit or 32-bit) + */ +void +_mesa_insert_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb) +{ + GLuint row, width, height; + + ASSERT(dsRb); + ASSERT(stencilRb); + + ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || + stencilRb->Format == MESA_FORMAT_S8); + + ASSERT(dsRb->Width == stencilRb->Width); + ASSERT(dsRb->Height == stencilRb->Height); + + width = dsRb->Width; + height = dsRb->Height; + + for (row = 0; row < height; row++) { + GLuint depthStencil[MAX_WIDTH]; + + dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); + + if (stencilRb->Format == MESA_FORMAT_S8) { + /* 8bpp stencil */ + GLubyte stencil[MAX_WIDTH]; + GLuint i; + stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); + for (i = 0; i < width; i++) { + depthStencil[i] = (depthStencil[i] & 0xffffff00) | stencil[i]; + } + } + else { + /* 32bpp stencil buffer */ + GLuint stencil[MAX_WIDTH], i; + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); + for (i = 0; i < width; i++) { + depthStencil[i] + = (depthStencil[i] & 0xffffff00) | (stencil[i] & 0xff); + } + } + + dsRb->PutRow(ctx, dsRb, width, 0, row, depthStencil, NULL); + } +} + + +/** + * Convert the stencil buffer from 8bpp to 32bpp depth/stencil. + * \param stencilRb the stencil renderbuffer to promote + */ +void +_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb) +{ + const GLsizei width = stencilRb->Width; + const GLsizei height = stencilRb->Height; + GLubyte *data; + GLint i, j, k; + + ASSERT(stencilRb->Format == MESA_FORMAT_S8); + ASSERT(stencilRb->Data); + + data = (GLubyte *) stencilRb->Data; + stencilRb->Data = NULL; + stencilRb->AllocStorage(ctx, stencilRb, GL_DEPTH24_STENCIL8_EXT, + width, height); + + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + k = 0; + for (i = 0; i < height; i++) { + GLuint depthStencil[MAX_WIDTH]; + for (j = 0; j < width; j++) { + depthStencil[j] = data[k++]; + } + stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL); + } + free(data); +} diff --git a/mesalib/src/mesa/main/depthstencil.h b/mesalib/src/mesa/main/depthstencil.h index afbac77f0..a86f54d96 100644 --- a/mesalib/src/mesa/main/depthstencil.h +++ b/mesalib/src/mesa/main/depthstencil.h @@ -1,57 +1,57 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef DEPTHSTENCIL_H -#define DEPTHSTENCIL_H - -#include "mtypes.h" - -extern struct gl_renderbuffer * -_mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx, - struct gl_renderbuffer *dsrb); - - -extern struct gl_renderbuffer * -_mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, - struct gl_renderbuffer *dsrb); - - -extern void -_mesa_extract_stencil(GLcontext *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb); - - -extern void -_mesa_insert_stencil(GLcontext *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb); - - -extern void -_mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb); - - -#endif /* DEPTHSTENCIL_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef DEPTHSTENCIL_H +#define DEPTHSTENCIL_H + +struct gl_context; + +extern struct gl_renderbuffer * +_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb); + + +extern struct gl_renderbuffer * +_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb); + + +extern void +_mesa_extract_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb); + + +extern void +_mesa_insert_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb); + + +extern void +_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb); + + +#endif /* DEPTHSTENCIL_H */ diff --git a/mesalib/src/mesa/main/dispatch.h b/mesalib/src/mesa/main/dispatch.h index 27f80a506..420d448c8 100644 --- a/mesalib/src/mesa/main/dispatch.h +++ b/mesalib/src/mesa/main/dispatch.h @@ -1,37 +1,37 @@ -/* - * (C) Copyright IBM Corporation 2005 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * IBM, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _DISPATCH_H -#define _DISPATCH_H - -#ifdef IN_DRI_DRIVER -#define _GLAPI_USE_REMAP_TABLE -#endif - -#include "glapi/glapitable.h" -#include "glapi/glapioffsets.h" -#include "glapi/glapidispatch.h" - -#endif /* _DISPATCH_H */ +/* + * (C) Copyright IBM Corporation 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _DISPATCH_H +#define _DISPATCH_H + +#include "main/mfeatures.h" + +#if FEATURE_remap_table +#define _GLAPI_USE_REMAP_TABLE +#endif + +#include "main/glapidispatch.h" + +#endif /* _DISPATCH_H */ diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index d847d4d5d..45517c994 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -1,10009 +1,10195 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file dlist.c - * Display lists management functions. - */ - -#include "glheader.h" -#include "imports.h" -#include "api_arrayelt.h" -#include "api_exec.h" -#include "api_loopback.h" -#if FEATURE_ATI_fragment_shader -#include "atifragshader.h" -#endif -#include "config.h" -#include "mfeatures.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "eval.h" -#include "framebuffer.h" -#include "glapi/glapi.h" -#include "hash.h" -#include "image.h" -#include "light.h" -#include "dlist.h" -#include "macros.h" -#include "queryobj.h" -#include "teximage.h" -#include "mtypes.h" -#include "varray.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif - -#include "math/m_matrix.h" - -#include "main/dispatch.h" - - - -/** - * Other parts of Mesa (such as the VBO module) can plug into the display - * list system. This structure describes new display list instructions. - */ -struct gl_list_instruction -{ - GLuint Size; - void (*Execute)( GLcontext *ctx, void *data ); - void (*Destroy)( GLcontext *ctx, void *data ); - void (*Print)( GLcontext *ctx, void *data ); -}; - - -#define MAX_DLIST_EXT_OPCODES 16 - -/** - * Used by device drivers to hook new commands into display lists. - */ -struct gl_list_extensions -{ - struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; - GLuint NumOpcodes; -}; - - - -/** - * Flush vertices. - * - * \param ctx GL context. - * - * Checks if dd_function_table::SaveNeedFlush is marked to flush - * stored (save) vertices, and calls - * dd_function_table::SaveFlushVertices if so. - */ -#define SAVE_FLUSH_VERTICES(ctx) \ -do { \ - if (ctx->Driver.SaveNeedFlush) \ - ctx->Driver.SaveFlushVertices(ctx); \ -} while (0) - - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - - - -/** - * Display list opcodes. - * - * The fact that these identifiers are assigned consecutive - * integer values starting at 0 is very important, see InstSize array usage) - */ -typedef enum -{ - OPCODE_INVALID = -1, /* Force signed enum */ - OPCODE_ACCUM, - OPCODE_ALPHA_FUNC, - OPCODE_BIND_TEXTURE, - OPCODE_BITMAP, - OPCODE_BLEND_COLOR, - OPCODE_BLEND_EQUATION, - OPCODE_BLEND_EQUATION_SEPARATE, - OPCODE_BLEND_FUNC_SEPARATE, - OPCODE_CALL_LIST, - OPCODE_CALL_LIST_OFFSET, - OPCODE_CLEAR, - OPCODE_CLEAR_ACCUM, - OPCODE_CLEAR_COLOR, - OPCODE_CLEAR_DEPTH, - OPCODE_CLEAR_INDEX, - OPCODE_CLEAR_STENCIL, - OPCODE_CLEAR_BUFFER_IV, - OPCODE_CLEAR_BUFFER_UIV, - OPCODE_CLEAR_BUFFER_FV, - OPCODE_CLEAR_BUFFER_FI, - OPCODE_CLIP_PLANE, - OPCODE_COLOR_MASK, - OPCODE_COLOR_MASK_INDEXED, - OPCODE_COLOR_MATERIAL, - OPCODE_COLOR_TABLE, - OPCODE_COLOR_TABLE_PARAMETER_FV, - OPCODE_COLOR_TABLE_PARAMETER_IV, - OPCODE_COLOR_SUB_TABLE, - OPCODE_CONVOLUTION_FILTER_1D, - OPCODE_CONVOLUTION_FILTER_2D, - OPCODE_CONVOLUTION_PARAMETER_I, - OPCODE_CONVOLUTION_PARAMETER_IV, - OPCODE_CONVOLUTION_PARAMETER_F, - OPCODE_CONVOLUTION_PARAMETER_FV, - OPCODE_COPY_COLOR_SUB_TABLE, - OPCODE_COPY_COLOR_TABLE, - OPCODE_COPY_PIXELS, - OPCODE_COPY_TEX_IMAGE1D, - OPCODE_COPY_TEX_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE1D, - OPCODE_COPY_TEX_SUB_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE3D, - OPCODE_CULL_FACE, - OPCODE_DEPTH_FUNC, - OPCODE_DEPTH_MASK, - OPCODE_DEPTH_RANGE, - OPCODE_DISABLE, - OPCODE_DISABLE_INDEXED, - OPCODE_DRAW_BUFFER, - OPCODE_DRAW_PIXELS, - OPCODE_ENABLE, - OPCODE_ENABLE_INDEXED, - OPCODE_EVALMESH1, - OPCODE_EVALMESH2, - OPCODE_FOG, - OPCODE_FRONT_FACE, - OPCODE_FRUSTUM, - OPCODE_HINT, - OPCODE_HISTOGRAM, - OPCODE_INDEX_MASK, - OPCODE_INIT_NAMES, - OPCODE_LIGHT, - OPCODE_LIGHT_MODEL, - OPCODE_LINE_STIPPLE, - OPCODE_LINE_WIDTH, - OPCODE_LIST_BASE, - OPCODE_LOAD_IDENTITY, - OPCODE_LOAD_MATRIX, - OPCODE_LOAD_NAME, - OPCODE_LOGIC_OP, - OPCODE_MAP1, - OPCODE_MAP2, - OPCODE_MAPGRID1, - OPCODE_MAPGRID2, - OPCODE_MATRIX_MODE, - OPCODE_MIN_MAX, - OPCODE_MULT_MATRIX, - OPCODE_ORTHO, - OPCODE_PASSTHROUGH, - OPCODE_PIXEL_MAP, - OPCODE_PIXEL_TRANSFER, - OPCODE_PIXEL_ZOOM, - OPCODE_POINT_SIZE, - OPCODE_POINT_PARAMETERS, - OPCODE_POLYGON_MODE, - OPCODE_POLYGON_STIPPLE, - OPCODE_POLYGON_OFFSET, - OPCODE_POP_ATTRIB, - OPCODE_POP_MATRIX, - OPCODE_POP_NAME, - OPCODE_PRIORITIZE_TEXTURE, - OPCODE_PUSH_ATTRIB, - OPCODE_PUSH_MATRIX, - OPCODE_PUSH_NAME, - OPCODE_RASTER_POS, - OPCODE_READ_BUFFER, - OPCODE_RESET_HISTOGRAM, - OPCODE_RESET_MIN_MAX, - OPCODE_ROTATE, - OPCODE_SCALE, - OPCODE_SCISSOR, - OPCODE_SELECT_TEXTURE_SGIS, - OPCODE_SELECT_TEXTURE_COORD_SET, - OPCODE_SHADE_MODEL, - OPCODE_STENCIL_FUNC, - OPCODE_STENCIL_MASK, - OPCODE_STENCIL_OP, - OPCODE_TEXENV, - OPCODE_TEXGEN, - OPCODE_TEXPARAMETER, - OPCODE_TEX_IMAGE1D, - OPCODE_TEX_IMAGE2D, - OPCODE_TEX_IMAGE3D, - OPCODE_TEX_SUB_IMAGE1D, - OPCODE_TEX_SUB_IMAGE2D, - OPCODE_TEX_SUB_IMAGE3D, - OPCODE_TRANSLATE, - OPCODE_VIEWPORT, - OPCODE_WINDOW_POS, - /* GL_ARB_multitexture */ - OPCODE_ACTIVE_TEXTURE, - /* GL_ARB_texture_compression */ - OPCODE_COMPRESSED_TEX_IMAGE_1D, - OPCODE_COMPRESSED_TEX_IMAGE_2D, - OPCODE_COMPRESSED_TEX_IMAGE_3D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, - /* GL_ARB_multisample */ - OPCODE_SAMPLE_COVERAGE, - /* GL_ARB_window_pos */ - OPCODE_WINDOW_POS_ARB, - /* GL_NV_vertex_program */ - OPCODE_BIND_PROGRAM_NV, - OPCODE_EXECUTE_PROGRAM_NV, - OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, - OPCODE_LOAD_PROGRAM_NV, - OPCODE_TRACK_MATRIX_NV, - /* GL_NV_fragment_program */ - OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, - OPCODE_PROGRAM_NAMED_PARAMETER_NV, - /* GL_EXT_stencil_two_side */ - OPCODE_ACTIVE_STENCIL_FACE_EXT, - /* GL_EXT_depth_bounds_test */ - OPCODE_DEPTH_BOUNDS_EXT, - /* GL_ARB_vertex/fragment_program */ - OPCODE_PROGRAM_STRING_ARB, - OPCODE_PROGRAM_ENV_PARAMETER_ARB, - /* GL_ARB_occlusion_query */ - OPCODE_BEGIN_QUERY_ARB, - OPCODE_END_QUERY_ARB, - /* GL_ARB_draw_buffers */ - OPCODE_DRAW_BUFFERS_ARB, - /* GL_ATI_fragment_shader */ - OPCODE_TEX_BUMP_PARAMETER_ATI, - /* GL_ATI_fragment_shader */ - OPCODE_BIND_FRAGMENT_SHADER_ATI, - OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, - /* OpenGL 2.0 */ - OPCODE_STENCIL_FUNC_SEPARATE, - OPCODE_STENCIL_OP_SEPARATE, - OPCODE_STENCIL_MASK_SEPARATE, - - /* GL_ARB_shader_objects */ - OPCODE_USE_PROGRAM, - OPCODE_UNIFORM_1F, - OPCODE_UNIFORM_2F, - OPCODE_UNIFORM_3F, - OPCODE_UNIFORM_4F, - OPCODE_UNIFORM_1FV, - OPCODE_UNIFORM_2FV, - OPCODE_UNIFORM_3FV, - OPCODE_UNIFORM_4FV, - OPCODE_UNIFORM_1I, - OPCODE_UNIFORM_2I, - OPCODE_UNIFORM_3I, - OPCODE_UNIFORM_4I, - OPCODE_UNIFORM_1IV, - OPCODE_UNIFORM_2IV, - OPCODE_UNIFORM_3IV, - OPCODE_UNIFORM_4IV, - OPCODE_UNIFORM_MATRIX22, - OPCODE_UNIFORM_MATRIX33, - OPCODE_UNIFORM_MATRIX44, - OPCODE_UNIFORM_MATRIX23, - OPCODE_UNIFORM_MATRIX32, - OPCODE_UNIFORM_MATRIX24, - OPCODE_UNIFORM_MATRIX42, - OPCODE_UNIFORM_MATRIX34, - OPCODE_UNIFORM_MATRIX43, - - /* OpenGL 3.0 */ - OPCODE_UNIFORM_1UI, - OPCODE_UNIFORM_2UI, - OPCODE_UNIFORM_3UI, - OPCODE_UNIFORM_4UI, - OPCODE_UNIFORM_1UIV, - OPCODE_UNIFORM_2UIV, - OPCODE_UNIFORM_3UIV, - OPCODE_UNIFORM_4UIV, - - /* GL_EXT_framebuffer_blit */ - OPCODE_BLIT_FRAMEBUFFER, - - /* Vertex attributes -- fallback for when optimized display - * list build isn't active. - */ - OPCODE_ATTR_1F_NV, - OPCODE_ATTR_2F_NV, - OPCODE_ATTR_3F_NV, - OPCODE_ATTR_4F_NV, - OPCODE_ATTR_1F_ARB, - OPCODE_ATTR_2F_ARB, - OPCODE_ATTR_3F_ARB, - OPCODE_ATTR_4F_ARB, - OPCODE_MATERIAL, - OPCODE_BEGIN, - OPCODE_END, - OPCODE_RECTF, - OPCODE_EVAL_C1, - OPCODE_EVAL_C2, - OPCODE_EVAL_P1, - OPCODE_EVAL_P2, - - /* GL_EXT_provoking_vertex */ - OPCODE_PROVOKING_VERTEX, - - /* GL_EXT_transform_feedback */ - OPCODE_BEGIN_TRANSFORM_FEEDBACK, - OPCODE_END_TRANSFORM_FEEDBACK, - - /* The following three are meta instructions */ - OPCODE_ERROR, /* raise compiled-in error */ - OPCODE_CONTINUE, - OPCODE_END_OF_LIST, - OPCODE_EXT_0 -} OpCode; - - - -/** - * Display list node. - * - * Display list instructions are stored as sequences of "nodes". Nodes - * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks - * are linked together with a pointer. - * - * Each instruction in the display list is stored as a sequence of - * contiguous nodes in memory. - * Each node is the union of a variety of data types. - */ -union gl_dlist_node -{ - OpCode opcode; - GLboolean b; - GLbitfield bf; - GLubyte ub; - GLshort s; - GLushort us; - GLint i; - GLuint ui; - GLenum e; - GLfloat f; - GLvoid *data; - void *next; /* If prev node's opcode==OPCODE_CONTINUE */ -}; - - -typedef union gl_dlist_node Node; - - -/** - * How many nodes to allocate at a time. - * - * \note Reduced now that we hold vertices etc. elsewhere. - */ -#define BLOCK_SIZE 256 - - - -/** - * Number of nodes of storage needed for each instruction. - * Sizes for dynamically allocated opcodes are stored in the context struct. - */ -static GLuint InstSize[OPCODE_END_OF_LIST + 1]; - - -#if FEATURE_dlist - - -void mesa_print_display_list(GLuint list); - - -/**********************************************************************/ -/***** Private *****/ -/**********************************************************************/ - - -/** - * Make an empty display list. This is used by glGenLists() to - * reserve display list IDs. - */ -static struct gl_display_list * -make_list(GLuint name, GLuint count) -{ - struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); - dlist->Name = name; - dlist->Head = (Node *) malloc(sizeof(Node) * count); - dlist->Head[0].opcode = OPCODE_END_OF_LIST; - return dlist; -} - - -/** - * Lookup function to just encapsulate casting. - */ -static INLINE struct gl_display_list * -lookup_list(GLcontext *ctx, GLuint list) -{ - return (struct gl_display_list *) - _mesa_HashLookup(ctx->Shared->DisplayList, list); -} - - -/** Is the given opcode an extension code? */ -static INLINE GLboolean -is_ext_opcode(OpCode opcode) -{ - return (opcode >= OPCODE_EXT_0); -} - - -/** Destroy an extended opcode instruction */ -static GLint -ext_opcode_destroy(GLcontext *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Execute an extended opcode instruction */ -static GLint -ext_opcode_execute(GLcontext *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Print an extended opcode instruction */ -static GLint -ext_opcode_print(GLcontext *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** - * Delete the named display list, but don't remove from hash table. - * \param dlist - display list pointer - */ -void -_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) -{ - Node *n, *block; - GLboolean done; - - n = block = dlist->Head; - - done = block ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - /* check for extension opcodes first */ - if (is_ext_opcode(opcode)) { - n += ext_opcode_destroy(ctx, n); - } - else { - switch (opcode) { - /* for some commands, we need to free malloc'd memory */ - case OPCODE_MAP1: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_MAP2: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_DRAW_PIXELS: - free(n[5].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_BITMAP: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_SUB_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_1D: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_2D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_POLYGON_STIPPLE: - free(n[1].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE1D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE3D: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_2D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_3D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; -#if FEATURE_NV_vertex_program - case OPCODE_LOAD_PROGRAM_NV: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - free(n[2].data); /* array of program ids */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - free(n[3].data); /* parameter name */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; -#endif - case OPCODE_UNIFORM_1FV: - case OPCODE_UNIFORM_2FV: - case OPCODE_UNIFORM_3FV: - case OPCODE_UNIFORM_4FV: - case OPCODE_UNIFORM_1IV: - case OPCODE_UNIFORM_2IV: - case OPCODE_UNIFORM_3IV: - case OPCODE_UNIFORM_4IV: - case OPCODE_UNIFORM_1UIV: - case OPCODE_UNIFORM_2UIV: - case OPCODE_UNIFORM_3UIV: - case OPCODE_UNIFORM_4UIV: - free(n[3].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_UNIFORM_MATRIX22: - case OPCODE_UNIFORM_MATRIX33: - case OPCODE_UNIFORM_MATRIX44: - case OPCODE_UNIFORM_MATRIX24: - case OPCODE_UNIFORM_MATRIX42: - case OPCODE_UNIFORM_MATRIX23: - case OPCODE_UNIFORM_MATRIX32: - case OPCODE_UNIFORM_MATRIX34: - case OPCODE_UNIFORM_MATRIX43: - free(n[4].data); - n += InstSize[n[0].opcode]; - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - free(block); - block = n; - break; - case OPCODE_END_OF_LIST: - free(block); - done = GL_TRUE; - break; - default: - /* Most frequent case */ - n += InstSize[n[0].opcode]; - break; - } - } - } - - free(dlist); -} - - -/** - * Destroy a display list and remove from hash table. - * \param list - display list number - */ -static void -destroy_list(GLcontext *ctx, GLuint list) -{ - struct gl_display_list *dlist; - - if (list == 0) - return; - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - _mesa_delete_list(ctx, dlist); - _mesa_HashRemove(ctx->Shared->DisplayList, list); -} - - -/* - * Translate the nth element of list from to GLint. - */ -static GLint -translate_id(GLsizei n, GLenum type, const GLvoid * list) -{ - GLbyte *bptr; - GLubyte *ubptr; - GLshort *sptr; - GLushort *usptr; - GLint *iptr; - GLuint *uiptr; - GLfloat *fptr; - - switch (type) { - case GL_BYTE: - bptr = (GLbyte *) list; - return (GLint) bptr[n]; - case GL_UNSIGNED_BYTE: - ubptr = (GLubyte *) list; - return (GLint) ubptr[n]; - case GL_SHORT: - sptr = (GLshort *) list; - return (GLint) sptr[n]; - case GL_UNSIGNED_SHORT: - usptr = (GLushort *) list; - return (GLint) usptr[n]; - case GL_INT: - iptr = (GLint *) list; - return iptr[n]; - case GL_UNSIGNED_INT: - uiptr = (GLuint *) list; - return (GLint) uiptr[n]; - case GL_FLOAT: - fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); - case GL_2_BYTES: - ubptr = ((GLubyte *) list) + 2 * n; - return (GLint) ubptr[0] * 256 - + (GLint) ubptr[1]; - case GL_3_BYTES: - ubptr = ((GLubyte *) list) + 3 * n; - return (GLint) ubptr[0] * 65536 - + (GLint) ubptr[1] * 256 - + (GLint) ubptr[2]; - case GL_4_BYTES: - ubptr = ((GLubyte *) list) + 4 * n; - return (GLint) ubptr[0] * 16777216 - + (GLint) ubptr[1] * 65536 - + (GLint) ubptr[2] * 256 - + (GLint) ubptr[3]; - default: - return 0; - } -} - - - - -/**********************************************************************/ -/***** Public *****/ -/**********************************************************************/ - -/** - * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. - * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. - */ -static GLvoid * -unpack_image(GLcontext *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *unpack) -{ - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); - if (pixels && !image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, pixels)) { - const GLubyte *map, *src; - GLvoid *image; - - map = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); - if (!map) { - /* unable to map src buffer! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); - return NULL; - } - - src = ADD_POINTERS(map, pixels); - image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, src, unpack); - - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - /* bad access! */ - return NULL; -} - - -/** - * Allocate space for a display list instruction (opcode + payload space). - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction payload size (not counting opcode) - * \return pointer to allocated memory (the opcode space) - */ -static Node * -dlist_alloc(GLcontext *ctx, OpCode opcode, GLuint bytes) -{ - const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); - Node *n; - - if (opcode < (GLuint) OPCODE_EXT_0) { - if (InstSize[opcode] == 0) { - /* save instruction size now */ - InstSize[opcode] = numNodes; - } - else { - /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); - } - } - - if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { - /* This block is full. Allocate a new block and chain to it */ - Node *newblock; - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - n[0].opcode = OPCODE_CONTINUE; - newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); - if (!newblock) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); - return NULL; - } - n[1].next = (Node *) newblock; - ctx->ListState.CurrentBlock = newblock; - ctx->ListState.CurrentPos = 0; - } - - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - ctx->ListState.CurrentPos += numNodes; - - n[0].opcode = opcode; - - return n; -} - - - -/** - * Allocate space for a display list instruction. Used by callers outside - * this file for things like VBO vertex data. - * - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction size in bytes, not counting opcode. - * \return pointer to the usable data area (not including the internal - * opcode). - */ -void * -_mesa_dlist_alloc(GLcontext *ctx, GLuint opcode, GLuint bytes) -{ - Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); - if (n) - return n + 1; /* return pointer to payload area, after opcode */ - else - return NULL; -} - - -/** - * This function allows modules and drivers to get their own opcodes - * for extending display list functionality. - * \param ctx the rendering context - * \param size number of bytes for storing the new display list command - * \param execute function to execute the new display list command - * \param destroy function to destroy the new display list command - * \param print function to print the new display list command - * \return the new opcode number or -1 if error - */ -GLint -_mesa_dlist_alloc_opcode(GLcontext *ctx, - GLuint size, - void (*execute) (GLcontext *, void *), - void (*destroy) (GLcontext *, void *), - void (*print) (GLcontext *, void *)) -{ - if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { - const GLuint i = ctx->ListExt->NumOpcodes++; - ctx->ListExt->Opcode[i].Size = - 1 + (size + sizeof(Node) - 1) / sizeof(Node); - ctx->ListExt->Opcode[i].Execute = execute; - ctx->ListExt->Opcode[i].Destroy = destroy; - ctx->ListExt->Opcode[i].Print = print; - return i + OPCODE_EXT_0; - } - return -1; -} - - -/** - * Allocate space for a display list instruction. The space is basically - * an array of Nodes where node[0] holds the opcode, node[1] is the first - * function parameter, node[2] is the second parameter, etc. - * - * \param opcode one of OPCODE_x - * \param nparams number of function parameters - * \return pointer to start of instruction space - */ -static INLINE Node * -alloc_instruction(GLcontext *ctx, OpCode opcode, GLuint nparams) -{ - return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); -} - - - -/* - * Display List compilation functions - */ -static void GLAPIENTRY -save_Accum(GLenum op, GLfloat value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACCUM, 2); - if (n) { - n[1].e = op; - n[2].f = value; - } - if (ctx->ExecuteFlag) { - CALL_Accum(ctx->Exec, (op, value)); - } -} - - -static void GLAPIENTRY -save_AlphaFunc(GLenum func, GLclampf ref) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); - if (n) { - n[1].e = func; - n[2].f = (GLfloat) ref; - } - if (ctx->ExecuteFlag) { - CALL_AlphaFunc(ctx->Exec, (func, ref)); - } -} - - -static void GLAPIENTRY -save_BindTexture(GLenum target, GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); - if (n) { - n[1].e = target; - n[2].ui = texture; - } - if (ctx->ExecuteFlag) { - CALL_BindTexture(ctx->Exec, (target, texture)); - } -} - - -static void GLAPIENTRY -save_Bitmap(GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, const GLubyte * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BITMAP, 7); - if (n) { - n[1].i = (GLint) width; - n[2].i = (GLint) height; - n[3].f = xorig; - n[4].f = yorig; - n[5].f = xmove; - n[6].f = ymove; - n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_Bitmap(ctx->Exec, (width, height, - xorig, yorig, xmove, ymove, pixels)); - } -} - - -static void GLAPIENTRY -save_BlendEquation(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquation(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); - if (n) { - n[1].e = modeRGB; - n[2].e = modeA; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); - } -} - - -static void GLAPIENTRY -save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); - if (n) { - n[1].e = sfactorRGB; - n[2].e = dfactorRGB; - n[3].e = sfactorA; - n[4].e = dfactorA; - } - if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateEXT(ctx->Exec, - (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); - } -} - - -static void GLAPIENTRY -save_BlendFunc(GLenum srcfactor, GLenum dstfactor) -{ - save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); -} - - -static void GLAPIENTRY -save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); - } -} - -static void invalidate_saved_current_state( GLcontext *ctx ) -{ - GLint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - ctx->ListState.ActiveAttribSize[i] = 0; - - for (i = 0; i < MAT_ATTRIB_MAX; i++) - ctx->ListState.ActiveMaterialSize[i] = 0; - - memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - -static void GLAPIENTRY -save_CallList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); - if (n) { - n[1].ui = list; - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - _mesa_CallList(list); - } -} - - -static void GLAPIENTRY -save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean typeErrorFlag; - - SAVE_FLUSH_VERTICES(ctx); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - typeErrorFlag = GL_FALSE; - break; - default: - typeErrorFlag = GL_TRUE; - } - - for (i = 0; i < num; i++) { - GLint list = translate_id(i, type, lists); - Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); - if (n) { - n[1].i = list; - n[2].b = typeErrorFlag; - } - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - CALL_CallLists(ctx->Exec, (num, type, lists)); - } -} - - -static void GLAPIENTRY -save_Clear(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_Clear(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].i = value[0]; - if (buffer == GL_COLOR) { - n[4].i = value[1]; - n[5].i = value[2]; - n[6].i = value[3]; - } - else { - n[4].i = 0; - n[5].i = 0; - n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].ui = value[0]; - if (buffer == GL_COLOR) { - n[4].ui = value[1]; - n[5].ui = value[2]; - n[6].ui = value[3]; - } - else { - n[4].ui = 0; - n[5].ui = 0; - n[6].ui = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = value[0]; - if (buffer == GL_COLOR) { - n[4].f = value[1]; - n[5].f = value[2]; - n[6].f = value[3]; - } - else { - n[4].f = 0.0F; - n[5].f = 0.0F; - n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = depth; - n[4].i = stencil; - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ - } -} - - -static void GLAPIENTRY -save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearDepth(GLclampd depth) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); - if (n) { - n[1].f = (GLfloat) depth; - } - if (ctx->ExecuteFlag) { - CALL_ClearDepth(ctx->Exec, (depth)); - } -} - - -static void GLAPIENTRY -save_ClearIndex(GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); - if (n) { - n[1].f = c; - } - if (ctx->ExecuteFlag) { - CALL_ClearIndex(ctx->Exec, (c)); - } -} - - -static void GLAPIENTRY -save_ClearStencil(GLint s) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); - if (n) { - n[1].i = s; - } - if (ctx->ExecuteFlag) { - CALL_ClearStencil(ctx->Exec, (s)); - } -} - - -static void GLAPIENTRY -save_ClipPlane(GLenum plane, const GLdouble * equ) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); - if (n) { - n[1].e = plane; - n[2].f = (GLfloat) equ[0]; - n[3].f = (GLfloat) equ[1]; - n[4].f = (GLfloat) equ[2]; - n[5].f = (GLfloat) equ[3]; - } - if (ctx->ExecuteFlag) { - CALL_ClipPlane(ctx->Exec, (plane, equ)); - } -} - - - -static void GLAPIENTRY -save_ColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); - if (n) { - n[1].b = red; - n[2].b = green; - n[3].b = blue; - n[4].b = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); - if (n) { - n[1].ui = buf; - n[2].b = red; - n[3].b = green; - n[4].b = blue; - n[5].b = alpha; - } - if (ctx->ExecuteFlag) { - /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ - } -} - - -static void GLAPIENTRY -save_ColorMaterial(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ColorMaterial(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_ColorTable(GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - if (_mesa_is_proxy_texture(target)) { - /* execute immediately */ - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - } -} - - - -static void GLAPIENTRY -save_ColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); - } -} - - - -static void GLAPIENTRY -save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = count; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorSubTable(ctx->Exec, - (target, start, count, format, type, table)); - } -} - - -static void GLAPIENTRY -save_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyColorTable(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); - if (n) { - n[1].e = target; - n[2].e = internalformat; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, - GLenum format, GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, - format, type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].i = height; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - else { - n[4].i = n[5].i = n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - n[5].e = type; - } - if (ctx->ExecuteFlag) { - CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); - } -} - - - -static void GLAPIENTRY -save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, - x, y, width, border)); - } -} - - -static void GLAPIENTRY -save_CopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = height; - n[8].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, - x, y, width, height, border)); - } -} - - - -static void GLAPIENTRY -save_CopyTexSubImage1D(GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = x; - n[5].i = y; - n[6].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage1D(ctx->Exec, - (target, level, xoffset, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = x; - n[6].i = y; - n[7].i = width; - n[8].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = x; - n[7].i = y; - n[8].i = width; - n[9].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CullFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_CullFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DepthFunc(GLenum func) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); - if (n) { - n[1].e = func; - } - if (ctx->ExecuteFlag) { - CALL_DepthFunc(ctx->Exec, (func)); - } -} - - -static void GLAPIENTRY -save_DepthMask(GLboolean mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); - if (n) { - n[1].b = mask; - } - if (ctx->ExecuteFlag) { - CALL_DepthMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); - if (n) { - n[1].f = (GLfloat) nearval; - n[2].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_DepthRange(ctx->Exec, (nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Disable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Disable(ctx->Exec, (cap)); - } -} - - -static void GLAPIENTRY -save_DisableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - -static void GLAPIENTRY -save_DrawBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DrawPixels(GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); - if (n) { - n[1].i = width; - n[2].i = height; - n[3].e = format; - n[4].e = type; - n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); - } -} - - - -static void GLAPIENTRY -save_Enable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Enable(ctx->Exec, (cap)); - } -} - - - -static void GLAPIENTRY -save_EnableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - - -static void GLAPIENTRY -save_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); - } -} - - -static void GLAPIENTRY -save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - n[4].i = j1; - n[5].i = j2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); - } -} - - - - -static void GLAPIENTRY -save_Fogfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FOG, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_Fogfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_Fogf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Fogfv(pname, parray); -} - - -static void GLAPIENTRY -save_Fogiv(GLenum pname, const GLint *params) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - p[0] = (GLfloat) *params; - p[1] = 0.0f; - p[2] = 0.0f; - p[3] = 0.0f; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT(params[0]); - p[1] = INT_TO_FLOAT(params[1]); - p[2] = INT_TO_FLOAT(params[2]); - p[3] = INT_TO_FLOAT(params[3]); - break; - default: - /* Error will be caught later in gl_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_Fogfv(pname, p); -} - - -static void GLAPIENTRY -save_Fogi(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Fogiv(pname, parray); -} - - -static void GLAPIENTRY -save_FrontFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_FrontFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Frustum(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Hint(GLenum target, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HINT, 2); - if (n) { - n[1].e = target; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_Hint(ctx->Exec, (target, mode)); - } -} - - -static void GLAPIENTRY -save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, - GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); - if (n) { - n[1].e = target; - n[2].i = width; - n[3].e = internalFormat; - n[4].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_IndexMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_IndexMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_InitNames(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); - if (ctx->ExecuteFlag) { - CALL_InitNames(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT, 6); - if (n) { - GLint i, nParams; - n[1].e = light; - n[2].e = pname; - switch (pname) { - case GL_AMBIENT: - nParams = 4; - break; - case GL_DIFFUSE: - nParams = 4; - break; - case GL_SPECULAR: - nParams = 4; - break; - case GL_POSITION: - nParams = 4; - break; - case GL_SPOT_DIRECTION: - nParams = 3; - break; - case GL_SPOT_EXPONENT: - nParams = 1; - break; - case GL_SPOT_CUTOFF: - nParams = 1; - break; - case GL_CONSTANT_ATTENUATION: - nParams = 1; - break; - case GL_LINEAR_ATTENUATION: - nParams = 1; - break; - case GL_QUADRATIC_ATTENUATION: - nParams = 1; - break; - default: - nParams = 0; - } - for (i = 0; i < nParams; i++) { - n[3 + i].f = params[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_Lightfv(ctx->Exec, (light, pname, params)); - } -} - - -static void GLAPIENTRY -save_Lightf(GLenum light, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Lightfv(light, pname, parray); -} - - -static void GLAPIENTRY -save_Lightiv(GLenum light, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - save_Lightfv(light, pname, fparam); -} - - -static void GLAPIENTRY -save_Lighti(GLenum light, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Lightiv(light, pname, parray); -} - - -static void GLAPIENTRY -save_LightModelfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_LightModelfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_LightModelf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_LightModelfv(pname, parray); -} - - -static void GLAPIENTRY -save_LightModeliv(GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - fparam[1] = 0.0F; - fparam[2] = 0.0F; - fparam[3] = 0.0F; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_LightModelfv(pname, fparam); -} - - -static void GLAPIENTRY -save_LightModeli(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_LightModeliv(pname, parray); -} - - -static void GLAPIENTRY -save_LineStipple(GLint factor, GLushort pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); - if (n) { - n[1].i = factor; - n[2].us = pattern; - } - if (ctx->ExecuteFlag) { - CALL_LineStipple(ctx->Exec, (factor, pattern)); - } -} - - -static void GLAPIENTRY -save_LineWidth(GLfloat width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); - if (n) { - n[1].f = width; - } - if (ctx->ExecuteFlag) { - CALL_LineWidth(ctx->Exec, (width)); - } -} - - -static void GLAPIENTRY -save_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); - if (n) { - n[1].ui = base; - } - if (ctx->ExecuteFlag) { - CALL_ListBase(ctx->Exec, (base)); - } -} - - -static void GLAPIENTRY -save_LoadIdentity(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); - if (ctx->ExecuteFlag) { - CALL_LoadIdentity(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_LoadMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_LoadMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_LoadMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_LoadMatrixf(f); -} - - -static void GLAPIENTRY -save_LoadName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_LoadName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_LogicOp(GLenum opcode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); - if (n) { - n[1].e = opcode; - } - if (ctx->ExecuteFlag) { - CALL_LogicOp(ctx->Exec, (opcode)); - } -} - - -static void GLAPIENTRY -save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - -static void GLAPIENTRY -save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - - -static void GLAPIENTRY -save_Map2d(GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].f = (GLfloat) v1; - n[5].f = (GLfloat) v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2d(ctx->Exec, (target, - u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_Map2f(GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].f = v1; - n[5].f = v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); - } -} - - -static void GLAPIENTRY -save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) -{ - save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); -} - - -static void GLAPIENTRY -save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - n[4].i = vn; - n[5].f = v1; - n[6].f = v2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); - } -} - - - -static void GLAPIENTRY -save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2) -{ - save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2); -} - - -static void GLAPIENTRY -save_MatrixMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_MatrixMode(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_MultMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_MultMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_MultMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_MultMatrixf(f); -} - - -static void GLAPIENTRY -save_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - /* It's an error to call this function while building a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - (void) name; - (void) mode; -} - - - -static void GLAPIENTRY -save_Ortho(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ORTHO, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); - if (n) { - n[1].e = map; - n[2].i = mapsize; - n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); - memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); - } -} - - -static void GLAPIENTRY -save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelTransferf(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); - if (n) { - n[1].e = pname; - n[2].f = param; - } - if (ctx->ExecuteFlag) { - CALL_PixelTransferf(ctx->Exec, (pname, param)); - } -} - - -static void GLAPIENTRY -save_PixelTransferi(GLenum pname, GLint param) -{ - save_PixelTransferf(pname, (GLfloat) param); -} - - -static void GLAPIENTRY -save_PixelZoom(GLfloat xfactor, GLfloat yfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); - if (n) { - n[1].f = xfactor; - n[2].f = yfactor; - } - if (ctx->ExecuteFlag) { - CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); - } -} - - -static void GLAPIENTRY -save_PointParameterfvEXT(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - } - if (ctx->ExecuteFlag) { - CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_PointParameterfEXT(GLenum pname, GLfloat param) -{ - GLfloat parray[3]; - parray[0] = param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameteriNV(GLenum pname, GLint param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameterivNV(GLenum pname, const GLint * param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param[0]; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - - -static void GLAPIENTRY -save_PointSize(GLfloat size) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); - if (n) { - n[1].f = size; - } - if (ctx->ExecuteFlag) { - CALL_PointSize(ctx->Exec, (size)); - } -} - - -static void GLAPIENTRY -save_PolygonMode(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_PolygonMode(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_PolygonStipple(const GLubyte * pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); - if (n) { - n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - pattern, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); - } -} - - -static void GLAPIENTRY -save_PolygonOffset(GLfloat factor, GLfloat units) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); - if (n) { - n[1].f = factor; - n[2].f = units; - } - if (ctx->ExecuteFlag) { - CALL_PolygonOffset(ctx->Exec, (factor, units)); - } -} - - -static void GLAPIENTRY -save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); -} - - -static void GLAPIENTRY -save_PopAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); - if (ctx->ExecuteFlag) { - CALL_PopAttrib(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PopMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopName(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); - if (ctx->ExecuteFlag) { - CALL_PopName(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PrioritizeTextures(GLsizei num, const GLuint * textures, - const GLclampf * priorities) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < num; i++) { - Node *n; - n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); - if (n) { - n[1].ui = textures[i]; - n[2].f = priorities[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); - } -} - - -static void GLAPIENTRY -save_PushAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_PushAttrib(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_PushMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PushMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PushName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_PushName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_RasterPos2d(GLdouble x, GLdouble y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2f(GLfloat x, GLfloat y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2i(GLint x, GLint y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2s(GLshort x, GLshort y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3i(GLint x, GLint y, GLint z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_RasterPos4f(x, y, z, w); -} - -static void GLAPIENTRY -save_RasterPos2dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_RasterPos4iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_PassThrough(GLfloat token) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); - if (n) { - n[1].f = token; - } - if (ctx->ExecuteFlag) { - CALL_PassThrough(ctx->Exec, (token)); - } -} - - -static void GLAPIENTRY -save_ReadBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ReadBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_ResetHistogram(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetHistogram(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_ResetMinmax(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetMinmax(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ROTATE, 4); - if (n) { - n[1].f = angle; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Rotatef(ctx->Exec, (angle, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) -{ - save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scalef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCALE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Scalef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Scaled(GLdouble x, GLdouble y, GLdouble z) -{ - save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = width; - n[4].i = height; - } - if (ctx->ExecuteFlag) { - CALL_Scissor(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_ShadeModel(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); - - if (ctx->ExecuteFlag) { - CALL_ShadeModel(ctx->Exec, (mode)); - } - - if (ctx->ListState.Current.ShadeModel == mode) - return; - - SAVE_FLUSH_VERTICES(ctx); - - /* Only save the value if we know the statechange will take effect: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) - ctx->ListState.Current.ShadeModel = mode; - - n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); - if (n) { - n[1].e = mode; - } -} - - -static void GLAPIENTRY -save_StencilFunc(GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); - if (n) { - n[1].e = func; - n[2].i = ref; - n[3].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFunc(ctx->Exec, (func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); - if (n) { - n[1].e = fail; - n[2].e = zfail; - n[3].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = func; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, - GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* GL_FRONT */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_FRONT; - n[2].e = frontfunc; - n[3].i = ref; - n[4].ui = mask; - } - /* GL_BACK */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_BACK; - n[2].e = backfunc; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); - CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMaskSeparate(GLenum face, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); - if (n) { - n[1].e = face; - n[2].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); - } -} - - -static void GLAPIENTRY -save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = fail; - n[3].e = zfail; - n[4].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXENV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - if (pname == GL_TEXTURE_ENV_COLOR) { - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[3].f = params[0]; - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_TexEnvfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexEnvf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexEnvfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexEnvi(GLenum target, GLenum pname, GLint param) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexEnviv(GLenum target, GLenum pname, const GLint * param) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; - } - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); - if (n) { - n[1].e = coord; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexGenfv(ctx->Exec, (coord, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGend(GLenum coord, GLenum pname, GLdouble param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGeni(GLenum coord, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_TexGeniv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexParameterfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) params[0]; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexImage1D(GLenum target, - GLint level, GLint components, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = border; - n[6].e = format; - n[7].e = type; - n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage2D(GLenum target, - GLint level, GLint components, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage3D(GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = (GLint) internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].e = format; - n[9].e = type; - n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, - format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - width, height, format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].e = type; - n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - width, height, depth, format, type, - pixels)); - } -} - - -static void GLAPIENTRY -save_Translatef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Translatef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Translated(GLdouble x, GLdouble y, GLdouble z) -{ - save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - - -static void GLAPIENTRY -save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - } - if (ctx->ExecuteFlag) { - CALL_Viewport(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2iMESA(GLint x, GLint y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2sMESA(GLshort x, GLshort y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_WindowPos4fMESA(x, y, z, w); -} - -static void GLAPIENTRY -save_WindowPos2dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_WindowPos4ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - - - -/* GL_ARB_multitexture */ -static void GLAPIENTRY -save_ActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ActiveTextureARB(ctx->Exec, (target)); - } -} - - -/* GL_ARB_transpose_matrix */ - -static void GLAPIENTRY -save_LoadTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_LoadTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_MultMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_MultMatrixf(tm); -} - - -/* GL_ARB_texture_compression */ -static void GLAPIENTRY -save_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, - width, border, imageSize, - data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = border; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage1DARB(ctx->Exec, - (target, level, internalFormat, width, - border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, - width, height, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].i = imageSize; - n[8].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage2DARB(ctx->Exec, - (target, level, internalFormat, width, - height, border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, - width, height, depth, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage3DARB(ctx->Exec, - (target, level, internalFormat, width, - height, depth, border, imageSize, - data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, - width, format, imageSize, - data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage2DARB(ctx->Exec, - (target, level, xoffset, yoffset, width, - height, format, imageSize, data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].i = imageSize; - n[11].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage3DARB(ctx->Exec, - (target, level, xoffset, yoffset, - zoffset, width, height, depth, format, - imageSize, data)); - } -} - - -/* GL_ARB_multisample */ -static void GLAPIENTRY -save_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); - if (n) { - n[1].f = value; - n[2].b = invert; - } - if (ctx->ExecuteFlag) { - CALL_SampleCoverageARB(ctx->Exec, (value, invert)); - } -} - - -/* - * GL_NV_vertex_program - */ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -static void GLAPIENTRY -save_BindProgramNV(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindProgramNV(ctx->Exec, (target, id)); - } -} - -static void GLAPIENTRY -save_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - save_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -static void GLAPIENTRY -save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat * params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) x, - (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) params[0], - (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ - -#if FEATURE_NV_vertex_program -static void GLAPIENTRY -save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); - if (n) { - n[1].e = target; - n[2].ui = id; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4dvNV(GLenum target, GLuint index, - GLuint num, const GLdouble *params) -{ - GLuint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4fvNV(GLenum target, GLuint index, - GLuint num, const GLfloat *params) -{ - GLuint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte * program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programCopy, program, len); - n[1].e = target; - n[2].ui = id; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); - } -} - - -static void GLAPIENTRY -save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); - if (n) { - GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); - if (!idCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); - return; - } - memcpy(idCopy, ids, num * sizeof(GLuint)); - n[1].i = num; - n[2].data = idCopy; - } - if (ctx->ExecuteFlag) { - CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); - } -} - - -static void GLAPIENTRY -save_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); - if (n) { - n[1].e = target; - n[2].ui = address; - n[3].e = matrix; - n[4].e = transform; - } - if (ctx->ExecuteFlag) { - CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); - } -} -#endif /* FEATURE_NV_vertex_program */ - - -/* - * GL_NV_fragment_program - */ -#if FEATURE_NV_fragment_program -static void GLAPIENTRY -save_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) x; - n[4].f = (GLfloat) y; - n[5].f = (GLfloat) z; - n[6].f = (GLfloat) w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) params[0]; - n[4].f = (GLfloat) params[1]; - n[5].f = (GLfloat) params[2]; - n[6].f = (GLfloat) params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); - } -} - -static void GLAPIENTRY -save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); - if (n) { - GLubyte *nameCopy = (GLubyte *) malloc(len); - if (!nameCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); - return; - } - memcpy(nameCopy, name, len); - n[1].ui = id; - n[2].i = len; - n[3].data = nameCopy; - n[4].f = x; - n[5].f = y; - n[6].f = z; - n[7].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, - const float v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, - const double v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], - (GLfloat) v[1], (GLfloat) v[2], - (GLfloat) v[3]); -} - -#endif /* FEATURE_NV_fragment_program */ - - - -/* GL_EXT_stencil_two_side */ -static void GLAPIENTRY -save_ActiveStencilFaceEXT(GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); - if (n) { - n[1].e = face; - } - if (ctx->ExecuteFlag) { - CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); - } -} - - -/* GL_EXT_depth_bounds_test */ -static void GLAPIENTRY -save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); - if (n) { - n[1].f = (GLfloat) zmin; - n[2].f = (GLfloat) zmax; - } - if (ctx->ExecuteFlag) { - CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); - } -} - - - -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - -static void GLAPIENTRY -save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid * string) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return; - } - memcpy(programCopy, string, len); - n[1].e = target; - n[2].e = format; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); - } -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ - - -#if FEATURE_queryobj - -static void GLAPIENTRY -save_BeginQueryARB(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BeginQueryARB(ctx->Exec, (target, id)); - } -} - - -static void GLAPIENTRY -save_EndQueryARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_EndQueryARB(ctx->Exec, (target)); - } -} - -#endif /* FEATURE_queryobj */ - - -static void GLAPIENTRY -save_DrawBuffersARB(GLsizei count, const GLenum * buffers) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); - if (n) { - GLint i; - n[1].i = count; - if (count > MAX_DRAW_BUFFERS) - count = MAX_DRAW_BUFFERS; - for (i = 0; i < count; i++) { - n[2 + i].e = buffers[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); - if (n) { - n[1].ui = pname; - n[2].f = param[0]; - n[3].f = param[1]; - n[4].f = param[2]; - n[5].f = param[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterivATI(GLenum pname, const GLint *param) -{ - GLfloat p[4]; - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - save_TexBumpParameterfvATI(pname, p); -} - -#if FEATURE_ATI_fragment_shader -static void GLAPIENTRY -save_BindFragmentShaderATI(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); - if (n) { - n[1].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindFragmentShaderATI(ctx->Exec, (id)); - } -} - -static void GLAPIENTRY -save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); - if (n) { - n[1].ui = dst; - n[2].f = value[0]; - n[3].f = value[1]; - n[4].f = value[2]; - n[5].f = value[3]; - } - if (ctx->ExecuteFlag) { - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); - } -} -#endif - -static void -save_Attr1fNV(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); - } -} - -static void -save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); - } -} - -static void -save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); - } -} - -static void -save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void -save_Attr1fARB(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); - } -} - -static void -save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); - } -} - -static void -save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); - } -} - -static void -save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_EvalCoord1f(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); - if (n) { - n[1].f = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord1f(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalCoord1fv(const GLfloat * v) -{ - save_EvalCoord1f(v[0]); -} - -static void GLAPIENTRY -save_EvalCoord2f(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); - if (n) { - n[1].f = x; - n[2].f = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord2f(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_EvalCoord2fv(const GLfloat * v) -{ - save_EvalCoord2f(v[0], v[1]); -} - - -static void GLAPIENTRY -save_EvalPoint1(GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); - if (n) { - n[1].i = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint1(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalPoint2(GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); - if (n) { - n[1].i = x; - n[2].i = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint2(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_Indexf(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); -} - -static void GLAPIENTRY -save_Indexfv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); -} - -static void GLAPIENTRY -save_EdgeFlag(GLboolean x) -{ - save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); -} - -static INLINE GLboolean compare4fv( const GLfloat *a, - const GLfloat *b, - GLuint count ) -{ - return memcmp( a, b, count * sizeof(GLfloat) ) == 0; -} - - -static void GLAPIENTRY -save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - int args, i; - GLuint bitmask; - - switch (face) { - case GL_BACK: - case GL_FRONT: - case GL_FRONT_AND_BACK: - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_AMBIENT_AND_DIFFUSE: - args = 4; - break; - case GL_SHININESS: - args = 1; - break; - case GL_COLOR_INDEXES: - args = 3; - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); - return; - } - - if (ctx->ExecuteFlag) { - CALL_Materialfv(ctx->Exec, (face, pname, param)); - } - - bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - - /* Try to eliminate redundant statechanges. Because it is legal to - * call glMaterial even inside begin/end calls, don't need to worry - * about ctx->Driver.CurrentSavePrimitive here. - */ - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - if (bitmask & (1 << i)) { - if (ctx->ListState.ActiveMaterialSize[i] == args && - compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { - bitmask &= ~(1 << i); - } - else { - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); - } - } - } - - /* If this call has effect, return early: - */ - if (bitmask == 0) - return; - - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); - if (n) { - n[1].e = face; - n[2].e = pname; - for (i = 0; i < args; i++) - n[3 + i].f = param[i]; - } -} - -static void GLAPIENTRY -save_Begin(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - GLboolean error = GL_FALSE; - - if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { - _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); - error = GL_TRUE; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { - /* Typically the first begin. This may raise an error on - * playback, depending on whether CallList is issued from inside - * a begin/end or not. - */ - ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentSavePrimitive = mode; - } - else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } - - if (!error) { - /* Give the driver an opportunity to hook in an optimized - * display list compiler. - */ - if (ctx->Driver.NotifySaveBegin(ctx, mode)) - return; - - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN, 1); - if (n) { - n[1].e = mode; - } - } - - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); - } -} - -static void GLAPIENTRY -save_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - (void) alloc_instruction(ctx, OPCODE_END, 0); - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - if (ctx->ExecuteFlag) { - CALL_End(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_RECTF, 4); - if (n) { - n[1].f = a; - n[2].f = b; - n[3].f = c; - n[4].f = d; - } - if (ctx->ExecuteFlag) { - CALL_Rectf(ctx->Exec, (a, b, c, d)); - } -} - - -static void GLAPIENTRY -save_Vertex2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_POS, x, y); -} - -static void GLAPIENTRY -save_Vertex2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); -} - -static void GLAPIENTRY -save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); -} - -static void GLAPIENTRY -save_Vertex3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); -} - -static void GLAPIENTRY -save_Vertex4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_TexCoord1f(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, x); -} - -static void GLAPIENTRY -save_TexCoord1fv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); -} - -static void GLAPIENTRY -save_TexCoord2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); -} - -static void GLAPIENTRY -save_TexCoord2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); -} - -static void GLAPIENTRY -save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); -} - -static void GLAPIENTRY -save_TexCoord3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); -} - -static void GLAPIENTRY -save_TexCoord4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); -} - -static void GLAPIENTRY -save_Normal3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_FogCoordfEXT(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, x); -} - -static void GLAPIENTRY -save_FogCoordfvEXT(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); -} - -static void GLAPIENTRY -save_Color3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); -} - -static void GLAPIENTRY -save_Color3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); -} - -static void GLAPIENTRY -save_Color4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); -} - -static void GLAPIENTRY -save_SecondaryColor3fvEXT(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); -} - - -/* Just call the respective ATTR for texcoord - */ -static void GLAPIENTRY -save_MultiTexCoord1f(GLenum target, GLfloat x) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, x); -} - -static void GLAPIENTRY -save_MultiTexCoord1fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, v[0]); -} - -static void GLAPIENTRY -save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, x, y); -} - -static void GLAPIENTRY -save_MultiTexCoord2fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, v[0], v[1]); -} - -static void GLAPIENTRY -save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, x, y, z); -} - -static void GLAPIENTRY -save_MultiTexCoord3fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, x, y, z, w); -} - -static void GLAPIENTRY -save_MultiTexCoord4fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); -} - - -/** - * Record a GL_INVALID_VALUE error when a invalid vertex attribute - * index is found. - */ -static void -index_error(void) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); -} - - -/* First level for NV_vertex_program: - * - * Check for errors at compile time?. - */ -static void GLAPIENTRY -save_VertexAttrib1fNV(GLuint index, GLfloat x) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - - - -static void GLAPIENTRY -save_VertexAttrib1fARB(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - -/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - -static void GLAPIENTRY -exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); -} - -static GLint GLAPIENTRY -exec_GetAttribLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); -} - -static GLint GLAPIENTRY -exec_GetUniformLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); -} -/* XXX more shader functions needed here */ - - -#if FEATURE_EXT_framebuffer_blit -static void GLAPIENTRY -save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); - if (n) { - n[1].i = srcX0; - n[2].i = srcY0; - n[3].i = srcX1; - n[4].i = srcY1; - n[5].i = dstX0; - n[6].i = dstY0; - n[7].i = dstX1; - n[8].i = dstY1; - n[9].i = mask; - n[10].e = filter; - } - if (ctx->ExecuteFlag) { - CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter)); - } -} -#endif - - -/** GL_EXT_provoking_vertex */ -static void GLAPIENTRY -save_ProvokingVertexEXT(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ - _mesa_ProvokingVertexEXT(mode); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_BeginTransformFeedback(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_EndTransformFeedback(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); - if (ctx->ExecuteFlag) { - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); - } -} - - -/* aka UseProgram() */ -static void GLAPIENTRY -save_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseProgramObjectARB(ctx->Exec, (program)); - } -} - - -static void GLAPIENTRY -save_Uniform1fARB(GLint location, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); - if (n) { - n[1].i = location; - n[2].f = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fARB(ctx->Exec, (location, x)); - } -} - - -static void GLAPIENTRY -save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fARB(ctx->Exec, (location, x, y)); - } -} - - -static void GLAPIENTRY -save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); - } -} - - -/** Return copy of memory */ -static void * -memdup(const void *src, GLsizei bytes) -{ - void *b = bytes >= 0 ? malloc(bytes) : NULL; - if (b) - memcpy(b, src, bytes); - return b; -} - - -static void GLAPIENTRY -save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); - } -} - - -static void GLAPIENTRY -save_Uniform1iARB(GLint location, GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1iARB(ctx->Exec, (location, x)); - } -} - -static void GLAPIENTRY -save_Uniform2iARB(GLint location, GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2iARB(ctx->Exec, (location, x, y)); - } -} - -static void GLAPIENTRY -save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); - } -} - -static void GLAPIENTRY -save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ui(GLint location, GLuint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ - } -} - -static void GLAPIENTRY -save_Uniform2ui(GLint location, GLuint x, GLuint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ - } -} - -static void GLAPIENTRY -save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ - } -} - -static void GLAPIENTRY -save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ - } -} - - - -static void GLAPIENTRY -save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ - } -} - - - -static void GLAPIENTRY -save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - - - -/** - * 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(GLcontext *ctx, GLenum error, const char *s) -{ - Node *n; - n = alloc_instruction(ctx, OPCODE_ERROR, 2); - if (n) { - n[1].e = error; - n[2].data = (void *) s; - } -} - - -/** - * Compile an error into current display list. - */ -void -_mesa_compile_error(GLcontext *ctx, GLenum error, const char *s) -{ - if (ctx->CompileFlag) - save_error(ctx, error, s); - if (ctx->ExecuteFlag) - _mesa_error(ctx, error, "%s", s); -} - - -/** - * Test if ID names a display list. - */ -static GLboolean -islist(GLcontext *ctx, GLuint list) -{ - if (list > 0 && lookup_list(ctx, list)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/**********************************************************************/ -/* Display list execution */ -/**********************************************************************/ - - -/* - * Execute a display list. Note that the ListBase offset must have already - * been added before calling this function. I.e. the list argument is - * the absolute list number, not relative to ListBase. - * \param list - display list number - */ -static void -execute_list(GLcontext *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (list == 0 || !islist(ctx, list)) - return; - - if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { - /* raise an error? */ - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - ctx->ListState.CallDepth++; - - if (ctx->Driver.BeginCallList) - ctx->Driver.BeginCallList(ctx, dlist); - - n = dlist->Head; - - done = GL_FALSE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_execute(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ERROR: - _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); - break; - case OPCODE_ACCUM: - CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ALPHA_FUNC: - CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_BIND_TEXTURE: - CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_BITMAP: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, - (const GLubyte *) n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_BLEND_COLOR: - CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_BLEND_EQUATION: - CALL_BlendEquation(ctx->Exec, (n[1].e)); - break; - case OPCODE_BLEND_EQUATION_SEPARATE: - CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_BLEND_FUNC_SEPARATE: - CALL_BlendFuncSeparateEXT(ctx->Exec, - (n[1].e, n[2].e, n[3].e, n[4].e)); - break; - case OPCODE_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_UNIFORM_1F: - CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); - break; - case OPCODE_UNIFORM_2F: - CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_UNIFORM_3F: - CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_UNIFORM_4F: - CALL_Uniform4fARB(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); - break; - case OPCODE_UNIFORM_1FV: - CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2FV: - CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3FV: - CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4FV: - CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1I: - CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); - break; - case OPCODE_UNIFORM_2I: - CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); - break; - case OPCODE_UNIFORM_3I: - CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_UNIFORM_4I: - CALL_Uniform4iARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_UNIFORM_1IV: - CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2IV: - CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3IV: - CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4IV: - CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1UI: - /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ - break; - case OPCODE_UNIFORM_2UI: - /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ - break; - case OPCODE_UNIFORM_3UI: - /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ - break; - case OPCODE_UNIFORM_4UI: - /*CALL_Uniform4uiARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - */ - break; - case OPCODE_UNIFORM_1UIV: - /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_2UIV: - /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_3UIV: - /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_4UIV: - /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_MATRIX22: - CALL_UniformMatrix2fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX33: - CALL_UniformMatrix3fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX44: - CALL_UniformMatrix4fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX23: - CALL_UniformMatrix2x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX32: - CALL_UniformMatrix3x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX24: - CALL_UniformMatrix2x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX42: - CALL_UniformMatrix4x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX34: - CALL_UniformMatrix3x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX43: - CALL_UniformMatrix4x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - - case OPCODE_TEX_BUMP_PARAMETER_ATI: - { - GLfloat values[4]; - GLuint i, pname = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); - } - break; -#if FEATURE_ATI_fragment_shader - case OPCODE_BIND_FRAGMENT_SHADER_ATI: - CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); - break; - case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: - { - GLfloat values[4]; - GLuint i, dst = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); - } - break; -#endif - case OPCODE_ATTR_1F_NV: - CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_NV: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_ATTR_1F_ARB: - CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_ARB: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_MATERIAL: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); - else { - GLfloat f[4]; - f[0] = n[3].f; - f[1] = n[4].f; - f[2] = n[5].f; - f[3] = n[6].f; - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); - } - break; - case OPCODE_BEGIN: - CALL_Begin(ctx->Exec, (n[1].e)); - break; - case OPCODE_END: - CALL_End(ctx->Exec, ()); - break; - case OPCODE_RECTF: - CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_EVAL_C1: - CALL_EvalCoord1f(ctx->Exec, (n[1].f)); - break; - case OPCODE_EVAL_C2: - CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_EVAL_P1: - CALL_EvalPoint1(ctx->Exec, (n[1].i)); - break; - case OPCODE_EVAL_P2: - CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - done = GL_TRUE; - break; - default: - { - char msg[1000]; - _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", - (int) opcode); - _mesa_problem(ctx, "%s", msg); - } - done = GL_TRUE; - } - - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } - - if (ctx->Driver.EndCallList) - ctx->Driver.EndCallList(ctx); - - ctx->ListState.CallDepth--; -} - - - -/**********************************************************************/ -/* GL functions */ -/**********************************************************************/ - -/** - * Test if a display list number is valid. - */ -static GLboolean GLAPIENTRY -_mesa_IsList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - return islist(ctx, list); -} - - -/** - * Delete a sequence of consecutive display lists. - */ -static void GLAPIENTRY -_mesa_DeleteLists(GLuint list, GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint i; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); - return; - } - for (i = list; i < list + range; i++) { - destroy_list(ctx, i); - } -} - - -/** - * Return a display list number, n, such that lists n through n+range-1 - * are free. - */ -static GLuint GLAPIENTRY -_mesa_GenLists(GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint base; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); - return 0; - } - if (range == 0) { - return 0; - } - - /* - * Make this an atomic operation - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); - if (base) { - /* reserve the list IDs by with empty/dummy lists */ - GLint i; - for (i = 0; i < range; i++) { - _mesa_HashInsert(ctx->Shared->DisplayList, base + i, - make_list(base + i, 1)); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return base; -} - - -/** - * Begin a new display list. - */ -static void GLAPIENTRY -_mesa_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - - FLUSH_CURRENT(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glNewList %u %s\n", name, - _mesa_lookup_enum_by_nr(mode)); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); - return; - } - - if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); - return; - } - - if (ctx->ListState.CurrentList) { - /* already compiling a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - return; - } - - ctx->CompileFlag = GL_TRUE; - ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); - - /* Reset acumulated list state: - */ - invalidate_saved_current_state( ctx ); - - /* Allocate new display list */ - ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); - ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; - ctx->ListState.CurrentPos = 0; - - ctx->Driver.NewList(ctx, name, mode); - - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -/** - * End definition of current display list. - */ -static void GLAPIENTRY -_mesa_EndList(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEndList\n"); - - /* Check that a list is under construction */ - if (!ctx->ListState.CurrentList) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); - return; - } - - /* Call before emitting END_OF_LIST, in case the driver wants to - * emit opcodes itself. - */ - ctx->Driver.EndList(ctx); - - (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); - - /* Destroy old list, if any */ - destroy_list(ctx, ctx->ListState.CurrentList->Name); - - /* Install the new list */ - _mesa_HashInsert(ctx->Shared->DisplayList, - ctx->ListState.CurrentList->Name, - ctx->ListState.CurrentList); - - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - mesa_print_display_list(ctx->ListState.CurrentList->Name); - - ctx->ListState.CurrentList = NULL; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - - ctx->CurrentDispatch = ctx->Exec; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -void GLAPIENTRY -_mesa_CallList(GLuint list) -{ - GLboolean save_compile_flag; - GET_CURRENT_CONTEXT(ctx); - FLUSH_CURRENT(ctx, 0); - /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ - /* execute the display list, and restore the CompileFlag. */ - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallList %d\n", list); - - if (list == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); - return; - } - -/* mesa_print_display_list( list ); */ - - save_compile_flag = ctx->CompileFlag; - if (save_compile_flag) { - ctx->CompileFlag = GL_FALSE; - } - - execute_list(ctx, list); - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Execute glCallLists: call multiple display lists. - */ -void GLAPIENTRY -_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean save_compile_flag; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallLists %d\n", n); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - return; - } - - /* Save the CompileFlag status, turn it off, execute display list, - * and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - ctx->CompileFlag = GL_FALSE; - - for (i = 0; i < n; i++) { - GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); - execute_list(ctx, list); - } - - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Set the offset added to list numbers in glCallLists. - */ -static void GLAPIENTRY -_mesa_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - ctx->List.ListBase = base; -} - - -/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. - */ -static void GLAPIENTRY -exec_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Finish(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Flush(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetBooleanv(GLenum pname, GLboolean *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetBooleanv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetClipPlane(GLenum plane, GLdouble * equation) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetClipPlane(ctx->Exec, (plane, equation)); -} - -static void GLAPIENTRY -exec_GetDoublev(GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetDoublev(ctx->Exec, (pname, params)); -} - -static GLenum GLAPIENTRY -exec_GetError(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetError(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetFloatv(GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetFloatv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetIntegerv(GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetIntegerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightfv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetLightiv(GLenum light, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightiv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapdv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapfv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapiv(GLenum target, GLenum query, GLint * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapiv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetPixelMapfv(GLenum map, GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapfv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapuiv(GLenum map, GLuint *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapuiv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapusv(GLenum map, GLushort *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapusv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPolygonStipple(GLubyte * dest) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPolygonStipple(ctx->Exec, (dest)); -} - -static const GLubyte *GLAPIENTRY -exec_GetString(GLenum name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetString(ctx->Exec, (name)); -} - -static void GLAPIENTRY -exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexImage(GLenum target, GLint level, GLenum format, - GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameterfv(GLenum target, GLint level, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameteriv(GLenum target, GLint level, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); -} - -static GLboolean GLAPIENTRY -exec_IsEnabled(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsEnabled(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_PixelStoref(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStoref(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_PixelStorei(GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStorei(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); -} - -static GLint GLAPIENTRY -exec_RenderMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_RenderMode(ctx->Exec, (mode)); -} - -static void GLAPIENTRY -exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); -} - -static void GLAPIENTRY -exec_SelectBuffer(GLsizei size, GLuint * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SelectBuffer(ctx->Exec, (size, buffer)); -} - -static GLboolean GLAPIENTRY -exec_AreTexturesResident(GLsizei n, const GLuint * texName, - GLboolean * residences) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); -} - -static void GLAPIENTRY -exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_DeleteTextures(GLsizei n, const GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DeleteTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_DisableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DisableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); -} - -static void GLAPIENTRY -exec_EnableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EnableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_GenTextures(GLsizei n, GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GenTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_GetPointerv(GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPointerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); -} - -static GLboolean GLAPIENTRY -exec_IsTexture(GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsTexture(ctx->Exec, (texture)); -} - -static void GLAPIENTRY -exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_PopClientAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PopClientAttrib(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_PushClientAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PushClientAttrib(ctx->Exec, (mask)); -} - -static void GLAPIENTRY -exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); -} - -static void GLAPIENTRY -exec_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter1D(ctx->Exec, - (target, internalFormat, x, y, width)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter2D(ctx->Exec, - (target, internalFormat, x, y, width, - height)); -} - -static void GLAPIENTRY -exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTable(ctx->Exec, (target, format, type, data)); -} - -static void GLAPIENTRY -exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid * image) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid *row, GLvoid *column, GLvoid *span) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetSeparableFilter(ctx->Exec, - (target, format, type, row, column, span)); -} - -static void GLAPIENTRY -exec_SeparableFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid *row, const GLvoid *column) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SeparableFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, row, column)); -} - -static void GLAPIENTRY -exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); -} - -static void GLAPIENTRY -exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_LockArraysEXT(ctx->Exec, (first, count)); -} - -static void GLAPIENTRY -exec_UnlockArraysEXT(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_UnlockArraysEXT(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_ClientActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ClientActiveTextureARB(ctx->Exec, (target)); -} - -static void GLAPIENTRY -exec_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); -} - -/* GL_EXT_multi_draw_arrays */ -static void GLAPIENTRY -exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, - const GLsizei * count, GLsizei primcount, - GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawArraysIBM(ctx->Exec, - (mode, first, count, primcount, modestride)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawElementsIBM(const GLenum * mode, - const GLsizei * count, - GLenum type, - const GLvoid * const *indices, - GLsizei primcount, GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawElementsIBM(ctx->Exec, - (mode, count, type, indices, primcount, - modestride)); -} - - - -/** - * Setup the given dispatch table to point to Mesa's display list - * building functions. - * - * This does not include any of the tnl functions - they are - * initialized from _mesa_init_api_defaults and from the active vtxfmt - * struct. - */ -struct _glapi_table * -_mesa_create_save_table(void) -{ - struct _glapi_table *table; - - table = _mesa_alloc_dispatch_table(sizeof *table); - if (table == NULL) - return NULL; - - _mesa_loopback_init_api_table(table); - - /* GL 1.0 */ - SET_Accum(table, save_Accum); - SET_AlphaFunc(table, save_AlphaFunc); - SET_Bitmap(table, save_Bitmap); - SET_BlendFunc(table, save_BlendFunc); - SET_CallList(table, save_CallList); - SET_CallLists(table, save_CallLists); - SET_Clear(table, save_Clear); - SET_ClearAccum(table, save_ClearAccum); - SET_ClearColor(table, save_ClearColor); - SET_ClearDepth(table, save_ClearDepth); - SET_ClearIndex(table, save_ClearIndex); - SET_ClearStencil(table, save_ClearStencil); - SET_ClipPlane(table, save_ClipPlane); - SET_ColorMask(table, save_ColorMask); - SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); - SET_ColorMaterial(table, save_ColorMaterial); - SET_CopyPixels(table, save_CopyPixels); - SET_CullFace(table, save_CullFace); - SET_DeleteLists(table, _mesa_DeleteLists); - SET_DepthFunc(table, save_DepthFunc); - SET_DepthMask(table, save_DepthMask); - SET_DepthRange(table, save_DepthRange); - SET_Disable(table, save_Disable); - SET_DisableIndexedEXT(table, save_DisableIndexed); - SET_DrawBuffer(table, save_DrawBuffer); - SET_DrawPixels(table, save_DrawPixels); - SET_Enable(table, save_Enable); - SET_EnableIndexedEXT(table, save_EnableIndexed); - SET_EndList(table, _mesa_EndList); - SET_EvalMesh1(table, save_EvalMesh1); - SET_EvalMesh2(table, save_EvalMesh2); - SET_Finish(table, exec_Finish); - SET_Flush(table, exec_Flush); - SET_Fogf(table, save_Fogf); - SET_Fogfv(table, save_Fogfv); - SET_Fogi(table, save_Fogi); - SET_Fogiv(table, save_Fogiv); - SET_FrontFace(table, save_FrontFace); - SET_Frustum(table, save_Frustum); - SET_GenLists(table, _mesa_GenLists); - SET_GetBooleanv(table, exec_GetBooleanv); - SET_GetClipPlane(table, exec_GetClipPlane); - SET_GetDoublev(table, exec_GetDoublev); - SET_GetError(table, exec_GetError); - SET_GetFloatv(table, exec_GetFloatv); - SET_GetIntegerv(table, exec_GetIntegerv); - SET_GetLightfv(table, exec_GetLightfv); - SET_GetLightiv(table, exec_GetLightiv); - SET_GetMapdv(table, exec_GetMapdv); - SET_GetMapfv(table, exec_GetMapfv); - SET_GetMapiv(table, exec_GetMapiv); - SET_GetMaterialfv(table, exec_GetMaterialfv); - SET_GetMaterialiv(table, exec_GetMaterialiv); - SET_GetPixelMapfv(table, exec_GetPixelMapfv); - SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); - SET_GetPixelMapusv(table, exec_GetPixelMapusv); - SET_GetPolygonStipple(table, exec_GetPolygonStipple); - SET_GetString(table, exec_GetString); - SET_GetTexEnvfv(table, exec_GetTexEnvfv); - SET_GetTexEnviv(table, exec_GetTexEnviv); - SET_GetTexGendv(table, exec_GetTexGendv); - SET_GetTexGenfv(table, exec_GetTexGenfv); - SET_GetTexGeniv(table, exec_GetTexGeniv); - SET_GetTexImage(table, exec_GetTexImage); - SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); - SET_GetTexParameterfv(table, exec_GetTexParameterfv); - SET_GetTexParameteriv(table, exec_GetTexParameteriv); - SET_Hint(table, save_Hint); - SET_IndexMask(table, save_IndexMask); - SET_InitNames(table, save_InitNames); - SET_IsEnabled(table, exec_IsEnabled); - SET_IsList(table, _mesa_IsList); - SET_LightModelf(table, save_LightModelf); - SET_LightModelfv(table, save_LightModelfv); - SET_LightModeli(table, save_LightModeli); - SET_LightModeliv(table, save_LightModeliv); - SET_Lightf(table, save_Lightf); - SET_Lightfv(table, save_Lightfv); - SET_Lighti(table, save_Lighti); - SET_Lightiv(table, save_Lightiv); - SET_LineStipple(table, save_LineStipple); - SET_LineWidth(table, save_LineWidth); - SET_ListBase(table, save_ListBase); - SET_LoadIdentity(table, save_LoadIdentity); - SET_LoadMatrixd(table, save_LoadMatrixd); - SET_LoadMatrixf(table, save_LoadMatrixf); - SET_LoadName(table, save_LoadName); - SET_LogicOp(table, save_LogicOp); - SET_Map1d(table, save_Map1d); - SET_Map1f(table, save_Map1f); - SET_Map2d(table, save_Map2d); - SET_Map2f(table, save_Map2f); - SET_MapGrid1d(table, save_MapGrid1d); - SET_MapGrid1f(table, save_MapGrid1f); - SET_MapGrid2d(table, save_MapGrid2d); - SET_MapGrid2f(table, save_MapGrid2f); - SET_MatrixMode(table, save_MatrixMode); - SET_MultMatrixd(table, save_MultMatrixd); - SET_MultMatrixf(table, save_MultMatrixf); - SET_NewList(table, save_NewList); - SET_Ortho(table, save_Ortho); - SET_PassThrough(table, save_PassThrough); - SET_PixelMapfv(table, save_PixelMapfv); - SET_PixelMapuiv(table, save_PixelMapuiv); - SET_PixelMapusv(table, save_PixelMapusv); - SET_PixelStoref(table, exec_PixelStoref); - SET_PixelStorei(table, exec_PixelStorei); - SET_PixelTransferf(table, save_PixelTransferf); - SET_PixelTransferi(table, save_PixelTransferi); - SET_PixelZoom(table, save_PixelZoom); - SET_PointSize(table, save_PointSize); - SET_PolygonMode(table, save_PolygonMode); - SET_PolygonOffset(table, save_PolygonOffset); - SET_PolygonStipple(table, save_PolygonStipple); - SET_PopAttrib(table, save_PopAttrib); - SET_PopMatrix(table, save_PopMatrix); - SET_PopName(table, save_PopName); - SET_PushAttrib(table, save_PushAttrib); - SET_PushMatrix(table, save_PushMatrix); - SET_PushName(table, save_PushName); - SET_RasterPos2d(table, save_RasterPos2d); - SET_RasterPos2dv(table, save_RasterPos2dv); - SET_RasterPos2f(table, save_RasterPos2f); - SET_RasterPos2fv(table, save_RasterPos2fv); - SET_RasterPos2i(table, save_RasterPos2i); - SET_RasterPos2iv(table, save_RasterPos2iv); - SET_RasterPos2s(table, save_RasterPos2s); - SET_RasterPos2sv(table, save_RasterPos2sv); - SET_RasterPos3d(table, save_RasterPos3d); - SET_RasterPos3dv(table, save_RasterPos3dv); - SET_RasterPos3f(table, save_RasterPos3f); - SET_RasterPos3fv(table, save_RasterPos3fv); - SET_RasterPos3i(table, save_RasterPos3i); - SET_RasterPos3iv(table, save_RasterPos3iv); - SET_RasterPos3s(table, save_RasterPos3s); - SET_RasterPos3sv(table, save_RasterPos3sv); - SET_RasterPos4d(table, save_RasterPos4d); - SET_RasterPos4dv(table, save_RasterPos4dv); - SET_RasterPos4f(table, save_RasterPos4f); - SET_RasterPos4fv(table, save_RasterPos4fv); - SET_RasterPos4i(table, save_RasterPos4i); - SET_RasterPos4iv(table, save_RasterPos4iv); - SET_RasterPos4s(table, save_RasterPos4s); - SET_RasterPos4sv(table, save_RasterPos4sv); - SET_ReadBuffer(table, save_ReadBuffer); - SET_ReadPixels(table, exec_ReadPixels); - SET_RenderMode(table, exec_RenderMode); - SET_Rotated(table, save_Rotated); - SET_Rotatef(table, save_Rotatef); - SET_Scaled(table, save_Scaled); - SET_Scalef(table, save_Scalef); - SET_Scissor(table, save_Scissor); - SET_FeedbackBuffer(table, exec_FeedbackBuffer); - SET_SelectBuffer(table, exec_SelectBuffer); - SET_ShadeModel(table, save_ShadeModel); - SET_StencilFunc(table, save_StencilFunc); - SET_StencilMask(table, save_StencilMask); - SET_StencilOp(table, save_StencilOp); - SET_TexEnvf(table, save_TexEnvf); - SET_TexEnvfv(table, save_TexEnvfv); - SET_TexEnvi(table, save_TexEnvi); - SET_TexEnviv(table, save_TexEnviv); - SET_TexGend(table, save_TexGend); - SET_TexGendv(table, save_TexGendv); - SET_TexGenf(table, save_TexGenf); - SET_TexGenfv(table, save_TexGenfv); - SET_TexGeni(table, save_TexGeni); - SET_TexGeniv(table, save_TexGeniv); - SET_TexImage1D(table, save_TexImage1D); - SET_TexImage2D(table, save_TexImage2D); - SET_TexParameterf(table, save_TexParameterf); - SET_TexParameterfv(table, save_TexParameterfv); - SET_TexParameteri(table, save_TexParameteri); - SET_TexParameteriv(table, save_TexParameteriv); - SET_Translated(table, save_Translated); - SET_Translatef(table, save_Translatef); - SET_Viewport(table, save_Viewport); - - /* GL 1.1 */ - SET_AreTexturesResident(table, exec_AreTexturesResident); - SET_BindTexture(table, save_BindTexture); - SET_ColorPointer(table, exec_ColorPointer); - SET_CopyTexImage1D(table, save_CopyTexImage1D); - SET_CopyTexImage2D(table, save_CopyTexImage2D); - SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); - SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); - SET_DeleteTextures(table, exec_DeleteTextures); - SET_DisableClientState(table, exec_DisableClientState); - SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); - SET_EnableClientState(table, exec_EnableClientState); - SET_GenTextures(table, exec_GenTextures); - SET_GetPointerv(table, exec_GetPointerv); - SET_IndexPointer(table, exec_IndexPointer); - SET_InterleavedArrays(table, exec_InterleavedArrays); - SET_IsTexture(table, exec_IsTexture); - SET_NormalPointer(table, exec_NormalPointer); - SET_PopClientAttrib(table, exec_PopClientAttrib); - SET_PrioritizeTextures(table, save_PrioritizeTextures); - SET_PushClientAttrib(table, exec_PushClientAttrib); - SET_TexCoordPointer(table, exec_TexCoordPointer); - SET_TexSubImage1D(table, save_TexSubImage1D); - SET_TexSubImage2D(table, save_TexSubImage2D); - SET_VertexPointer(table, exec_VertexPointer); - - /* GL 1.2 */ - SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); - SET_TexImage3D(table, save_TexImage3D); - SET_TexSubImage3D(table, save_TexSubImage3D); - - /* GL 2.0 */ - SET_StencilFuncSeparate(table, save_StencilFuncSeparate); - SET_StencilMaskSeparate(table, save_StencilMaskSeparate); - SET_StencilOpSeparate(table, save_StencilOpSeparate); - - /* ATI_separate_stencil */ - SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); - - /* GL_ARB_imaging */ - /* Not all are supported */ - SET_BlendColor(table, save_BlendColor); - SET_BlendEquation(table, save_BlendEquation); - SET_ColorSubTable(table, save_ColorSubTable); - SET_ColorTable(table, save_ColorTable); - SET_ColorTableParameterfv(table, save_ColorTableParameterfv); - SET_ColorTableParameteriv(table, save_ColorTableParameteriv); - SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); - SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); - SET_ConvolutionParameterf(table, save_ConvolutionParameterf); - SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); - SET_ConvolutionParameteri(table, save_ConvolutionParameteri); - SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); - SET_CopyColorSubTable(table, save_CopyColorSubTable); - SET_CopyColorTable(table, save_CopyColorTable); - SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); - SET_GetColorTable(table, exec_GetColorTable); - SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); - SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); - SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); - SET_GetHistogram(table, exec_GetHistogram); - SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); - SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); - SET_GetMinmax(table, exec_GetMinmax); - SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); - SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); - SET_GetSeparableFilter(table, exec_GetSeparableFilter); - SET_Histogram(table, save_Histogram); - SET_Minmax(table, save_Minmax); - SET_ResetHistogram(table, save_ResetHistogram); - SET_ResetMinmax(table, save_ResetMinmax); - SET_SeparableFilter2D(table, exec_SeparableFilter2D); - - /* 2. GL_EXT_blend_color */ -#if 0 - SET_BlendColorEXT(table, save_BlendColorEXT); -#endif - - /* 3. GL_EXT_polygon_offset */ - SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); - - /* 6. GL_EXT_texture3d */ -#if 0 - SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); - SET_TexImage3DEXT(table, save_TexImage3DEXT); - SET_TexSubImage3DEXT(table, save_TexSubImage3D); -#endif - - /* 14. GL_SGI_color_table */ -#if 0 - SET_ColorTableSGI(table, save_ColorTable); - SET_ColorSubTableSGI(table, save_ColorSubTable); - SET_GetColorTableSGI(table, exec_GetColorTable); - SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); -#endif - - /* 30. GL_EXT_vertex_array */ - SET_ColorPointerEXT(table, exec_ColorPointerEXT); - SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); - SET_IndexPointerEXT(table, exec_IndexPointerEXT); - SET_NormalPointerEXT(table, exec_NormalPointerEXT); - SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); - SET_VertexPointerEXT(table, exec_VertexPointerEXT); - - /* 37. GL_EXT_blend_minmax */ -#if 0 - SET_BlendEquationEXT(table, save_BlendEquationEXT); -#endif - - /* 54. GL_EXT_point_parameters */ - SET_PointParameterfEXT(table, save_PointParameterfEXT); - SET_PointParameterfvEXT(table, save_PointParameterfvEXT); - - /* 97. GL_EXT_compiled_vertex_array */ - SET_LockArraysEXT(table, exec_LockArraysEXT); - SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); - - /* 145. GL_EXT_secondary_color */ - SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); - - /* 148. GL_EXT_multi_draw_arrays */ - SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); - - /* 149. GL_EXT_fog_coord */ - SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); - - /* 173. GL_EXT_blend_func_separate */ - SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); - - /* 196. GL_MESA_resize_buffers */ - SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(table, save_WindowPos2dMESA); - SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); - SET_WindowPos2fMESA(table, save_WindowPos2fMESA); - SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); - SET_WindowPos2iMESA(table, save_WindowPos2iMESA); - SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); - SET_WindowPos2sMESA(table, save_WindowPos2sMESA); - SET_WindowPos2svMESA(table, save_WindowPos2svMESA); - SET_WindowPos3dMESA(table, save_WindowPos3dMESA); - SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); - SET_WindowPos3fMESA(table, save_WindowPos3fMESA); - SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); - SET_WindowPos3iMESA(table, save_WindowPos3iMESA); - SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); - SET_WindowPos3sMESA(table, save_WindowPos3sMESA); - SET_WindowPos3svMESA(table, save_WindowPos3svMESA); - SET_WindowPos4dMESA(table, save_WindowPos4dMESA); - SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); - SET_WindowPos4fMESA(table, save_WindowPos4fMESA); - SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); - SET_WindowPos4iMESA(table, save_WindowPos4iMESA); - SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); - SET_WindowPos4sMESA(table, save_WindowPos4sMESA); - SET_WindowPos4svMESA(table, save_WindowPos4svMESA); - - /* 200. GL_IBM_multimode_draw_arrays */ - SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); - -#if FEATURE_NV_vertex_program - /* 233. GL_NV_vertex_program */ - /* The following commands DO NOT go into display lists: - * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, - * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* - */ - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_ExecuteProgramNV(table, save_ExecuteProgramNV); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(table, _mesa_GetProgramivNV); - SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_LoadProgramNV(table, save_LoadProgramNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); - SET_TrackMatrixNV(table, save_TrackMatrixNV); - SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); -#endif - - /* 244. GL_ATI_envmap_bumpmap */ - SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); - - /* 245. GL_ATI_fragment_shader */ -#if FEATURE_ATI_fragment_shader - SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); - SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); -#endif - - /* 282. GL_NV_fragment_program */ -#if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(table, - _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(table, - _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); -#endif - - /* 262. GL_NV_point_sprite */ - SET_PointParameteriNV(table, save_PointParameteriNV); - SET_PointParameterivNV(table, save_PointParameterivNV); - - /* 268. GL_EXT_stencil_two_side */ - SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); - - /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); - SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); - SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(table, save_DepthBoundsEXT); - - /* ARB 1. GL_ARB_multitexture */ - SET_ActiveTextureARB(table, save_ActiveTextureARB); - SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); - - /* ARB 3. GL_ARB_transpose_matrix */ - SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); - - /* ARB 5. GL_ARB_multisample */ - SET_SampleCoverageARB(table, save_SampleCoverageARB); - - /* ARB 12. GL_ARB_texture_compression */ - SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); - SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); - SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); - SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); - SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); - SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); - SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); - - /* ARB 14. GL_ARB_point_parameters */ - /* aliased with EXT_point_parameters functions */ - - /* ARB 25. GL_ARB_window_pos */ - /* aliased with MESA_window_pos functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ - SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(table, save_ProgramStringARB); - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(table, _mesa_GetProgramivARB); - SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); -#endif - - /* ARB 28. GL_ARB_vertex_buffer_object */ -#if FEATURE_ARB_vertex_buffer_object - /* None of the extension's functions get compiled */ - SET_BindBufferARB(table, _mesa_BindBufferARB); - SET_BufferDataARB(table, _mesa_BufferDataARB); - SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(table, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(table, _mesa_IsBufferARB); - SET_MapBufferARB(table, _mesa_MapBufferARB); - SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); -#endif - -#if FEATURE_queryobj - SET_BeginQueryARB(table, save_BeginQueryARB); - SET_EndQueryARB(table, save_EndQueryARB); - SET_GenQueriesARB(table, _mesa_GenQueriesARB); - SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB); - SET_IsQueryARB(table, _mesa_IsQueryARB); - SET_GetQueryivARB(table, _mesa_GetQueryivARB); - SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB); - SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB); -#endif - SET_DrawBuffersARB(table, save_DrawBuffersARB); - -#if FEATURE_EXT_framebuffer_blit - SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); -#endif - - /* GL_ARB_shader_objects */ - SET_UseProgramObjectARB(table, save_UseProgramObjectARB); - SET_Uniform1fARB(table, save_Uniform1fARB); - SET_Uniform2fARB(table, save_Uniform2fARB); - SET_Uniform3fARB(table, save_Uniform3fARB); - SET_Uniform4fARB(table, save_Uniform4fARB); - SET_Uniform1fvARB(table, save_Uniform1fvARB); - SET_Uniform2fvARB(table, save_Uniform2fvARB); - SET_Uniform3fvARB(table, save_Uniform3fvARB); - SET_Uniform4fvARB(table, save_Uniform4fvARB); - SET_Uniform1iARB(table, save_Uniform1iARB); - SET_Uniform2iARB(table, save_Uniform2iARB); - SET_Uniform3iARB(table, save_Uniform3iARB); - SET_Uniform4iARB(table, save_Uniform4iARB); - SET_Uniform1ivARB(table, save_Uniform1ivARB); - SET_Uniform2ivARB(table, save_Uniform2ivARB); - SET_Uniform3ivARB(table, save_Uniform3ivARB); - SET_Uniform4ivARB(table, save_Uniform4ivARB); - SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); - SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); - - /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); - SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); - SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); - /* XXX additional functions need to be implemented here! */ - - /* 299. GL_EXT_blend_equation_separate */ - SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); -#endif - - /* ARB 50. GL_ARB_map_buffer_range */ -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ - SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ -#endif - - /* ARB 59. GL_ARB_copy_buffer */ - SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ - - /* 352. GL_EXT_transform_feedback */ -#if FEATURE_EXT_transform_feedback - SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); - SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); -#endif - - /* 364. GL_EXT_provoking_vertex */ - SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); - - /* 371. GL_APPLE_object_purgeable */ -#if FEATURE_APPLE_object_purgeable - SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); - SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); -#endif - - /* GL 3.0 */ -#if 0 - SET_ClearBufferiv(table, save_ClearBufferiv); - SET_ClearBufferuiv(table, save_ClearBufferuiv); - SET_ClearBufferfv(table, save_ClearBufferfv); - SET_ClearBufferfi(table, save_ClearBufferfi); - SET_Uniform1ui(table, save_Uniform1ui); - SET_Uniform2ui(table, save_Uniform2ui); - SET_Uniform3ui(table, save_Uniform3ui); - SET_Uniform4ui(table, save_Uniform4ui); - SET_Uniform1uiv(table, save_Uniform1uiv); - SET_Uniform2uiv(table, save_Uniform2uiv); - SET_Uniform3uiv(table, save_Uniform3uiv); - SET_Uniform4uiv(table, save_Uniform4uiv); -#else - (void) save_ClearBufferiv; - (void) save_ClearBufferuiv; - (void) save_ClearBufferfv; - (void) save_ClearBufferfi; - (void) save_Uniform1ui; - (void) save_Uniform2ui; - (void) save_Uniform3ui; - (void) save_Uniform4ui; - (void) save_Uniform1uiv; - (void) save_Uniform2uiv; - (void) save_Uniform3uiv; - (void) save_Uniform4uiv; -#endif - - return table; -} - - - -static const char * -enum_string(GLenum k) -{ - return _mesa_lookup_enum_by_nr(k); -} - - -/** - * Print the commands in a display list. For debugging only. - * TODO: many commands aren't handled yet. - */ -static void GLAPIENTRY -print_list(GLcontext *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (!islist(ctx, list)) { - printf("%u is not a display list ID\n", list); - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - n = dlist->Head; - - printf("START-LIST %u, address %p\n", list, (void *) n); - - done = n ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_print(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ACCUM: - printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); - break; - case OPCODE_BITMAP: - printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); - break; - case OPCODE_CALL_LIST: - printf("CallList %d\n", (int) n[1].ui); - break; - case OPCODE_CALL_LIST_OFFSET: - printf("CallList %d + offset %u = %u\n", (int) n[1].ui, - ctx->List.ListBase, ctx->List.ListBase + n[1].ui); - break; - case OPCODE_COLOR_TABLE_PARAMETER_FV: - printf("ColorTableParameterfv %s %s %f %f %f %f\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_COLOR_TABLE_PARAMETER_IV: - printf("ColorTableParameteriv %s %s %d %d %d %d\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].i, n[4].i, n[5].i, n[6].i); - break; - case OPCODE_DISABLE: - printf("Disable %s\n", enum_string(n[1].e)); - break; - case OPCODE_ENABLE: - printf("Enable %s\n", enum_string(n[1].e)); - break; - case OPCODE_FRUSTUM: - printf("Frustum %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_LINE_STIPPLE: - printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); - break; - case OPCODE_LOAD_IDENTITY: - printf("LoadIdentity\n"); - break; - case OPCODE_LOAD_MATRIX: - printf("LoadMatrix\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_MULT_MATRIX: - printf("MultMatrix (or Rotate)\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_ORTHO: - printf("Ortho %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_POP_ATTRIB: - printf("PopAttrib\n"); - break; - case OPCODE_POP_MATRIX: - printf("PopMatrix\n"); - break; - case OPCODE_POP_NAME: - printf("PopName\n"); - break; - case OPCODE_PUSH_ATTRIB: - printf("PushAttrib %x\n", n[1].bf); - break; - case OPCODE_PUSH_MATRIX: - printf("PushMatrix\n"); - break; - case OPCODE_PUSH_NAME: - printf("PushName %d\n", (int) n[1].ui); - break; - case OPCODE_RASTER_POS: - printf("RasterPos %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ROTATE: - printf("Rotate %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_SCALE: - printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_TRANSLATE: - printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_BIND_TEXTURE: - printf("BindTexture %s %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); - break; - case OPCODE_SHADE_MODEL: - printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); - break; - case OPCODE_MAP1: - printf("Map1 %s %.3f %.3f %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].i, n[5].i); - break; - case OPCODE_MAP2: - printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].f, n[5].f, - n[6].i, n[7].i, n[8].i, n[9].i); - break; - case OPCODE_MAPGRID1: - printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); - break; - case OPCODE_MAPGRID2: - printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", - n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); - break; - case OPCODE_EVALMESH1: - printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); - break; - case OPCODE_EVALMESH2: - printf("EvalMesh2 %d %d %d %d\n", - n[1].i, n[2].i, n[3].i, n[4].i); - break; - - case OPCODE_ATTR_1F_NV: - printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_NV: - printf("ATTR_2F_NV attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_NV: - printf("ATTR_3F_NV attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_NV: - printf("ATTR_4F_NV attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - case OPCODE_ATTR_1F_ARB: - printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_ARB: - printf("ATTR_2F_ARB attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_ARB: - printf("ATTR_3F_ARB attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_ARB: - printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - - case OPCODE_MATERIAL: - printf("MATERIAL %x %x: %f %f %f %f\n", - n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_BEGIN: - printf("BEGIN %x\n", n[1].i); - break; - case OPCODE_END: - printf("END\n"); - break; - case OPCODE_RECTF: - printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, - n[4].f); - break; - case OPCODE_EVAL_C1: - printf("EVAL_C1 %f\n", n[1].f); - break; - case OPCODE_EVAL_C2: - printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); - break; - case OPCODE_EVAL_P1: - printf("EVAL_P1 %d\n", n[1].i); - break; - case OPCODE_EVAL_P2: - printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); - break; - - case OPCODE_PROVOKING_VERTEX: - printf("ProvokingVertex %s\n", - _mesa_lookup_enum_by_nr(n[1].ui)); - break; - - /* - * meta opcodes/commands - */ - case OPCODE_ERROR: - printf("Error: %s %s\n", - enum_string(n[1].e), (const char *) n[2].data); - break; - case OPCODE_CONTINUE: - printf("DISPLAY-LIST-CONTINUE\n"); - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - printf("END-LIST %u\n", list); - done = GL_TRUE; - break; - default: - if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { - printf - ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", - opcode, (void *) n); - return; - } - else { - printf("command %d, %u operands\n", opcode, - InstSize[opcode]); - } - } - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } -} - - - -/** - * Clients may call this function to help debug display list problems. - * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, - * changed, or break in the future without notice. - */ -void -mesa_print_display_list(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - print_list(ctx, list); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void -_mesa_save_vtxfmt_init(GLvertexformat * vfmt) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = save_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, save_); - - vfmt->Color3f = save_Color3f; - vfmt->Color3fv = save_Color3fv; - vfmt->Color4f = save_Color4f; - vfmt->Color4fv = save_Color4fv; - vfmt->EdgeFlag = save_EdgeFlag; - vfmt->End = save_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, save_); - - vfmt->FogCoordfEXT = save_FogCoordfEXT; - vfmt->FogCoordfvEXT = save_FogCoordfvEXT; - vfmt->Indexf = save_Indexf; - vfmt->Indexfv = save_Indexfv; - vfmt->Materialfv = save_Materialfv; - vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; - vfmt->Normal3f = save_Normal3f; - vfmt->Normal3fv = save_Normal3fv; - vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; - vfmt->TexCoord1f = save_TexCoord1f; - vfmt->TexCoord1fv = save_TexCoord1fv; - vfmt->TexCoord2f = save_TexCoord2f; - vfmt->TexCoord2fv = save_TexCoord2fv; - vfmt->TexCoord3f = save_TexCoord3f; - vfmt->TexCoord3fv = save_TexCoord3fv; - vfmt->TexCoord4f = save_TexCoord4f; - vfmt->TexCoord4fv = save_TexCoord4fv; - vfmt->Vertex2f = save_Vertex2f; - vfmt->Vertex2fv = save_Vertex2fv; - vfmt->Vertex3f = save_Vertex3f; - vfmt->Vertex3fv = save_Vertex3fv; - vfmt->Vertex4f = save_Vertex4f; - vfmt->Vertex4fv = save_Vertex4fv; - vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; - - vfmt->Rectf = save_Rectf; - - /* The driver is required to implement these as - * 1) They can probably do a better job. - * 2) A lot of new mechanisms would have to be added to this module - * to support it. That code would probably never get used, - * because of (1). - */ -#if 0 - vfmt->DrawArrays = 0; - vfmt->DrawElements = 0; - vfmt->DrawRangeElements = 0; - vfmt->MultiDrawElemementsEXT = 0; - vfmt->DrawElementsBaseVertex = 0; - vfmt->DrawRangeElementsBaseVertex = 0; - vfmt->MultiDrawElemementsBaseVertex = 0; -#endif -} - - -void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_CallList(disp, vfmt->CallList); - SET_CallLists(disp, vfmt->CallLists); -} - - -void _mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ - SET_CallList(disp, _mesa_CallList); - SET_CallLists(disp, _mesa_CallLists); - - SET_DeleteLists(disp, _mesa_DeleteLists); - SET_EndList(disp, _mesa_EndList); - SET_GenLists(disp, _mesa_GenLists); - SET_IsList(disp, _mesa_IsList); - SET_ListBase(disp, _mesa_ListBase); - SET_NewList(disp, _mesa_NewList); -} - - -#endif /* FEATURE_dlist */ - - -/** - * Initialize display list state for given context. - */ -void -_mesa_init_display_list(GLcontext *ctx) -{ - static GLboolean tableInitialized = GL_FALSE; - - /* zero-out the instruction size table, just once */ - if (!tableInitialized) { - memset(InstSize, 0, sizeof(InstSize)); - tableInitialized = GL_TRUE; - } - - /* extension info */ - ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); - - /* Display list */ - ctx->ListState.CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->ListState.CurrentBlock = NULL; - ctx->ListState.CurrentPos = 0; - - /* Display List group */ - ctx->List.ListBase = 0; - -#if FEATURE_dlist - _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); -#endif -} - - -void -_mesa_free_display_list_data(GLcontext *ctx) -{ - free(ctx->ListExt); - ctx->ListExt = NULL; -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file dlist.c + * Display lists management functions. + */ + +#include "glheader.h" +#include "imports.h" +#include "api_arrayelt.h" +#include "api_exec.h" +#include "api_loopback.h" +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif +#include "config.h" +#include "mfeatures.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#include "context.h" +#include "dlist.h" +#include "enums.h" +#include "eval.h" +#include "framebuffer.h" +#include "glapi/glapi.h" +#include "hash.h" +#include "image.h" +#include "light.h" +#include "macros.h" +#include "pack.h" +#include "queryobj.h" +#include "teximage.h" +#include "mtypes.h" +#include "varray.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "arbprogram.h" +#endif +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "nvprogram.h" +#endif + +#include "math/m_matrix.h" + +#include "main/dispatch.h" + + + +/** + * Other parts of Mesa (such as the VBO module) can plug into the display + * list system. This structure describes new display list instructions. + */ +struct gl_list_instruction +{ + GLuint Size; + void (*Execute)( struct gl_context *ctx, void *data ); + void (*Destroy)( struct gl_context *ctx, void *data ); + void (*Print)( struct gl_context *ctx, void *data ); +}; + + +#define MAX_DLIST_EXT_OPCODES 16 + +/** + * Used by device drivers to hook new commands into display lists. + */ +struct gl_list_extensions +{ + struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; + GLuint NumOpcodes; +}; + + + +/** + * Flush vertices. + * + * \param ctx GL context. + * + * Checks if dd_function_table::SaveNeedFlush is marked to flush + * stored (save) vertices, and calls + * dd_function_table::SaveFlushVertices if so. + */ +#define SAVE_FLUSH_VERTICES(ctx) \ +do { \ + if (ctx->Driver.SaveNeedFlush) \ + ctx->Driver.SaveFlushVertices(ctx); \ +} while (0) + + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + + + +/** + * Display list opcodes. + * + * The fact that these identifiers are assigned consecutive + * integer values starting at 0 is very important, see InstSize array usage) + */ +typedef enum +{ + OPCODE_INVALID = -1, /* Force signed enum */ + OPCODE_ACCUM, + OPCODE_ALPHA_FUNC, + OPCODE_BIND_TEXTURE, + OPCODE_BITMAP, + OPCODE_BLEND_COLOR, + OPCODE_BLEND_EQUATION, + OPCODE_BLEND_EQUATION_SEPARATE, + OPCODE_BLEND_FUNC_SEPARATE, + OPCODE_CALL_LIST, + OPCODE_CALL_LIST_OFFSET, + OPCODE_CLEAR, + OPCODE_CLEAR_ACCUM, + OPCODE_CLEAR_COLOR, + OPCODE_CLEAR_DEPTH, + OPCODE_CLEAR_INDEX, + OPCODE_CLEAR_STENCIL, + OPCODE_CLEAR_BUFFER_IV, + OPCODE_CLEAR_BUFFER_UIV, + OPCODE_CLEAR_BUFFER_FV, + OPCODE_CLEAR_BUFFER_FI, + OPCODE_CLIP_PLANE, + OPCODE_COLOR_MASK, + OPCODE_COLOR_MASK_INDEXED, + OPCODE_COLOR_MATERIAL, + OPCODE_COLOR_TABLE, + OPCODE_COLOR_TABLE_PARAMETER_FV, + OPCODE_COLOR_TABLE_PARAMETER_IV, + OPCODE_COLOR_SUB_TABLE, + OPCODE_CONVOLUTION_FILTER_1D, + OPCODE_CONVOLUTION_FILTER_2D, + OPCODE_CONVOLUTION_PARAMETER_I, + OPCODE_CONVOLUTION_PARAMETER_IV, + OPCODE_CONVOLUTION_PARAMETER_F, + OPCODE_CONVOLUTION_PARAMETER_FV, + OPCODE_COPY_COLOR_SUB_TABLE, + OPCODE_COPY_COLOR_TABLE, + OPCODE_COPY_PIXELS, + OPCODE_COPY_TEX_IMAGE1D, + OPCODE_COPY_TEX_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE1D, + OPCODE_COPY_TEX_SUB_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE3D, + OPCODE_CULL_FACE, + OPCODE_DEPTH_FUNC, + OPCODE_DEPTH_MASK, + OPCODE_DEPTH_RANGE, + OPCODE_DISABLE, + OPCODE_DISABLE_INDEXED, + OPCODE_DRAW_BUFFER, + OPCODE_DRAW_PIXELS, + OPCODE_ENABLE, + OPCODE_ENABLE_INDEXED, + OPCODE_EVALMESH1, + OPCODE_EVALMESH2, + OPCODE_FOG, + OPCODE_FRONT_FACE, + OPCODE_FRUSTUM, + OPCODE_HINT, + OPCODE_HISTOGRAM, + OPCODE_INDEX_MASK, + OPCODE_INIT_NAMES, + OPCODE_LIGHT, + OPCODE_LIGHT_MODEL, + OPCODE_LINE_STIPPLE, + OPCODE_LINE_WIDTH, + OPCODE_LIST_BASE, + OPCODE_LOAD_IDENTITY, + OPCODE_LOAD_MATRIX, + OPCODE_LOAD_NAME, + OPCODE_LOGIC_OP, + OPCODE_MAP1, + OPCODE_MAP2, + OPCODE_MAPGRID1, + OPCODE_MAPGRID2, + OPCODE_MATRIX_MODE, + OPCODE_MIN_MAX, + OPCODE_MULT_MATRIX, + OPCODE_ORTHO, + OPCODE_PASSTHROUGH, + OPCODE_PIXEL_MAP, + OPCODE_PIXEL_TRANSFER, + OPCODE_PIXEL_ZOOM, + OPCODE_POINT_SIZE, + OPCODE_POINT_PARAMETERS, + OPCODE_POLYGON_MODE, + OPCODE_POLYGON_STIPPLE, + OPCODE_POLYGON_OFFSET, + OPCODE_POP_ATTRIB, + OPCODE_POP_MATRIX, + OPCODE_POP_NAME, + OPCODE_PRIORITIZE_TEXTURE, + OPCODE_PUSH_ATTRIB, + OPCODE_PUSH_MATRIX, + OPCODE_PUSH_NAME, + OPCODE_RASTER_POS, + OPCODE_READ_BUFFER, + OPCODE_RESET_HISTOGRAM, + OPCODE_RESET_MIN_MAX, + OPCODE_ROTATE, + OPCODE_SCALE, + OPCODE_SCISSOR, + OPCODE_SELECT_TEXTURE_SGIS, + OPCODE_SELECT_TEXTURE_COORD_SET, + OPCODE_SHADE_MODEL, + OPCODE_STENCIL_FUNC, + OPCODE_STENCIL_MASK, + OPCODE_STENCIL_OP, + OPCODE_TEXENV, + OPCODE_TEXGEN, + OPCODE_TEXPARAMETER, + OPCODE_TEX_IMAGE1D, + OPCODE_TEX_IMAGE2D, + OPCODE_TEX_IMAGE3D, + OPCODE_TEX_SUB_IMAGE1D, + OPCODE_TEX_SUB_IMAGE2D, + OPCODE_TEX_SUB_IMAGE3D, + OPCODE_TRANSLATE, + OPCODE_VIEWPORT, + OPCODE_WINDOW_POS, + /* GL_ARB_multitexture */ + OPCODE_ACTIVE_TEXTURE, + /* GL_ARB_texture_compression */ + OPCODE_COMPRESSED_TEX_IMAGE_1D, + OPCODE_COMPRESSED_TEX_IMAGE_2D, + OPCODE_COMPRESSED_TEX_IMAGE_3D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, + /* GL_ARB_multisample */ + OPCODE_SAMPLE_COVERAGE, + /* GL_ARB_window_pos */ + OPCODE_WINDOW_POS_ARB, + /* GL_NV_vertex_program */ + OPCODE_BIND_PROGRAM_NV, + OPCODE_EXECUTE_PROGRAM_NV, + OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, + OPCODE_LOAD_PROGRAM_NV, + OPCODE_TRACK_MATRIX_NV, + /* GL_NV_fragment_program */ + OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, + OPCODE_PROGRAM_NAMED_PARAMETER_NV, + /* GL_EXT_stencil_two_side */ + OPCODE_ACTIVE_STENCIL_FACE_EXT, + /* GL_EXT_depth_bounds_test */ + OPCODE_DEPTH_BOUNDS_EXT, + /* GL_ARB_vertex/fragment_program */ + OPCODE_PROGRAM_STRING_ARB, + OPCODE_PROGRAM_ENV_PARAMETER_ARB, + /* GL_ARB_occlusion_query */ + OPCODE_BEGIN_QUERY_ARB, + OPCODE_END_QUERY_ARB, + /* GL_ARB_draw_buffers */ + OPCODE_DRAW_BUFFERS_ARB, + /* GL_ATI_fragment_shader */ + OPCODE_TEX_BUMP_PARAMETER_ATI, + /* GL_ATI_fragment_shader */ + OPCODE_BIND_FRAGMENT_SHADER_ATI, + OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, + /* OpenGL 2.0 */ + OPCODE_STENCIL_FUNC_SEPARATE, + OPCODE_STENCIL_OP_SEPARATE, + OPCODE_STENCIL_MASK_SEPARATE, + + /* GL_ARB_shader_objects */ + OPCODE_USE_PROGRAM, + OPCODE_UNIFORM_1F, + OPCODE_UNIFORM_2F, + OPCODE_UNIFORM_3F, + OPCODE_UNIFORM_4F, + OPCODE_UNIFORM_1FV, + OPCODE_UNIFORM_2FV, + OPCODE_UNIFORM_3FV, + OPCODE_UNIFORM_4FV, + OPCODE_UNIFORM_1I, + OPCODE_UNIFORM_2I, + OPCODE_UNIFORM_3I, + OPCODE_UNIFORM_4I, + OPCODE_UNIFORM_1IV, + OPCODE_UNIFORM_2IV, + OPCODE_UNIFORM_3IV, + OPCODE_UNIFORM_4IV, + OPCODE_UNIFORM_MATRIX22, + OPCODE_UNIFORM_MATRIX33, + OPCODE_UNIFORM_MATRIX44, + OPCODE_UNIFORM_MATRIX23, + OPCODE_UNIFORM_MATRIX32, + OPCODE_UNIFORM_MATRIX24, + OPCODE_UNIFORM_MATRIX42, + OPCODE_UNIFORM_MATRIX34, + OPCODE_UNIFORM_MATRIX43, + + /* OpenGL 3.0 */ + OPCODE_UNIFORM_1UI, + OPCODE_UNIFORM_2UI, + OPCODE_UNIFORM_3UI, + OPCODE_UNIFORM_4UI, + OPCODE_UNIFORM_1UIV, + OPCODE_UNIFORM_2UIV, + OPCODE_UNIFORM_3UIV, + OPCODE_UNIFORM_4UIV, + + /* GL_EXT_framebuffer_blit */ + OPCODE_BLIT_FRAMEBUFFER, + + /* Vertex attributes -- fallback for when optimized display + * list build isn't active. + */ + OPCODE_ATTR_1F_NV, + OPCODE_ATTR_2F_NV, + OPCODE_ATTR_3F_NV, + OPCODE_ATTR_4F_NV, + OPCODE_ATTR_1F_ARB, + OPCODE_ATTR_2F_ARB, + OPCODE_ATTR_3F_ARB, + OPCODE_ATTR_4F_ARB, + OPCODE_MATERIAL, + OPCODE_BEGIN, + OPCODE_END, + OPCODE_RECTF, + OPCODE_EVAL_C1, + OPCODE_EVAL_C2, + OPCODE_EVAL_P1, + OPCODE_EVAL_P2, + + /* GL_EXT_provoking_vertex */ + OPCODE_PROVOKING_VERTEX, + + /* GL_EXT_transform_feedback */ + OPCODE_BEGIN_TRANSFORM_FEEDBACK, + OPCODE_END_TRANSFORM_FEEDBACK, + + /* GL_EXT_texture_integer */ + OPCODE_CLEARCOLOR_I, + OPCODE_CLEARCOLOR_UI, + OPCODE_TEXPARAMETER_I, + OPCODE_TEXPARAMETER_UI, + + /* GL_EXT_separate_shader_objects */ + OPCODE_ACTIVE_PROGRAM_EXT, + OPCODE_USE_SHADER_PROGRAM_EXT, + + /* The following three are meta instructions */ + OPCODE_ERROR, /* raise compiled-in error */ + OPCODE_CONTINUE, + OPCODE_END_OF_LIST, + OPCODE_EXT_0 +} OpCode; + + + +/** + * Display list node. + * + * Display list instructions are stored as sequences of "nodes". Nodes + * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks + * are linked together with a pointer. + * + * Each instruction in the display list is stored as a sequence of + * contiguous nodes in memory. + * Each node is the union of a variety of data types. + */ +union gl_dlist_node +{ + OpCode opcode; + GLboolean b; + GLbitfield bf; + GLubyte ub; + GLshort s; + GLushort us; + GLint i; + GLuint ui; + GLenum e; + GLfloat f; + GLvoid *data; + void *next; /* If prev node's opcode==OPCODE_CONTINUE */ +}; + + +typedef union gl_dlist_node Node; + + +/** + * How many nodes to allocate at a time. + * + * \note Reduced now that we hold vertices etc. elsewhere. + */ +#define BLOCK_SIZE 256 + + + +/** + * Number of nodes of storage needed for each instruction. + * Sizes for dynamically allocated opcodes are stored in the context struct. + */ +static GLuint InstSize[OPCODE_END_OF_LIST + 1]; + + +#if FEATURE_dlist + + +void mesa_print_display_list(GLuint list); + + +/**********************************************************************/ +/***** Private *****/ +/**********************************************************************/ + + +/** + * Make an empty display list. This is used by glGenLists() to + * reserve display list IDs. + */ +static struct gl_display_list * +make_list(GLuint name, GLuint count) +{ + struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); + dlist->Name = name; + dlist->Head = (Node *) malloc(sizeof(Node) * count); + dlist->Head[0].opcode = OPCODE_END_OF_LIST; + return dlist; +} + + +/** + * Lookup function to just encapsulate casting. + */ +static INLINE struct gl_display_list * +lookup_list(struct gl_context *ctx, GLuint list) +{ + return (struct gl_display_list *) + _mesa_HashLookup(ctx->Shared->DisplayList, list); +} + + +/** Is the given opcode an extension code? */ +static INLINE GLboolean +is_ext_opcode(OpCode opcode) +{ + return (opcode >= OPCODE_EXT_0); +} + + +/** Destroy an extended opcode instruction */ +static GLint +ext_opcode_destroy(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Execute an extended opcode instruction */ +static GLint +ext_opcode_execute(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Print an extended opcode instruction */ +static GLint +ext_opcode_print(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Print(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** + * Delete the named display list, but don't remove from hash table. + * \param dlist - display list pointer + */ +void +_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) +{ + Node *n, *block; + GLboolean done; + + n = block = dlist->Head; + + done = block ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + /* check for extension opcodes first */ + if (is_ext_opcode(opcode)) { + n += ext_opcode_destroy(ctx, n); + } + else { + switch (opcode) { + /* for some commands, we need to free malloc'd memory */ + case OPCODE_MAP1: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_MAP2: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_DRAW_PIXELS: + free(n[5].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_BITMAP: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_SUB_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_1D: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_2D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_POLYGON_STIPPLE: + free(n[1].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE1D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE3D: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; +#if FEATURE_NV_vertex_program + case OPCODE_LOAD_PROGRAM_NV: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + free(n[2].data); /* array of program ids */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + free(n[3].data); /* parameter name */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; +#endif + case OPCODE_UNIFORM_1FV: + case OPCODE_UNIFORM_2FV: + case OPCODE_UNIFORM_3FV: + case OPCODE_UNIFORM_4FV: + case OPCODE_UNIFORM_1IV: + case OPCODE_UNIFORM_2IV: + case OPCODE_UNIFORM_3IV: + case OPCODE_UNIFORM_4IV: + case OPCODE_UNIFORM_1UIV: + case OPCODE_UNIFORM_2UIV: + case OPCODE_UNIFORM_3UIV: + case OPCODE_UNIFORM_4UIV: + free(n[3].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_UNIFORM_MATRIX22: + case OPCODE_UNIFORM_MATRIX33: + case OPCODE_UNIFORM_MATRIX44: + case OPCODE_UNIFORM_MATRIX24: + case OPCODE_UNIFORM_MATRIX42: + case OPCODE_UNIFORM_MATRIX23: + case OPCODE_UNIFORM_MATRIX32: + case OPCODE_UNIFORM_MATRIX34: + case OPCODE_UNIFORM_MATRIX43: + free(n[4].data); + n += InstSize[n[0].opcode]; + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + free(block); + block = n; + break; + case OPCODE_END_OF_LIST: + free(block); + done = GL_TRUE; + break; + default: + /* Most frequent case */ + n += InstSize[n[0].opcode]; + break; + } + } + } + + free(dlist); +} + + +/** + * Destroy a display list and remove from hash table. + * \param list - display list number + */ +static void +destroy_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + + if (list == 0) + return; + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + _mesa_delete_list(ctx, dlist); + _mesa_HashRemove(ctx->Shared->DisplayList, list); +} + + +/* + * Translate the nth element of list from to GLint. + */ +static GLint +translate_id(GLsizei n, GLenum type, const GLvoid * list) +{ + GLbyte *bptr; + GLubyte *ubptr; + GLshort *sptr; + GLushort *usptr; + GLint *iptr; + GLuint *uiptr; + GLfloat *fptr; + + switch (type) { + case GL_BYTE: + bptr = (GLbyte *) list; + return (GLint) bptr[n]; + case GL_UNSIGNED_BYTE: + ubptr = (GLubyte *) list; + return (GLint) ubptr[n]; + case GL_SHORT: + sptr = (GLshort *) list; + return (GLint) sptr[n]; + case GL_UNSIGNED_SHORT: + usptr = (GLushort *) list; + return (GLint) usptr[n]; + case GL_INT: + iptr = (GLint *) list; + return iptr[n]; + case GL_UNSIGNED_INT: + uiptr = (GLuint *) list; + return (GLint) uiptr[n]; + case GL_FLOAT: + fptr = (GLfloat *) list; + return (GLint) FLOORF(fptr[n]); + case GL_2_BYTES: + ubptr = ((GLubyte *) list) + 2 * n; + return (GLint) ubptr[0] * 256 + + (GLint) ubptr[1]; + case GL_3_BYTES: + ubptr = ((GLubyte *) list) + 3 * n; + return (GLint) ubptr[0] * 65536 + + (GLint) ubptr[1] * 256 + + (GLint) ubptr[2]; + case GL_4_BYTES: + ubptr = ((GLubyte *) list) + 4 * n; + return (GLint) ubptr[0] * 16777216 + + (GLint) ubptr[1] * 65536 + + (GLint) ubptr[2] * 256 + + (GLint) ubptr[3]; + default: + return 0; + } +} + + + + +/**********************************************************************/ +/***** Public *****/ +/**********************************************************************/ + +/** + * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. + * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. + */ +static GLvoid * +unpack_image(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels, + const struct gl_pixelstore_attrib *unpack) +{ + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, pixels, unpack); + if (pixels && !image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { + const GLubyte *map, *src; + GLvoid *image; + + map = (GLubyte *) + ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); + if (!map) { + /* unable to map src buffer! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); + return NULL; + } + + src = ADD_POINTERS(map, pixels); + image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, src, unpack); + + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + /* bad access! */ + return NULL; +} + + +/** + * Allocate space for a display list instruction (opcode + payload space). + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction payload size (not counting opcode) + * \return pointer to allocated memory (the opcode space) + */ +static Node * +dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) +{ + const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); + Node *n; + + if (opcode < (GLuint) OPCODE_EXT_0) { + if (InstSize[opcode] == 0) { + /* save instruction size now */ + InstSize[opcode] = numNodes; + } + else { + /* make sure instruction size agrees */ + ASSERT(numNodes == InstSize[opcode]); + } + } + + if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { + /* This block is full. Allocate a new block and chain to it */ + Node *newblock; + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + n[0].opcode = OPCODE_CONTINUE; + newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); + if (!newblock) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); + return NULL; + } + n[1].next = (Node *) newblock; + ctx->ListState.CurrentBlock = newblock; + ctx->ListState.CurrentPos = 0; + } + + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + ctx->ListState.CurrentPos += numNodes; + + n[0].opcode = opcode; + + return n; +} + + + +/** + * Allocate space for a display list instruction. Used by callers outside + * this file for things like VBO vertex data. + * + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction size in bytes, not counting opcode. + * \return pointer to the usable data area (not including the internal + * opcode). + */ +void * +_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) +{ + Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); + if (n) + return n + 1; /* return pointer to payload area, after opcode */ + else + return NULL; +} + + +/** + * This function allows modules and drivers to get their own opcodes + * for extending display list functionality. + * \param ctx the rendering context + * \param size number of bytes for storing the new display list command + * \param execute function to execute the new display list command + * \param destroy function to destroy the new display list command + * \param print function to print the new display list command + * \return the new opcode number or -1 if error + */ +GLint +_mesa_dlist_alloc_opcode(struct gl_context *ctx, + GLuint size, + void (*execute) (struct gl_context *, void *), + void (*destroy) (struct gl_context *, void *), + void (*print) (struct gl_context *, void *)) +{ + if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { + const GLuint i = ctx->ListExt->NumOpcodes++; + ctx->ListExt->Opcode[i].Size = + 1 + (size + sizeof(Node) - 1) / sizeof(Node); + ctx->ListExt->Opcode[i].Execute = execute; + ctx->ListExt->Opcode[i].Destroy = destroy; + ctx->ListExt->Opcode[i].Print = print; + return i + OPCODE_EXT_0; + } + return -1; +} + + +/** + * Allocate space for a display list instruction. The space is basically + * an array of Nodes where node[0] holds the opcode, node[1] is the first + * function parameter, node[2] is the second parameter, etc. + * + * \param opcode one of OPCODE_x + * \param nparams number of function parameters + * \return pointer to start of instruction space + */ +static INLINE Node * +alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) +{ + return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); +} + + + +/* + * Display List compilation functions + */ +static void GLAPIENTRY +save_Accum(GLenum op, GLfloat value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACCUM, 2); + if (n) { + n[1].e = op; + n[2].f = value; + } + if (ctx->ExecuteFlag) { + CALL_Accum(ctx->Exec, (op, value)); + } +} + + +static void GLAPIENTRY +save_AlphaFunc(GLenum func, GLclampf ref) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); + if (n) { + n[1].e = func; + n[2].f = (GLfloat) ref; + } + if (ctx->ExecuteFlag) { + CALL_AlphaFunc(ctx->Exec, (func, ref)); + } +} + + +static void GLAPIENTRY +save_BindTexture(GLenum target, GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); + if (n) { + n[1].e = target; + n[2].ui = texture; + } + if (ctx->ExecuteFlag) { + CALL_BindTexture(ctx->Exec, (target, texture)); + } +} + + +static void GLAPIENTRY +save_Bitmap(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, const GLubyte * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BITMAP, 7); + if (n) { + n[1].i = (GLint) width; + n[2].i = (GLint) height; + n[3].f = xorig; + n[4].f = yorig; + n[5].f = xmove; + n[6].f = ymove; + n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_Bitmap(ctx->Exec, (width, height, + xorig, yorig, xmove, ymove, pixels)); + } +} + + +static void GLAPIENTRY +save_BlendEquation(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquation(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); + if (n) { + n[1].e = modeRGB; + n[2].e = modeA; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); + } +} + + +static void GLAPIENTRY +save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); + if (n) { + n[1].e = sfactorRGB; + n[2].e = dfactorRGB; + n[3].e = sfactorA; + n[4].e = dfactorA; + } + if (ctx->ExecuteFlag) { + CALL_BlendFuncSeparateEXT(ctx->Exec, + (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); + } +} + + +static void GLAPIENTRY +save_BlendFunc(GLenum srcfactor, GLenum dstfactor) +{ + save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); +} + + +static void GLAPIENTRY +save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); + } +} + +static void invalidate_saved_current_state( struct gl_context *ctx ) +{ + GLint i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + ctx->ListState.ActiveAttribSize[i] = 0; + + for (i = 0; i < MAT_ATTRIB_MAX; i++) + ctx->ListState.ActiveMaterialSize[i] = 0; + + memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); + + ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; +} + +static void GLAPIENTRY +save_CallList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); + if (n) { + n[1].ui = list; + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + _mesa_CallList(list); + } +} + + +static void GLAPIENTRY +save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean typeErrorFlag; + + SAVE_FLUSH_VERTICES(ctx); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + typeErrorFlag = GL_FALSE; + break; + default: + typeErrorFlag = GL_TRUE; + } + + for (i = 0; i < num; i++) { + GLint list = translate_id(i, type, lists); + Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); + if (n) { + n[1].i = list; + n[2].b = typeErrorFlag; + } + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + CALL_CallLists(ctx->Exec, (num, type, lists)); + } +} + + +static void GLAPIENTRY +save_Clear(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_Clear(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].i = value[0]; + if (buffer == GL_COLOR) { + n[4].i = value[1]; + n[5].i = value[2]; + n[6].i = value[3]; + } + else { + n[4].i = 0; + n[5].i = 0; + n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].ui = value[0]; + if (buffer == GL_COLOR) { + n[4].ui = value[1]; + n[5].ui = value[2]; + n[6].ui = value[3]; + } + else { + n[4].ui = 0; + n[5].ui = 0; + n[6].ui = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = value[0]; + if (buffer == GL_COLOR) { + n[4].f = value[1]; + n[5].f = value[2]; + n[6].f = value[3]; + } + else { + n[4].f = 0.0F; + n[5].f = 0.0F; + n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = depth; + n[4].i = stencil; + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ + } +} + + +static void GLAPIENTRY +save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearDepth(GLclampd depth) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); + if (n) { + n[1].f = (GLfloat) depth; + } + if (ctx->ExecuteFlag) { + CALL_ClearDepth(ctx->Exec, (depth)); + } +} + + +static void GLAPIENTRY +save_ClearIndex(GLfloat c) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); + if (n) { + n[1].f = c; + } + if (ctx->ExecuteFlag) { + CALL_ClearIndex(ctx->Exec, (c)); + } +} + + +static void GLAPIENTRY +save_ClearStencil(GLint s) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); + if (n) { + n[1].i = s; + } + if (ctx->ExecuteFlag) { + CALL_ClearStencil(ctx->Exec, (s)); + } +} + + +static void GLAPIENTRY +save_ClipPlane(GLenum plane, const GLdouble * equ) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); + if (n) { + n[1].e = plane; + n[2].f = (GLfloat) equ[0]; + n[3].f = (GLfloat) equ[1]; + n[4].f = (GLfloat) equ[2]; + n[5].f = (GLfloat) equ[3]; + } + if (ctx->ExecuteFlag) { + CALL_ClipPlane(ctx->Exec, (plane, equ)); + } +} + + + +static void GLAPIENTRY +save_ColorMask(GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); + if (n) { + n[1].b = red; + n[2].b = green; + n[3].b = blue; + n[4].b = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); + if (n) { + n[1].ui = buf; + n[2].b = red; + n[3].b = green; + n[4].b = blue; + n[5].b = alpha; + } + if (ctx->ExecuteFlag) { + /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ + } +} + + +static void GLAPIENTRY +save_ColorMaterial(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ColorMaterial(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_ColorTable(GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + if (_mesa_is_proxy_texture(target)) { + /* execute immediately */ + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + } +} + + + +static void GLAPIENTRY +save_ColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); + } +} + + + +static void GLAPIENTRY +save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = count; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorSubTable(ctx->Exec, + (target, start, count, format, type, table)); + } +} + + +static void GLAPIENTRY +save_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); + if (n) { + n[1].e = target; + n[2].e = internalformat; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, + GLenum format, GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, + format, type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].i = height; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + n[5].e = type; + } + if (ctx->ExecuteFlag) { + CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); + } +} + + + +static void GLAPIENTRY +save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, + x, y, width, border)); + } +} + + +static void GLAPIENTRY +save_CopyTexImage2D(GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = height; + n[8].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, + x, y, width, height, border)); + } +} + + + +static void GLAPIENTRY +save_CopyTexSubImage1D(GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = x; + n[5].i = y; + n[6].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage1D(ctx->Exec, + (target, level, xoffset, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = x; + n[7].i = y; + n[8].i = width; + n[9].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CullFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_CullFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DepthFunc(GLenum func) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); + if (n) { + n[1].e = func; + } + if (ctx->ExecuteFlag) { + CALL_DepthFunc(ctx->Exec, (func)); + } +} + + +static void GLAPIENTRY +save_DepthMask(GLboolean mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); + if (n) { + n[1].b = mask; + } + if (ctx->ExecuteFlag) { + CALL_DepthMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_DepthRange(GLclampd nearval, GLclampd farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); + if (n) { + n[1].f = (GLfloat) nearval; + n[2].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_DepthRange(ctx->Exec, (nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Disable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Disable(ctx->Exec, (cap)); + } +} + + +static void GLAPIENTRY +save_DisableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + +static void GLAPIENTRY +save_DrawBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DrawPixels(GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); + if (n) { + n[1].i = width; + n[2].i = height; + n[3].e = format; + n[4].e = type; + n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); + } +} + + + +static void GLAPIENTRY +save_Enable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Enable(ctx->Exec, (cap)); + } +} + + + +static void GLAPIENTRY +save_EnableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + + +static void GLAPIENTRY +save_EvalMesh1(GLenum mode, GLint i1, GLint i2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); + } +} + + +static void GLAPIENTRY +save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + n[4].i = j1; + n[5].i = j2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); + } +} + + + + +static void GLAPIENTRY +save_Fogfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FOG, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_Fogfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_Fogf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Fogfv(pname, parray); +} + + +static void GLAPIENTRY +save_Fogiv(GLenum pname, const GLint *params) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + p[1] = 0.0f; + p[2] = 0.0f; + p[3] = 0.0f; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT(params[0]); + p[1] = INT_TO_FLOAT(params[1]); + p[2] = INT_TO_FLOAT(params[2]); + p[3] = INT_TO_FLOAT(params[3]); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_Fogfv(pname, p); +} + + +static void GLAPIENTRY +save_Fogi(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Fogiv(pname, parray); +} + + +static void GLAPIENTRY +save_FrontFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_FrontFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Frustum(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Hint(GLenum target, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HINT, 2); + if (n) { + n[1].e = target; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_Hint(ctx->Exec, (target, mode)); + } +} + + +static void GLAPIENTRY +save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, + GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); + if (n) { + n[1].e = target; + n[2].i = width; + n[3].e = internalFormat; + n[4].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_IndexMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_IndexMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_InitNames(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); + if (ctx->ExecuteFlag) { + CALL_InitNames(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT, 6); + if (n) { + GLint i, nParams; + n[1].e = light; + n[2].e = pname; + switch (pname) { + case GL_AMBIENT: + nParams = 4; + break; + case GL_DIFFUSE: + nParams = 4; + break; + case GL_SPECULAR: + nParams = 4; + break; + case GL_POSITION: + nParams = 4; + break; + case GL_SPOT_DIRECTION: + nParams = 3; + break; + case GL_SPOT_EXPONENT: + nParams = 1; + break; + case GL_SPOT_CUTOFF: + nParams = 1; + break; + case GL_CONSTANT_ATTENUATION: + nParams = 1; + break; + case GL_LINEAR_ATTENUATION: + nParams = 1; + break; + case GL_QUADRATIC_ATTENUATION: + nParams = 1; + break; + default: + nParams = 0; + } + for (i = 0; i < nParams; i++) { + n[3 + i].f = params[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_Lightfv(ctx->Exec, (light, pname, params)); + } +} + + +static void GLAPIENTRY +save_Lightf(GLenum light, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Lightfv(light, pname, parray); +} + + +static void GLAPIENTRY +save_Lightiv(GLenum light, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + save_Lightfv(light, pname, fparam); +} + + +static void GLAPIENTRY +save_Lighti(GLenum light, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Lightiv(light, pname, parray); +} + + +static void GLAPIENTRY +save_LightModelfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_LightModelfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_LightModelf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_LightModelfv(pname, parray); +} + + +static void GLAPIENTRY +save_LightModeliv(GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + fparam[1] = 0.0F; + fparam[2] = 0.0F; + fparam[3] = 0.0F; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_LightModelfv(pname, fparam); +} + + +static void GLAPIENTRY +save_LightModeli(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_LightModeliv(pname, parray); +} + + +static void GLAPIENTRY +save_LineStipple(GLint factor, GLushort pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); + if (n) { + n[1].i = factor; + n[2].us = pattern; + } + if (ctx->ExecuteFlag) { + CALL_LineStipple(ctx->Exec, (factor, pattern)); + } +} + + +static void GLAPIENTRY +save_LineWidth(GLfloat width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); + if (n) { + n[1].f = width; + } + if (ctx->ExecuteFlag) { + CALL_LineWidth(ctx->Exec, (width)); + } +} + + +static void GLAPIENTRY +save_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); + if (n) { + n[1].ui = base; + } + if (ctx->ExecuteFlag) { + CALL_ListBase(ctx->Exec, (base)); + } +} + + +static void GLAPIENTRY +save_LoadIdentity(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); + if (ctx->ExecuteFlag) { + CALL_LoadIdentity(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_LoadMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_LoadMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_LoadMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_LoadMatrixf(f); +} + + +static void GLAPIENTRY +save_LoadName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_LoadName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_LogicOp(GLenum opcode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); + if (n) { + n[1].e = opcode; + } + if (ctx->ExecuteFlag) { + CALL_LogicOp(ctx->Exec, (opcode)); + } +} + + +static void GLAPIENTRY +save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + +static void GLAPIENTRY +save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + + +static void GLAPIENTRY +save_Map2d(GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].f = (GLfloat) v1; + n[5].f = (GLfloat) v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2d(ctx->Exec, (target, + u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_Map2f(GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].f = v1; + n[5].f = v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); + } +} + + +static void GLAPIENTRY +save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) +{ + save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); +} + + +static void GLAPIENTRY +save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + n[4].i = vn; + n[5].f = v1; + n[6].f = v2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); + } +} + + + +static void GLAPIENTRY +save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2) +{ + save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2); +} + + +static void GLAPIENTRY +save_MatrixMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_MatrixMode(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_MultMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_MultMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_MultMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_MultMatrixf(f); +} + + +static void GLAPIENTRY +save_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + /* It's an error to call this function while building a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + (void) name; + (void) mode; +} + + + +static void GLAPIENTRY +save_Ortho(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ORTHO, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); + if (n) { + n[1].e = map; + n[2].i = mapsize; + n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); + memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); + } +} + + +static void GLAPIENTRY +save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = UINT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = USHORT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelTransferf(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); + if (n) { + n[1].e = pname; + n[2].f = param; + } + if (ctx->ExecuteFlag) { + CALL_PixelTransferf(ctx->Exec, (pname, param)); + } +} + + +static void GLAPIENTRY +save_PixelTransferi(GLenum pname, GLint param) +{ + save_PixelTransferf(pname, (GLfloat) param); +} + + +static void GLAPIENTRY +save_PixelZoom(GLfloat xfactor, GLfloat yfactor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); + if (n) { + n[1].f = xfactor; + n[2].f = yfactor; + } + if (ctx->ExecuteFlag) { + CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); + } +} + + +static void GLAPIENTRY +save_PointParameterfvEXT(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + } + if (ctx->ExecuteFlag) { + CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_PointParameterfEXT(GLenum pname, GLfloat param) +{ + GLfloat parray[3]; + parray[0] = param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameteriNV(GLenum pname, GLint param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameterivNV(GLenum pname, const GLint * param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param[0]; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + + +static void GLAPIENTRY +save_PointSize(GLfloat size) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); + if (n) { + n[1].f = size; + } + if (ctx->ExecuteFlag) { + CALL_PointSize(ctx->Exec, (size)); + } +} + + +static void GLAPIENTRY +save_PolygonMode(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_PolygonMode(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_PolygonStipple(const GLubyte * pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); + if (n) { + n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + pattern, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); + } +} + + +static void GLAPIENTRY +save_PolygonOffset(GLfloat factor, GLfloat units) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); + if (n) { + n[1].f = factor; + n[2].f = units; + } + if (ctx->ExecuteFlag) { + CALL_PolygonOffset(ctx->Exec, (factor, units)); + } +} + + +static void GLAPIENTRY +save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) +{ + GET_CURRENT_CONTEXT(ctx); + /* XXX mult by DepthMaxF here??? */ + save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); +} + + +static void GLAPIENTRY +save_PopAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); + if (ctx->ExecuteFlag) { + CALL_PopAttrib(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PopMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopName(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); + if (ctx->ExecuteFlag) { + CALL_PopName(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PrioritizeTextures(GLsizei num, const GLuint * textures, + const GLclampf * priorities) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < num; i++) { + Node *n; + n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); + if (n) { + n[1].ui = textures[i]; + n[2].f = priorities[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); + } +} + + +static void GLAPIENTRY +save_PushAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_PushAttrib(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_PushMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PushMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PushName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_PushName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_RasterPos2d(GLdouble x, GLdouble y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2f(GLfloat x, GLfloat y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2i(GLint x, GLint y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2s(GLshort x, GLshort y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3i(GLint x, GLint y, GLint z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_RasterPos4f(x, y, z, w); +} + +static void GLAPIENTRY +save_RasterPos2dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_RasterPos4iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_PassThrough(GLfloat token) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); + if (n) { + n[1].f = token; + } + if (ctx->ExecuteFlag) { + CALL_PassThrough(ctx->Exec, (token)); + } +} + + +static void GLAPIENTRY +save_ReadBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ReadBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetHistogram(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetMinmax(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ROTATE, 4); + if (n) { + n[1].f = angle; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Rotatef(ctx->Exec, (angle, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) +{ + save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scalef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCALE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Scalef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Scaled(GLdouble x, GLdouble y, GLdouble z) +{ + save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = width; + n[4].i = height; + } + if (ctx->ExecuteFlag) { + CALL_Scissor(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_ShadeModel(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); + + if (ctx->ExecuteFlag) { + CALL_ShadeModel(ctx->Exec, (mode)); + } + + if (ctx->ListState.Current.ShadeModel == mode) + return; + + SAVE_FLUSH_VERTICES(ctx); + + /* Only save the value if we know the statechange will take effect: + */ + if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) + ctx->ListState.Current.ShadeModel = mode; + + n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); + if (n) { + n[1].e = mode; + } +} + + +static void GLAPIENTRY +save_StencilFunc(GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); + if (n) { + n[1].e = func; + n[2].i = ref; + n[3].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFunc(ctx->Exec, (func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); + if (n) { + n[1].e = fail; + n[2].e = zfail; + n[3].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = func; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, + GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* GL_FRONT */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_FRONT; + n[2].e = frontfunc; + n[3].i = ref; + n[4].ui = mask; + } + /* GL_BACK */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_BACK; + n[2].e = backfunc; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); + CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); + if (n) { + n[1].e = face; + n[2].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); + } +} + + +static void GLAPIENTRY +save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = fail; + n[3].e = zfail; + n[4].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXENV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + if (pname == GL_TEXTURE_ENV_COLOR) { + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[3].f = params[0]; + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_TexEnvfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexEnvfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexEnvi(GLenum target, GLenum pname, GLint param) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0F; + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexEnviv(GLenum target, GLenum pname, const GLint * param) +{ + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0.0F; + } + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); + if (n) { + n[1].e = coord; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexGenfv(ctx->Exec, (coord, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGend(GLenum coord, GLenum pname, GLdouble param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGeni(GLenum coord, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_TexGeniv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexParameterfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) params[0]; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexImage1D(GLenum target, + GLint level, GLint components, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = border; + n[6].e = format; + n[7].e = type; + n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage2D(GLenum target, + GLint level, GLint components, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage3D(GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = (GLint) internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].e = format; + n[9].e = type; + n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, + format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + width, height, format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].e = type; + n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + width, height, depth, format, type, + pixels)); + } +} + + +static void GLAPIENTRY +save_Translatef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Translatef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Translated(GLdouble x, GLdouble y, GLdouble z) +{ + save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + + +static void GLAPIENTRY +save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + } + if (ctx->ExecuteFlag) { + CALL_Viewport(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_WindowPos2dMESA(GLdouble x, GLdouble y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fMESA(GLfloat x, GLfloat y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2iMESA(GLint x, GLint y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2sMESA(GLshort x, GLshort y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3iMESA(GLint x, GLint y, GLint z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_WindowPos4fMESA(x, y, z, w); +} + +static void GLAPIENTRY +save_WindowPos2dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_WindowPos4ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + + + +/* GL_ARB_multitexture */ +static void GLAPIENTRY +save_ActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ActiveTextureARB(ctx->Exec, (target)); + } +} + + +/* GL_ARB_transpose_matrix */ + +static void GLAPIENTRY +save_LoadTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_LoadTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_MultMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_MultMatrixf(tm); +} + + +/* GL_ARB_texture_compression */ +static void GLAPIENTRY +save_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, + width, border, imageSize, + data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = border; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage1DARB(ctx->Exec, + (target, level, internalFormat, width, + border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, + width, height, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].i = imageSize; + n[8].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage2DARB(ctx->Exec, + (target, level, internalFormat, width, + height, border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, + width, height, depth, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage3DARB(ctx->Exec, + (target, level, internalFormat, width, + height, depth, border, imageSize, + data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, + width, format, imageSize, + data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (target, level, xoffset, yoffset, width, + height, format, imageSize, data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].i = imageSize; + n[11].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (target, level, xoffset, yoffset, + zoffset, width, height, depth, format, + imageSize, data)); + } +} + + +/* GL_ARB_multisample */ +static void GLAPIENTRY +save_SampleCoverageARB(GLclampf value, GLboolean invert) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); + if (n) { + n[1].f = value; + n[2].b = invert; + } + if (ctx->ExecuteFlag) { + CALL_SampleCoverageARB(ctx->Exec, (value, invert)); + } +} + + +/* + * GL_NV_vertex_program + */ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +static void GLAPIENTRY +save_BindProgramNV(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindProgramNV(ctx->Exec, (target, id)); + } +} + +static void GLAPIENTRY +save_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + save_ProgramEnvParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +static void GLAPIENTRY +save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat * params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) x, + (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) params[0], + (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ + +#if FEATURE_NV_vertex_program +static void GLAPIENTRY +save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); + if (n) { + n[1].e = target; + n[2].ui = id; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4dvNV(GLenum target, GLuint index, + GLsizei num, const GLdouble *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4fvNV(GLenum target, GLuint index, + GLsizei num, const GLfloat *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte * program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + memcpy(programCopy, program, len); + n[1].e = target; + n[2].ui = id; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); + } +} + + +static void GLAPIENTRY +save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); + if (n) { + GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); + if (!idCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); + return; + } + memcpy(idCopy, ids, num * sizeof(GLuint)); + n[1].i = num; + n[2].data = idCopy; + } + if (ctx->ExecuteFlag) { + CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); + } +} + + +static void GLAPIENTRY +save_TrackMatrixNV(GLenum target, GLuint address, + GLenum matrix, GLenum transform) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); + if (n) { + n[1].e = target; + n[2].ui = address; + n[3].e = matrix; + n[4].e = transform; + } + if (ctx->ExecuteFlag) { + CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); + } +} +#endif /* FEATURE_NV_vertex_program */ + + +/* + * GL_NV_fragment_program + */ +#if FEATURE_NV_fragment_program +static void GLAPIENTRY +save_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) x; + n[4].f = (GLfloat) y; + n[5].f = (GLfloat) z; + n[6].f = (GLfloat) w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) params[0]; + n[4].f = (GLfloat) params[1]; + n[5].f = (GLfloat) params[2]; + n[6].f = (GLfloat) params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); + } +} + +static void GLAPIENTRY +save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); + if (n) { + GLubyte *nameCopy = (GLubyte *) malloc(len); + if (!nameCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); + return; + } + memcpy(nameCopy, name, len); + n[1].ui = id; + n[2].i = len; + n[3].data = nameCopy; + n[4].f = x; + n[5].f = y; + n[6].f = z; + n[7].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, + const float v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, + const double v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], + (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +#endif /* FEATURE_NV_fragment_program */ + + + +/* GL_EXT_stencil_two_side */ +static void GLAPIENTRY +save_ActiveStencilFaceEXT(GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); + if (n) { + n[1].e = face; + } + if (ctx->ExecuteFlag) { + CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); + } +} + + +/* GL_EXT_depth_bounds_test */ +static void GLAPIENTRY +save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); + if (n) { + n[1].f = (GLfloat) zmin; + n[2].f = (GLfloat) zmax; + } + if (ctx->ExecuteFlag) { + CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); + } +} + + + +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + +static void GLAPIENTRY +save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid * string) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); + return; + } + memcpy(programCopy, string, len); + n[1].e = target; + n[2].e = format; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); + } +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ + + +#if FEATURE_queryobj + +static void GLAPIENTRY +save_BeginQueryARB(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BeginQueryARB(ctx->Exec, (target, id)); + } +} + + +static void GLAPIENTRY +save_EndQueryARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_EndQueryARB(ctx->Exec, (target)); + } +} + +#endif /* FEATURE_queryobj */ + + +static void GLAPIENTRY +save_DrawBuffersARB(GLsizei count, const GLenum * buffers) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); + if (n) { + GLint i; + n[1].i = count; + if (count > MAX_DRAW_BUFFERS) + count = MAX_DRAW_BUFFERS; + for (i = 0; i < count; i++) { + n[2 + i].e = buffers[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); + if (n) { + n[1].ui = pname; + n[2].f = param[0]; + n[3].f = param[1]; + n[4].f = param[2]; + n[5].f = param[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterivATI(GLenum pname, const GLint *param) +{ + GLfloat p[4]; + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + save_TexBumpParameterfvATI(pname, p); +} + +#if FEATURE_ATI_fragment_shader +static void GLAPIENTRY +save_BindFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); + if (n) { + n[1].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindFragmentShaderATI(ctx->Exec, (id)); + } +} + +static void GLAPIENTRY +save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); + if (n) { + n[1].ui = dst; + n[2].f = value[0]; + n[3].f = value[1]; + n[4].f = value[2]; + n[5].f = value[3]; + } + if (ctx->ExecuteFlag) { + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); + } +} +#endif + +static void +save_Attr1fNV(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); + } +} + +static void +save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); + } +} + +static void +save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); + } +} + +static void +save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void +save_Attr1fARB(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); + } +} + +static void +save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); + } +} + +static void +save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); + } +} + +static void +save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_EvalCoord1f(GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); + if (n) { + n[1].f = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord1f(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalCoord1fv(const GLfloat * v) +{ + save_EvalCoord1f(v[0]); +} + +static void GLAPIENTRY +save_EvalCoord2f(GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); + if (n) { + n[1].f = x; + n[2].f = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord2f(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_EvalCoord2fv(const GLfloat * v) +{ + save_EvalCoord2f(v[0], v[1]); +} + + +static void GLAPIENTRY +save_EvalPoint1(GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); + if (n) { + n[1].i = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint1(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalPoint2(GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); + if (n) { + n[1].i = x; + n[2].i = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint2(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_Indexf(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); +} + +static void GLAPIENTRY +save_Indexfv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); +} + +static void GLAPIENTRY +save_EdgeFlag(GLboolean x) +{ + save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); +} + +static INLINE GLboolean compare4fv( const GLfloat *a, + const GLfloat *b, + GLuint count ) +{ + return memcmp( a, b, count * sizeof(GLfloat) ) == 0; +} + + +static void GLAPIENTRY +save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + int args, i; + GLuint bitmask; + + switch (face) { + case GL_BACK: + case GL_FRONT: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); + return; + } + + switch (pname) { + case GL_EMISSION: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_AMBIENT_AND_DIFFUSE: + args = 4; + break; + case GL_SHININESS: + args = 1; + break; + case GL_COLOR_INDEXES: + args = 3; + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); + return; + } + + if (ctx->ExecuteFlag) { + CALL_Materialfv(ctx->Exec, (face, pname, param)); + } + + bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); + + /* Try to eliminate redundant statechanges. Because it is legal to + * call glMaterial even inside begin/end calls, don't need to worry + * about ctx->Driver.CurrentSavePrimitive here. + */ + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + if (bitmask & (1 << i)) { + if (ctx->ListState.ActiveMaterialSize[i] == args && + compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { + bitmask &= ~(1 << i); + } + else { + ctx->ListState.ActiveMaterialSize[i] = args; + COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + } + } + } + + /* If this call has effect, return early: + */ + if (bitmask == 0) + return; + + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); + if (n) { + n[1].e = face; + n[2].e = pname; + for (i = 0; i < args; i++) + n[3 + i].f = param[i]; + } +} + +static void GLAPIENTRY +save_Begin(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + GLboolean error = GL_FALSE; + + if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { + _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); + error = GL_TRUE; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { + /* Typically the first begin. This may raise an error on + * playback, depending on whether CallList is issued from inside + * a begin/end or not. + */ + ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { + ctx->Driver.CurrentSavePrimitive = mode; + } + else { + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); + error = GL_TRUE; + } + + if (!error) { + /* Give the driver an opportunity to hook in an optimized + * display list compiler. + */ + if (ctx->Driver.NotifySaveBegin(ctx, mode)) + return; + + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN, 1); + if (n) { + n[1].e = mode; + } + } + + if (ctx->ExecuteFlag) { + CALL_Begin(ctx->Exec, (mode)); + } +} + +static void GLAPIENTRY +save_End(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + (void) alloc_instruction(ctx, OPCODE_END, 0); + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + if (ctx->ExecuteFlag) { + CALL_End(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_RECTF, 4); + if (n) { + n[1].f = a; + n[2].f = b; + n[3].f = c; + n[4].f = d; + } + if (ctx->ExecuteFlag) { + CALL_Rectf(ctx->Exec, (a, b, c, d)); + } +} + + +static void GLAPIENTRY +save_Vertex2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_POS, x, y); +} + +static void GLAPIENTRY +save_Vertex2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); +} + +static void GLAPIENTRY +save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); +} + +static void GLAPIENTRY +save_Vertex3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); +} + +static void GLAPIENTRY +save_Vertex4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_TexCoord1f(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, x); +} + +static void GLAPIENTRY +save_TexCoord1fv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); +} + +static void GLAPIENTRY +save_TexCoord2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); +} + +static void GLAPIENTRY +save_TexCoord2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); +} + +static void GLAPIENTRY +save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); +} + +static void GLAPIENTRY +save_TexCoord3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); +} + +static void GLAPIENTRY +save_TexCoord4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_Normal3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); +} + +static void GLAPIENTRY +save_Normal3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_FogCoordfEXT(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, x); +} + +static void GLAPIENTRY +save_FogCoordfvEXT(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); +} + +static void GLAPIENTRY +save_Color3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); +} + +static void GLAPIENTRY +save_Color3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); +} + +static void GLAPIENTRY +save_Color4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); +} + +static void GLAPIENTRY +save_SecondaryColor3fvEXT(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); +} + + +/* Just call the respective ATTR for texcoord + */ +static void GLAPIENTRY +save_MultiTexCoord1f(GLenum target, GLfloat x) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, x); +} + +static void GLAPIENTRY +save_MultiTexCoord1fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, v[0]); +} + +static void GLAPIENTRY +save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, x, y); +} + +static void GLAPIENTRY +save_MultiTexCoord2fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, v[0], v[1]); +} + +static void GLAPIENTRY +save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, x, y, z); +} + +static void GLAPIENTRY +save_MultiTexCoord3fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, x, y, z, w); +} + +static void GLAPIENTRY +save_MultiTexCoord4fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); +} + + +/** + * Record a GL_INVALID_VALUE error when a invalid vertex attribute + * index is found. + */ +static void +index_error(void) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); +} + + +/* First level for NV_vertex_program: + * + * Check for errors at compile time?. + */ +static void GLAPIENTRY +save_VertexAttrib1fNV(GLuint index, GLfloat x) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + + + +static void GLAPIENTRY +save_VertexAttrib1fARB(GLuint index, GLfloat x) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + +/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + +static void GLAPIENTRY +exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); +} + +static GLint GLAPIENTRY +exec_GetAttribLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); +} + +static GLint GLAPIENTRY +exec_GetUniformLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); +} +/* XXX more shader functions needed here */ + + +#if FEATURE_EXT_framebuffer_blit +static void GLAPIENTRY +save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); + if (n) { + n[1].i = srcX0; + n[2].i = srcY0; + n[3].i = srcX1; + n[4].i = srcY1; + n[5].i = dstX0; + n[6].i = dstY0; + n[7].i = dstX1; + n[8].i = dstY1; + n[9].i = mask; + n[10].e = filter; + } + if (ctx->ExecuteFlag) { + CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter)); + } +} +#endif + + +/** GL_EXT_provoking_vertex */ +static void GLAPIENTRY +save_ProvokingVertexEXT(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ + _mesa_ProvokingVertexEXT(mode); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_BeginTransformFeedback(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_EndTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + } +} + + +/* aka UseProgram() */ +static void GLAPIENTRY +save_UseProgramObjectARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseProgramObjectARB(ctx->Exec, (program)); + } +} + + +static void GLAPIENTRY +save_Uniform1fARB(GLint location, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); + if (n) { + n[1].i = location; + n[2].f = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fARB(ctx->Exec, (location, x)); + } +} + + +static void GLAPIENTRY +save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fARB(ctx->Exec, (location, x, y)); + } +} + + +static void GLAPIENTRY +save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); + } +} + + +/** Return copy of memory */ +static void * +memdup(const void *src, GLsizei bytes) +{ + void *b = bytes >= 0 ? malloc(bytes) : NULL; + if (b) + memcpy(b, src, bytes); + return b; +} + + +static void GLAPIENTRY +save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); + } +} + + +static void GLAPIENTRY +save_Uniform1iARB(GLint location, GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1iARB(ctx->Exec, (location, x)); + } +} + +static void GLAPIENTRY +save_Uniform2iARB(GLint location, GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2iARB(ctx->Exec, (location, x, y)); + } +} + +static void GLAPIENTRY +save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); + } +} + +static void GLAPIENTRY +save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ui(GLint location, GLuint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ + } +} + +static void GLAPIENTRY +save_Uniform2ui(GLint location, GLuint x, GLuint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ + } +} + +static void GLAPIENTRY +save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ + } +} + +static void GLAPIENTRY +save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ + } +} + + + +static void GLAPIENTRY +save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ + } +} + + + +static void GLAPIENTRY +save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UseShaderProgramEXT(GLenum type, GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); + if (n) { + n[1].ui = type; + n[2].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); + } +} + +static void GLAPIENTRY +save_ActiveProgramEXT(GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_ActiveProgramEXT(ctx->Exec, (program)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); + if (n) { + n[1].i = red; + n[2].i = green; + n[3].i = blue; + n[4].i = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); + if (n) { + n[1].ui = red; + n[2].ui = green; + n[3].ui = blue; + n[4].ui = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].ui = params[0]; + n[4].ui = params[1]; + n[5].ui = params[2]; + n[6].ui = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); +} + + + + + +/** + * Save an error-generating command into display list. + * + * KW: Will appear in the list before the vertex buffer containing the + * command that provoked the error. I don't see this as a problem. + */ +static void +save_error(struct gl_context *ctx, GLenum error, const char *s) +{ + Node *n; + n = alloc_instruction(ctx, OPCODE_ERROR, 2); + if (n) { + n[1].e = error; + n[2].data = (void *) s; + } +} + + +/** + * Compile an error into current display list. + */ +void +_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) +{ + if (ctx->CompileFlag) + save_error(ctx, error, s); + if (ctx->ExecuteFlag) + _mesa_error(ctx, error, "%s", s); +} + + +/** + * Test if ID names a display list. + */ +static GLboolean +islist(struct gl_context *ctx, GLuint list) +{ + if (list > 0 && lookup_list(ctx, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/**********************************************************************/ +/* Display list execution */ +/**********************************************************************/ + + +/* + * Execute a display list. Note that the ListBase offset must have already + * been added before calling this function. I.e. the list argument is + * the absolute list number, not relative to ListBase. + * \param list - display list number + */ +static void +execute_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (list == 0 || !islist(ctx, list)) + return; + + if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { + /* raise an error? */ + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + ctx->ListState.CallDepth++; + + if (ctx->Driver.BeginCallList) + ctx->Driver.BeginCallList(ctx, dlist); + + n = dlist->Head; + + done = GL_FALSE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_execute(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ERROR: + _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); + break; + case OPCODE_ACCUM: + CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ALPHA_FUNC: + CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_BIND_TEXTURE: + CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_BITMAP: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, + (const GLubyte *) n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_BLEND_COLOR: + CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_BLEND_EQUATION: + CALL_BlendEquation(ctx->Exec, (n[1].e)); + break; + case OPCODE_BLEND_EQUATION_SEPARATE: + CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE: + CALL_BlendFuncSeparateEXT(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + case OPCODE_CALL_LIST: + /* Generated by glCallList(), don't add ListBase */ + if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + execute_list(ctx, n[1].ui); + } + break; + case OPCODE_CALL_LIST_OFFSET: + /* Generated by glCallLists() so we must add ListBase */ + if (n[2].b) { + /* user specified a bad data type at compile time */ + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + } + else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); + execute_list(ctx, list); + } + break; + case OPCODE_CLEAR: + CALL_Clear(ctx->Exec, (n[1].bf)); + break; + case OPCODE_CLEAR_BUFFER_IV: + { + GLint value[4]; + value[0] = n[3].i; + value[1] = n[4].i; + value[2] = n[5].i; + value[3] = n[6].i; + /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_UIV: + { + GLuint value[4]; + value[0] = n[3].ui; + value[1] = n[4].ui; + value[2] = n[5].ui; + value[3] = n[6].ui; + /*CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FV: + { + GLfloat value[4]; + value[0] = n[3].f; + value[1] = n[4].f; + value[2] = n[5].f; + value[3] = n[6].f; + /*CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FI: + /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/ + break; + case OPCODE_CLEAR_COLOR: + CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_ACCUM: + CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_DEPTH: + CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); + break; + case OPCODE_CLEAR_INDEX: + CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); + break; + case OPCODE_CLEAR_STENCIL: + CALL_ClearStencil(ctx->Exec, (n[1].i)); + break; + case OPCODE_CLIP_PLANE: + { + GLdouble eq[4]; + eq[0] = n[2].f; + eq[1] = n[3].f; + eq[2] = n[4].f; + eq[3] = n[5].f; + CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); + } + break; + case OPCODE_COLOR_MASK: + CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); + break; + case OPCODE_COLOR_MASK_INDEXED: + CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b, + n[4].b, n[5].b)); + break; + case OPCODE_COLOR_MATERIAL: + CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_COLOR_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e, + n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ColorTableParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ColorTableParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_SUB_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, + n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, n[6].e, + n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_PARAMETER_I: + CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i)); + break; + case OPCODE_CONVOLUTION_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ConvolutionParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_CONVOLUTION_PARAMETER_F: + CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f)); + break; + case OPCODE_CONVOLUTION_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ConvolutionParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COPY_COLOR_SUB_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_COLOR_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_PIXELS: + CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i, + n[5].e)); + break; + case OPCODE_COPY_TEX_IMAGE1D: + CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i)); + break; + case OPCODE_COPY_TEX_IMAGE2D: + CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE1D: + CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE2D: + CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE3D: + CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].i)); + break; + case OPCODE_CULL_FACE: + CALL_CullFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_FUNC: + CALL_DepthFunc(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_MASK: + CALL_DepthMask(ctx->Exec, (n[1].b)); + break; + case OPCODE_DEPTH_RANGE: + CALL_DepthRange(ctx->Exec, + ((GLclampd) n[1].f, (GLclampd) n[2].f)); + break; + case OPCODE_DISABLE: + CALL_Disable(ctx->Exec, (n[1].e)); + break; + case OPCODE_DISABLE_INDEXED: + CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_DRAW_BUFFER: + CALL_DrawBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_DRAW_PIXELS: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, + n[5].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_ENABLE: + CALL_Enable(ctx->Exec, (n[1].e)); + break; + case OPCODE_ENABLE_INDEXED: + CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_EVALMESH1: + CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); + break; + case OPCODE_EVALMESH2: + CALL_EvalMesh2(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_FOG: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_Fogfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_FRONT_FACE: + CALL_FrontFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_FRUSTUM: + CALL_Frustum(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_HINT: + CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_HISTOGRAM: + CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b)); + break; + case OPCODE_INDEX_MASK: + CALL_IndexMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_INIT_NAMES: + CALL_InitNames(ctx->Exec, ()); + break; + case OPCODE_LIGHT: + { + GLfloat p[4]; + p[0] = n[3].f; + p[1] = n[4].f; + p[2] = n[5].f; + p[3] = n[6].f; + CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); + } + break; + case OPCODE_LIGHT_MODEL: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_LightModelfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_LINE_STIPPLE: + CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); + break; + case OPCODE_LINE_WIDTH: + CALL_LineWidth(ctx->Exec, (n[1].f)); + break; + case OPCODE_LIST_BASE: + CALL_ListBase(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOAD_IDENTITY: + CALL_LoadIdentity(ctx->Exec, ()); + break; + case OPCODE_LOAD_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_LoadMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_LOAD_NAME: + CALL_LoadName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOGIC_OP: + CALL_LogicOp(ctx->Exec, (n[1].e)); + break; + case OPCODE_MAP1: + { + GLenum target = n[1].e; + GLint ustride = _mesa_evaluator_components(target); + GLint uorder = n[5].i; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, + (GLfloat *) n[6].data)); + } + break; + case OPCODE_MAP2: + { + GLenum target = n[1].e; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + GLfloat v1 = n[4].f; + GLfloat v2 = n[5].f; + GLint ustride = n[6].i; + GLint vstride = n[7].i; + GLint uorder = n[8].i; + GLint vorder = n[9].i; + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, + (GLfloat *) n[10].data)); + } + break; + case OPCODE_MAPGRID1: + CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_MAPGRID2: + CALL_MapGrid2f(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); + break; + case OPCODE_MATRIX_MODE: + CALL_MatrixMode(ctx->Exec, (n[1].e)); + break; + case OPCODE_MIN_MAX: + CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b)); + break; + case OPCODE_MULT_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_MultMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_MultMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_ORTHO: + CALL_Ortho(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_PASSTHROUGH: + CALL_PassThrough(ctx->Exec, (n[1].f)); + break; + case OPCODE_PIXEL_MAP: + CALL_PixelMapfv(ctx->Exec, + (n[1].e, n[2].i, (GLfloat *) n[3].data)); + break; + case OPCODE_PIXEL_TRANSFER: + CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_PIXEL_ZOOM: + CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POINT_SIZE: + CALL_PointSize(ctx->Exec, (n[1].f)); + break; + case OPCODE_POINT_PARAMETERS: + { + GLfloat params[3]; + params[0] = n[2].f; + params[1] = n[3].f; + params[2] = n[4].f; + CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); + } + break; + case OPCODE_POLYGON_MODE: + CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_POLYGON_STIPPLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_POLYGON_OFFSET: + CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POP_ATTRIB: + CALL_PopAttrib(ctx->Exec, ()); + break; + case OPCODE_POP_MATRIX: + CALL_PopMatrix(ctx->Exec, ()); + break; + case OPCODE_POP_NAME: + CALL_PopName(ctx->Exec, ()); + break; + case OPCODE_PRIORITIZE_TEXTURE: + CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); + break; + case OPCODE_PUSH_ATTRIB: + CALL_PushAttrib(ctx->Exec, (n[1].bf)); + break; + case OPCODE_PUSH_MATRIX: + CALL_PushMatrix(ctx->Exec, ()); + break; + case OPCODE_PUSH_NAME: + CALL_PushName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_RASTER_POS: + CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_READ_BUFFER: + CALL_ReadBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_HISTOGRAM: + CALL_ResetHistogram(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_MIN_MAX: + CALL_ResetMinmax(ctx->Exec, (n[1].e)); + break; + case OPCODE_ROTATE: + CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_SCALE: + CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_SCISSOR: + CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_SHADE_MODEL: + CALL_ShadeModel(ctx->Exec, (n[1].e)); + break; + case OPCODE_PROVOKING_VERTEX: + CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_BEGIN_TRANSFORM_FEEDBACK: + CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_END_TRANSFORM_FEEDBACK: + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + break; + case OPCODE_STENCIL_FUNC: + CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); + break; + case OPCODE_STENCIL_MASK: + CALL_StencilMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_STENCIL_OP: + CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); + break; + case OPCODE_STENCIL_FUNC_SEPARATE: + CALL_StencilFuncSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].ui)); + break; + case OPCODE_STENCIL_MASK_SEPARATE: + CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_STENCIL_OP_SEPARATE: + CALL_StencilOpSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + case OPCODE_TEXENV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXGEN: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEX_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].e, /* border */ + n[6].e, /* format */ + n[7].e, /* type */ + n[8].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].e, /* border */ + n[7].e, /* format */ + n[8].e, /* type */ + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].i, /* depth */ + n[7].e, /* border */ + n[8].e, /* format */ + n[9].e, /* type */ + n[10].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].e, n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].i, n[7].e, n[8].e, + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].e, n[10].e, + n[11].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TRANSLATE: + CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_VIEWPORT: + CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i)); + break; + case OPCODE_WINDOW_POS: + CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ + CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage1DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].e, n[6].i, n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].e, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].e, n[10].i, n[11].data)); + break; + case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ + CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); + break; + case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ + CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ + CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); + break; +#endif +#if FEATURE_NV_vertex_program + case OPCODE_EXECUTE_PROGRAM_NV: + { + GLfloat v[4]; + v[0] = n[3].f; + v[1] = n[4].f; + v[2] = n[5].f; + v[3] = n[6].f; + CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v)); + } + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui, + (GLuint *) n[2].data)); + break; + case OPCODE_LOAD_PROGRAM_NV: + CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, + (const GLubyte *) n[4].data)); + break; + case OPCODE_TRACK_MATRIX_NV: + CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); + break; +#endif + +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: + CALL_ProgramLocalParameter4fARB(ctx->Exec, + (n[1].e, n[2].ui, n[3].f, n[4].f, + n[5].f, n[6].f)); + break; + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, + (const GLubyte *) n[3]. + data, n[4].f, n[5].f, + n[6].f, n[7].f)); + break; +#endif + + case OPCODE_ACTIVE_STENCIL_FACE_EXT: + CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_BOUNDS_EXT: + CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); + break; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + CALL_ProgramStringARB(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].data)); + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program + case OPCODE_PROGRAM_ENV_PARAMETER_ARB: + CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, + n[4].f, n[5].f, + n[6].f)); + break; +#endif +#if FEATURE_queryobj + case OPCODE_BEGIN_QUERY_ARB: + CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_END_QUERY_ARB: + CALL_EndQueryARB(ctx->Exec, (n[1].e)); + break; +#endif + case OPCODE_DRAW_BUFFERS_ARB: + { + GLenum buffers[MAX_DRAW_BUFFERS]; + GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); + for (i = 0; i < count; i++) + buffers[i] = n[2 + i].e; + CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers)); + } + break; +#if FEATURE_EXT_framebuffer_blit + case OPCODE_BLIT_FRAMEBUFFER: + CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].i, n[10].e)); + break; +#endif + + case OPCODE_USE_PROGRAM: + CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); + break; + case OPCODE_USE_SHADER_PROGRAM_EXT: + CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); + break; + case OPCODE_ACTIVE_PROGRAM_EXT: + CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); + break; + case OPCODE_UNIFORM_1F: + CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); + break; + case OPCODE_UNIFORM_2F: + CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_UNIFORM_3F: + CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_UNIFORM_4F: + CALL_Uniform4fARB(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); + break; + case OPCODE_UNIFORM_1FV: + CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2FV: + CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3FV: + CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4FV: + CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1I: + CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); + break; + case OPCODE_UNIFORM_2I: + CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); + break; + case OPCODE_UNIFORM_3I: + CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_UNIFORM_4I: + CALL_Uniform4iARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_UNIFORM_1IV: + CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2IV: + CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3IV: + CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4IV: + CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1UI: + /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ + break; + case OPCODE_UNIFORM_2UI: + /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ + break; + case OPCODE_UNIFORM_3UI: + /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ + break; + case OPCODE_UNIFORM_4UI: + /*CALL_Uniform4uiARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + */ + break; + case OPCODE_UNIFORM_1UIV: + /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_2UIV: + /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_3UIV: + /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_4UIV: + /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_MATRIX22: + CALL_UniformMatrix2fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX33: + CALL_UniformMatrix3fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX44: + CALL_UniformMatrix4fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX23: + CALL_UniformMatrix2x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX32: + CALL_UniformMatrix3x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX24: + CALL_UniformMatrix2x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX42: + CALL_UniformMatrix4x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX34: + CALL_UniformMatrix3x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX43: + CALL_UniformMatrix4x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + + case OPCODE_TEX_BUMP_PARAMETER_ATI: + { + GLfloat values[4]; + GLuint i, pname = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); + } + break; +#if FEATURE_ATI_fragment_shader + case OPCODE_BIND_FRAGMENT_SHADER_ATI: + CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); + break; + case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: + { + GLfloat values[4]; + GLuint i, dst = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); + } + break; +#endif + case OPCODE_ATTR_1F_NV: + CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_NV: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_ATTR_1F_ARB: + CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_ARB: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_MATERIAL: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); + else { + GLfloat f[4]; + f[0] = n[3].f; + f[1] = n[4].f; + f[2] = n[5].f; + f[3] = n[6].f; + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); + } + break; + case OPCODE_BEGIN: + CALL_Begin(ctx->Exec, (n[1].e)); + break; + case OPCODE_END: + CALL_End(ctx->Exec, ()); + break; + case OPCODE_RECTF: + CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_EVAL_C1: + CALL_EvalCoord1f(ctx->Exec, (n[1].f)); + break; + case OPCODE_EVAL_C2: + CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_EVAL_P1: + CALL_EvalPoint1(ctx->Exec, (n[1].i)); + break; + case OPCODE_EVAL_P2: + CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); + break; + + /* GL_EXT_texture_integer */ + case OPCODE_CLEARCOLOR_I: + CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_CLEARCOLOR_UI: + CALL_ClearColorIuiEXT(ctx->Exec, + (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); + break; + case OPCODE_TEXPARAMETER_I: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER_UI: + { + GLuint params[4]; + params[0] = n[3].ui; + params[1] = n[4].ui; + params[2] = n[5].ui; + params[3] = n[6].ui; + CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + done = GL_TRUE; + break; + default: + { + char msg[1000]; + _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", + (int) opcode); + _mesa_problem(ctx, "%s", msg); + } + done = GL_TRUE; + } + + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } + + if (ctx->Driver.EndCallList) + ctx->Driver.EndCallList(ctx); + + ctx->ListState.CallDepth--; +} + + + +/**********************************************************************/ +/* GL functions */ +/**********************************************************************/ + +/** + * Test if a display list number is valid. + */ +static GLboolean GLAPIENTRY +_mesa_IsList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + return islist(ctx, list); +} + + +/** + * Delete a sequence of consecutive display lists. + */ +static void GLAPIENTRY +_mesa_DeleteLists(GLuint list, GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint i; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); + return; + } + for (i = list; i < list + range; i++) { + destroy_list(ctx, i); + } +} + + +/** + * Return a display list number, n, such that lists n through n+range-1 + * are free. + */ +static GLuint GLAPIENTRY +_mesa_GenLists(GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint base; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); + return 0; + } + if (range == 0) { + return 0; + } + + /* + * Make this an atomic operation + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); + if (base) { + /* reserve the list IDs by with empty/dummy lists */ + GLint i; + for (i = 0; i < range; i++) { + _mesa_HashInsert(ctx->Shared->DisplayList, base + i, + make_list(base + i, 1)); + } + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + return base; +} + + +/** + * Begin a new display list. + */ +static void GLAPIENTRY +_mesa_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + + FLUSH_CURRENT(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glNewList %u %s\n", name, + _mesa_lookup_enum_by_nr(mode)); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); + return; + } + + if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); + return; + } + + if (ctx->ListState.CurrentList) { + /* already compiling a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + return; + } + + ctx->CompileFlag = GL_TRUE; + ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); + + /* Reset acumulated list state: + */ + invalidate_saved_current_state( ctx ); + + /* Allocate new display list */ + ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); + ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; + ctx->ListState.CurrentPos = 0; + + ctx->Driver.NewList(ctx, name, mode); + + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +/** + * End definition of current display list. + */ +static void GLAPIENTRY +_mesa_EndList(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndList\n"); + + /* Check that a list is under construction */ + if (!ctx->ListState.CurrentList) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); + return; + } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); + + (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); + + /* Destroy old list, if any */ + destroy_list(ctx, ctx->ListState.CurrentList->Name); + + /* Install the new list */ + _mesa_HashInsert(ctx->Shared->DisplayList, + ctx->ListState.CurrentList->Name, + ctx->ListState.CurrentList); + + + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) + mesa_print_display_list(ctx->ListState.CurrentList->Name); + + ctx->ListState.CurrentList = NULL; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + + ctx->CurrentDispatch = ctx->Exec; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +void GLAPIENTRY +_mesa_CallList(GLuint list) +{ + GLboolean save_compile_flag; + GET_CURRENT_CONTEXT(ctx); + FLUSH_CURRENT(ctx, 0); + /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ + /* execute the display list, and restore the CompileFlag. */ + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallList %d\n", list); + + if (list == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); + return; + } + +/* mesa_print_display_list( list ); */ + + save_compile_flag = ctx->CompileFlag; + if (save_compile_flag) { + ctx->CompileFlag = GL_FALSE; + } + + execute_list(ctx, list); + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Execute glCallLists: call multiple display lists. + */ +void GLAPIENTRY +_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean save_compile_flag; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallLists %d\n", n); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + return; + } + + /* Save the CompileFlag status, turn it off, execute display list, + * and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; + + for (i = 0; i < n; i++) { + GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); + execute_list(ctx, list); + } + + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Set the offset added to list numbers in glCallLists. + */ +static void GLAPIENTRY +_mesa_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + ctx->List.ListBase = base; +} + + +/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. + */ +static void GLAPIENTRY +exec_Finish(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Finish(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_Flush(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Flush(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetBooleanv(GLenum pname, GLboolean *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetBooleanv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetClipPlane(GLenum plane, GLdouble * equation) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetClipPlane(ctx->Exec, (plane, equation)); +} + +static void GLAPIENTRY +exec_GetDoublev(GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetDoublev(ctx->Exec, (pname, params)); +} + +static GLenum GLAPIENTRY +exec_GetError(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetError(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetFloatv(GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetFloatv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetIntegerv(GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetIntegerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightfv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetLightiv(GLenum light, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightiv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapdv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapfv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapiv(GLenum target, GLenum query, GLint * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapiv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetPixelMapfv(GLenum map, GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapfv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapuiv(GLenum map, GLuint *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapuiv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapusv(GLenum map, GLushort *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapusv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPolygonStipple(GLubyte * dest) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPolygonStipple(ctx->Exec, (dest)); +} + +static const GLubyte *GLAPIENTRY +exec_GetString(GLenum name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetString(ctx->Exec, (name)); +} + +static void GLAPIENTRY +exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexImage(GLenum target, GLint level, GLenum format, + GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameterfv(GLenum target, GLint level, + GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameteriv(GLenum target, GLint level, + GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); +} + +static GLboolean GLAPIENTRY +exec_IsEnabled(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsEnabled(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_PixelStoref(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStoref(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_PixelStorei(GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStorei(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); +} + +static GLint GLAPIENTRY +exec_RenderMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_RenderMode(ctx->Exec, (mode)); +} + +static void GLAPIENTRY +exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); +} + +static void GLAPIENTRY +exec_SelectBuffer(GLsizei size, GLuint * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SelectBuffer(ctx->Exec, (size, buffer)); +} + +static GLboolean GLAPIENTRY +exec_AreTexturesResident(GLsizei n, const GLuint * texName, + GLboolean * residences) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); +} + +static void GLAPIENTRY +exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_DeleteTextures(GLsizei n, const GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DeleteTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_DisableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DisableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); +} + +static void GLAPIENTRY +exec_EnableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EnableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_GenTextures(GLsizei n, GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GenTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_GetPointerv(GLenum pname, GLvoid **params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPointerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); +} + +static GLboolean GLAPIENTRY +exec_IsTexture(GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsTexture(ctx->Exec, (texture)); +} + +static void GLAPIENTRY +exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_PopClientAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PopClientAttrib(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_PushClientAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PushClientAttrib(ctx->Exec, (mask)); +} + +static void GLAPIENTRY +exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); +} + +static void GLAPIENTRY +exec_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter1D(ctx->Exec, + (target, internalFormat, x, y, width)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter2D(ctx->Exec, + (target, internalFormat, x, y, width, + height)); +} + +static void GLAPIENTRY +exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTable(ctx->Exec, (target, format, type, data)); +} + +static void GLAPIENTRY +exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid * image) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid *row, GLvoid *column, GLvoid *span) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetSeparableFilter(ctx->Exec, + (target, format, type, row, column, span)); +} + +static void GLAPIENTRY +exec_SeparableFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SeparableFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, row, column)); +} + +static void GLAPIENTRY +exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); +} + +static void GLAPIENTRY +exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_LockArraysEXT(GLint first, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_LockArraysEXT(ctx->Exec, (first, count)); +} + +static void GLAPIENTRY +exec_UnlockArraysEXT(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_UnlockArraysEXT(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_ClientActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ClientActiveTextureARB(ctx->Exec, (target)); +} + +static void GLAPIENTRY +exec_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); +} + +/* GL_EXT_multi_draw_arrays */ +static void GLAPIENTRY +exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, + const GLsizei * count, GLsizei primcount, + GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawArraysIBM(ctx->Exec, + (mode, first, count, primcount, modestride)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawElementsIBM(const GLenum * mode, + const GLsizei * count, + GLenum type, + const GLvoid * const *indices, + GLsizei primcount, GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawElementsIBM(ctx->Exec, + (mode, count, type, indices, primcount, + modestride)); +} + + + +/** + * Setup the given dispatch table to point to Mesa's display list + * building functions. + * + * This does not include any of the tnl functions - they are + * initialized from _mesa_init_api_defaults and from the active vtxfmt + * struct. + */ +struct _glapi_table * +_mesa_create_save_table(void) +{ + struct _glapi_table *table; + + table = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (table == NULL) + return NULL; + + _mesa_loopback_init_api_table(table); + + /* GL 1.0 */ + SET_Accum(table, save_Accum); + SET_AlphaFunc(table, save_AlphaFunc); + SET_Bitmap(table, save_Bitmap); + SET_BlendFunc(table, save_BlendFunc); + SET_CallList(table, save_CallList); + SET_CallLists(table, save_CallLists); + SET_Clear(table, save_Clear); + SET_ClearAccum(table, save_ClearAccum); + SET_ClearColor(table, save_ClearColor); + SET_ClearDepth(table, save_ClearDepth); + SET_ClearIndex(table, save_ClearIndex); + SET_ClearStencil(table, save_ClearStencil); + SET_ClipPlane(table, save_ClipPlane); + SET_ColorMask(table, save_ColorMask); + SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); + SET_ColorMaterial(table, save_ColorMaterial); + SET_CopyPixels(table, save_CopyPixels); + SET_CullFace(table, save_CullFace); + SET_DeleteLists(table, _mesa_DeleteLists); + SET_DepthFunc(table, save_DepthFunc); + SET_DepthMask(table, save_DepthMask); + SET_DepthRange(table, save_DepthRange); + SET_Disable(table, save_Disable); + SET_DisableIndexedEXT(table, save_DisableIndexed); + SET_DrawBuffer(table, save_DrawBuffer); + SET_DrawPixels(table, save_DrawPixels); + SET_Enable(table, save_Enable); + SET_EnableIndexedEXT(table, save_EnableIndexed); + SET_EndList(table, _mesa_EndList); + SET_EvalMesh1(table, save_EvalMesh1); + SET_EvalMesh2(table, save_EvalMesh2); + SET_Finish(table, exec_Finish); + SET_Flush(table, exec_Flush); + SET_Fogf(table, save_Fogf); + SET_Fogfv(table, save_Fogfv); + SET_Fogi(table, save_Fogi); + SET_Fogiv(table, save_Fogiv); + SET_FrontFace(table, save_FrontFace); + SET_Frustum(table, save_Frustum); + SET_GenLists(table, _mesa_GenLists); + SET_GetBooleanv(table, exec_GetBooleanv); + SET_GetClipPlane(table, exec_GetClipPlane); + SET_GetDoublev(table, exec_GetDoublev); + SET_GetError(table, exec_GetError); + SET_GetFloatv(table, exec_GetFloatv); + SET_GetIntegerv(table, exec_GetIntegerv); + SET_GetLightfv(table, exec_GetLightfv); + SET_GetLightiv(table, exec_GetLightiv); + SET_GetMapdv(table, exec_GetMapdv); + SET_GetMapfv(table, exec_GetMapfv); + SET_GetMapiv(table, exec_GetMapiv); + SET_GetMaterialfv(table, exec_GetMaterialfv); + SET_GetMaterialiv(table, exec_GetMaterialiv); + SET_GetPixelMapfv(table, exec_GetPixelMapfv); + SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); + SET_GetPixelMapusv(table, exec_GetPixelMapusv); + SET_GetPolygonStipple(table, exec_GetPolygonStipple); + SET_GetString(table, exec_GetString); + SET_GetTexEnvfv(table, exec_GetTexEnvfv); + SET_GetTexEnviv(table, exec_GetTexEnviv); + SET_GetTexGendv(table, exec_GetTexGendv); + SET_GetTexGenfv(table, exec_GetTexGenfv); + SET_GetTexGeniv(table, exec_GetTexGeniv); + SET_GetTexImage(table, exec_GetTexImage); + SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); + SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); + SET_GetTexParameterfv(table, exec_GetTexParameterfv); + SET_GetTexParameteriv(table, exec_GetTexParameteriv); + SET_Hint(table, save_Hint); + SET_IndexMask(table, save_IndexMask); + SET_InitNames(table, save_InitNames); + SET_IsEnabled(table, exec_IsEnabled); + SET_IsList(table, _mesa_IsList); + SET_LightModelf(table, save_LightModelf); + SET_LightModelfv(table, save_LightModelfv); + SET_LightModeli(table, save_LightModeli); + SET_LightModeliv(table, save_LightModeliv); + SET_Lightf(table, save_Lightf); + SET_Lightfv(table, save_Lightfv); + SET_Lighti(table, save_Lighti); + SET_Lightiv(table, save_Lightiv); + SET_LineStipple(table, save_LineStipple); + SET_LineWidth(table, save_LineWidth); + SET_ListBase(table, save_ListBase); + SET_LoadIdentity(table, save_LoadIdentity); + SET_LoadMatrixd(table, save_LoadMatrixd); + SET_LoadMatrixf(table, save_LoadMatrixf); + SET_LoadName(table, save_LoadName); + SET_LogicOp(table, save_LogicOp); + SET_Map1d(table, save_Map1d); + SET_Map1f(table, save_Map1f); + SET_Map2d(table, save_Map2d); + SET_Map2f(table, save_Map2f); + SET_MapGrid1d(table, save_MapGrid1d); + SET_MapGrid1f(table, save_MapGrid1f); + SET_MapGrid2d(table, save_MapGrid2d); + SET_MapGrid2f(table, save_MapGrid2f); + SET_MatrixMode(table, save_MatrixMode); + SET_MultMatrixd(table, save_MultMatrixd); + SET_MultMatrixf(table, save_MultMatrixf); + SET_NewList(table, save_NewList); + SET_Ortho(table, save_Ortho); + SET_PassThrough(table, save_PassThrough); + SET_PixelMapfv(table, save_PixelMapfv); + SET_PixelMapuiv(table, save_PixelMapuiv); + SET_PixelMapusv(table, save_PixelMapusv); + SET_PixelStoref(table, exec_PixelStoref); + SET_PixelStorei(table, exec_PixelStorei); + SET_PixelTransferf(table, save_PixelTransferf); + SET_PixelTransferi(table, save_PixelTransferi); + SET_PixelZoom(table, save_PixelZoom); + SET_PointSize(table, save_PointSize); + SET_PolygonMode(table, save_PolygonMode); + SET_PolygonOffset(table, save_PolygonOffset); + SET_PolygonStipple(table, save_PolygonStipple); + SET_PopAttrib(table, save_PopAttrib); + SET_PopMatrix(table, save_PopMatrix); + SET_PopName(table, save_PopName); + SET_PushAttrib(table, save_PushAttrib); + SET_PushMatrix(table, save_PushMatrix); + SET_PushName(table, save_PushName); + SET_RasterPos2d(table, save_RasterPos2d); + SET_RasterPos2dv(table, save_RasterPos2dv); + SET_RasterPos2f(table, save_RasterPos2f); + SET_RasterPos2fv(table, save_RasterPos2fv); + SET_RasterPos2i(table, save_RasterPos2i); + SET_RasterPos2iv(table, save_RasterPos2iv); + SET_RasterPos2s(table, save_RasterPos2s); + SET_RasterPos2sv(table, save_RasterPos2sv); + SET_RasterPos3d(table, save_RasterPos3d); + SET_RasterPos3dv(table, save_RasterPos3dv); + SET_RasterPos3f(table, save_RasterPos3f); + SET_RasterPos3fv(table, save_RasterPos3fv); + SET_RasterPos3i(table, save_RasterPos3i); + SET_RasterPos3iv(table, save_RasterPos3iv); + SET_RasterPos3s(table, save_RasterPos3s); + SET_RasterPos3sv(table, save_RasterPos3sv); + SET_RasterPos4d(table, save_RasterPos4d); + SET_RasterPos4dv(table, save_RasterPos4dv); + SET_RasterPos4f(table, save_RasterPos4f); + SET_RasterPos4fv(table, save_RasterPos4fv); + SET_RasterPos4i(table, save_RasterPos4i); + SET_RasterPos4iv(table, save_RasterPos4iv); + SET_RasterPos4s(table, save_RasterPos4s); + SET_RasterPos4sv(table, save_RasterPos4sv); + SET_ReadBuffer(table, save_ReadBuffer); + SET_ReadPixels(table, exec_ReadPixels); + SET_RenderMode(table, exec_RenderMode); + SET_Rotated(table, save_Rotated); + SET_Rotatef(table, save_Rotatef); + SET_Scaled(table, save_Scaled); + SET_Scalef(table, save_Scalef); + SET_Scissor(table, save_Scissor); + SET_FeedbackBuffer(table, exec_FeedbackBuffer); + SET_SelectBuffer(table, exec_SelectBuffer); + SET_ShadeModel(table, save_ShadeModel); + SET_StencilFunc(table, save_StencilFunc); + SET_StencilMask(table, save_StencilMask); + SET_StencilOp(table, save_StencilOp); + SET_TexEnvf(table, save_TexEnvf); + SET_TexEnvfv(table, save_TexEnvfv); + SET_TexEnvi(table, save_TexEnvi); + SET_TexEnviv(table, save_TexEnviv); + SET_TexGend(table, save_TexGend); + SET_TexGendv(table, save_TexGendv); + SET_TexGenf(table, save_TexGenf); + SET_TexGenfv(table, save_TexGenfv); + SET_TexGeni(table, save_TexGeni); + SET_TexGeniv(table, save_TexGeniv); + SET_TexImage1D(table, save_TexImage1D); + SET_TexImage2D(table, save_TexImage2D); + SET_TexParameterf(table, save_TexParameterf); + SET_TexParameterfv(table, save_TexParameterfv); + SET_TexParameteri(table, save_TexParameteri); + SET_TexParameteriv(table, save_TexParameteriv); + SET_Translated(table, save_Translated); + SET_Translatef(table, save_Translatef); + SET_Viewport(table, save_Viewport); + + /* GL 1.1 */ + SET_AreTexturesResident(table, exec_AreTexturesResident); + SET_BindTexture(table, save_BindTexture); + SET_ColorPointer(table, exec_ColorPointer); + SET_CopyTexImage1D(table, save_CopyTexImage1D); + SET_CopyTexImage2D(table, save_CopyTexImage2D); + SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); + SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); + SET_DeleteTextures(table, exec_DeleteTextures); + SET_DisableClientState(table, exec_DisableClientState); + SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); + SET_EnableClientState(table, exec_EnableClientState); + SET_GenTextures(table, exec_GenTextures); + SET_GetPointerv(table, exec_GetPointerv); + SET_IndexPointer(table, exec_IndexPointer); + SET_InterleavedArrays(table, exec_InterleavedArrays); + SET_IsTexture(table, exec_IsTexture); + SET_NormalPointer(table, exec_NormalPointer); + SET_PopClientAttrib(table, exec_PopClientAttrib); + SET_PrioritizeTextures(table, save_PrioritizeTextures); + SET_PushClientAttrib(table, exec_PushClientAttrib); + SET_TexCoordPointer(table, exec_TexCoordPointer); + SET_TexSubImage1D(table, save_TexSubImage1D); + SET_TexSubImage2D(table, save_TexSubImage2D); + SET_VertexPointer(table, exec_VertexPointer); + + /* GL 1.2 */ + SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); + SET_TexImage3D(table, save_TexImage3D); + SET_TexSubImage3D(table, save_TexSubImage3D); + + /* GL 2.0 */ + SET_StencilFuncSeparate(table, save_StencilFuncSeparate); + SET_StencilMaskSeparate(table, save_StencilMaskSeparate); + SET_StencilOpSeparate(table, save_StencilOpSeparate); + + /* ATI_separate_stencil */ + SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); + + /* GL_ARB_imaging */ + /* Not all are supported */ + SET_BlendColor(table, save_BlendColor); + SET_BlendEquation(table, save_BlendEquation); + SET_ColorSubTable(table, save_ColorSubTable); + SET_ColorTable(table, save_ColorTable); + SET_ColorTableParameterfv(table, save_ColorTableParameterfv); + SET_ColorTableParameteriv(table, save_ColorTableParameteriv); + SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); + SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); + SET_ConvolutionParameterf(table, save_ConvolutionParameterf); + SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); + SET_ConvolutionParameteri(table, save_ConvolutionParameteri); + SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); + SET_CopyColorSubTable(table, save_CopyColorSubTable); + SET_CopyColorTable(table, save_CopyColorTable); + SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); + SET_GetColorTable(table, exec_GetColorTable); + SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); + SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); + SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); + SET_GetHistogram(table, exec_GetHistogram); + SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); + SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); + SET_GetMinmax(table, exec_GetMinmax); + SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); + SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); + SET_GetSeparableFilter(table, exec_GetSeparableFilter); + SET_Histogram(table, save_Histogram); + SET_Minmax(table, save_Minmax); + SET_ResetHistogram(table, save_ResetHistogram); + SET_ResetMinmax(table, save_ResetMinmax); + SET_SeparableFilter2D(table, exec_SeparableFilter2D); + + /* 2. GL_EXT_blend_color */ +#if 0 + SET_BlendColorEXT(table, save_BlendColorEXT); +#endif + + /* 3. GL_EXT_polygon_offset */ + SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); + + /* 6. GL_EXT_texture3d */ +#if 0 + SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); + SET_TexImage3DEXT(table, save_TexImage3DEXT); + SET_TexSubImage3DEXT(table, save_TexSubImage3D); +#endif + + /* 14. GL_SGI_color_table */ +#if 0 + SET_ColorTableSGI(table, save_ColorTable); + SET_ColorSubTableSGI(table, save_ColorSubTable); + SET_GetColorTableSGI(table, exec_GetColorTable); + SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); +#endif + + /* 30. GL_EXT_vertex_array */ + SET_ColorPointerEXT(table, exec_ColorPointerEXT); + SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); + SET_IndexPointerEXT(table, exec_IndexPointerEXT); + SET_NormalPointerEXT(table, exec_NormalPointerEXT); + SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); + SET_VertexPointerEXT(table, exec_VertexPointerEXT); + + /* 37. GL_EXT_blend_minmax */ +#if 0 + SET_BlendEquationEXT(table, save_BlendEquationEXT); +#endif + + /* 54. GL_EXT_point_parameters */ + SET_PointParameterfEXT(table, save_PointParameterfEXT); + SET_PointParameterfvEXT(table, save_PointParameterfvEXT); + + /* 97. GL_EXT_compiled_vertex_array */ + SET_LockArraysEXT(table, exec_LockArraysEXT); + SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); + + /* 145. GL_EXT_secondary_color */ + SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); + + /* 148. GL_EXT_multi_draw_arrays */ + SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); + + /* 149. GL_EXT_fog_coord */ + SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); + + /* 173. GL_EXT_blend_func_separate */ + SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); + + /* 196. GL_MESA_resize_buffers */ + SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); + + /* 197. GL_MESA_window_pos */ + SET_WindowPos2dMESA(table, save_WindowPos2dMESA); + SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); + SET_WindowPos2fMESA(table, save_WindowPos2fMESA); + SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); + SET_WindowPos2iMESA(table, save_WindowPos2iMESA); + SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); + SET_WindowPos2sMESA(table, save_WindowPos2sMESA); + SET_WindowPos2svMESA(table, save_WindowPos2svMESA); + SET_WindowPos3dMESA(table, save_WindowPos3dMESA); + SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); + SET_WindowPos3fMESA(table, save_WindowPos3fMESA); + SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); + SET_WindowPos3iMESA(table, save_WindowPos3iMESA); + SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); + SET_WindowPos3sMESA(table, save_WindowPos3sMESA); + SET_WindowPos3svMESA(table, save_WindowPos3svMESA); + SET_WindowPos4dMESA(table, save_WindowPos4dMESA); + SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); + SET_WindowPos4fMESA(table, save_WindowPos4fMESA); + SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); + SET_WindowPos4iMESA(table, save_WindowPos4iMESA); + SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); + SET_WindowPos4sMESA(table, save_WindowPos4sMESA); + SET_WindowPos4svMESA(table, save_WindowPos4svMESA); + + /* 200. GL_IBM_multimode_draw_arrays */ + SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); + +#if FEATURE_NV_vertex_program + /* 233. GL_NV_vertex_program */ + /* The following commands DO NOT go into display lists: + * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, + * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* + */ + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_ExecuteProgramNV(table, save_ExecuteProgramNV); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(table, _mesa_GetProgramivNV); + SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_LoadProgramNV(table, save_LoadProgramNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); + SET_TrackMatrixNV(table, save_TrackMatrixNV); + SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); +#endif + + /* 244. GL_ATI_envmap_bumpmap */ + SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); + + /* 245. GL_ATI_fragment_shader */ +#if FEATURE_ATI_fragment_shader + SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); + SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); +#endif + + /* 282. GL_NV_fragment_program */ +#if FEATURE_NV_fragment_program + SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(table, + _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(table, + _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); +#endif + + /* 262. GL_NV_point_sprite */ + SET_PointParameteriNV(table, save_PointParameteriNV); + SET_PointParameterivNV(table, save_PointParameterivNV); + + /* 268. GL_EXT_stencil_two_side */ + SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); + + /* 273. GL_APPLE_vertex_array_object */ + SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); + + /* ???. GL_EXT_depth_bounds_test */ + SET_DepthBoundsEXT(table, save_DepthBoundsEXT); + + /* ARB 1. GL_ARB_multitexture */ + SET_ActiveTextureARB(table, save_ActiveTextureARB); + SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); + + /* ARB 3. GL_ARB_transpose_matrix */ + SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); + + /* ARB 5. GL_ARB_multisample */ + SET_SampleCoverageARB(table, save_SampleCoverageARB); + + /* ARB 12. GL_ARB_texture_compression */ + SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); + SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); + SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); + + /* ARB 14. GL_ARB_point_parameters */ + /* aliased with EXT_point_parameters functions */ + + /* ARB 25. GL_ARB_window_pos */ + /* aliased with MESA_window_pos functions */ + + /* ARB 26. GL_ARB_vertex_program */ + /* ARB 27. GL_ARB_fragment_program */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ + SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); + SET_ProgramStringARB(table, save_ProgramStringARB); + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramivARB(table, _mesa_GetProgramivARB); + SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); +#endif + + /* ARB 28. GL_ARB_vertex_buffer_object */ +#if FEATURE_ARB_vertex_buffer_object + /* None of the extension's functions get compiled */ + SET_BindBufferARB(table, _mesa_BindBufferARB); + SET_BufferDataARB(table, _mesa_BufferDataARB); + SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); + SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); + SET_GenBuffersARB(table, _mesa_GenBuffersARB); + SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); + SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); + SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); + SET_IsBufferARB(table, _mesa_IsBufferARB); + SET_MapBufferARB(table, _mesa_MapBufferARB); + SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); +#endif + +#if FEATURE_queryobj + SET_BeginQueryARB(table, save_BeginQueryARB); + SET_EndQueryARB(table, save_EndQueryARB); + SET_GenQueriesARB(table, _mesa_GenQueriesARB); + SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB); + SET_IsQueryARB(table, _mesa_IsQueryARB); + SET_GetQueryivARB(table, _mesa_GetQueryivARB); + SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB); + SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB); +#endif + SET_DrawBuffersARB(table, save_DrawBuffersARB); + +#if FEATURE_EXT_framebuffer_blit + SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); +#endif + + /* GL_ARB_shader_objects */ + SET_UseProgramObjectARB(table, save_UseProgramObjectARB); + SET_Uniform1fARB(table, save_Uniform1fARB); + SET_Uniform2fARB(table, save_Uniform2fARB); + SET_Uniform3fARB(table, save_Uniform3fARB); + SET_Uniform4fARB(table, save_Uniform4fARB); + SET_Uniform1fvARB(table, save_Uniform1fvARB); + SET_Uniform2fvARB(table, save_Uniform2fvARB); + SET_Uniform3fvARB(table, save_Uniform3fvARB); + SET_Uniform4fvARB(table, save_Uniform4fvARB); + SET_Uniform1iARB(table, save_Uniform1iARB); + SET_Uniform2iARB(table, save_Uniform2iARB); + SET_Uniform3iARB(table, save_Uniform3iARB); + SET_Uniform4iARB(table, save_Uniform4iARB); + SET_Uniform1ivARB(table, save_Uniform1ivARB); + SET_Uniform2ivARB(table, save_Uniform2ivARB); + SET_Uniform3ivARB(table, save_Uniform3ivARB); + SET_Uniform4ivARB(table, save_Uniform4ivARB); + SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); + SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); + SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); + SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); + + /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); + SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); + SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); + /* XXX additional functions need to be implemented here! */ + + /* 299. GL_EXT_blend_equation_separate */ + SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); + + /* GL_EXT_gpu_program_parameters */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); +#endif + + /* ARB 50. GL_ARB_map_buffer_range */ +#if FEATURE_ARB_map_buffer_range + SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ + SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ +#endif + + /* ARB 59. GL_ARB_copy_buffer */ + SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ + + /* 352. GL_EXT_transform_feedback */ +#if FEATURE_EXT_transform_feedback + SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); + SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); +#endif + + /* 364. GL_EXT_provoking_vertex */ + SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); + + /* 371. GL_APPLE_object_purgeable */ +#if FEATURE_APPLE_object_purgeable + SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); + SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); +#endif + + /* GL_EXT_texture_integer */ + SET_ClearColorIiEXT(table, save_ClearColorIi); + SET_ClearColorIuiEXT(table, save_ClearColorIui); + SET_TexParameterIivEXT(table, save_TexParameterIiv); + SET_TexParameterIuivEXT(table, save_TexParameterIuiv); + SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); + SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); + + /* 377. GL_EXT_separate_shader_objects */ + SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); + SET_ActiveProgramEXT(table, save_ActiveProgramEXT); + + /* GL 3.0 */ +#if 0 + SET_ClearBufferiv(table, save_ClearBufferiv); + SET_ClearBufferuiv(table, save_ClearBufferuiv); + SET_ClearBufferfv(table, save_ClearBufferfv); + SET_ClearBufferfi(table, save_ClearBufferfi); + SET_Uniform1ui(table, save_Uniform1ui); + SET_Uniform2ui(table, save_Uniform2ui); + SET_Uniform3ui(table, save_Uniform3ui); + SET_Uniform4ui(table, save_Uniform4ui); + SET_Uniform1uiv(table, save_Uniform1uiv); + SET_Uniform2uiv(table, save_Uniform2uiv); + SET_Uniform3uiv(table, save_Uniform3uiv); + SET_Uniform4uiv(table, save_Uniform4uiv); +#else + (void) save_ClearBufferiv; + (void) save_ClearBufferuiv; + (void) save_ClearBufferfv; + (void) save_ClearBufferfi; + (void) save_Uniform1ui; + (void) save_Uniform2ui; + (void) save_Uniform3ui; + (void) save_Uniform4ui; + (void) save_Uniform1uiv; + (void) save_Uniform2uiv; + (void) save_Uniform3uiv; + (void) save_Uniform4uiv; +#endif + + return table; +} + + + +static const char * +enum_string(GLenum k) +{ + return _mesa_lookup_enum_by_nr(k); +} + + +/** + * Print the commands in a display list. For debugging only. + * TODO: many commands aren't handled yet. + */ +static void GLAPIENTRY +print_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (!islist(ctx, list)) { + printf("%u is not a display list ID\n", list); + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + n = dlist->Head; + + printf("START-LIST %u, address %p\n", list, (void *) n); + + done = n ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_print(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ACCUM: + printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); + break; + case OPCODE_BITMAP: + printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); + break; + case OPCODE_CALL_LIST: + printf("CallList %d\n", (int) n[1].ui); + break; + case OPCODE_CALL_LIST_OFFSET: + printf("CallList %d + offset %u = %u\n", (int) n[1].ui, + ctx->List.ListBase, ctx->List.ListBase + n[1].ui); + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + printf("ColorTableParameterfv %s %s %f %f %f %f\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + printf("ColorTableParameteriv %s %s %d %d %d %d\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].i, n[4].i, n[5].i, n[6].i); + break; + case OPCODE_DISABLE: + printf("Disable %s\n", enum_string(n[1].e)); + break; + case OPCODE_ENABLE: + printf("Enable %s\n", enum_string(n[1].e)); + break; + case OPCODE_FRUSTUM: + printf("Frustum %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_LINE_STIPPLE: + printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); + break; + case OPCODE_LOAD_IDENTITY: + printf("LoadIdentity\n"); + break; + case OPCODE_LOAD_MATRIX: + printf("LoadMatrix\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_MULT_MATRIX: + printf("MultMatrix (or Rotate)\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_ORTHO: + printf("Ortho %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_POP_ATTRIB: + printf("PopAttrib\n"); + break; + case OPCODE_POP_MATRIX: + printf("PopMatrix\n"); + break; + case OPCODE_POP_NAME: + printf("PopName\n"); + break; + case OPCODE_PUSH_ATTRIB: + printf("PushAttrib %x\n", n[1].bf); + break; + case OPCODE_PUSH_MATRIX: + printf("PushMatrix\n"); + break; + case OPCODE_PUSH_NAME: + printf("PushName %d\n", (int) n[1].ui); + break; + case OPCODE_RASTER_POS: + printf("RasterPos %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ROTATE: + printf("Rotate %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_SCALE: + printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_TRANSLATE: + printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_BIND_TEXTURE: + printf("BindTexture %s %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); + break; + case OPCODE_SHADE_MODEL: + printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); + break; + case OPCODE_MAP1: + printf("Map1 %s %.3f %.3f %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].i, n[5].i); + break; + case OPCODE_MAP2: + printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].f, n[5].f, + n[6].i, n[7].i, n[8].i, n[9].i); + break; + case OPCODE_MAPGRID1: + printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); + break; + case OPCODE_MAPGRID2: + printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", + n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); + break; + case OPCODE_EVALMESH1: + printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); + break; + case OPCODE_EVALMESH2: + printf("EvalMesh2 %d %d %d %d\n", + n[1].i, n[2].i, n[3].i, n[4].i); + break; + + case OPCODE_ATTR_1F_NV: + printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_NV: + printf("ATTR_2F_NV attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_NV: + printf("ATTR_3F_NV attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_NV: + printf("ATTR_4F_NV attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + case OPCODE_ATTR_1F_ARB: + printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_ARB: + printf("ATTR_2F_ARB attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_ARB: + printf("ATTR_3F_ARB attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_ARB: + printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + + case OPCODE_MATERIAL: + printf("MATERIAL %x %x: %f %f %f %f\n", + n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_BEGIN: + printf("BEGIN %x\n", n[1].i); + break; + case OPCODE_END: + printf("END\n"); + break; + case OPCODE_RECTF: + printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, + n[4].f); + break; + case OPCODE_EVAL_C1: + printf("EVAL_C1 %f\n", n[1].f); + break; + case OPCODE_EVAL_C2: + printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); + break; + case OPCODE_EVAL_P1: + printf("EVAL_P1 %d\n", n[1].i); + break; + case OPCODE_EVAL_P2: + printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); + break; + + case OPCODE_PROVOKING_VERTEX: + printf("ProvokingVertex %s\n", + _mesa_lookup_enum_by_nr(n[1].ui)); + break; + + /* + * meta opcodes/commands + */ + case OPCODE_ERROR: + printf("Error: %s %s\n", + enum_string(n[1].e), (const char *) n[2].data); + break; + case OPCODE_CONTINUE: + printf("DISPLAY-LIST-CONTINUE\n"); + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + printf("END-LIST %u\n", list); + done = GL_TRUE; + break; + default: + if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { + printf + ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", + opcode, (void *) n); + return; + } + else { + printf("command %d, %u operands\n", opcode, + InstSize[opcode]); + } + } + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } +} + + + +/** + * Clients may call this function to help debug display list problems. + * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, + * changed, or break in the future without notice. + */ +void +mesa_print_display_list(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + print_list(ctx, list); +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void +_mesa_save_vtxfmt_init(GLvertexformat * vfmt) +{ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + + vfmt->Begin = save_Begin; + + _MESA_INIT_DLIST_VTXFMT(vfmt, save_); + + vfmt->Color3f = save_Color3f; + vfmt->Color3fv = save_Color3fv; + vfmt->Color4f = save_Color4f; + vfmt->Color4fv = save_Color4fv; + vfmt->EdgeFlag = save_EdgeFlag; + vfmt->End = save_End; + + _MESA_INIT_EVAL_VTXFMT(vfmt, save_); + + vfmt->FogCoordfEXT = save_FogCoordfEXT; + vfmt->FogCoordfvEXT = save_FogCoordfvEXT; + vfmt->Indexf = save_Indexf; + vfmt->Indexfv = save_Indexfv; + vfmt->Materialfv = save_Materialfv; + vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; + vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; + vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; + vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; + vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; + vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; + vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; + vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; + vfmt->Normal3f = save_Normal3f; + vfmt->Normal3fv = save_Normal3fv; + vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; + vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; + vfmt->TexCoord1f = save_TexCoord1f; + vfmt->TexCoord1fv = save_TexCoord1fv; + vfmt->TexCoord2f = save_TexCoord2f; + vfmt->TexCoord2fv = save_TexCoord2fv; + vfmt->TexCoord3f = save_TexCoord3f; + vfmt->TexCoord3fv = save_TexCoord3fv; + vfmt->TexCoord4f = save_TexCoord4f; + vfmt->TexCoord4fv = save_TexCoord4fv; + vfmt->Vertex2f = save_Vertex2f; + vfmt->Vertex2fv = save_Vertex2fv; + vfmt->Vertex3f = save_Vertex3f; + vfmt->Vertex3fv = save_Vertex3fv; + vfmt->Vertex4f = save_Vertex4f; + vfmt->Vertex4fv = save_Vertex4fv; + vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; + vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; + vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; + vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; + vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; + vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; + vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; + vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; + vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; + vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; + vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; + vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; + vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; + vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; + vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; + + vfmt->Rectf = save_Rectf; + + /* The driver is required to implement these as + * 1) They can probably do a better job. + * 2) A lot of new mechanisms would have to be added to this module + * to support it. That code would probably never get used, + * because of (1). + */ +#if 0 + vfmt->DrawArrays = 0; + vfmt->DrawElements = 0; + vfmt->DrawRangeElements = 0; + vfmt->MultiDrawElemementsEXT = 0; + vfmt->DrawElementsBaseVertex = 0; + vfmt->DrawRangeElementsBaseVertex = 0; + vfmt->MultiDrawElemementsBaseVertex = 0; +#endif +} + + +void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_CallList(disp, vfmt->CallList); + SET_CallLists(disp, vfmt->CallLists); +} + + +void _mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ + SET_CallList(disp, _mesa_CallList); + SET_CallLists(disp, _mesa_CallLists); + + SET_DeleteLists(disp, _mesa_DeleteLists); + SET_EndList(disp, _mesa_EndList); + SET_GenLists(disp, _mesa_GenLists); + SET_IsList(disp, _mesa_IsList); + SET_ListBase(disp, _mesa_ListBase); + SET_NewList(disp, _mesa_NewList); +} + + +#endif /* FEATURE_dlist */ + + +/** + * Initialize display list state for given context. + */ +void +_mesa_init_display_list(struct gl_context *ctx) +{ + static GLboolean tableInitialized = GL_FALSE; + + /* zero-out the instruction size table, just once */ + if (!tableInitialized) { + memset(InstSize, 0, sizeof(InstSize)); + tableInitialized = GL_TRUE; + } + + /* extension info */ + ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); + + /* Display list */ + ctx->ListState.CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->ListState.CurrentBlock = NULL; + ctx->ListState.CurrentPos = 0; + + /* Display List group */ + ctx->List.ListBase = 0; + +#if FEATURE_dlist + _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); +#endif +} + + +void +_mesa_free_display_list_data(struct gl_context *ctx) +{ + free(ctx->ListExt); + ctx->ListExt = NULL; +} diff --git a/mesalib/src/mesa/main/dlist.h b/mesalib/src/mesa/main/dlist.h index 86bb132e5..784368d1a 100644 --- a/mesalib/src/mesa/main/dlist.h +++ b/mesalib/src/mesa/main/dlist.h @@ -1,103 +1,103 @@ -/** - * \file dlist.h - * Display lists management. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef DLIST_H -#define DLIST_H - - -#include "main/mtypes.h" - - -#if FEATURE_dlist - -#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->CallList = impl ## CallList; \ - (vfmt)->CallLists = impl ## CallLists; \ - } while (0) - -extern void GLAPIENTRY _mesa_CallList( GLuint list ); - -extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ); - - -extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s ); - -extern void *_mesa_dlist_alloc(GLcontext *ctx, GLuint opcode, GLuint sz); - -extern GLint _mesa_dlist_alloc_opcode( GLcontext *ctx, GLuint sz, - void (*execute)( GLcontext *, void * ), - void (*destroy)( GLcontext *, void * ), - void (*print)( GLcontext *, void * ) ); - -extern void _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist); - -extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt ); - -extern struct _glapi_table *_mesa_create_save_table(void); - -extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_dlist */ - -#include "main/compiler.h" - -#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0) - -static INLINE void -_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) -{ - /* there should be no list to delete */ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -static INLINE void -_mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_dlist */ - -extern void _mesa_init_display_list( GLcontext * ctx ); - -extern void _mesa_free_display_list_data(GLcontext *ctx); - - -#endif /* DLIST_H */ +/** + * \file dlist.h + * Display lists management. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef DLIST_H +#define DLIST_H + + +#include "main/mtypes.h" + + +#if FEATURE_dlist + +#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->CallList = impl ## CallList; \ + (vfmt)->CallLists = impl ## CallLists; \ + } while (0) + +extern void GLAPIENTRY _mesa_CallList( GLuint list ); + +extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ); + + +extern void _mesa_compile_error( struct gl_context *ctx, GLenum error, const char *s ); + +extern void *_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint sz); + +extern GLint _mesa_dlist_alloc_opcode( struct gl_context *ctx, GLuint sz, + void (*execute)( struct gl_context *, void * ), + void (*destroy)( struct gl_context *, void * ), + void (*print)( struct gl_context *, void * ) ); + +extern void _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist); + +extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt ); + +extern struct _glapi_table *_mesa_create_save_table(void); + +extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); + +extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_dlist */ + +#include "main/compiler.h" + +#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0) + +static INLINE void +_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) +{ + /* there should be no list to delete */ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} + +static INLINE void +_mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_dlist */ + +extern void _mesa_init_display_list( struct gl_context * ctx ); + +extern void _mesa_free_display_list_data(struct gl_context *ctx); + + +#endif /* DLIST_H */ diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c index bf36a7e7a..40a1cb5df 100644 --- a/mesalib/src/mesa/main/drawpix.c +++ b/mesalib/src/mesa/main/drawpix.c @@ -1,317 +1,279 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "drawpix.h" -#include "enums.h" -#include "feedback.h" -#include "framebuffer.h" -#include "readpix.h" -#include "state.h" -#include "main/dispatch.h" - - -#if FEATURE_drawpix - - -/** - * If a fragment program is enabled, check that it's valid. - * \return GL_TRUE if valid, GL_FALSE otherwise - */ -static GLboolean -valid_fragment_program(GLcontext *ctx) -{ - return !(ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled); -} - - -/* - * Execute glDrawPixels - */ -static void GLAPIENTRY -_mesa_DrawPixels( GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" ); - return; - } - - /* We're not using the current vertex program, and the driver may install - * it's own. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (!valid_fragment_program(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels (invalid fragment program)"); - goto end; - } - - if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { - /* the error was already recorded */ - goto end; - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glDrawPixels(incomplete framebuffer)" ); - goto end; - } - - if (!ctx->Current.RasterPosValid) { - goto end; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - if (width > 0 && height > 0) { - /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ - GLint x = IROUND(ctx->Current.RasterPos[0]); - GLint y = IROUND(ctx->Current.RasterPos[1]); - - if (ctx->Unpack.BufferObj->Name) { - /* unpack from PBO */ - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(invalid PBO access)"); - goto end; - } - if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(PBO is mapped)"); - goto end; - } - } - - ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, - &ctx->Unpack, pixels); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - /* Feedback the current raster pos info */ - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); -} - - -static void GLAPIENTRY -_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); - return; - } - - /* Note: more detailed 'type' checking is done by the - * _mesa_source/dest_buffer_exists() calls below. That's where we - * check if the stencil buffer exists, etc. - */ - if (type != GL_COLOR && - type != GL_DEPTH && - type != GL_STENCIL && - type != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - /* We're not using the current vertex program, and the driver may install - * it's own. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (!valid_fragment_program(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyPixels (invalid fragment program)"); - goto end; - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || - ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyPixels(incomplete framebuffer)" ); - goto end; - } - - if (!_mesa_source_buffer_exists(ctx, type) || - !_mesa_dest_buffer_exists(ctx, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyPixels(missing source or dest buffer)"); - goto end; - } - - if (!ctx->Current.RasterPosValid || width ==0 || height == 0) { - goto end; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - /* Round to satisfy conformance tests (matches SGI's OpenGL) */ - if (width > 0 && height > 0) { - GLint destx = IROUND(ctx->Current.RasterPos[0]); - GLint desty = IROUND(ctx->Current.RasterPos[1]); - ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty, - type ); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); -} - - -static void GLAPIENTRY -_mesa_Bitmap( GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); - return; - } - - if (!ctx->Current.RasterPosValid) { - return; /* do nothing */ - } - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - if (!valid_fragment_program(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBitmap (invalid fragment program)"); - return; - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glBitmap(incomplete framebuffer)"); - return; - } - - if (ctx->RenderMode == GL_RENDER) { - /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - if (width > 0 && height > 0) { - const GLfloat epsilon = 0.0001F; - GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); - - if (ctx->Unpack.BufferObj->Name) { - /* unpack from PBO */ - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, - GL_COLOR_INDEX, GL_BITMAP, - (GLvoid *) bitmap)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBitmap(invalid PBO access)"); - return; - } - if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBitmap(PBO is mapped)"); - return; - } - } - - ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); - } - } -#if _HAVE_FULL_GL - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT(ctx, 0); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } -#endif - - /* update raster position */ - ctx->Current.RasterPos[0] += xmove; - ctx->Current.RasterPos[1] += ymove; -} - - -void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp) -{ - SET_Bitmap(disp, _mesa_Bitmap); - SET_CopyPixels(disp, _mesa_CopyPixels); - SET_DrawPixels(disp, _mesa_DrawPixels); -} - - -#endif /* FEATURE_drawpix */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "drawpix.h" +#include "enums.h" +#include "feedback.h" +#include "framebuffer.h" +#include "readpix.h" +#include "state.h" +#include "dispatch.h" + + +#if FEATURE_drawpix + + +/* + * Execute glDrawPixels + */ +static void GLAPIENTRY +_mesa_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" ); + return; + } + + /* We're not using the current vertex program, and the driver may install + * its own. Note: this may dirty some state. + */ + _mesa_set_vp_override(ctx, GL_TRUE); + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glDrawPixels")) { + goto end; /* the error code was recorded */ + } + + if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { + goto end; /* the error code was recorded */ + } + + if (!ctx->Current.RasterPosValid) { + goto end; /* no-op, not an error */ + } + + if (ctx->RenderMode == GL_RENDER) { + if (width > 0 && height > 0) { + /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ + GLint x = IROUND(ctx->Current.RasterPos[0]); + GLint y = IROUND(ctx->Current.RasterPos[1]); + + if (ctx->Unpack.BufferObj->Name) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(invalid PBO access)"); + goto end; + } + if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(PBO is mapped)"); + goto end; + } + } + + ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, + &ctx->Unpack, pixels); + } + } + else if (ctx->RenderMode == GL_FEEDBACK) { + /* Feedback the current raster pos info */ + FLUSH_CURRENT( ctx, 0 ); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } + +end: + _mesa_set_vp_override(ctx, GL_FALSE); +} + + +static void GLAPIENTRY +_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, + GLenum type ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); + return; + } + + /* Note: more detailed 'type' checking is done by the + * _mesa_source/dest_buffer_exists() calls below. That's where we + * check if the stencil buffer exists, etc. + */ + if (type != GL_COLOR && + type != GL_DEPTH && + type != GL_STENCIL && + type != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", + _mesa_lookup_enum_by_nr(type)); + return; + } + + /* We're not using the current vertex program, and the driver may install + * it's own. Note: this may dirty some state. + */ + _mesa_set_vp_override(ctx, GL_TRUE); + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glCopyPixels")) { + goto end; /* the error code was recorded */ + } + + /* Check read buffer's status (draw buffer was already checked) */ + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyPixels(incomplete framebuffer)" ); + goto end; + } + + if (!_mesa_source_buffer_exists(ctx, type) || + !_mesa_dest_buffer_exists(ctx, type)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyPixels(missing source or dest buffer)"); + goto end; + } + + if (!ctx->Current.RasterPosValid || width ==0 || height == 0) { + goto end; /* no-op, not an error */ + } + + if (ctx->RenderMode == GL_RENDER) { + /* Round to satisfy conformance tests (matches SGI's OpenGL) */ + if (width > 0 && height > 0) { + GLint destx = IROUND(ctx->Current.RasterPos[0]); + GLint desty = IROUND(ctx->Current.RasterPos[1]); + ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty, + type ); + } + } + else if (ctx->RenderMode == GL_FEEDBACK) { + FLUSH_CURRENT( ctx, 0 ); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } + +end: + _mesa_set_vp_override(ctx, GL_FALSE); +} + + +static void GLAPIENTRY +_mesa_Bitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); + return; + } + + if (!ctx->Current.RasterPosValid) { + return; /* do nothing */ + } + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glBitmap")) { + /* the error code was recorded */ + return; + } + + if (ctx->RenderMode == GL_RENDER) { + /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ + if (width > 0 && height > 0) { + const GLfloat epsilon = 0.0001F; + GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); + GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); + + if (ctx->Unpack.BufferObj->Name) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1, + GL_COLOR_INDEX, GL_BITMAP, + (GLvoid *) bitmap)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBitmap(invalid PBO access)"); + return; + } + if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBitmap(PBO is mapped)"); + return; + } + } + + ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); + } + } +#if _HAVE_FULL_GL + else if (ctx->RenderMode == GL_FEEDBACK) { + FLUSH_CURRENT(ctx, 0); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } +#endif + + /* update raster position */ + ctx->Current.RasterPos[0] += xmove; + ctx->Current.RasterPos[1] += ymove; +} + + +void +_mesa_init_drawpix_dispatch(struct _glapi_table *disp) +{ + SET_Bitmap(disp, _mesa_Bitmap); + SET_CopyPixels(disp, _mesa_CopyPixels); + SET_DrawPixels(disp, _mesa_DrawPixels); +} + + +#endif /* FEATURE_drawpix */ diff --git a/mesalib/src/mesa/main/drawpix.h b/mesalib/src/mesa/main/drawpix.h index 1f95ff529..88d3ecc95 100644 --- a/mesalib/src/mesa/main/drawpix.h +++ b/mesalib/src/mesa/main/drawpix.h @@ -1,47 +1,50 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef DRAWPIX_H -#define DRAWPIX_H - - -#include "main/mtypes.h" - - -#if FEATURE_drawpix - -extern void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_drawpix */ - -static INLINE void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_drawpix */ - - -#endif /* DRAWPIX_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef DRAWPIX_H +#define DRAWPIX_H + + +#include "compiler.h" +#include "mfeatures.h" + +struct _glapi_table; + + +#if FEATURE_drawpix + +extern void +_mesa_init_drawpix_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_drawpix */ + +static INLINE void +_mesa_init_drawpix_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_drawpix */ + + +#endif /* DRAWPIX_H */ diff --git a/mesalib/src/mesa/main/drawtex.c b/mesalib/src/mesa/main/drawtex.c index c2ad5f238..3e91f15bc 100644 --- a/mesalib/src/mesa/main/drawtex.c +++ b/mesalib/src/mesa/main/drawtex.c @@ -1,131 +1,131 @@ -/* - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -#include "main/drawtex.h" -#include "main/state.h" -#include "main/imports.h" - - -#if FEATURE_OES_draw_texture - - -static void -draw_texture(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height) -{ - if (!ctx->Extensions.OES_draw_texture) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawTex(unsupported)"); - return; - } - if (width <= 0.0f || height <= 0.0f) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - ASSERT(ctx->Driver.DrawTex); - ctx->Driver.DrawTex(ctx, x, y, z, width, height); -} - - -void GLAPIENTRY -_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, x, y, z, width, height); -} - - -void GLAPIENTRY -_mesa_DrawTexfv(const GLfloat *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, - (GLfloat) width, (GLfloat) height); -} - - -void GLAPIENTRY -_mesa_DrawTexiv(const GLint *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], - (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, - (GLfloat) width, (GLfloat) height); -} - - -void GLAPIENTRY -_mesa_DrawTexsv(const GLshort *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], - (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, - (GLfloat) x / 65536.0f, - (GLfloat) y / 65536.0f, - (GLfloat) z / 65536.0f, - (GLfloat) width / 65536.0f, - (GLfloat) height / 65536.0f); -} - - -void GLAPIENTRY -_mesa_DrawTexxv(const GLfixed *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, - (GLfloat) coords[0] / 65536.0f, - (GLfloat) coords[1] / 65536.0f, - (GLfloat) coords[2] / 65536.0f, - (GLfloat) coords[3] / 65536.0f, - (GLfloat) coords[4] / 65536.0f); -} - -#endif /* FEATURE_OES_draw_texture */ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +#include "main/drawtex.h" +#include "main/state.h" +#include "main/imports.h" + + +#if FEATURE_OES_draw_texture + + +static void +draw_texture(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + if (!ctx->Extensions.OES_draw_texture) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawTex(unsupported)"); + return; + } + if (width <= 0.0f || height <= 0.0f) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + ASSERT(ctx->Driver.DrawTex); + ctx->Driver.DrawTex(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) x / 65536.0f, + (GLfloat) y / 65536.0f, + (GLfloat) z / 65536.0f, + (GLfloat) width / 65536.0f, + (GLfloat) height / 65536.0f); +} + + +void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) coords[0] / 65536.0f, + (GLfloat) coords[1] / 65536.0f, + (GLfloat) coords[2] / 65536.0f, + (GLfloat) coords[3] / 65536.0f, + (GLfloat) coords[4] / 65536.0f); +} + +#endif /* FEATURE_OES_draw_texture */ diff --git a/mesalib/src/mesa/main/drawtex.h b/mesalib/src/mesa/main/drawtex.h index d7d507566..78bbd5b45 100644 --- a/mesalib/src/mesa/main/drawtex.h +++ b/mesalib/src/mesa/main/drawtex.h @@ -1,60 +1,61 @@ -/* - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -#ifndef DRAWTEX_H -#define DRAWTEX_H - - -#include "main/mtypes.h" - - -#if FEATURE_OES_draw_texture - -extern void GLAPIENTRY -_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); - -extern void GLAPIENTRY -_mesa_DrawTexfv(const GLfloat *coords); - -extern void GLAPIENTRY -_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); - -extern void GLAPIENTRY -_mesa_DrawTexiv(const GLint *coords); - -extern void GLAPIENTRY -_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); - -extern void GLAPIENTRY -_mesa_DrawTexsv(const GLshort *coords); - -extern void GLAPIENTRY -_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); - -extern void GLAPIENTRY -_mesa_DrawTexxv(const GLfixed *coords); - -#endif /* FEATURE_OES_draw_texture */ - - -#endif /* DRAWTEX_H */ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +#ifndef DRAWTEX_H +#define DRAWTEX_H + + +#include "glheader.h" +#include "mfeatures.h" + + +#if FEATURE_OES_draw_texture + +extern void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); + +extern void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords); + +extern void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); + +extern void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords); + +extern void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); + +extern void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords); + +extern void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); + +extern void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords); + +#endif /* FEATURE_OES_draw_texture */ + + +#endif /* DRAWTEX_H */ diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index db30123c0..c3dbd4a29 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -1,1567 +1,1491 @@ -/** - * \file enable.c - * Enable/disable/query GL capabilities. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.0.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "context.h" -#include "enable.h" -#include "light.h" -#include "simple_list.h" -#include "mtypes.h" -#include "enums.h" -#include "api_arrayelt.h" -#include "texstate.h" - - - -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper to enable/disable client-side state. - */ -static void -client_state(GLcontext *ctx, GLenum cap, GLboolean state) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint flag; - GLboolean *var; - - switch (cap) { - case GL_VERTEX_ARRAY: - var = &arrayObj->Vertex.Enabled; - flag = _NEW_ARRAY_VERTEX; - break; - case GL_NORMAL_ARRAY: - var = &arrayObj->Normal.Enabled; - flag = _NEW_ARRAY_NORMAL; - break; - case GL_COLOR_ARRAY: - var = &arrayObj->Color.Enabled; - flag = _NEW_ARRAY_COLOR0; - break; - case GL_INDEX_ARRAY: - var = &arrayObj->Index.Enabled; - flag = _NEW_ARRAY_INDEX; - break; - case GL_TEXTURE_COORD_ARRAY: - var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; - flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); - break; - case GL_EDGE_FLAG_ARRAY: - var = &arrayObj->EdgeFlag.Enabled; - flag = _NEW_ARRAY_EDGEFLAG; - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - var = &arrayObj->FogCoord.Enabled; - flag = _NEW_ARRAY_FOGCOORD; - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - var = &arrayObj->SecondaryColor.Enabled; - flag = _NEW_ARRAY_COLOR1; - break; - -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_OES: - var = &arrayObj->PointSize.Enabled; - flag = _NEW_ARRAY_POINT_SIZE; - break; -#endif - -#if FEATURE_NV_vertex_program - case GL_VERTEX_ATTRIB_ARRAY0_NV: - case GL_VERTEX_ATTRIB_ARRAY1_NV: - case GL_VERTEX_ATTRIB_ARRAY2_NV: - case GL_VERTEX_ATTRIB_ARRAY3_NV: - case GL_VERTEX_ATTRIB_ARRAY4_NV: - case GL_VERTEX_ATTRIB_ARRAY5_NV: - case GL_VERTEX_ATTRIB_ARRAY6_NV: - case GL_VERTEX_ATTRIB_ARRAY7_NV: - case GL_VERTEX_ATTRIB_ARRAY8_NV: - case GL_VERTEX_ATTRIB_ARRAY9_NV: - case GL_VERTEX_ATTRIB_ARRAY10_NV: - case GL_VERTEX_ATTRIB_ARRAY11_NV: - case GL_VERTEX_ATTRIB_ARRAY12_NV: - case GL_VERTEX_ATTRIB_ARRAY13_NV: - case GL_VERTEX_ATTRIB_ARRAY14_NV: - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; - ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); - var = &arrayObj->VertexAttrib[n].Enabled; - flag = _NEW_ARRAY_ATTRIB(n); - } - break; -#endif /* FEATURE_NV_vertex_program */ - - default: - goto invalid_enum_error; - } - - if (*var == state) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.NewState |= flag; - - _ae_invalidate_state(ctx, _NEW_ARRAY); - - *var = state; - - if (state) - ctx->Array.ArrayObj->_Enabled |= flag; - else - ctx->Array.ArrayObj->_Enabled &= ~flag; - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_EnableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_DisableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_FALSE ); -} - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - - -/** - * Return pointer to current texture unit for setting/getting coordinate - * state. - * Note that we'll set GL_INVALID_OPERATION if the active texture unit is - * higher than the number of supported coordinate units. And we'll return NULL. - */ -static struct gl_texture_unit * -get_texcoord_unit(GLcontext *ctx) -{ - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); - return NULL; - } - else { - return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - } -} - - -/** - * Helper function to enable or disable a texture target. - * \param bit one of the TEXTURE_x_BIT values - * \return GL_TRUE if state is changing or GL_FALSE if no change - */ -static GLboolean -enable_texture(GLcontext *ctx, GLboolean state, GLbitfield texBit) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - const GLbitfield newenabled = state - ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); - - if (texUnit->Enabled == newenabled) - return GL_FALSE; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; - return GL_TRUE; -} - - -/** - * Helper function to enable or disable state. - * - * \param ctx GL context. - * \param cap the state to enable/disable - * \param state whether to enable or disable the specified capability. - * - * Updates the current context and flushes the vertices as needed. For - * capabilities associated with extensions it verifies that those extensions - * are effectivly present before updating. Notifies the driver via - * dd_function_table::Enable. - */ -void -_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "%s %s (newstate is %x)\n", - state ? "glEnable" : "glDisable", - _mesa_lookup_enum_by_nr(cap), - ctx->NewState); - - switch (cap) { - case GL_ALPHA_TEST: - if (ctx->Color.AlphaEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.AlphaEnabled = state; - break; - case GL_AUTO_NORMAL: - if (ctx->Eval.AutoNormal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.AutoNormal = state; - break; - case GL_BLEND: - { - GLbitfield newEnabled = state * ((1 << ctx->Const.MaxDrawBuffers) - 1); - if (newEnabled != ctx->Color.BlendEnabled) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEnabled = newEnabled; - } - } - break; -#if FEATURE_userclip - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - { - const GLuint p = cap - GL_CLIP_PLANE0; - - if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) - return; - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - if (state) { - ctx->Transform.ClipPlanesEnabled |= (1 << p); - - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* This derived state also calculated in clip.c and - * from _mesa_update_state() on changes to EyeUserPlane - * and ctx->ProjectionMatrix respectively. - */ - _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], - ctx->Transform.EyeUserPlane[p], - ctx->ProjectionMatrixStack.Top->inv ); - } - else { - ctx->Transform.ClipPlanesEnabled &= ~(1 << p); - } - } - break; -#endif - case GL_COLOR_MATERIAL: - if (ctx->Light.ColorMaterialEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - FLUSH_CURRENT(ctx, 0); - ctx->Light.ColorMaterialEnabled = state; - if (state) { - _mesa_update_color_material( ctx, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - } - break; - case GL_CULL_FACE: - if (ctx->Polygon.CullFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFlag = state; - break; - case GL_CULL_VERTEX_EXT: - CHECK_EXTENSION(EXT_cull_vertex, cap); - if (ctx->Transform.CullVertexFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.CullVertexFlag = state; - break; - case GL_DEPTH_TEST: - if (ctx->Depth.Test == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Test = state; - break; - case GL_DITHER: - if (ctx->NoDither) { - state = GL_FALSE; /* MESA_NO_DITHER env var */ - } - if (ctx->Color.DitherFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.DitherFlag = state; - break; - case GL_FOG: - if (ctx->Fog.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Enabled = state; - break; - case GL_HISTOGRAM: - CHECK_EXTENSION(EXT_histogram, cap); - if (ctx->Pixel.HistogramEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.HistogramEnabled = state; - break; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; - if (state) { - insert_at_tail(&ctx->Light.EnabledList, - &ctx->Light.Light[cap-GL_LIGHT0]); - } - else { - remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); - } - break; - case GL_LIGHTING: - if (ctx->Light.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Enabled = state; - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; - case GL_LINE_SMOOTH: - if (ctx->Line.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_LINE_SMOOTH; - break; - case GL_LINE_STIPPLE: - if (ctx->Line.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFlag = state; - ctx->_TriangleCaps ^= DD_LINE_STIPPLE; - break; - case GL_INDEX_LOGIC_OP: - if (ctx->Color.IndexLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.IndexLogicOpEnabled = state; - break; - case GL_COLOR_LOGIC_OP: - if (ctx->Color.ColorLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ColorLogicOpEnabled = state; - break; - case GL_MAP1_COLOR_4: - if (ctx->Eval.Map1Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Color4 = state; - break; - case GL_MAP1_INDEX: - if (ctx->Eval.Map1Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Index = state; - break; - case GL_MAP1_NORMAL: - if (ctx->Eval.Map1Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Normal = state; - break; - case GL_MAP1_TEXTURE_COORD_1: - if (ctx->Eval.Map1TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord1 = state; - break; - case GL_MAP1_TEXTURE_COORD_2: - if (ctx->Eval.Map1TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord2 = state; - break; - case GL_MAP1_TEXTURE_COORD_3: - if (ctx->Eval.Map1TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord3 = state; - break; - case GL_MAP1_TEXTURE_COORD_4: - if (ctx->Eval.Map1TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord4 = state; - break; - case GL_MAP1_VERTEX_3: - if (ctx->Eval.Map1Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex3 = state; - break; - case GL_MAP1_VERTEX_4: - if (ctx->Eval.Map1Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex4 = state; - break; - case GL_MAP2_COLOR_4: - if (ctx->Eval.Map2Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Color4 = state; - break; - case GL_MAP2_INDEX: - if (ctx->Eval.Map2Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Index = state; - break; - case GL_MAP2_NORMAL: - if (ctx->Eval.Map2Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Normal = state; - break; - case GL_MAP2_TEXTURE_COORD_1: - if (ctx->Eval.Map2TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord1 = state; - break; - case GL_MAP2_TEXTURE_COORD_2: - if (ctx->Eval.Map2TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord2 = state; - break; - case GL_MAP2_TEXTURE_COORD_3: - if (ctx->Eval.Map2TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord3 = state; - break; - case GL_MAP2_TEXTURE_COORD_4: - if (ctx->Eval.Map2TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord4 = state; - break; - case GL_MAP2_VERTEX_3: - if (ctx->Eval.Map2Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex3 = state; - break; - case GL_MAP2_VERTEX_4: - if (ctx->Eval.Map2Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex4 = state; - break; - case GL_MINMAX: - if (ctx->Pixel.MinMaxEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MinMaxEnabled = state; - break; - case GL_NORMALIZE: - if (ctx->Transform.Normalize == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.Normalize = state; - break; - case GL_POINT_SMOOTH: - if (ctx->Point.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_POINT_SMOOTH; - break; - case GL_POLYGON_SMOOTH: - if (ctx->Polygon.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_TRI_SMOOTH; - break; - case GL_POLYGON_STIPPLE: - if (ctx->Polygon.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.StippleFlag = state; - ctx->_TriangleCaps ^= DD_TRI_STIPPLE; - break; - case GL_POLYGON_OFFSET_POINT: - if (ctx->Polygon.OffsetPoint == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetPoint = state; - break; - case GL_POLYGON_OFFSET_LINE: - if (ctx->Polygon.OffsetLine == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetLine = state; - break; - case GL_POLYGON_OFFSET_FILL: - /*case GL_POLYGON_OFFSET_EXT:*/ - if (ctx->Polygon.OffsetFill == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFill = state; - break; - case GL_RESCALE_NORMAL_EXT: - if (ctx->Transform.RescaleNormals == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RescaleNormals = state; - break; - case GL_SCISSOR_TEST: - if (ctx->Scissor.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.Enabled = state; - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - if (ctx->Texture.SharedPalette == state) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.SharedPalette = state; - break; - case GL_STENCIL_TEST: - if (ctx->Stencil.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Enabled = state; - break; - case GL_TEXTURE_1D: - if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { - return; - } - break; - case GL_TEXTURE_2D: - if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { - return; - } - break; - case GL_TEXTURE_3D: - if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { - return; - } - break; - case GL_TEXTURE_GEN_Q: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; - if (state) - newenabled |= Q_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - case GL_TEXTURE_GEN_R: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; - if (state) - newenabled |= R_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - case GL_TEXTURE_GEN_S: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; - if (state) - newenabled |= S_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - case GL_TEXTURE_GEN_T: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; - if (state) - newenabled |= T_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - /* disable S, T, and R at the same time */ - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = - texUnit->TexGenEnabled & ~STR_BITS; - if (state) - newenabled |= STR_BITS; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; -#endif - - /* - * CLIENT STATE!!! - */ - case GL_VERTEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_COLOR_ARRAY: - case GL_INDEX_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_FOG_COORDINATE_ARRAY_EXT: - case GL_SECONDARY_COLOR_ARRAY_EXT: - case GL_POINT_SIZE_ARRAY_OES: - client_state( ctx, cap, state ); - return; - - /* GL_SGI_color_table */ - case GL_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table, cap); - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_texture_color_table, cap); - if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; - break; - - /* GL_EXT_convolution */ - case GL_CONVOLUTION_1D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Convolution1DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Convolution1DEnabled = state; - break; - case GL_CONVOLUTION_2D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Convolution2DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Convolution2DEnabled = state; - break; - case GL_SEPARABLE_2D: - CHECK_EXTENSION(EXT_convolution, cap); - if (ctx->Pixel.Separable2DEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.Separable2DEnabled = state; - break; - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map, cap); - if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { - return; - } - break; - - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); - if (ctx->Fog.ColorSumEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.ColorSumEnabled = state; - break; - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - if (ctx->Multisample.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.Enabled = state; - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - if (ctx->Multisample.SampleAlphaToCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToCoverage = state; - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - if (ctx->Multisample.SampleAlphaToOne == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToOne = state; - break; - case GL_SAMPLE_COVERAGE_ARB: - if (ctx->Multisample.SampleCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverage = state; - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - if (ctx->Multisample.SampleCoverageInvert == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverageInvert = state; - break; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip, cap); - if (ctx->Transform.RasterPositionUnclipped == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RasterPositionUnclipped = state; - break; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); - if (ctx->Point.PointSprite == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.PointSprite = state; - break; - -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.Enabled = state; - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.PointSizeEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.PointSizeEnabled = state; - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.TwoSideEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.TwoSideEnabled = state; - break; -#endif -#if FEATURE_NV_vertex_program - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Attrib[map] = state; - } - break; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Attrib[map] = state; - } - break; -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_NV_fragment_program */ - - /* GL_NV_texture_rectangle */ - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXTENSION(NV_texture_rectangle, cap); - if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { - return; - } - break; - - /* GL_EXT_stencil_two_side */ - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXTENSION(EXT_stencil_two_side, cap); - if (ctx->Stencil.TestTwoSide == state) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.TestTwoSide = state; - if (state) { - ctx->Stencil._BackFace = 2; - ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; - } else { - ctx->Stencil._BackFace = 1; - ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; - } - break; - -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXTENSION(ARB_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_ARB_fragment_program */ - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test, cap); - if (ctx->Depth.BoundsTest == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsTest = state; - break; - - case GL_DEPTH_CLAMP: - if (ctx->Transform.DepthClamp == state) - return; - CHECK_EXTENSION(ARB_depth_clamp, cap); - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.DepthClamp = state; - break; - -#if FEATURE_ATI_fragment_shader - case GL_FRAGMENT_SHADER_ATI: - CHECK_EXTENSION(ATI_fragment_shader, cap); - if (ctx->ATIFragmentShader.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->ATIFragmentShader.Enabled = state; - break; -#endif - - /* GL_MESA_texture_array */ - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXTENSION(MESA_texture_array, cap); - if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { - return; - } - break; - - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXTENSION(MESA_texture_array, cap); - if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { - return; - } - break; - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXTENSION(ARB_seamless_cube_map, cap); - ctx->Texture.CubeMapSeamless = state; - break; - -#if FEATURE_EXT_transform_feedback - case GL_RASTERIZER_DISCARD: - CHECK_EXTENSION(EXT_transform_feedback, cap); - if (ctx->TransformFeedback.RasterDiscard != state) { - ctx->TransformFeedback.RasterDiscard = state; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - } - break; -#endif - - /* GL 3.1 primitive restart */ - case GL_PRIMITIVE_RESTART: - if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { - goto invalid_enum_error; - } - if (ctx->Array.PrimitiveRestart != state) { - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Array.PrimitiveRestart = state; - } - break; - - default: - goto invalid_enum_error; - } - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. Called by glEnable() - * \param cap state to enable. - */ -void GLAPIENTRY -_mesa_Enable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. Called by glDisable() - * \param cap state to disable. - */ -void GLAPIENTRY -_mesa_Disable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_FALSE ); -} - - - -/** - * Enable/disable an indexed state var. - */ -void -_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) -{ - ASSERT(state == 0 || state == 1); - switch (cap) { - case GL_BLEND: - if (!ctx->Extensions.EXT_draw_buffers2) { - goto invalid_enum_error; - } - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", - state ? "glEnableIndexed" : "glDisableIndexed", index); - return; - } - if (((ctx->Color.BlendEnabled >> index) & 1) != state) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - if (state) - ctx->Color.BlendEnabled |= (1 << index); - else - ctx->Color.BlendEnabled &= ~(1 << index); - } - break; - default: - goto invalid_enum_error; - } - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", - state ? "glEnablei" : "glDisablei", - _mesa_lookup_enum_by_nr(cap)); -} - - -void GLAPIENTRY -_mesa_DisableIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_set_enablei(ctx, cap, index, GL_FALSE); -} - - -void GLAPIENTRY -_mesa_EnableIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_set_enablei(ctx, cap, index, GL_TRUE); -} - - -GLboolean GLAPIENTRY -_mesa_IsEnabledIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - switch (cap) { - case GL_BLEND: - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", - index); - return GL_FALSE; - } - return (ctx->Color.BlendEnabled >> index) & 1; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", - _mesa_lookup_enum_by_nr(cap)); - return GL_FALSE; - } -} - - - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#undef CHECK_EXTENSION2 -#define CHECK_EXTENSION2(EXT1, EXT2) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper function to determine whether a texture target is enabled. - */ -static GLboolean -is_texture_enabled(GLcontext *ctx, GLbitfield bit) -{ - const struct gl_texture_unit *const texUnit = - &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; -} - - -/** - * Return simple enable/disable state. - * - * \param cap state variable to query. - * - * Returns the state of the specified capability from the current GL context. - * For the capabilities associated with extensions verifies that those - * extensions are effectively present before reporting. - */ -GLboolean GLAPIENTRY -_mesa_IsEnabled( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - switch (cap) { - case GL_ALPHA_TEST: - return ctx->Color.AlphaEnabled; - case GL_AUTO_NORMAL: - return ctx->Eval.AutoNormal; - case GL_BLEND: - return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; - case GL_COLOR_MATERIAL: - return ctx->Light.ColorMaterialEnabled; - case GL_CULL_FACE: - return ctx->Polygon.CullFlag; - case GL_DEPTH_TEST: - return ctx->Depth.Test; - case GL_DITHER: - return ctx->Color.DitherFlag; - case GL_FOG: - return ctx->Fog.Enabled; - case GL_LIGHTING: - return ctx->Light.Enabled; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - return ctx->Light.Light[cap-GL_LIGHT0].Enabled; - case GL_LINE_SMOOTH: - return ctx->Line.SmoothFlag; - case GL_LINE_STIPPLE: - return ctx->Line.StippleFlag; - case GL_INDEX_LOGIC_OP: - return ctx->Color.IndexLogicOpEnabled; - case GL_COLOR_LOGIC_OP: - return ctx->Color.ColorLogicOpEnabled; - case GL_MAP1_COLOR_4: - return ctx->Eval.Map1Color4; - case GL_MAP1_INDEX: - return ctx->Eval.Map1Index; - case GL_MAP1_NORMAL: - return ctx->Eval.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return ctx->Eval.Map1TextureCoord1; - case GL_MAP1_TEXTURE_COORD_2: - return ctx->Eval.Map1TextureCoord2; - case GL_MAP1_TEXTURE_COORD_3: - return ctx->Eval.Map1TextureCoord3; - case GL_MAP1_TEXTURE_COORD_4: - return ctx->Eval.Map1TextureCoord4; - case GL_MAP1_VERTEX_3: - return ctx->Eval.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return ctx->Eval.Map1Vertex4; - case GL_MAP2_COLOR_4: - return ctx->Eval.Map2Color4; - case GL_MAP2_INDEX: - return ctx->Eval.Map2Index; - case GL_MAP2_NORMAL: - return ctx->Eval.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return ctx->Eval.Map2TextureCoord1; - case GL_MAP2_TEXTURE_COORD_2: - return ctx->Eval.Map2TextureCoord2; - case GL_MAP2_TEXTURE_COORD_3: - return ctx->Eval.Map2TextureCoord3; - case GL_MAP2_TEXTURE_COORD_4: - return ctx->Eval.Map2TextureCoord4; - case GL_MAP2_VERTEX_3: - return ctx->Eval.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return ctx->Eval.Map2Vertex4; - case GL_NORMALIZE: - return ctx->Transform.Normalize; - case GL_POINT_SMOOTH: - return ctx->Point.SmoothFlag; - case GL_POLYGON_SMOOTH: - return ctx->Polygon.SmoothFlag; - case GL_POLYGON_STIPPLE: - return ctx->Polygon.StippleFlag; - case GL_POLYGON_OFFSET_POINT: - return ctx->Polygon.OffsetPoint; - case GL_POLYGON_OFFSET_LINE: - return ctx->Polygon.OffsetLine; - case GL_POLYGON_OFFSET_FILL: - /*case GL_POLYGON_OFFSET_EXT:*/ - return ctx->Polygon.OffsetFill; - case GL_RESCALE_NORMAL_EXT: - return ctx->Transform.RescaleNormals; - case GL_SCISSOR_TEST: - return ctx->Scissor.Enabled; - case GL_SHARED_TEXTURE_PALETTE_EXT: - return ctx->Texture.SharedPalette; - case GL_STENCIL_TEST: - return ctx->Stencil.Enabled; - case GL_TEXTURE_1D: - return is_texture_enabled(ctx, TEXTURE_1D_BIT); - case GL_TEXTURE_2D: - return is_texture_enabled(ctx, TEXTURE_2D_BIT); - case GL_TEXTURE_3D: - return is_texture_enabled(ctx, TEXTURE_3D_BIT); - case GL_TEXTURE_GEN_Q: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; - case GL_TEXTURE_GEN_R: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; - case GL_TEXTURE_GEN_S: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; - case GL_TEXTURE_GEN_T: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS ? GL_TRUE : GL_FALSE; - } - } -#endif - - /* - * CLIENT STATE!!! - */ - case GL_VERTEX_ARRAY: - return (ctx->Array.ArrayObj->Vertex.Enabled != 0); - case GL_NORMAL_ARRAY: - return (ctx->Array.ArrayObj->Normal.Enabled != 0); - case GL_COLOR_ARRAY: - return (ctx->Array.ArrayObj->Color.Enabled != 0); - case GL_INDEX_ARRAY: - return (ctx->Array.ArrayObj->Index.Enabled != 0); - case GL_TEXTURE_COORD_ARRAY: - return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0); - case GL_EDGE_FLAG_ARRAY: - return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXTENSION(EXT_fog_coord); - return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXTENSION(EXT_secondary_color); - return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_OES: - return (ctx->Array.ArrayObj->PointSize.Enabled != 0); -#endif - - /* GL_EXT_histogram */ - case GL_HISTOGRAM: - CHECK_EXTENSION(EXT_histogram); - return ctx->Pixel.HistogramEnabled; - case GL_MINMAX: - CHECK_EXTENSION(EXT_histogram); - return ctx->Pixel.MinMaxEnabled; - - /* GL_SGI_color_table */ - case GL_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_color_table); - return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; - - /* GL_SGI_texture_color_table */ - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXTENSION(SGI_texture_color_table); - return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; - - /* GL_EXT_convolution */ - case GL_CONVOLUTION_1D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Convolution1DEnabled; - case GL_CONVOLUTION_2D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Convolution2DEnabled; - case GL_SEPARABLE_2D: - CHECK_EXTENSION(EXT_convolution); - return ctx->Pixel.Separable2DEnabled; - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map); - return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); - - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); - return ctx->Fog.ColorSumEnabled; - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - return ctx->Multisample.Enabled; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - return ctx->Multisample.SampleAlphaToCoverage; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - return ctx->Multisample.SampleAlphaToOne; - case GL_SAMPLE_COVERAGE_ARB: - return ctx->Multisample.SampleCoverage; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - return ctx->Multisample.SampleCoverageInvert; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip); - return ctx->Transform.RasterPositionUnclipped; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) - return ctx->Point.PointSprite; - -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.Enabled; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.PointSizeEnabled; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.TwoSideEnabled; -#endif -#if FEATURE_NV_vertex_program - case GL_VERTEX_ATTRIB_ARRAY0_NV: - case GL_VERTEX_ATTRIB_ARRAY1_NV: - case GL_VERTEX_ATTRIB_ARRAY2_NV: - case GL_VERTEX_ATTRIB_ARRAY3_NV: - case GL_VERTEX_ATTRIB_ARRAY4_NV: - case GL_VERTEX_ATTRIB_ARRAY5_NV: - case GL_VERTEX_ATTRIB_ARRAY6_NV: - case GL_VERTEX_ATTRIB_ARRAY7_NV: - case GL_VERTEX_ATTRIB_ARRAY8_NV: - case GL_VERTEX_ATTRIB_ARRAY9_NV: - case GL_VERTEX_ATTRIB_ARRAY10_NV: - case GL_VERTEX_ATTRIB_ARRAY11_NV: - case GL_VERTEX_ATTRIB_ARRAY12_NV: - case GL_VERTEX_ATTRIB_ARRAY13_NV: - case GL_VERTEX_ATTRIB_ARRAY14_NV: - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXTENSION(NV_vertex_program); - { - GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; - ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); - return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); - } - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map1Attrib[map]; - } - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map2Attrib[map]; - } -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program); - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_NV_fragment_program */ - - /* GL_NV_texture_rectangle */ - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXTENSION(NV_texture_rectangle); - return is_texture_enabled(ctx, TEXTURE_RECT_BIT); - - /* GL_EXT_stencil_two_side */ - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXTENSION(EXT_stencil_two_side); - return ctx->Stencil.TestTwoSide; - -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_ARB_fragment_program */ - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test); - return ctx->Depth.BoundsTest; - - /* GL_ARB_depth_clamp */ - case GL_DEPTH_CLAMP: - CHECK_EXTENSION(ARB_depth_clamp); - return ctx->Transform.DepthClamp; - -#if FEATURE_ATI_fragment_shader - case GL_FRAGMENT_SHADER_ATI: - CHECK_EXTENSION(ATI_fragment_shader); - return ctx->ATIFragmentShader.Enabled; -#endif /* FEATURE_ATI_fragment_shader */ - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXTENSION(ARB_seamless_cube_map); - return ctx->Texture.CubeMapSeamless; - -#if FEATURE_EXT_transform_feedback - case GL_RASTERIZER_DISCARD: - CHECK_EXTENSION(EXT_transform_feedback); - return ctx->TransformFeedback.RasterDiscard; -#endif - - /* GL 3.1 primitive restart */ - case GL_PRIMITIVE_RESTART: - if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { - goto invalid_enum_error; - } - return ctx->Array.PrimitiveRestart; - - default: - goto invalid_enum_error; - } - - return GL_FALSE; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); - return GL_FALSE; -} +/** + * \file enable.c + * Enable/disable/query GL capabilities. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.0.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "context.h" +#include "enable.h" +#include "light.h" +#include "simple_list.h" +#include "mtypes.h" +#include "enums.h" +#include "api_arrayelt.h" +#include "texstate.h" + + + +#define CHECK_EXTENSION(EXTNAME, CAP) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + + +/** + * Helper to enable/disable client-side state. + */ +static void +client_state(struct gl_context *ctx, GLenum cap, GLboolean state) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint flag; + GLboolean *var; + + switch (cap) { + case GL_VERTEX_ARRAY: + var = &arrayObj->Vertex.Enabled; + flag = _NEW_ARRAY_VERTEX; + break; + case GL_NORMAL_ARRAY: + var = &arrayObj->Normal.Enabled; + flag = _NEW_ARRAY_NORMAL; + break; + case GL_COLOR_ARRAY: + var = &arrayObj->Color.Enabled; + flag = _NEW_ARRAY_COLOR0; + break; + case GL_INDEX_ARRAY: + var = &arrayObj->Index.Enabled; + flag = _NEW_ARRAY_INDEX; + break; + case GL_TEXTURE_COORD_ARRAY: + var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; + flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); + break; + case GL_EDGE_FLAG_ARRAY: + var = &arrayObj->EdgeFlag.Enabled; + flag = _NEW_ARRAY_EDGEFLAG; + break; + case GL_FOG_COORDINATE_ARRAY_EXT: + var = &arrayObj->FogCoord.Enabled; + flag = _NEW_ARRAY_FOGCOORD; + break; + case GL_SECONDARY_COLOR_ARRAY_EXT: + var = &arrayObj->SecondaryColor.Enabled; + flag = _NEW_ARRAY_COLOR1; + break; + +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_OES: + var = &arrayObj->PointSize.Enabled; + flag = _NEW_ARRAY_POINT_SIZE; + break; +#endif + +#if FEATURE_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; + ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); + var = &arrayObj->VertexAttrib[n].Enabled; + flag = _NEW_ARRAY_ATTRIB(n); + } + break; +#endif /* FEATURE_NV_vertex_program */ + + /* GL_NV_primitive_restart */ + case GL_PRIMITIVE_RESTART_NV: + if (!ctx->Extensions.NV_primitive_restart) { + goto invalid_enum_error; + } + var = &ctx->Array.PrimitiveRestart; + flag = 0; + break; + + default: + goto invalid_enum_error; + } + + if (*var == state) + return; + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.NewState |= flag; + + _ae_invalidate_state(ctx, _NEW_ARRAY); + + *var = state; + + if (state) + ctx->Array.ArrayObj->_Enabled |= flag; + else + ctx->Array.ArrayObj->_Enabled &= ~flag; + + if (ctx->Driver.Enable) { + ctx->Driver.Enable( ctx, cap, state ); + } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", + state ? "Enable" : "Disable", cap); +} + + +/** + * Enable GL capability. + * \param cap state to enable/disable. + * + * Get's the current context, assures that we're outside glBegin()/glEnd() and + * calls client_state(). + */ +void GLAPIENTRY +_mesa_EnableClientState( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + client_state( ctx, cap, GL_TRUE ); +} + + +/** + * Disable GL capability. + * \param cap state to enable/disable. + * + * Get's the current context, assures that we're outside glBegin()/glEnd() and + * calls client_state(). + */ +void GLAPIENTRY +_mesa_DisableClientState( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + client_state( ctx, cap, GL_FALSE ); +} + + +#undef CHECK_EXTENSION +#define CHECK_EXTENSION(EXTNAME, CAP) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + +#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ + goto invalid_enum_error; \ + } + + + +/** + * Return pointer to current texture unit for setting/getting coordinate + * state. + * Note that we'll set GL_INVALID_OPERATION if the active texture unit is + * higher than the number of supported coordinate units. And we'll return NULL. + */ +static struct gl_texture_unit * +get_texcoord_unit(struct gl_context *ctx) +{ + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); + return NULL; + } + else { + return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + } +} + + +/** + * Helper function to enable or disable a texture target. + * \param bit one of the TEXTURE_x_BIT values + * \return GL_TRUE if state is changing or GL_FALSE if no change + */ +static GLboolean +enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + const GLbitfield newenabled = state + ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); + + if (texUnit->Enabled == newenabled) + return GL_FALSE; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Enabled = newenabled; + return GL_TRUE; +} + + +/** + * Helper function to enable or disable state. + * + * \param ctx GL context. + * \param cap the state to enable/disable + * \param state whether to enable or disable the specified capability. + * + * Updates the current context and flushes the vertices as needed. For + * capabilities associated with extensions it verifies that those extensions + * are effectivly present before updating. Notifies the driver via + * dd_function_table::Enable. + */ +void +_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) +{ + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "%s %s (newstate is %x)\n", + state ? "glEnable" : "glDisable", + _mesa_lookup_enum_by_nr(cap), + ctx->NewState); + + switch (cap) { + case GL_ALPHA_TEST: + if (ctx->Color.AlphaEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.AlphaEnabled = state; + break; + case GL_AUTO_NORMAL: + if (ctx->Eval.AutoNormal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.AutoNormal = state; + break; + case GL_BLEND: + { + GLbitfield newEnabled = state * ((1 << ctx->Const.MaxDrawBuffers) - 1); + if (newEnabled != ctx->Color.BlendEnabled) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.BlendEnabled = newEnabled; + } + } + break; +#if FEATURE_userclip + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + { + const GLuint p = cap - GL_CLIP_PLANE0; + + if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) + return; + + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + + if (state) { + ctx->Transform.ClipPlanesEnabled |= (1 << p); + + if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) + _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); + + /* This derived state also calculated in clip.c and + * from _mesa_update_state() on changes to EyeUserPlane + * and ctx->ProjectionMatrix respectively. + */ + _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], + ctx->Transform.EyeUserPlane[p], + ctx->ProjectionMatrixStack.Top->inv ); + } + else { + ctx->Transform.ClipPlanesEnabled &= ~(1 << p); + } + } + break; +#endif + case GL_COLOR_MATERIAL: + if (ctx->Light.ColorMaterialEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + FLUSH_CURRENT(ctx, 0); + ctx->Light.ColorMaterialEnabled = state; + if (state) { + _mesa_update_color_material( ctx, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); + } + break; + case GL_CULL_FACE: + if (ctx->Polygon.CullFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.CullFlag = state; + break; + case GL_DEPTH_TEST: + if (ctx->Depth.Test == state) + return; + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Test = state; + break; + case GL_DITHER: + if (ctx->NoDither) { + state = GL_FALSE; /* MESA_NO_DITHER env var */ + } + if (ctx->Color.DitherFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.DitherFlag = state; + break; + case GL_FOG: + if (ctx->Fog.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Enabled = state; + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; + if (state) { + insert_at_tail(&ctx->Light.EnabledList, + &ctx->Light.Light[cap-GL_LIGHT0]); + } + else { + remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); + } + break; + case GL_LIGHTING: + if (ctx->Light.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Enabled = state; + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + else + ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; + break; + case GL_LINE_SMOOTH: + if (ctx->Line.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_LINE_SMOOTH; + break; + case GL_LINE_STIPPLE: + if (ctx->Line.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.StippleFlag = state; + ctx->_TriangleCaps ^= DD_LINE_STIPPLE; + break; + case GL_INDEX_LOGIC_OP: + if (ctx->Color.IndexLogicOpEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.IndexLogicOpEnabled = state; + break; + case GL_COLOR_LOGIC_OP: + if (ctx->Color.ColorLogicOpEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.ColorLogicOpEnabled = state; + break; + case GL_MAP1_COLOR_4: + if (ctx->Eval.Map1Color4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Color4 = state; + break; + case GL_MAP1_INDEX: + if (ctx->Eval.Map1Index == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Index = state; + break; + case GL_MAP1_NORMAL: + if (ctx->Eval.Map1Normal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Normal = state; + break; + case GL_MAP1_TEXTURE_COORD_1: + if (ctx->Eval.Map1TextureCoord1 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord1 = state; + break; + case GL_MAP1_TEXTURE_COORD_2: + if (ctx->Eval.Map1TextureCoord2 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord2 = state; + break; + case GL_MAP1_TEXTURE_COORD_3: + if (ctx->Eval.Map1TextureCoord3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord3 = state; + break; + case GL_MAP1_TEXTURE_COORD_4: + if (ctx->Eval.Map1TextureCoord4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord4 = state; + break; + case GL_MAP1_VERTEX_3: + if (ctx->Eval.Map1Vertex3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Vertex3 = state; + break; + case GL_MAP1_VERTEX_4: + if (ctx->Eval.Map1Vertex4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Vertex4 = state; + break; + case GL_MAP2_COLOR_4: + if (ctx->Eval.Map2Color4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Color4 = state; + break; + case GL_MAP2_INDEX: + if (ctx->Eval.Map2Index == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Index = state; + break; + case GL_MAP2_NORMAL: + if (ctx->Eval.Map2Normal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Normal = state; + break; + case GL_MAP2_TEXTURE_COORD_1: + if (ctx->Eval.Map2TextureCoord1 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord1 = state; + break; + case GL_MAP2_TEXTURE_COORD_2: + if (ctx->Eval.Map2TextureCoord2 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord2 = state; + break; + case GL_MAP2_TEXTURE_COORD_3: + if (ctx->Eval.Map2TextureCoord3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord3 = state; + break; + case GL_MAP2_TEXTURE_COORD_4: + if (ctx->Eval.Map2TextureCoord4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord4 = state; + break; + case GL_MAP2_VERTEX_3: + if (ctx->Eval.Map2Vertex3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Vertex3 = state; + break; + case GL_MAP2_VERTEX_4: + if (ctx->Eval.Map2Vertex4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Vertex4 = state; + break; + case GL_NORMALIZE: + if (ctx->Transform.Normalize == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.Normalize = state; + break; + case GL_POINT_SMOOTH: + if (ctx->Point.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_POINT_SMOOTH; + break; + case GL_POLYGON_SMOOTH: + if (ctx->Polygon.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_TRI_SMOOTH; + break; + case GL_POLYGON_STIPPLE: + if (ctx->Polygon.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.StippleFlag = state; + ctx->_TriangleCaps ^= DD_TRI_STIPPLE; + break; + case GL_POLYGON_OFFSET_POINT: + if (ctx->Polygon.OffsetPoint == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetPoint = state; + break; + case GL_POLYGON_OFFSET_LINE: + if (ctx->Polygon.OffsetLine == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetLine = state; + break; + case GL_POLYGON_OFFSET_FILL: + /*case GL_POLYGON_OFFSET_EXT:*/ + if (ctx->Polygon.OffsetFill == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetFill = state; + break; + case GL_RESCALE_NORMAL_EXT: + if (ctx->Transform.RescaleNormals == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.RescaleNormals = state; + break; + case GL_SCISSOR_TEST: + if (ctx->Scissor.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_SCISSOR); + ctx->Scissor.Enabled = state; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + if (ctx->Texture.SharedPalette == state) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.SharedPalette = state; + break; + case GL_STENCIL_TEST: + if (ctx->Stencil.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Enabled = state; + break; + case GL_TEXTURE_1D: + if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { + return; + } + break; + case GL_TEXTURE_2D: + if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { + return; + } + break; + case GL_TEXTURE_3D: + if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { + return; + } + break; + case GL_TEXTURE_GEN_Q: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; + if (state) + newenabled |= Q_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; + case GL_TEXTURE_GEN_R: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; + if (state) + newenabled |= R_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; + case GL_TEXTURE_GEN_S: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; + if (state) + newenabled |= S_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; + case GL_TEXTURE_GEN_T: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; + if (state) + newenabled |= T_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; + +#if FEATURE_ES1 + case GL_TEXTURE_GEN_STR_OES: + /* disable S, T, and R at the same time */ + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = + texUnit->TexGenEnabled & ~STR_BITS; + if (state) + newenabled |= STR_BITS; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; +#endif + + /* + * CLIENT STATE!!! + */ + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_INDEX_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_FOG_COORDINATE_ARRAY_EXT: + case GL_SECONDARY_COLOR_ARRAY_EXT: + case GL_POINT_SIZE_ARRAY_OES: + client_state( ctx, cap, state ); + return; + + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION(SGI_texture_color_table, cap); + if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; + break; + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + CHECK_EXTENSION(ARB_texture_cube_map, cap); + if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { + return; + } + break; + + /* GL_EXT_secondary_color */ + case GL_COLOR_SUM_EXT: + CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); + if (ctx->Fog.ColorSumEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.ColorSumEnabled = state; + break; + + /* GL_ARB_multisample */ + case GL_MULTISAMPLE_ARB: + if (ctx->Multisample.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.Enabled = state; + break; + case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: + if (ctx->Multisample.SampleAlphaToCoverage == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleAlphaToCoverage = state; + break; + case GL_SAMPLE_ALPHA_TO_ONE_ARB: + if (ctx->Multisample.SampleAlphaToOne == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleAlphaToOne = state; + break; + case GL_SAMPLE_COVERAGE_ARB: + if (ctx->Multisample.SampleCoverage == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleCoverage = state; + break; + case GL_SAMPLE_COVERAGE_INVERT_ARB: + if (ctx->Multisample.SampleCoverageInvert == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleCoverageInvert = state; + break; + + /* GL_IBM_rasterpos_clip */ + case GL_RASTER_POSITION_UNCLIPPED_IBM: + CHECK_EXTENSION(IBM_rasterpos_clip, cap); + if (ctx->Transform.RasterPositionUnclipped == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.RasterPositionUnclipped = state; + break; + + /* GL_NV_point_sprite */ + case GL_POINT_SPRITE_NV: + CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); + if (ctx->Point.PointSprite == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.PointSprite = state; + break; + +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + case GL_VERTEX_PROGRAM_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.Enabled = state; + break; + case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.PointSizeEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.PointSizeEnabled = state; + break; + case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.TwoSideEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.TwoSideEnabled = state; + break; +#endif +#if FEATURE_NV_vertex_program + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Attrib[map] = state; + } + break; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Attrib[map] = state; + } + break; +#endif /* FEATURE_NV_vertex_program */ + +#if FEATURE_NV_fragment_program + case GL_FRAGMENT_PROGRAM_NV: + CHECK_EXTENSION(NV_fragment_program, cap); + if (ctx->FragmentProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->FragmentProgram.Enabled = state; + break; +#endif /* FEATURE_NV_fragment_program */ + + /* GL_NV_texture_rectangle */ + case GL_TEXTURE_RECTANGLE_NV: + CHECK_EXTENSION(NV_texture_rectangle, cap); + if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { + return; + } + break; + + /* GL_EXT_stencil_two_side */ + case GL_STENCIL_TEST_TWO_SIDE_EXT: + CHECK_EXTENSION(EXT_stencil_two_side, cap); + if (ctx->Stencil.TestTwoSide == state) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.TestTwoSide = state; + if (state) { + ctx->Stencil._BackFace = 2; + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; + } else { + ctx->Stencil._BackFace = 1; + ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; + } + break; + +#if FEATURE_ARB_fragment_program + case GL_FRAGMENT_PROGRAM_ARB: + CHECK_EXTENSION(ARB_fragment_program, cap); + if (ctx->FragmentProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->FragmentProgram.Enabled = state; + break; +#endif /* FEATURE_ARB_fragment_program */ + + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_TEST_EXT: + CHECK_EXTENSION(EXT_depth_bounds_test, cap); + if (ctx->Depth.BoundsTest == state) + return; + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.BoundsTest = state; + break; + + case GL_DEPTH_CLAMP: + if (ctx->Transform.DepthClamp == state) + return; + CHECK_EXTENSION(ARB_depth_clamp, cap); + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.DepthClamp = state; + break; + +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader, cap); + if (ctx->ATIFragmentShader.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->ATIFragmentShader.Enabled = state; + break; +#endif + + /* GL_MESA_texture_array */ + case GL_TEXTURE_1D_ARRAY_EXT: + CHECK_EXTENSION(MESA_texture_array, cap); + if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { + return; + } + break; + + case GL_TEXTURE_2D_ARRAY_EXT: + CHECK_EXTENSION(MESA_texture_array, cap); + if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { + return; + } + break; + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + CHECK_EXTENSION(ARB_seamless_cube_map, cap); + ctx->Texture.CubeMapSeamless = state; + break; + +#if FEATURE_EXT_transform_feedback + case GL_RASTERIZER_DISCARD: + CHECK_EXTENSION(EXT_transform_feedback, cap); + if (ctx->TransformFeedback.RasterDiscard != state) { + ctx->TransformFeedback.RasterDiscard = state; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + } + break; +#endif + + /* GL 3.1 primitive restart. Note: this enum is different from + * GL_PRIMITIVE_RESTART_NV (which is client state). + */ + case GL_PRIMITIVE_RESTART: + if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { + goto invalid_enum_error; + } + if (ctx->Array.PrimitiveRestart != state) { + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Array.PrimitiveRestart = state; + } + break; + + default: + goto invalid_enum_error; + } + + if (ctx->Driver.Enable) { + ctx->Driver.Enable( ctx, cap, state ); + } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", + state ? "Enable" : "Disable", cap); +} + + +/** + * Enable GL capability. Called by glEnable() + * \param cap state to enable. + */ +void GLAPIENTRY +_mesa_Enable( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + _mesa_set_enable( ctx, cap, GL_TRUE ); +} + + +/** + * Disable GL capability. Called by glDisable() + * \param cap state to disable. + */ +void GLAPIENTRY +_mesa_Disable( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + _mesa_set_enable( ctx, cap, GL_FALSE ); +} + + + +/** + * Enable/disable an indexed state var. + */ +void +_mesa_set_enablei(struct gl_context *ctx, GLenum cap, GLuint index, GLboolean state) +{ + ASSERT(state == 0 || state == 1); + switch (cap) { + case GL_BLEND: + if (!ctx->Extensions.EXT_draw_buffers2) { + goto invalid_enum_error; + } + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", + state ? "glEnableIndexed" : "glDisableIndexed", index); + return; + } + if (((ctx->Color.BlendEnabled >> index) & 1) != state) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + if (state) + ctx->Color.BlendEnabled |= (1 << index); + else + ctx->Color.BlendEnabled &= ~(1 << index); + } + break; + default: + goto invalid_enum_error; + } + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", + state ? "glEnablei" : "glDisablei", + _mesa_lookup_enum_by_nr(cap)); +} + + +void GLAPIENTRY +_mesa_DisableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_FALSE); +} + + +void GLAPIENTRY +_mesa_EnableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_TRUE); +} + + +GLboolean GLAPIENTRY +_mesa_IsEnabledIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + switch (cap) { + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", + index); + return GL_FALSE; + } + return (ctx->Color.BlendEnabled >> index) & 1; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", + _mesa_lookup_enum_by_nr(cap)); + return GL_FALSE; + } +} + + + + +#undef CHECK_EXTENSION +#define CHECK_EXTENSION(EXTNAME) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + +#undef CHECK_EXTENSION2 +#define CHECK_EXTENSION2(EXT1, EXT2) \ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ + goto invalid_enum_error; \ + } + + +/** + * Helper function to determine whether a texture target is enabled. + */ +static GLboolean +is_texture_enabled(struct gl_context *ctx, GLbitfield bit) +{ + const struct gl_texture_unit *const texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; +} + + +/** + * Return simple enable/disable state. + * + * \param cap state variable to query. + * + * Returns the state of the specified capability from the current GL context. + * For the capabilities associated with extensions verifies that those + * extensions are effectively present before reporting. + */ +GLboolean GLAPIENTRY +_mesa_IsEnabled( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + switch (cap) { + case GL_ALPHA_TEST: + return ctx->Color.AlphaEnabled; + case GL_AUTO_NORMAL: + return ctx->Eval.AutoNormal; + case GL_BLEND: + return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; + case GL_COLOR_MATERIAL: + return ctx->Light.ColorMaterialEnabled; + case GL_CULL_FACE: + return ctx->Polygon.CullFlag; + case GL_DEPTH_TEST: + return ctx->Depth.Test; + case GL_DITHER: + return ctx->Color.DitherFlag; + case GL_FOG: + return ctx->Fog.Enabled; + case GL_LIGHTING: + return ctx->Light.Enabled; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + return ctx->Light.Light[cap-GL_LIGHT0].Enabled; + case GL_LINE_SMOOTH: + return ctx->Line.SmoothFlag; + case GL_LINE_STIPPLE: + return ctx->Line.StippleFlag; + case GL_INDEX_LOGIC_OP: + return ctx->Color.IndexLogicOpEnabled; + case GL_COLOR_LOGIC_OP: + return ctx->Color.ColorLogicOpEnabled; + case GL_MAP1_COLOR_4: + return ctx->Eval.Map1Color4; + case GL_MAP1_INDEX: + return ctx->Eval.Map1Index; + case GL_MAP1_NORMAL: + return ctx->Eval.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return ctx->Eval.Map1TextureCoord1; + case GL_MAP1_TEXTURE_COORD_2: + return ctx->Eval.Map1TextureCoord2; + case GL_MAP1_TEXTURE_COORD_3: + return ctx->Eval.Map1TextureCoord3; + case GL_MAP1_TEXTURE_COORD_4: + return ctx->Eval.Map1TextureCoord4; + case GL_MAP1_VERTEX_3: + return ctx->Eval.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return ctx->Eval.Map1Vertex4; + case GL_MAP2_COLOR_4: + return ctx->Eval.Map2Color4; + case GL_MAP2_INDEX: + return ctx->Eval.Map2Index; + case GL_MAP2_NORMAL: + return ctx->Eval.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return ctx->Eval.Map2TextureCoord1; + case GL_MAP2_TEXTURE_COORD_2: + return ctx->Eval.Map2TextureCoord2; + case GL_MAP2_TEXTURE_COORD_3: + return ctx->Eval.Map2TextureCoord3; + case GL_MAP2_TEXTURE_COORD_4: + return ctx->Eval.Map2TextureCoord4; + case GL_MAP2_VERTEX_3: + return ctx->Eval.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return ctx->Eval.Map2Vertex4; + case GL_NORMALIZE: + return ctx->Transform.Normalize; + case GL_POINT_SMOOTH: + return ctx->Point.SmoothFlag; + case GL_POLYGON_SMOOTH: + return ctx->Polygon.SmoothFlag; + case GL_POLYGON_STIPPLE: + return ctx->Polygon.StippleFlag; + case GL_POLYGON_OFFSET_POINT: + return ctx->Polygon.OffsetPoint; + case GL_POLYGON_OFFSET_LINE: + return ctx->Polygon.OffsetLine; + case GL_POLYGON_OFFSET_FILL: + /*case GL_POLYGON_OFFSET_EXT:*/ + return ctx->Polygon.OffsetFill; + case GL_RESCALE_NORMAL_EXT: + return ctx->Transform.RescaleNormals; + case GL_SCISSOR_TEST: + return ctx->Scissor.Enabled; + case GL_SHARED_TEXTURE_PALETTE_EXT: + return ctx->Texture.SharedPalette; + case GL_STENCIL_TEST: + return ctx->Stencil.Enabled; + case GL_TEXTURE_1D: + return is_texture_enabled(ctx, TEXTURE_1D_BIT); + case GL_TEXTURE_2D: + return is_texture_enabled(ctx, TEXTURE_2D_BIT); + case GL_TEXTURE_3D: + return is_texture_enabled(ctx, TEXTURE_3D_BIT); + case GL_TEXTURE_GEN_Q: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; + } + } + return GL_FALSE; + case GL_TEXTURE_GEN_R: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; + } + } + return GL_FALSE; + case GL_TEXTURE_GEN_S: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; + } + } + return GL_FALSE; + case GL_TEXTURE_GEN_T: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; + } + } + return GL_FALSE; +#if FEATURE_ES1 + case GL_TEXTURE_GEN_STR_OES: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS ? GL_TRUE : GL_FALSE; + } + } +#endif + + /* + * CLIENT STATE!!! + */ + case GL_VERTEX_ARRAY: + return (ctx->Array.ArrayObj->Vertex.Enabled != 0); + case GL_NORMAL_ARRAY: + return (ctx->Array.ArrayObj->Normal.Enabled != 0); + case GL_COLOR_ARRAY: + return (ctx->Array.ArrayObj->Color.Enabled != 0); + case GL_INDEX_ARRAY: + return (ctx->Array.ArrayObj->Index.Enabled != 0); + case GL_TEXTURE_COORD_ARRAY: + return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0); + case GL_EDGE_FLAG_ARRAY: + return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); + case GL_FOG_COORDINATE_ARRAY_EXT: + CHECK_EXTENSION(EXT_fog_coord); + return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); + case GL_SECONDARY_COLOR_ARRAY_EXT: + CHECK_EXTENSION(EXT_secondary_color); + return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_OES: + return (ctx->Array.ArrayObj->PointSize.Enabled != 0); +#endif + + /* GL_SGI_texture_color_table */ + case GL_TEXTURE_COLOR_TABLE_SGI: + CHECK_EXTENSION(SGI_texture_color_table); + return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + CHECK_EXTENSION(ARB_texture_cube_map); + return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); + + /* GL_EXT_secondary_color */ + case GL_COLOR_SUM_EXT: + CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); + return ctx->Fog.ColorSumEnabled; + + /* GL_ARB_multisample */ + case GL_MULTISAMPLE_ARB: + return ctx->Multisample.Enabled; + case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: + return ctx->Multisample.SampleAlphaToCoverage; + case GL_SAMPLE_ALPHA_TO_ONE_ARB: + return ctx->Multisample.SampleAlphaToOne; + case GL_SAMPLE_COVERAGE_ARB: + return ctx->Multisample.SampleCoverage; + case GL_SAMPLE_COVERAGE_INVERT_ARB: + return ctx->Multisample.SampleCoverageInvert; + + /* GL_IBM_rasterpos_clip */ + case GL_RASTER_POSITION_UNCLIPPED_IBM: + CHECK_EXTENSION(IBM_rasterpos_clip); + return ctx->Transform.RasterPositionUnclipped; + + /* GL_NV_point_sprite */ + case GL_POINT_SPRITE_NV: + CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) + return ctx->Point.PointSprite; + +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + case GL_VERTEX_PROGRAM_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.Enabled; + case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.PointSizeEnabled; + case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.TwoSideEnabled; +#endif +#if FEATURE_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: + CHECK_EXTENSION(NV_vertex_program); + { + GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; + ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); + return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); + } + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map1Attrib[map]; + } + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map2Attrib[map]; + } +#endif /* FEATURE_NV_vertex_program */ + +#if FEATURE_NV_fragment_program + case GL_FRAGMENT_PROGRAM_NV: + CHECK_EXTENSION(NV_fragment_program); + return ctx->FragmentProgram.Enabled; +#endif /* FEATURE_NV_fragment_program */ + + /* GL_NV_texture_rectangle */ + case GL_TEXTURE_RECTANGLE_NV: + CHECK_EXTENSION(NV_texture_rectangle); + return is_texture_enabled(ctx, TEXTURE_RECT_BIT); + + /* GL_EXT_stencil_two_side */ + case GL_STENCIL_TEST_TWO_SIDE_EXT: + CHECK_EXTENSION(EXT_stencil_two_side); + return ctx->Stencil.TestTwoSide; + +#if FEATURE_ARB_fragment_program + case GL_FRAGMENT_PROGRAM_ARB: + return ctx->FragmentProgram.Enabled; +#endif /* FEATURE_ARB_fragment_program */ + + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_TEST_EXT: + CHECK_EXTENSION(EXT_depth_bounds_test); + return ctx->Depth.BoundsTest; + + /* GL_ARB_depth_clamp */ + case GL_DEPTH_CLAMP: + CHECK_EXTENSION(ARB_depth_clamp); + return ctx->Transform.DepthClamp; + +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader); + return ctx->ATIFragmentShader.Enabled; +#endif /* FEATURE_ATI_fragment_shader */ + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + CHECK_EXTENSION(ARB_seamless_cube_map); + return ctx->Texture.CubeMapSeamless; + +#if FEATURE_EXT_transform_feedback + case GL_RASTERIZER_DISCARD: + CHECK_EXTENSION(EXT_transform_feedback); + return ctx->TransformFeedback.RasterDiscard; +#endif + + /* GL_NV_primitive_restart */ + case GL_PRIMITIVE_RESTART_NV: + if (!ctx->Extensions.NV_primitive_restart) { + goto invalid_enum_error; + } + return ctx->Array.PrimitiveRestart; + + /* GL 3.1 primitive restart */ + case GL_PRIMITIVE_RESTART: + if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { + goto invalid_enum_error; + } + return ctx->Array.PrimitiveRestart; + + default: + goto invalid_enum_error; + } + + return GL_FALSE; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); + return GL_FALSE; +} diff --git a/mesalib/src/mesa/main/enable.h b/mesalib/src/mesa/main/enable.h index 24e3181a8..685e11d47 100644 --- a/mesalib/src/mesa/main/enable.h +++ b/mesalib/src/mesa/main/enable.h @@ -1,69 +1,71 @@ -/** - * \file enable.h - * Enable/disable/query GL capabilities. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef ENABLE_H -#define ENABLE_H - - -#include "mtypes.h" - - -extern void -_mesa_set_enable( GLcontext* ctx, GLenum cap, GLboolean state ); - -extern void GLAPIENTRY -_mesa_Disable( GLenum cap ); - -extern void GLAPIENTRY -_mesa_Enable( GLenum cap ); - -extern GLboolean GLAPIENTRY -_mesa_IsEnabled( GLenum cap ); - -extern void -_mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state); - -extern void GLAPIENTRY -_mesa_DisableIndexed( GLenum cap, GLuint index ); - -extern void GLAPIENTRY -_mesa_EnableIndexed( GLenum cap, GLuint index ); - -extern GLboolean GLAPIENTRY -_mesa_IsEnabledIndexed( GLenum cap, GLuint index ); - -extern void GLAPIENTRY -_mesa_EnableClientState( GLenum cap ); - -extern void GLAPIENTRY -_mesa_DisableClientState( GLenum cap ); - - -#endif +/** + * \file enable.h + * Enable/disable/query GL capabilities. + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef ENABLE_H +#define ENABLE_H + + +#include "glheader.h" + +struct gl_context; + + +extern void +_mesa_set_enable( struct gl_context* ctx, GLenum cap, GLboolean state ); + +extern void GLAPIENTRY +_mesa_Disable( GLenum cap ); + +extern void GLAPIENTRY +_mesa_Enable( GLenum cap ); + +extern GLboolean GLAPIENTRY +_mesa_IsEnabled( GLenum cap ); + +extern void +_mesa_set_enablei(struct gl_context *ctx, GLenum cap, GLuint index, GLboolean state); + +extern void GLAPIENTRY +_mesa_DisableIndexed( GLenum cap, GLuint index ); + +extern void GLAPIENTRY +_mesa_EnableIndexed( GLenum cap, GLuint index ); + +extern GLboolean GLAPIENTRY +_mesa_IsEnabledIndexed( GLenum cap, GLuint index ); + +extern void GLAPIENTRY +_mesa_EnableClientState( GLenum cap ); + +extern void GLAPIENTRY +_mesa_DisableClientState( GLenum cap ); + + +#endif diff --git a/mesalib/src/mesa/main/enums.c b/mesalib/src/mesa/main/enums.c index bc18e1b11..680b3f187 100644 --- a/mesalib/src/mesa/main/enums.c +++ b/mesalib/src/mesa/main/enums.c @@ -1,5694 +1,6280 @@ -/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */ - -/* - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "main/glheader.h" -#include "main/mfeatures.h" -#include "main/enums.h" -#include "main/imports.h" - -typedef struct { - size_t offset; - int n; -} enum_elt; - -LONGSTRING static const char enum_string_table[] = - "GL_2D\0" - "GL_2_BYTES\0" - "GL_3D\0" - "GL_3D_COLOR\0" - "GL_3D_COLOR_TEXTURE\0" - "GL_3_BYTES\0" - "GL_4D_COLOR_TEXTURE\0" - "GL_4_BYTES\0" - "GL_ACCUM\0" - "GL_ACCUM_ALPHA_BITS\0" - "GL_ACCUM_BLUE_BITS\0" - "GL_ACCUM_BUFFER_BIT\0" - "GL_ACCUM_CLEAR_VALUE\0" - "GL_ACCUM_GREEN_BITS\0" - "GL_ACCUM_RED_BITS\0" - "GL_ACTIVE_ATTRIBUTES\0" - "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH\0" - "GL_ACTIVE_STENCIL_FACE_EXT\0" - "GL_ACTIVE_TEXTURE\0" - "GL_ACTIVE_TEXTURE_ARB\0" - "GL_ACTIVE_UNIFORMS\0" - "GL_ACTIVE_UNIFORM_MAX_LENGTH\0" - "GL_ACTIVE_VERTEX_UNITS_ARB\0" - "GL_ADD\0" - "GL_ADD_SIGNED\0" - "GL_ADD_SIGNED_ARB\0" - "GL_ADD_SIGNED_EXT\0" - "GL_ALIASED_LINE_WIDTH_RANGE\0" - "GL_ALIASED_POINT_SIZE_RANGE\0" - "GL_ALL_ATTRIB_BITS\0" - "GL_ALL_CLIENT_ATTRIB_BITS\0" - "GL_ALPHA\0" - "GL_ALPHA12\0" - "GL_ALPHA12_EXT\0" - "GL_ALPHA16\0" - "GL_ALPHA16_EXT\0" - "GL_ALPHA4\0" - "GL_ALPHA4_EXT\0" - "GL_ALPHA8\0" - "GL_ALPHA8_EXT\0" - "GL_ALPHA_BIAS\0" - "GL_ALPHA_BITS\0" - "GL_ALPHA_SCALE\0" - "GL_ALPHA_TEST\0" - "GL_ALPHA_TEST_FUNC\0" - "GL_ALPHA_TEST_REF\0" - "GL_ALREADY_SIGNALED\0" - "GL_ALWAYS\0" - "GL_AMBIENT\0" - "GL_AMBIENT_AND_DIFFUSE\0" - "GL_AND\0" - "GL_AND_INVERTED\0" - "GL_AND_REVERSE\0" - "GL_ARRAY_BUFFER\0" - "GL_ARRAY_BUFFER_BINDING\0" - "GL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_ATTACHED_SHADERS\0" - "GL_ATTRIB_ARRAY_POINTER_NV\0" - "GL_ATTRIB_ARRAY_SIZE_NV\0" - "GL_ATTRIB_ARRAY_STRIDE_NV\0" - "GL_ATTRIB_ARRAY_TYPE_NV\0" - "GL_ATTRIB_STACK_DEPTH\0" - "GL_AUTO_NORMAL\0" - "GL_AUX0\0" - "GL_AUX1\0" - "GL_AUX2\0" - "GL_AUX3\0" - "GL_AUX_BUFFERS\0" - "GL_BACK\0" - "GL_BACK_LEFT\0" - "GL_BACK_RIGHT\0" - "GL_BGR\0" - "GL_BGRA\0" - "GL_BGRA_EXT\0" - "GL_BITMAP\0" - "GL_BITMAP_TOKEN\0" - "GL_BLEND\0" - "GL_BLEND_COLOR\0" - "GL_BLEND_COLOR_EXT\0" - "GL_BLEND_DST\0" - "GL_BLEND_DST_ALPHA\0" - "GL_BLEND_DST_ALPHA_OES\0" - "GL_BLEND_DST_RGB\0" - "GL_BLEND_DST_RGB_OES\0" - "GL_BLEND_EQUATION\0" - "GL_BLEND_EQUATION_ALPHA\0" - "GL_BLEND_EQUATION_ALPHA_EXT\0" - "GL_BLEND_EQUATION_ALPHA_OES\0" - "GL_BLEND_EQUATION_EXT\0" - "GL_BLEND_EQUATION_OES\0" - "GL_BLEND_EQUATION_RGB\0" - "GL_BLEND_EQUATION_RGB_EXT\0" - "GL_BLEND_EQUATION_RGB_OES\0" - "GL_BLEND_SRC\0" - "GL_BLEND_SRC_ALPHA\0" - "GL_BLEND_SRC_ALPHA_OES\0" - "GL_BLEND_SRC_RGB\0" - "GL_BLEND_SRC_RGB_OES\0" - "GL_BLUE\0" - "GL_BLUE_BIAS\0" - "GL_BLUE_BITS\0" - "GL_BLUE_SCALE\0" - "GL_BOOL\0" - "GL_BOOL_ARB\0" - "GL_BOOL_VEC2\0" - "GL_BOOL_VEC2_ARB\0" - "GL_BOOL_VEC3\0" - "GL_BOOL_VEC3_ARB\0" - "GL_BOOL_VEC4\0" - "GL_BOOL_VEC4_ARB\0" - "GL_BUFFER_ACCESS\0" - "GL_BUFFER_ACCESS_ARB\0" - "GL_BUFFER_ACCESS_OES\0" - "GL_BUFFER_FLUSHING_UNMAP_APPLE\0" - "GL_BUFFER_MAPPED\0" - "GL_BUFFER_MAPPED_ARB\0" - "GL_BUFFER_MAPPED_OES\0" - "GL_BUFFER_MAP_POINTER\0" - "GL_BUFFER_MAP_POINTER_ARB\0" - "GL_BUFFER_MAP_POINTER_OES\0" - "GL_BUFFER_OBJECT_APPLE\0" - "GL_BUFFER_SERIALIZED_MODIFY_APPLE\0" - "GL_BUFFER_SIZE\0" - "GL_BUFFER_SIZE_ARB\0" - "GL_BUFFER_USAGE\0" - "GL_BUFFER_USAGE_ARB\0" - "GL_BUMP_ENVMAP_ATI\0" - "GL_BUMP_NUM_TEX_UNITS_ATI\0" - "GL_BUMP_ROT_MATRIX_ATI\0" - "GL_BUMP_ROT_MATRIX_SIZE_ATI\0" - "GL_BUMP_TARGET_ATI\0" - "GL_BUMP_TEX_UNITS_ATI\0" - "GL_BYTE\0" - "GL_C3F_V3F\0" - "GL_C4F_N3F_V3F\0" - "GL_C4UB_V2F\0" - "GL_C4UB_V3F\0" - "GL_CCW\0" - "GL_CLAMP\0" - "GL_CLAMP_TO_BORDER\0" - "GL_CLAMP_TO_BORDER_ARB\0" - "GL_CLAMP_TO_BORDER_SGIS\0" - "GL_CLAMP_TO_EDGE\0" - "GL_CLAMP_TO_EDGE_SGIS\0" - "GL_CLEAR\0" - "GL_CLIENT_ACTIVE_TEXTURE\0" - "GL_CLIENT_ACTIVE_TEXTURE_ARB\0" - "GL_CLIENT_ALL_ATTRIB_BITS\0" - "GL_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_CLIENT_PIXEL_STORE_BIT\0" - "GL_CLIENT_VERTEX_ARRAY_BIT\0" - "GL_CLIP_PLANE0\0" - "GL_CLIP_PLANE1\0" - "GL_CLIP_PLANE2\0" - "GL_CLIP_PLANE3\0" - "GL_CLIP_PLANE4\0" - "GL_CLIP_PLANE5\0" - "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0" - "GL_COEFF\0" - "GL_COLOR\0" - "GL_COLOR_ARRAY\0" - "GL_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_COLOR_ARRAY_POINTER\0" - "GL_COLOR_ARRAY_SIZE\0" - "GL_COLOR_ARRAY_STRIDE\0" - "GL_COLOR_ARRAY_TYPE\0" - "GL_COLOR_ATTACHMENT0\0" - "GL_COLOR_ATTACHMENT0_EXT\0" - "GL_COLOR_ATTACHMENT0_OES\0" - "GL_COLOR_ATTACHMENT1\0" - "GL_COLOR_ATTACHMENT10\0" - "GL_COLOR_ATTACHMENT10_EXT\0" - "GL_COLOR_ATTACHMENT11\0" - "GL_COLOR_ATTACHMENT11_EXT\0" - "GL_COLOR_ATTACHMENT12\0" - "GL_COLOR_ATTACHMENT12_EXT\0" - "GL_COLOR_ATTACHMENT13\0" - "GL_COLOR_ATTACHMENT13_EXT\0" - "GL_COLOR_ATTACHMENT14\0" - "GL_COLOR_ATTACHMENT14_EXT\0" - "GL_COLOR_ATTACHMENT15\0" - "GL_COLOR_ATTACHMENT15_EXT\0" - "GL_COLOR_ATTACHMENT1_EXT\0" - "GL_COLOR_ATTACHMENT2\0" - "GL_COLOR_ATTACHMENT2_EXT\0" - "GL_COLOR_ATTACHMENT3\0" - "GL_COLOR_ATTACHMENT3_EXT\0" - "GL_COLOR_ATTACHMENT4\0" - "GL_COLOR_ATTACHMENT4_EXT\0" - "GL_COLOR_ATTACHMENT5\0" - "GL_COLOR_ATTACHMENT5_EXT\0" - "GL_COLOR_ATTACHMENT6\0" - "GL_COLOR_ATTACHMENT6_EXT\0" - "GL_COLOR_ATTACHMENT7\0" - "GL_COLOR_ATTACHMENT7_EXT\0" - "GL_COLOR_ATTACHMENT8\0" - "GL_COLOR_ATTACHMENT8_EXT\0" - "GL_COLOR_ATTACHMENT9\0" - "GL_COLOR_ATTACHMENT9_EXT\0" - "GL_COLOR_BUFFER_BIT\0" - "GL_COLOR_CLEAR_VALUE\0" - "GL_COLOR_INDEX\0" - "GL_COLOR_INDEXES\0" - "GL_COLOR_LOGIC_OP\0" - "GL_COLOR_MATERIAL\0" - "GL_COLOR_MATERIAL_FACE\0" - "GL_COLOR_MATERIAL_PARAMETER\0" - "GL_COLOR_MATRIX\0" - "GL_COLOR_MATRIX_SGI\0" - "GL_COLOR_MATRIX_STACK_DEPTH\0" - "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_COLOR_SUM\0" - "GL_COLOR_SUM_ARB\0" - "GL_COLOR_TABLE\0" - "GL_COLOR_TABLE_ALPHA_SIZE\0" - "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0" - "GL_COLOR_TABLE_ALPHA_SIZE_SGI\0" - "GL_COLOR_TABLE_BIAS\0" - "GL_COLOR_TABLE_BIAS_SGI\0" - "GL_COLOR_TABLE_BLUE_SIZE\0" - "GL_COLOR_TABLE_BLUE_SIZE_EXT\0" - "GL_COLOR_TABLE_BLUE_SIZE_SGI\0" - "GL_COLOR_TABLE_FORMAT\0" - "GL_COLOR_TABLE_FORMAT_EXT\0" - "GL_COLOR_TABLE_FORMAT_SGI\0" - "GL_COLOR_TABLE_GREEN_SIZE\0" - "GL_COLOR_TABLE_GREEN_SIZE_EXT\0" - "GL_COLOR_TABLE_GREEN_SIZE_SGI\0" - "GL_COLOR_TABLE_INTENSITY_SIZE\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_SGI\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_SGI\0" - "GL_COLOR_TABLE_RED_SIZE\0" - "GL_COLOR_TABLE_RED_SIZE_EXT\0" - "GL_COLOR_TABLE_RED_SIZE_SGI\0" - "GL_COLOR_TABLE_SCALE\0" - "GL_COLOR_TABLE_SCALE_SGI\0" - "GL_COLOR_TABLE_WIDTH\0" - "GL_COLOR_TABLE_WIDTH_EXT\0" - "GL_COLOR_TABLE_WIDTH_SGI\0" - "GL_COLOR_WRITEMASK\0" - "GL_COMBINE\0" - "GL_COMBINE4\0" - "GL_COMBINE_ALPHA\0" - "GL_COMBINE_ALPHA_ARB\0" - "GL_COMBINE_ALPHA_EXT\0" - "GL_COMBINE_ARB\0" - "GL_COMBINE_EXT\0" - "GL_COMBINE_RGB\0" - "GL_COMBINE_RGB_ARB\0" - "GL_COMBINE_RGB_EXT\0" - "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT\0" - "GL_COMPARE_R_TO_TEXTURE\0" - "GL_COMPARE_R_TO_TEXTURE_ARB\0" - "GL_COMPILE\0" - "GL_COMPILE_AND_EXECUTE\0" - "GL_COMPILE_STATUS\0" - "GL_COMPRESSED_ALPHA\0" - "GL_COMPRESSED_ALPHA_ARB\0" - "GL_COMPRESSED_INTENSITY\0" - "GL_COMPRESSED_INTENSITY_ARB\0" - "GL_COMPRESSED_LUMINANCE\0" - "GL_COMPRESSED_LUMINANCE_ALPHA\0" - "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0" - "GL_COMPRESSED_LUMINANCE_ARB\0" - "GL_COMPRESSED_RGB\0" - "GL_COMPRESSED_RGBA\0" - "GL_COMPRESSED_RGBA_ARB\0" - "GL_COMPRESSED_RGBA_FXT1_3DFX\0" - "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0" - "GL_COMPRESSED_RGB_ARB\0" - "GL_COMPRESSED_RGB_FXT1_3DFX\0" - "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_SLUMINANCE\0" - "GL_COMPRESSED_SLUMINANCE_ALPHA\0" - "GL_COMPRESSED_SRGB\0" - "GL_COMPRESSED_SRGB_ALPHA\0" - "GL_COMPRESSED_TEXTURE_FORMATS\0" - "GL_CONDITION_SATISFIED\0" - "GL_CONSTANT\0" - "GL_CONSTANT_ALPHA\0" - "GL_CONSTANT_ALPHA_EXT\0" - "GL_CONSTANT_ARB\0" - "GL_CONSTANT_ATTENUATION\0" - "GL_CONSTANT_BORDER_HP\0" - "GL_CONSTANT_COLOR\0" - "GL_CONSTANT_COLOR_EXT\0" - "GL_CONSTANT_EXT\0" - "GL_CONVOLUTION_1D\0" - "GL_CONVOLUTION_2D\0" - "GL_CONVOLUTION_BORDER_COLOR\0" - "GL_CONVOLUTION_BORDER_COLOR_HP\0" - "GL_CONVOLUTION_BORDER_MODE\0" - "GL_CONVOLUTION_BORDER_MODE_EXT\0" - "GL_CONVOLUTION_FILTER_BIAS\0" - "GL_CONVOLUTION_FILTER_BIAS_EXT\0" - "GL_CONVOLUTION_FILTER_SCALE\0" - "GL_CONVOLUTION_FILTER_SCALE_EXT\0" - "GL_CONVOLUTION_FORMAT\0" - "GL_CONVOLUTION_FORMAT_EXT\0" - "GL_CONVOLUTION_HEIGHT\0" - "GL_CONVOLUTION_HEIGHT_EXT\0" - "GL_CONVOLUTION_WIDTH\0" - "GL_CONVOLUTION_WIDTH_EXT\0" - "GL_COORD_REPLACE\0" - "GL_COORD_REPLACE_ARB\0" - "GL_COORD_REPLACE_NV\0" - "GL_COORD_REPLACE_OES\0" - "GL_COPY\0" - "GL_COPY_INVERTED\0" - "GL_COPY_PIXEL_TOKEN\0" - "GL_COPY_READ_BUFFER\0" - "GL_COPY_WRITE_BUFFER\0" - "GL_CULL_FACE\0" - "GL_CULL_FACE_MODE\0" - "GL_CULL_VERTEX_EXT\0" - "GL_CULL_VERTEX_EYE_POSITION_EXT\0" - "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0" - "GL_CURRENT_ATTRIB_NV\0" - "GL_CURRENT_BIT\0" - "GL_CURRENT_COLOR\0" - "GL_CURRENT_FOG_COORD\0" - "GL_CURRENT_FOG_COORDINATE\0" - "GL_CURRENT_INDEX\0" - "GL_CURRENT_MATRIX_ARB\0" - "GL_CURRENT_MATRIX_INDEX_ARB\0" - "GL_CURRENT_MATRIX_NV\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0" - "GL_CURRENT_NORMAL\0" - "GL_CURRENT_PALETTE_MATRIX_ARB\0" - "GL_CURRENT_PALETTE_MATRIX_OES\0" - "GL_CURRENT_PROGRAM\0" - "GL_CURRENT_QUERY\0" - "GL_CURRENT_QUERY_ARB\0" - "GL_CURRENT_RASTER_COLOR\0" - "GL_CURRENT_RASTER_DISTANCE\0" - "GL_CURRENT_RASTER_INDEX\0" - "GL_CURRENT_RASTER_POSITION\0" - "GL_CURRENT_RASTER_POSITION_VALID\0" - "GL_CURRENT_RASTER_SECONDARY_COLOR\0" - "GL_CURRENT_RASTER_TEXTURE_COORDS\0" - "GL_CURRENT_SECONDARY_COLOR\0" - "GL_CURRENT_TEXTURE_COORDS\0" - "GL_CURRENT_VERTEX_ATTRIB\0" - "GL_CURRENT_VERTEX_ATTRIB_ARB\0" - "GL_CURRENT_WEIGHT_ARB\0" - "GL_CW\0" - "GL_DEBUG_ASSERT_MESA\0" - "GL_DEBUG_OBJECT_MESA\0" - "GL_DEBUG_PRINT_MESA\0" - "GL_DECAL\0" - "GL_DECR\0" - "GL_DECR_WRAP\0" - "GL_DECR_WRAP_EXT\0" - "GL_DELETE_STATUS\0" - "GL_DEPTH\0" - "GL_DEPTH24_STENCIL8\0" - "GL_DEPTH24_STENCIL8_EXT\0" - "GL_DEPTH24_STENCIL8_OES\0" - "GL_DEPTH_ATTACHMENT\0" - "GL_DEPTH_ATTACHMENT_EXT\0" - "GL_DEPTH_ATTACHMENT_OES\0" - "GL_DEPTH_BIAS\0" - "GL_DEPTH_BITS\0" - "GL_DEPTH_BOUNDS_EXT\0" - "GL_DEPTH_BOUNDS_TEST_EXT\0" - "GL_DEPTH_BUFFER_BIT\0" - "GL_DEPTH_CLAMP\0" - "GL_DEPTH_CLAMP_NV\0" - "GL_DEPTH_CLEAR_VALUE\0" - "GL_DEPTH_COMPONENT\0" - "GL_DEPTH_COMPONENT16\0" - "GL_DEPTH_COMPONENT16_ARB\0" - "GL_DEPTH_COMPONENT16_OES\0" - "GL_DEPTH_COMPONENT16_SGIX\0" - "GL_DEPTH_COMPONENT24\0" - "GL_DEPTH_COMPONENT24_ARB\0" - "GL_DEPTH_COMPONENT24_OES\0" - "GL_DEPTH_COMPONENT24_SGIX\0" - "GL_DEPTH_COMPONENT32\0" - "GL_DEPTH_COMPONENT32_ARB\0" - "GL_DEPTH_COMPONENT32_OES\0" - "GL_DEPTH_COMPONENT32_SGIX\0" - "GL_DEPTH_FUNC\0" - "GL_DEPTH_RANGE\0" - "GL_DEPTH_SCALE\0" - "GL_DEPTH_STENCIL\0" - "GL_DEPTH_STENCIL_ATTACHMENT\0" - "GL_DEPTH_STENCIL_EXT\0" - "GL_DEPTH_STENCIL_NV\0" - "GL_DEPTH_STENCIL_OES\0" - "GL_DEPTH_STENCIL_TO_BGRA_NV\0" - "GL_DEPTH_STENCIL_TO_RGBA_NV\0" - "GL_DEPTH_TEST\0" - "GL_DEPTH_TEXTURE_MODE\0" - "GL_DEPTH_TEXTURE_MODE_ARB\0" - "GL_DEPTH_WRITEMASK\0" - "GL_DIFFUSE\0" - "GL_DITHER\0" - "GL_DOMAIN\0" - "GL_DONT_CARE\0" - "GL_DOT3_RGB\0" - "GL_DOT3_RGBA\0" - "GL_DOT3_RGBA_ARB\0" - "GL_DOT3_RGBA_EXT\0" - "GL_DOT3_RGB_ARB\0" - "GL_DOT3_RGB_EXT\0" - "GL_DOUBLE\0" - "GL_DOUBLEBUFFER\0" - "GL_DRAW_BUFFER\0" - "GL_DRAW_BUFFER0\0" - "GL_DRAW_BUFFER0_ARB\0" - "GL_DRAW_BUFFER0_ATI\0" - "GL_DRAW_BUFFER1\0" - "GL_DRAW_BUFFER10\0" - "GL_DRAW_BUFFER10_ARB\0" - "GL_DRAW_BUFFER10_ATI\0" - "GL_DRAW_BUFFER11\0" - "GL_DRAW_BUFFER11_ARB\0" - "GL_DRAW_BUFFER11_ATI\0" - "GL_DRAW_BUFFER12\0" - "GL_DRAW_BUFFER12_ARB\0" - "GL_DRAW_BUFFER12_ATI\0" - "GL_DRAW_BUFFER13\0" - "GL_DRAW_BUFFER13_ARB\0" - "GL_DRAW_BUFFER13_ATI\0" - "GL_DRAW_BUFFER14\0" - "GL_DRAW_BUFFER14_ARB\0" - "GL_DRAW_BUFFER14_ATI\0" - "GL_DRAW_BUFFER15\0" - "GL_DRAW_BUFFER15_ARB\0" - "GL_DRAW_BUFFER15_ATI\0" - "GL_DRAW_BUFFER1_ARB\0" - "GL_DRAW_BUFFER1_ATI\0" - "GL_DRAW_BUFFER2\0" - "GL_DRAW_BUFFER2_ARB\0" - "GL_DRAW_BUFFER2_ATI\0" - "GL_DRAW_BUFFER3\0" - "GL_DRAW_BUFFER3_ARB\0" - "GL_DRAW_BUFFER3_ATI\0" - "GL_DRAW_BUFFER4\0" - "GL_DRAW_BUFFER4_ARB\0" - "GL_DRAW_BUFFER4_ATI\0" - "GL_DRAW_BUFFER5\0" - "GL_DRAW_BUFFER5_ARB\0" - "GL_DRAW_BUFFER5_ATI\0" - "GL_DRAW_BUFFER6\0" - "GL_DRAW_BUFFER6_ARB\0" - "GL_DRAW_BUFFER6_ATI\0" - "GL_DRAW_BUFFER7\0" - "GL_DRAW_BUFFER7_ARB\0" - "GL_DRAW_BUFFER7_ATI\0" - "GL_DRAW_BUFFER8\0" - "GL_DRAW_BUFFER8_ARB\0" - "GL_DRAW_BUFFER8_ATI\0" - "GL_DRAW_BUFFER9\0" - "GL_DRAW_BUFFER9_ARB\0" - "GL_DRAW_BUFFER9_ATI\0" - "GL_DRAW_FRAMEBUFFER\0" - "GL_DRAW_FRAMEBUFFER_BINDING\0" - "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0" - "GL_DRAW_FRAMEBUFFER_EXT\0" - "GL_DRAW_PIXEL_TOKEN\0" - "GL_DST_ALPHA\0" - "GL_DST_COLOR\0" - "GL_DU8DV8_ATI\0" - "GL_DUDV_ATI\0" - "GL_DYNAMIC_COPY\0" - "GL_DYNAMIC_COPY_ARB\0" - "GL_DYNAMIC_DRAW\0" - "GL_DYNAMIC_DRAW_ARB\0" - "GL_DYNAMIC_READ\0" - "GL_DYNAMIC_READ_ARB\0" - "GL_EDGE_FLAG\0" - "GL_EDGE_FLAG_ARRAY\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EDGE_FLAG_ARRAY_POINTER\0" - "GL_EDGE_FLAG_ARRAY_STRIDE\0" - "GL_ELEMENT_ARRAY_BUFFER\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EMISSION\0" - "GL_ENABLE_BIT\0" - "GL_EQUAL\0" - "GL_EQUIV\0" - "GL_EVAL_BIT\0" - "GL_EXP\0" - "GL_EXP2\0" - "GL_EXTENSIONS\0" - "GL_EYE_LINEAR\0" - "GL_EYE_PLANE\0" - "GL_EYE_PLANE_ABSOLUTE_NV\0" - "GL_EYE_RADIAL_NV\0" - "GL_FALSE\0" - "GL_FASTEST\0" - "GL_FEEDBACK\0" - "GL_FEEDBACK_BUFFER_POINTER\0" - "GL_FEEDBACK_BUFFER_SIZE\0" - "GL_FEEDBACK_BUFFER_TYPE\0" - "GL_FILL\0" - "GL_FIRST_VERTEX_CONVENTION\0" - "GL_FIRST_VERTEX_CONVENTION_EXT\0" - "GL_FIXED\0" - "GL_FIXED_OES\0" - "GL_FLAT\0" - "GL_FLOAT\0" - "GL_FLOAT_MAT2\0" - "GL_FLOAT_MAT2_ARB\0" - "GL_FLOAT_MAT2x3\0" - "GL_FLOAT_MAT2x4\0" - "GL_FLOAT_MAT3\0" - "GL_FLOAT_MAT3_ARB\0" - "GL_FLOAT_MAT3x2\0" - "GL_FLOAT_MAT3x4\0" - "GL_FLOAT_MAT4\0" - "GL_FLOAT_MAT4_ARB\0" - "GL_FLOAT_MAT4x2\0" - "GL_FLOAT_MAT4x3\0" - "GL_FLOAT_VEC2\0" - "GL_FLOAT_VEC2_ARB\0" - "GL_FLOAT_VEC3\0" - "GL_FLOAT_VEC3_ARB\0" - "GL_FLOAT_VEC4\0" - "GL_FLOAT_VEC4_ARB\0" - "GL_FOG\0" - "GL_FOG_BIT\0" - "GL_FOG_COLOR\0" - "GL_FOG_COORD\0" - "GL_FOG_COORDINATE\0" - "GL_FOG_COORDINATE_ARRAY\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0" - "GL_FOG_COORDINATE_ARRAY_POINTER\0" - "GL_FOG_COORDINATE_ARRAY_STRIDE\0" - "GL_FOG_COORDINATE_ARRAY_TYPE\0" - "GL_FOG_COORDINATE_SOURCE\0" - "GL_FOG_COORD_ARRAY\0" - "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORD_ARRAY_POINTER\0" - "GL_FOG_COORD_ARRAY_STRIDE\0" - "GL_FOG_COORD_ARRAY_TYPE\0" - "GL_FOG_COORD_SRC\0" - "GL_FOG_DENSITY\0" - "GL_FOG_DISTANCE_MODE_NV\0" - "GL_FOG_END\0" - "GL_FOG_HINT\0" - "GL_FOG_INDEX\0" - "GL_FOG_MODE\0" - "GL_FOG_OFFSET_SGIX\0" - "GL_FOG_OFFSET_VALUE_SGIX\0" - "GL_FOG_START\0" - "GL_FRAGMENT_DEPTH\0" - "GL_FRAGMENT_PROGRAM_ARB\0" - "GL_FRAGMENT_SHADER\0" - "GL_FRAGMENT_SHADER_ARB\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES\0" - "GL_FRAMEBUFFER\0" - "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING\0" - "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES\0" - "GL_FRAMEBUFFER_BINDING\0" - "GL_FRAMEBUFFER_BINDING_EXT\0" - "GL_FRAMEBUFFER_BINDING_OES\0" - "GL_FRAMEBUFFER_COMPLETE\0" - "GL_FRAMEBUFFER_COMPLETE_EXT\0" - "GL_FRAMEBUFFER_COMPLETE_OES\0" - "GL_FRAMEBUFFER_DEFAULT\0" - "GL_FRAMEBUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES\0" - "GL_FRAMEBUFFER_OES\0" - "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0" - "GL_FRAMEBUFFER_UNDEFINED\0" - "GL_FRAMEBUFFER_UNSUPPORTED\0" - "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0" - "GL_FRAMEBUFFER_UNSUPPORTED_OES\0" - "GL_FRONT\0" - "GL_FRONT_AND_BACK\0" - "GL_FRONT_FACE\0" - "GL_FRONT_LEFT\0" - "GL_FRONT_RIGHT\0" - "GL_FUNC_ADD\0" - "GL_FUNC_ADD_EXT\0" - "GL_FUNC_ADD_OES\0" - "GL_FUNC_REVERSE_SUBTRACT\0" - "GL_FUNC_REVERSE_SUBTRACT_EXT\0" - "GL_FUNC_REVERSE_SUBTRACT_OES\0" - "GL_FUNC_SUBTRACT\0" - "GL_FUNC_SUBTRACT_EXT\0" - "GL_FUNC_SUBTRACT_OES\0" - "GL_GENERATE_MIPMAP\0" - "GL_GENERATE_MIPMAP_HINT\0" - "GL_GENERATE_MIPMAP_HINT_SGIS\0" - "GL_GENERATE_MIPMAP_SGIS\0" - "GL_GEOMETRY_INPUT_TYPE_ARB\0" - "GL_GEOMETRY_OUTPUT_TYPE_ARB\0" - "GL_GEOMETRY_SHADER_ARB\0" - "GL_GEOMETRY_VERTICES_OUT_ARB\0" - "GL_GEQUAL\0" - "GL_GREATER\0" - "GL_GREEN\0" - "GL_GREEN_BIAS\0" - "GL_GREEN_BITS\0" - "GL_GREEN_SCALE\0" - "GL_HALF_FLOAT\0" - "GL_HALF_FLOAT_OES\0" - "GL_HIGH_FLOAT\0" - "GL_HIGH_INT\0" - "GL_HINT_BIT\0" - "GL_HISTOGRAM\0" - "GL_HISTOGRAM_ALPHA_SIZE\0" - "GL_HISTOGRAM_ALPHA_SIZE_EXT\0" - "GL_HISTOGRAM_BLUE_SIZE\0" - "GL_HISTOGRAM_BLUE_SIZE_EXT\0" - "GL_HISTOGRAM_EXT\0" - "GL_HISTOGRAM_FORMAT\0" - "GL_HISTOGRAM_FORMAT_EXT\0" - "GL_HISTOGRAM_GREEN_SIZE\0" - "GL_HISTOGRAM_GREEN_SIZE_EXT\0" - "GL_HISTOGRAM_LUMINANCE_SIZE\0" - "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0" - "GL_HISTOGRAM_RED_SIZE\0" - "GL_HISTOGRAM_RED_SIZE_EXT\0" - "GL_HISTOGRAM_SINK\0" - "GL_HISTOGRAM_SINK_EXT\0" - "GL_HISTOGRAM_WIDTH\0" - "GL_HISTOGRAM_WIDTH_EXT\0" - "GL_IDENTITY_NV\0" - "GL_IGNORE_BORDER_HP\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0" - "GL_INCR\0" - "GL_INCR_WRAP\0" - "GL_INCR_WRAP_EXT\0" - "GL_INDEX\0" - "GL_INDEX_ARRAY\0" - "GL_INDEX_ARRAY_BUFFER_BINDING\0" - "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_INDEX_ARRAY_POINTER\0" - "GL_INDEX_ARRAY_STRIDE\0" - "GL_INDEX_ARRAY_TYPE\0" - "GL_INDEX_BITS\0" - "GL_INDEX_CLEAR_VALUE\0" - "GL_INDEX_LOGIC_OP\0" - "GL_INDEX_MODE\0" - "GL_INDEX_OFFSET\0" - "GL_INDEX_SHIFT\0" - "GL_INDEX_WRITEMASK\0" - "GL_INFO_LOG_LENGTH\0" - "GL_INT\0" - "GL_INTENSITY\0" - "GL_INTENSITY12\0" - "GL_INTENSITY12_EXT\0" - "GL_INTENSITY16\0" - "GL_INTENSITY16_EXT\0" - "GL_INTENSITY4\0" - "GL_INTENSITY4_EXT\0" - "GL_INTENSITY8\0" - "GL_INTENSITY8_EXT\0" - "GL_INTENSITY_EXT\0" - "GL_INTERLEAVED_ATTRIBS_EXT\0" - "GL_INTERPOLATE\0" - "GL_INTERPOLATE_ARB\0" - "GL_INTERPOLATE_EXT\0" - "GL_INT_10_10_10_2_OES\0" - "GL_INT_VEC2\0" - "GL_INT_VEC2_ARB\0" - "GL_INT_VEC3\0" - "GL_INT_VEC3_ARB\0" - "GL_INT_VEC4\0" - "GL_INT_VEC4_ARB\0" - "GL_INVALID_ENUM\0" - "GL_INVALID_FRAMEBUFFER_OPERATION\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_OES\0" - "GL_INVALID_OPERATION\0" - "GL_INVALID_VALUE\0" - "GL_INVERSE_NV\0" - "GL_INVERSE_TRANSPOSE_NV\0" - "GL_INVERT\0" - "GL_KEEP\0" - "GL_LAST_VERTEX_CONVENTION\0" - "GL_LAST_VERTEX_CONVENTION_EXT\0" - "GL_LEFT\0" - "GL_LEQUAL\0" - "GL_LESS\0" - "GL_LIGHT0\0" - "GL_LIGHT1\0" - "GL_LIGHT2\0" - "GL_LIGHT3\0" - "GL_LIGHT4\0" - "GL_LIGHT5\0" - "GL_LIGHT6\0" - "GL_LIGHT7\0" - "GL_LIGHTING\0" - "GL_LIGHTING_BIT\0" - "GL_LIGHT_MODEL_AMBIENT\0" - "GL_LIGHT_MODEL_COLOR_CONTROL\0" - "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0" - "GL_LIGHT_MODEL_LOCAL_VIEWER\0" - "GL_LIGHT_MODEL_TWO_SIDE\0" - "GL_LINE\0" - "GL_LINEAR\0" - "GL_LINEAR_ATTENUATION\0" - "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0" - "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0" - "GL_LINEAR_MIPMAP_LINEAR\0" - "GL_LINEAR_MIPMAP_NEAREST\0" - "GL_LINES\0" - "GL_LINES_ADJACENCY_ARB\0" - "GL_LINE_BIT\0" - "GL_LINE_LOOP\0" - "GL_LINE_RESET_TOKEN\0" - "GL_LINE_SMOOTH\0" - "GL_LINE_SMOOTH_HINT\0" - "GL_LINE_STIPPLE\0" - "GL_LINE_STIPPLE_PATTERN\0" - "GL_LINE_STIPPLE_REPEAT\0" - "GL_LINE_STRIP\0" - "GL_LINE_STRIP_ADJACENCY_ARB\0" - "GL_LINE_TOKEN\0" - "GL_LINE_WIDTH\0" - "GL_LINE_WIDTH_GRANULARITY\0" - "GL_LINE_WIDTH_RANGE\0" - "GL_LINK_STATUS\0" - "GL_LIST_BASE\0" - "GL_LIST_BIT\0" - "GL_LIST_INDEX\0" - "GL_LIST_MODE\0" - "GL_LOAD\0" - "GL_LOGIC_OP\0" - "GL_LOGIC_OP_MODE\0" - "GL_LOWER_LEFT\0" - "GL_LOW_FLOAT\0" - "GL_LOW_INT\0" - "GL_LUMINANCE\0" - "GL_LUMINANCE12\0" - "GL_LUMINANCE12_ALPHA12\0" - "GL_LUMINANCE12_ALPHA12_EXT\0" - "GL_LUMINANCE12_ALPHA4\0" - "GL_LUMINANCE12_ALPHA4_EXT\0" - "GL_LUMINANCE12_EXT\0" - "GL_LUMINANCE16\0" - "GL_LUMINANCE16_ALPHA16\0" - "GL_LUMINANCE16_ALPHA16_EXT\0" - "GL_LUMINANCE16_EXT\0" - "GL_LUMINANCE4\0" - "GL_LUMINANCE4_ALPHA4\0" - "GL_LUMINANCE4_ALPHA4_EXT\0" - "GL_LUMINANCE4_EXT\0" - "GL_LUMINANCE6_ALPHA2\0" - "GL_LUMINANCE6_ALPHA2_EXT\0" - "GL_LUMINANCE8\0" - "GL_LUMINANCE8_ALPHA8\0" - "GL_LUMINANCE8_ALPHA8_EXT\0" - "GL_LUMINANCE8_EXT\0" - "GL_LUMINANCE_ALPHA\0" - "GL_MAP1_COLOR_4\0" - "GL_MAP1_GRID_DOMAIN\0" - "GL_MAP1_GRID_SEGMENTS\0" - "GL_MAP1_INDEX\0" - "GL_MAP1_NORMAL\0" - "GL_MAP1_TEXTURE_COORD_1\0" - "GL_MAP1_TEXTURE_COORD_2\0" - "GL_MAP1_TEXTURE_COORD_3\0" - "GL_MAP1_TEXTURE_COORD_4\0" - "GL_MAP1_VERTEX_3\0" - "GL_MAP1_VERTEX_4\0" - "GL_MAP1_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP2_COLOR_4\0" - "GL_MAP2_GRID_DOMAIN\0" - "GL_MAP2_GRID_SEGMENTS\0" - "GL_MAP2_INDEX\0" - "GL_MAP2_NORMAL\0" - "GL_MAP2_TEXTURE_COORD_1\0" - "GL_MAP2_TEXTURE_COORD_2\0" - "GL_MAP2_TEXTURE_COORD_3\0" - "GL_MAP2_TEXTURE_COORD_4\0" - "GL_MAP2_VERTEX_3\0" - "GL_MAP2_VERTEX_4\0" - "GL_MAP2_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP_COLOR\0" - "GL_MAP_FLUSH_EXPLICIT_BIT\0" - "GL_MAP_INVALIDATE_BUFFER_BIT\0" - "GL_MAP_INVALIDATE_RANGE_BIT\0" - "GL_MAP_READ_BIT\0" - "GL_MAP_STENCIL\0" - "GL_MAP_UNSYNCHRONIZED_BIT\0" - "GL_MAP_WRITE_BIT\0" - "GL_MATRIX0_ARB\0" - "GL_MATRIX0_NV\0" - "GL_MATRIX10_ARB\0" - "GL_MATRIX11_ARB\0" - "GL_MATRIX12_ARB\0" - "GL_MATRIX13_ARB\0" - "GL_MATRIX14_ARB\0" - "GL_MATRIX15_ARB\0" - "GL_MATRIX16_ARB\0" - "GL_MATRIX17_ARB\0" - "GL_MATRIX18_ARB\0" - "GL_MATRIX19_ARB\0" - "GL_MATRIX1_ARB\0" - "GL_MATRIX1_NV\0" - "GL_MATRIX20_ARB\0" - "GL_MATRIX21_ARB\0" - "GL_MATRIX22_ARB\0" - "GL_MATRIX23_ARB\0" - "GL_MATRIX24_ARB\0" - "GL_MATRIX25_ARB\0" - "GL_MATRIX26_ARB\0" - "GL_MATRIX27_ARB\0" - "GL_MATRIX28_ARB\0" - "GL_MATRIX29_ARB\0" - "GL_MATRIX2_ARB\0" - "GL_MATRIX2_NV\0" - "GL_MATRIX30_ARB\0" - "GL_MATRIX31_ARB\0" - "GL_MATRIX3_ARB\0" - "GL_MATRIX3_NV\0" - "GL_MATRIX4_ARB\0" - "GL_MATRIX4_NV\0" - "GL_MATRIX5_ARB\0" - "GL_MATRIX5_NV\0" - "GL_MATRIX6_ARB\0" - "GL_MATRIX6_NV\0" - "GL_MATRIX7_ARB\0" - "GL_MATRIX7_NV\0" - "GL_MATRIX8_ARB\0" - "GL_MATRIX9_ARB\0" - "GL_MATRIX_INDEX_ARRAY_ARB\0" - "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES\0" - "GL_MATRIX_INDEX_ARRAY_OES\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_OES\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_OES\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_OES\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_OES\0" - "GL_MATRIX_MODE\0" - "GL_MATRIX_PALETTE_ARB\0" - "GL_MATRIX_PALETTE_OES\0" - "GL_MAX\0" - "GL_MAX_3D_TEXTURE_SIZE\0" - "GL_MAX_3D_TEXTURE_SIZE_OES\0" - "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT\0" - "GL_MAX_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIPMAP_DEPTH_SGIX\0" - "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_MAX_CLIP_PLANES\0" - "GL_MAX_COLOR_ATTACHMENTS\0" - "GL_MAX_COLOR_ATTACHMENTS_EXT\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_CONVOLUTION_HEIGHT\0" - "GL_MAX_CONVOLUTION_HEIGHT_EXT\0" - "GL_MAX_CONVOLUTION_WIDTH\0" - "GL_MAX_CONVOLUTION_WIDTH_EXT\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES\0" - "GL_MAX_DRAW_BUFFERS\0" - "GL_MAX_DRAW_BUFFERS_ARB\0" - "GL_MAX_DRAW_BUFFERS_ATI\0" - "GL_MAX_ELEMENTS_INDICES\0" - "GL_MAX_ELEMENTS_VERTICES\0" - "GL_MAX_EVAL_ORDER\0" - "GL_MAX_EXT\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_FRAGMENT_UNIFORM_VECTORS\0" - "GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB\0" - "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB\0" - "GL_MAX_LIGHTS\0" - "GL_MAX_LIST_NESTING\0" - "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0" - "GL_MAX_MODELVIEW_STACK_DEPTH\0" - "GL_MAX_NAME_STACK_DEPTH\0" - "GL_MAX_PALETTE_MATRICES_ARB\0" - "GL_MAX_PALETTE_MATRICES_OES\0" - "GL_MAX_PIXEL_MAP_TABLE\0" - "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_CALL_DEPTH_NV\0" - "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0" - "GL_MAX_PROGRAM_IF_DEPTH_NV\0" - "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_LOOP_COUNT_NV\0" - "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0" - "GL_MAX_PROGRAM_MATRICES_ARB\0" - "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROJECTION_STACK_DEPTH\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0" - "GL_MAX_RENDERBUFFER_SIZE\0" - "GL_MAX_RENDERBUFFER_SIZE_EXT\0" - "GL_MAX_RENDERBUFFER_SIZE_OES\0" - "GL_MAX_SAMPLES\0" - "GL_MAX_SAMPLES_EXT\0" - "GL_MAX_SERVER_WAIT_TIMEOUT\0" - "GL_MAX_SHININESS_NV\0" - "GL_MAX_SPOT_EXPONENT_NV\0" - "GL_MAX_TEXTURE_COORDS\0" - "GL_MAX_TEXTURE_COORDS_ARB\0" - "GL_MAX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_TEXTURE_LOD_BIAS\0" - "GL_MAX_TEXTURE_LOD_BIAS_EXT\0" - "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_MAX_TEXTURE_SIZE\0" - "GL_MAX_TEXTURE_STACK_DEPTH\0" - "GL_MAX_TEXTURE_UNITS\0" - "GL_MAX_TEXTURE_UNITS_ARB\0" - "GL_MAX_TRACK_MATRICES_NV\0" - "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" - "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT\0" - "GL_MAX_VARYING_COMPONENTS\0" - "GL_MAX_VARYING_FLOATS\0" - "GL_MAX_VARYING_FLOATS_ARB\0" - "GL_MAX_VARYING_VECTORS\0" - "GL_MAX_VERTEX_ATTRIBS\0" - "GL_MAX_VERTEX_ATTRIBS_ARB\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_VECTORS\0" - "GL_MAX_VERTEX_UNITS_ARB\0" - "GL_MAX_VERTEX_UNITS_OES\0" - "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB\0" - "GL_MAX_VIEWPORT_DIMS\0" - "GL_MEDIUM_FLOAT\0" - "GL_MEDIUM_INT\0" - "GL_MIN\0" - "GL_MINMAX\0" - "GL_MINMAX_EXT\0" - "GL_MINMAX_FORMAT\0" - "GL_MINMAX_FORMAT_EXT\0" - "GL_MINMAX_SINK\0" - "GL_MINMAX_SINK_EXT\0" - "GL_MIN_EXT\0" - "GL_MIRRORED_REPEAT\0" - "GL_MIRRORED_REPEAT_ARB\0" - "GL_MIRRORED_REPEAT_IBM\0" - "GL_MIRROR_CLAMP_ATI\0" - "GL_MIRROR_CLAMP_EXT\0" - "GL_MIRROR_CLAMP_TO_BORDER_EXT\0" - "GL_MIRROR_CLAMP_TO_EDGE_ATI\0" - "GL_MIRROR_CLAMP_TO_EDGE_EXT\0" - "GL_MODELVIEW\0" - "GL_MODELVIEW0_ARB\0" - "GL_MODELVIEW10_ARB\0" - "GL_MODELVIEW11_ARB\0" - "GL_MODELVIEW12_ARB\0" - "GL_MODELVIEW13_ARB\0" - "GL_MODELVIEW14_ARB\0" - "GL_MODELVIEW15_ARB\0" - "GL_MODELVIEW16_ARB\0" - "GL_MODELVIEW17_ARB\0" - "GL_MODELVIEW18_ARB\0" - "GL_MODELVIEW19_ARB\0" - "GL_MODELVIEW1_ARB\0" - "GL_MODELVIEW20_ARB\0" - "GL_MODELVIEW21_ARB\0" - "GL_MODELVIEW22_ARB\0" - "GL_MODELVIEW23_ARB\0" - "GL_MODELVIEW24_ARB\0" - "GL_MODELVIEW25_ARB\0" - "GL_MODELVIEW26_ARB\0" - "GL_MODELVIEW27_ARB\0" - "GL_MODELVIEW28_ARB\0" - "GL_MODELVIEW29_ARB\0" - "GL_MODELVIEW2_ARB\0" - "GL_MODELVIEW30_ARB\0" - "GL_MODELVIEW31_ARB\0" - "GL_MODELVIEW3_ARB\0" - "GL_MODELVIEW4_ARB\0" - "GL_MODELVIEW5_ARB\0" - "GL_MODELVIEW6_ARB\0" - "GL_MODELVIEW7_ARB\0" - "GL_MODELVIEW8_ARB\0" - "GL_MODELVIEW9_ARB\0" - "GL_MODELVIEW_MATRIX\0" - "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_MODELVIEW_PROJECTION_NV\0" - "GL_MODELVIEW_STACK_DEPTH\0" - "GL_MODULATE\0" - "GL_MODULATE_ADD_ATI\0" - "GL_MODULATE_SIGNED_ADD_ATI\0" - "GL_MODULATE_SUBTRACT_ATI\0" - "GL_MULT\0" - "GL_MULTISAMPLE\0" - "GL_MULTISAMPLE_3DFX\0" - "GL_MULTISAMPLE_ARB\0" - "GL_MULTISAMPLE_BIT\0" - "GL_MULTISAMPLE_BIT_3DFX\0" - "GL_MULTISAMPLE_BIT_ARB\0" - "GL_MULTISAMPLE_FILTER_HINT_NV\0" - "GL_N3F_V3F\0" - "GL_NAME_STACK_DEPTH\0" - "GL_NAND\0" - "GL_NEAREST\0" - "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0" - "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0" - "GL_NEAREST_MIPMAP_LINEAR\0" - "GL_NEAREST_MIPMAP_NEAREST\0" - "GL_NEVER\0" - "GL_NICEST\0" - "GL_NONE\0" - "GL_NONE_OES\0" - "GL_NOOP\0" - "GL_NOR\0" - "GL_NORMALIZE\0" - "GL_NORMAL_ARRAY\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_NORMAL_ARRAY_POINTER\0" - "GL_NORMAL_ARRAY_STRIDE\0" - "GL_NORMAL_ARRAY_TYPE\0" - "GL_NORMAL_MAP\0" - "GL_NORMAL_MAP_ARB\0" - "GL_NORMAL_MAP_NV\0" - "GL_NORMAL_MAP_OES\0" - "GL_NOTEQUAL\0" - "GL_NO_ERROR\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" - "GL_NUM_PROGRAM_BINARY_FORMATS_OES\0" - "GL_NUM_SHADER_BINARY_FORMATS\0" - "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" - "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0" - "GL_OBJECT_ATTACHED_OBJECTS_ARB\0" - "GL_OBJECT_COMPILE_STATUS_ARB\0" - "GL_OBJECT_DELETE_STATUS_ARB\0" - "GL_OBJECT_INFO_LOG_LENGTH_ARB\0" - "GL_OBJECT_LINEAR\0" - "GL_OBJECT_LINK_STATUS_ARB\0" - "GL_OBJECT_PLANE\0" - "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0" - "GL_OBJECT_SUBTYPE_ARB\0" - "GL_OBJECT_TYPE\0" - "GL_OBJECT_TYPE_ARB\0" - "GL_OBJECT_VALIDATE_STATUS_ARB\0" - "GL_OCCLUSION_TEST_HP\0" - "GL_OCCLUSION_TEST_RESULT_HP\0" - "GL_ONE\0" - "GL_ONE_MINUS_CONSTANT_ALPHA\0" - "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0" - "GL_ONE_MINUS_CONSTANT_COLOR\0" - "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0" - "GL_ONE_MINUS_DST_ALPHA\0" - "GL_ONE_MINUS_DST_COLOR\0" - "GL_ONE_MINUS_SRC_ALPHA\0" - "GL_ONE_MINUS_SRC_COLOR\0" - "GL_OPERAND0_ALPHA\0" - "GL_OPERAND0_ALPHA_ARB\0" - "GL_OPERAND0_ALPHA_EXT\0" - "GL_OPERAND0_RGB\0" - "GL_OPERAND0_RGB_ARB\0" - "GL_OPERAND0_RGB_EXT\0" - "GL_OPERAND1_ALPHA\0" - "GL_OPERAND1_ALPHA_ARB\0" - "GL_OPERAND1_ALPHA_EXT\0" - "GL_OPERAND1_RGB\0" - "GL_OPERAND1_RGB_ARB\0" - "GL_OPERAND1_RGB_EXT\0" - "GL_OPERAND2_ALPHA\0" - "GL_OPERAND2_ALPHA_ARB\0" - "GL_OPERAND2_ALPHA_EXT\0" - "GL_OPERAND2_RGB\0" - "GL_OPERAND2_RGB_ARB\0" - "GL_OPERAND2_RGB_EXT\0" - "GL_OPERAND3_ALPHA_NV\0" - "GL_OPERAND3_RGB_NV\0" - "GL_OR\0" - "GL_ORDER\0" - "GL_OR_INVERTED\0" - "GL_OR_REVERSE\0" - "GL_OUT_OF_MEMORY\0" - "GL_PACK_ALIGNMENT\0" - "GL_PACK_IMAGE_HEIGHT\0" - "GL_PACK_INVERT_MESA\0" - "GL_PACK_LSB_FIRST\0" - "GL_PACK_ROW_LENGTH\0" - "GL_PACK_SKIP_IMAGES\0" - "GL_PACK_SKIP_PIXELS\0" - "GL_PACK_SKIP_ROWS\0" - "GL_PACK_SWAP_BYTES\0" - "GL_PALETTE4_R5_G6_B5_OES\0" - "GL_PALETTE4_RGB5_A1_OES\0" - "GL_PALETTE4_RGB8_OES\0" - "GL_PALETTE4_RGBA4_OES\0" - "GL_PALETTE4_RGBA8_OES\0" - "GL_PALETTE8_R5_G6_B5_OES\0" - "GL_PALETTE8_RGB5_A1_OES\0" - "GL_PALETTE8_RGB8_OES\0" - "GL_PALETTE8_RGBA4_OES\0" - "GL_PALETTE8_RGBA8_OES\0" - "GL_PASS_THROUGH_TOKEN\0" - "GL_PERSPECTIVE_CORRECTION_HINT\0" - "GL_PIXEL_MAP_A_TO_A\0" - "GL_PIXEL_MAP_A_TO_A_SIZE\0" - "GL_PIXEL_MAP_B_TO_B\0" - "GL_PIXEL_MAP_B_TO_B_SIZE\0" - "GL_PIXEL_MAP_G_TO_G\0" - "GL_PIXEL_MAP_G_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_A\0" - "GL_PIXEL_MAP_I_TO_A_SIZE\0" - "GL_PIXEL_MAP_I_TO_B\0" - "GL_PIXEL_MAP_I_TO_B_SIZE\0" - "GL_PIXEL_MAP_I_TO_G\0" - "GL_PIXEL_MAP_I_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_I\0" - "GL_PIXEL_MAP_I_TO_I_SIZE\0" - "GL_PIXEL_MAP_I_TO_R\0" - "GL_PIXEL_MAP_I_TO_R_SIZE\0" - "GL_PIXEL_MAP_R_TO_R\0" - "GL_PIXEL_MAP_R_TO_R_SIZE\0" - "GL_PIXEL_MAP_S_TO_S\0" - "GL_PIXEL_MAP_S_TO_S_SIZE\0" - "GL_PIXEL_MODE_BIT\0" - "GL_PIXEL_PACK_BUFFER\0" - "GL_PIXEL_PACK_BUFFER_BINDING\0" - "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_PACK_BUFFER_EXT\0" - "GL_PIXEL_UNPACK_BUFFER\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_UNPACK_BUFFER_EXT\0" - "GL_POINT\0" - "GL_POINTS\0" - "GL_POINT_BIT\0" - "GL_POINT_DISTANCE_ATTENUATION\0" - "GL_POINT_DISTANCE_ATTENUATION_ARB\0" - "GL_POINT_DISTANCE_ATTENUATION_EXT\0" - "GL_POINT_DISTANCE_ATTENUATION_SGIS\0" - "GL_POINT_FADE_THRESHOLD_SIZE\0" - "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0" - "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0" - "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0" - "GL_POINT_SIZE\0" - "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES\0" - "GL_POINT_SIZE_ARRAY_OES\0" - "GL_POINT_SIZE_ARRAY_POINTER_OES\0" - "GL_POINT_SIZE_ARRAY_STRIDE_OES\0" - "GL_POINT_SIZE_ARRAY_TYPE_OES\0" - "GL_POINT_SIZE_GRANULARITY\0" - "GL_POINT_SIZE_MAX\0" - "GL_POINT_SIZE_MAX_ARB\0" - "GL_POINT_SIZE_MAX_EXT\0" - "GL_POINT_SIZE_MAX_SGIS\0" - "GL_POINT_SIZE_MIN\0" - "GL_POINT_SIZE_MIN_ARB\0" - "GL_POINT_SIZE_MIN_EXT\0" - "GL_POINT_SIZE_MIN_SGIS\0" - "GL_POINT_SIZE_RANGE\0" - "GL_POINT_SMOOTH\0" - "GL_POINT_SMOOTH_HINT\0" - "GL_POINT_SPRITE\0" - "GL_POINT_SPRITE_ARB\0" - "GL_POINT_SPRITE_COORD_ORIGIN\0" - "GL_POINT_SPRITE_NV\0" - "GL_POINT_SPRITE_OES\0" - "GL_POINT_SPRITE_R_MODE_NV\0" - "GL_POINT_TOKEN\0" - "GL_POLYGON\0" - "GL_POLYGON_BIT\0" - "GL_POLYGON_MODE\0" - "GL_POLYGON_OFFSET_BIAS\0" - "GL_POLYGON_OFFSET_FACTOR\0" - "GL_POLYGON_OFFSET_FILL\0" - "GL_POLYGON_OFFSET_LINE\0" - "GL_POLYGON_OFFSET_POINT\0" - "GL_POLYGON_OFFSET_UNITS\0" - "GL_POLYGON_SMOOTH\0" - "GL_POLYGON_SMOOTH_HINT\0" - "GL_POLYGON_STIPPLE\0" - "GL_POLYGON_STIPPLE_BIT\0" - "GL_POLYGON_TOKEN\0" - "GL_POSITION\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_RED_BIAS\0" - "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_RED_SCALE\0" - "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0" - "GL_POST_CONVOLUTION_BLUE_BIAS\0" - "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0" - "GL_POST_CONVOLUTION_BLUE_SCALE\0" - "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0" - "GL_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_POST_CONVOLUTION_GREEN_BIAS\0" - "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0" - "GL_POST_CONVOLUTION_GREEN_SCALE\0" - "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0" - "GL_POST_CONVOLUTION_RED_BIAS\0" - "GL_POST_CONVOLUTION_RED_BIAS_EXT\0" - "GL_POST_CONVOLUTION_RED_SCALE\0" - "GL_POST_CONVOLUTION_RED_SCALE_EXT\0" - "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0" - "GL_PREVIOUS\0" - "GL_PREVIOUS_ARB\0" - "GL_PREVIOUS_EXT\0" - "GL_PRIMARY_COLOR\0" - "GL_PRIMARY_COLOR_ARB\0" - "GL_PRIMARY_COLOR_EXT\0" - "GL_PRIMITIVES_GENERATED_EXT\0" - "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_ATTRIBS_ARB\0" - "GL_PROGRAM_BINARY_FORMATS_OES\0" - "GL_PROGRAM_BINARY_LENGTH_OES\0" - "GL_PROGRAM_BINDING_ARB\0" - "GL_PROGRAM_ERROR_POSITION_ARB\0" - "GL_PROGRAM_ERROR_POSITION_NV\0" - "GL_PROGRAM_ERROR_STRING_ARB\0" - "GL_PROGRAM_FORMAT_ARB\0" - "GL_PROGRAM_FORMAT_ASCII_ARB\0" - "GL_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_LENGTH_ARB\0" - "GL_PROGRAM_LENGTH_NV\0" - "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_OBJECT_ARB\0" - "GL_PROGRAM_PARAMETERS_ARB\0" - "GL_PROGRAM_PARAMETER_NV\0" - "GL_PROGRAM_POINT_SIZE_ARB\0" - "GL_PROGRAM_RESIDENT_NV\0" - "GL_PROGRAM_STRING_ARB\0" - "GL_PROGRAM_STRING_NV\0" - "GL_PROGRAM_TARGET_NV\0" - "GL_PROGRAM_TEMPORARIES_ARB\0" - "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0" - "GL_PROJECTION\0" - "GL_PROJECTION_MATRIX\0" - "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_PROJECTION_STACK_DEPTH\0" - "GL_PROVOKING_VERTEX\0" - "GL_PROVOKING_VERTEX_EXT\0" - "GL_PROXY_COLOR_TABLE\0" - "GL_PROXY_HISTOGRAM\0" - "GL_PROXY_HISTOGRAM_EXT\0" - "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_PROXY_TEXTURE_1D\0" - "GL_PROXY_TEXTURE_1D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_1D_EXT\0" - "GL_PROXY_TEXTURE_2D\0" - "GL_PROXY_TEXTURE_2D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_2D_EXT\0" - "GL_PROXY_TEXTURE_3D\0" - "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0" - "GL_PROXY_TEXTURE_CUBE_MAP\0" - "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE_NV\0" - "GL_PURGEABLE_APPLE\0" - "GL_Q\0" - "GL_QUADRATIC_ATTENUATION\0" - "GL_QUADS\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0" - "GL_QUAD_MESH_SUN\0" - "GL_QUAD_STRIP\0" - "GL_QUERY_BY_REGION_NO_WAIT_NV\0" - "GL_QUERY_BY_REGION_WAIT_NV\0" - "GL_QUERY_COUNTER_BITS\0" - "GL_QUERY_COUNTER_BITS_ARB\0" - "GL_QUERY_NO_WAIT_NV\0" - "GL_QUERY_RESULT\0" - "GL_QUERY_RESULT_ARB\0" - "GL_QUERY_RESULT_AVAILABLE\0" - "GL_QUERY_RESULT_AVAILABLE_ARB\0" - "GL_QUERY_WAIT_NV\0" - "GL_R\0" - "GL_R3_G3_B2\0" - "GL_RASTERIZER_DISCARD_EXT\0" - "GL_RASTER_POSITION_UNCLIPPED_IBM\0" - "GL_READ_BUFFER\0" - "GL_READ_FRAMEBUFFER\0" - "GL_READ_FRAMEBUFFER_BINDING\0" - "GL_READ_FRAMEBUFFER_BINDING_EXT\0" - "GL_READ_FRAMEBUFFER_EXT\0" - "GL_READ_ONLY\0" - "GL_READ_ONLY_ARB\0" - "GL_READ_WRITE\0" - "GL_READ_WRITE_ARB\0" - "GL_RED\0" - "GL_REDUCE\0" - "GL_REDUCE_EXT\0" - "GL_RED_BIAS\0" - "GL_RED_BITS\0" - "GL_RED_SCALE\0" - "GL_REFLECTION_MAP\0" - "GL_REFLECTION_MAP_ARB\0" - "GL_REFLECTION_MAP_NV\0" - "GL_REFLECTION_MAP_OES\0" - "GL_RELEASED_APPLE\0" - "GL_RENDER\0" - "GL_RENDERBUFFER\0" - "GL_RENDERBUFFER_ALPHA_SIZE\0" - "GL_RENDERBUFFER_ALPHA_SIZE_OES\0" - "GL_RENDERBUFFER_BINDING\0" - "GL_RENDERBUFFER_BINDING_EXT\0" - "GL_RENDERBUFFER_BINDING_OES\0" - "GL_RENDERBUFFER_BLUE_SIZE\0" - "GL_RENDERBUFFER_BLUE_SIZE_OES\0" - "GL_RENDERBUFFER_DEPTH_SIZE\0" - "GL_RENDERBUFFER_DEPTH_SIZE_OES\0" - "GL_RENDERBUFFER_EXT\0" - "GL_RENDERBUFFER_GREEN_SIZE\0" - "GL_RENDERBUFFER_GREEN_SIZE_OES\0" - "GL_RENDERBUFFER_HEIGHT\0" - "GL_RENDERBUFFER_HEIGHT_EXT\0" - "GL_RENDERBUFFER_HEIGHT_OES\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_OES\0" - "GL_RENDERBUFFER_OES\0" - "GL_RENDERBUFFER_RED_SIZE\0" - "GL_RENDERBUFFER_RED_SIZE_OES\0" - "GL_RENDERBUFFER_SAMPLES\0" - "GL_RENDERBUFFER_SAMPLES_EXT\0" - "GL_RENDERBUFFER_STENCIL_SIZE\0" - "GL_RENDERBUFFER_STENCIL_SIZE_OES\0" - "GL_RENDERBUFFER_WIDTH\0" - "GL_RENDERBUFFER_WIDTH_EXT\0" - "GL_RENDERBUFFER_WIDTH_OES\0" - "GL_RENDERER\0" - "GL_RENDER_MODE\0" - "GL_REPEAT\0" - "GL_REPLACE\0" - "GL_REPLACE_EXT\0" - "GL_REPLICATE_BORDER_HP\0" - "GL_RESCALE_NORMAL\0" - "GL_RESCALE_NORMAL_EXT\0" - "GL_RETAINED_APPLE\0" - "GL_RETURN\0" - "GL_RGB\0" - "GL_RGB10\0" - "GL_RGB10_A2\0" - "GL_RGB10_A2_EXT\0" - "GL_RGB10_EXT\0" - "GL_RGB12\0" - "GL_RGB12_EXT\0" - "GL_RGB16\0" - "GL_RGB16_EXT\0" - "GL_RGB2_EXT\0" - "GL_RGB4\0" - "GL_RGB4_EXT\0" - "GL_RGB4_S3TC\0" - "GL_RGB5\0" - "GL_RGB565\0" - "GL_RGB565_OES\0" - "GL_RGB5_A1\0" - "GL_RGB5_A1_EXT\0" - "GL_RGB5_A1_OES\0" - "GL_RGB5_EXT\0" - "GL_RGB8\0" - "GL_RGB8_EXT\0" - "GL_RGB8_OES\0" - "GL_RGBA\0" - "GL_RGBA12\0" - "GL_RGBA12_EXT\0" - "GL_RGBA16\0" - "GL_RGBA16_EXT\0" - "GL_RGBA2\0" - "GL_RGBA2_EXT\0" - "GL_RGBA4\0" - "GL_RGBA4_DXT5_S3TC\0" - "GL_RGBA4_EXT\0" - "GL_RGBA4_OES\0" - "GL_RGBA4_S3TC\0" - "GL_RGBA8\0" - "GL_RGBA8_EXT\0" - "GL_RGBA8_OES\0" - "GL_RGBA8_SNORM\0" - "GL_RGBA_DXT5_S3TC\0" - "GL_RGBA_MODE\0" - "GL_RGBA_S3TC\0" - "GL_RGBA_SNORM\0" - "GL_RGB_S3TC\0" - "GL_RGB_SCALE\0" - "GL_RGB_SCALE_ARB\0" - "GL_RGB_SCALE_EXT\0" - "GL_RIGHT\0" - "GL_S\0" - "GL_SAMPLER_1D\0" - "GL_SAMPLER_1D_SHADOW\0" - "GL_SAMPLER_2D\0" - "GL_SAMPLER_2D_SHADOW\0" - "GL_SAMPLER_3D\0" - "GL_SAMPLER_3D_OES\0" - "GL_SAMPLER_CUBE\0" - "GL_SAMPLES\0" - "GL_SAMPLES_3DFX\0" - "GL_SAMPLES_ARB\0" - "GL_SAMPLES_PASSED\0" - "GL_SAMPLES_PASSED_ARB\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0" - "GL_SAMPLE_ALPHA_TO_ONE\0" - "GL_SAMPLE_ALPHA_TO_ONE_ARB\0" - "GL_SAMPLE_BUFFERS\0" - "GL_SAMPLE_BUFFERS_3DFX\0" - "GL_SAMPLE_BUFFERS_ARB\0" - "GL_SAMPLE_COVERAGE\0" - "GL_SAMPLE_COVERAGE_ARB\0" - "GL_SAMPLE_COVERAGE_INVERT\0" - "GL_SAMPLE_COVERAGE_INVERT_ARB\0" - "GL_SAMPLE_COVERAGE_VALUE\0" - "GL_SAMPLE_COVERAGE_VALUE_ARB\0" - "GL_SCISSOR_BIT\0" - "GL_SCISSOR_BOX\0" - "GL_SCISSOR_TEST\0" - "GL_SECONDARY_COLOR_ARRAY\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_SECONDARY_COLOR_ARRAY_POINTER\0" - "GL_SECONDARY_COLOR_ARRAY_SIZE\0" - "GL_SECONDARY_COLOR_ARRAY_STRIDE\0" - "GL_SECONDARY_COLOR_ARRAY_TYPE\0" - "GL_SELECT\0" - "GL_SELECTION_BUFFER_POINTER\0" - "GL_SELECTION_BUFFER_SIZE\0" - "GL_SEPARABLE_2D\0" - "GL_SEPARATE_ATTRIBS_EXT\0" - "GL_SEPARATE_SPECULAR_COLOR\0" - "GL_SEPARATE_SPECULAR_COLOR_EXT\0" - "GL_SET\0" - "GL_SHADER_BINARY_FORMATS\0" - "GL_SHADER_COMPILER\0" - "GL_SHADER_OBJECT_ARB\0" - "GL_SHADER_SOURCE_LENGTH\0" - "GL_SHADER_TYPE\0" - "GL_SHADE_MODEL\0" - "GL_SHADING_LANGUAGE_VERSION\0" - "GL_SHADOW_AMBIENT_SGIX\0" - "GL_SHARED_TEXTURE_PALETTE_EXT\0" - "GL_SHININESS\0" - "GL_SHORT\0" - "GL_SIGNALED\0" - "GL_SIGNED_NORMALIZED\0" - "GL_SINGLE_COLOR\0" - "GL_SINGLE_COLOR_EXT\0" - "GL_SLICE_ACCUM_SUN\0" - "GL_SLUMINANCE\0" - "GL_SLUMINANCE8\0" - "GL_SLUMINANCE8_ALPHA8\0" - "GL_SLUMINANCE_ALPHA\0" - "GL_SMOOTH\0" - "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0" - "GL_SMOOTH_LINE_WIDTH_RANGE\0" - "GL_SMOOTH_POINT_SIZE_GRANULARITY\0" - "GL_SMOOTH_POINT_SIZE_RANGE\0" - "GL_SOURCE0_ALPHA\0" - "GL_SOURCE0_ALPHA_ARB\0" - "GL_SOURCE0_ALPHA_EXT\0" - "GL_SOURCE0_RGB\0" - "GL_SOURCE0_RGB_ARB\0" - "GL_SOURCE0_RGB_EXT\0" - "GL_SOURCE1_ALPHA\0" - "GL_SOURCE1_ALPHA_ARB\0" - "GL_SOURCE1_ALPHA_EXT\0" - "GL_SOURCE1_RGB\0" - "GL_SOURCE1_RGB_ARB\0" - "GL_SOURCE1_RGB_EXT\0" - "GL_SOURCE2_ALPHA\0" - "GL_SOURCE2_ALPHA_ARB\0" - "GL_SOURCE2_ALPHA_EXT\0" - "GL_SOURCE2_RGB\0" - "GL_SOURCE2_RGB_ARB\0" - "GL_SOURCE2_RGB_EXT\0" - "GL_SOURCE3_ALPHA_NV\0" - "GL_SOURCE3_RGB_NV\0" - "GL_SPECULAR\0" - "GL_SPHERE_MAP\0" - "GL_SPOT_CUTOFF\0" - "GL_SPOT_DIRECTION\0" - "GL_SPOT_EXPONENT\0" - "GL_SRC0_ALPHA\0" - "GL_SRC0_RGB\0" - "GL_SRC1_ALPHA\0" - "GL_SRC1_RGB\0" - "GL_SRC2_ALPHA\0" - "GL_SRC2_RGB\0" - "GL_SRC_ALPHA\0" - "GL_SRC_ALPHA_SATURATE\0" - "GL_SRC_COLOR\0" - "GL_SRGB\0" - "GL_SRGB8\0" - "GL_SRGB8_ALPHA8\0" - "GL_SRGB_ALPHA\0" - "GL_STACK_OVERFLOW\0" - "GL_STACK_UNDERFLOW\0" - "GL_STATIC_COPY\0" - "GL_STATIC_COPY_ARB\0" - "GL_STATIC_DRAW\0" - "GL_STATIC_DRAW_ARB\0" - "GL_STATIC_READ\0" - "GL_STATIC_READ_ARB\0" - "GL_STENCIL\0" - "GL_STENCIL_ATTACHMENT\0" - "GL_STENCIL_ATTACHMENT_EXT\0" - "GL_STENCIL_ATTACHMENT_OES\0" - "GL_STENCIL_BACK_FAIL\0" - "GL_STENCIL_BACK_FAIL_ATI\0" - "GL_STENCIL_BACK_FUNC\0" - "GL_STENCIL_BACK_FUNC_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI\0" - "GL_STENCIL_BACK_REF\0" - "GL_STENCIL_BACK_VALUE_MASK\0" - "GL_STENCIL_BACK_WRITEMASK\0" - "GL_STENCIL_BITS\0" - "GL_STENCIL_BUFFER_BIT\0" - "GL_STENCIL_CLEAR_VALUE\0" - "GL_STENCIL_FAIL\0" - "GL_STENCIL_FUNC\0" - "GL_STENCIL_INDEX\0" - "GL_STENCIL_INDEX1\0" - "GL_STENCIL_INDEX16\0" - "GL_STENCIL_INDEX16_EXT\0" - "GL_STENCIL_INDEX1_EXT\0" - "GL_STENCIL_INDEX1_OES\0" - "GL_STENCIL_INDEX4\0" - "GL_STENCIL_INDEX4_EXT\0" - "GL_STENCIL_INDEX4_OES\0" - "GL_STENCIL_INDEX8\0" - "GL_STENCIL_INDEX8_EXT\0" - "GL_STENCIL_INDEX8_OES\0" - "GL_STENCIL_INDEX_EXT\0" - "GL_STENCIL_PASS_DEPTH_FAIL\0" - "GL_STENCIL_PASS_DEPTH_PASS\0" - "GL_STENCIL_REF\0" - "GL_STENCIL_TEST\0" - "GL_STENCIL_TEST_TWO_SIDE_EXT\0" - "GL_STENCIL_VALUE_MASK\0" - "GL_STENCIL_WRITEMASK\0" - "GL_STEREO\0" - "GL_STORAGE_CACHED_APPLE\0" - "GL_STORAGE_PRIVATE_APPLE\0" - "GL_STORAGE_SHARED_APPLE\0" - "GL_STREAM_COPY\0" - "GL_STREAM_COPY_ARB\0" - "GL_STREAM_DRAW\0" - "GL_STREAM_DRAW_ARB\0" - "GL_STREAM_READ\0" - "GL_STREAM_READ_ARB\0" - "GL_SUBPIXEL_BITS\0" - "GL_SUBTRACT\0" - "GL_SUBTRACT_ARB\0" - "GL_SYNC_CONDITION\0" - "GL_SYNC_FENCE\0" - "GL_SYNC_FLAGS\0" - "GL_SYNC_FLUSH_COMMANDS_BIT\0" - "GL_SYNC_GPU_COMMANDS_COMPLETE\0" - "GL_SYNC_STATUS\0" - "GL_T\0" - "GL_T2F_C3F_V3F\0" - "GL_T2F_C4F_N3F_V3F\0" - "GL_T2F_C4UB_V3F\0" - "GL_T2F_N3F_V3F\0" - "GL_T2F_V3F\0" - "GL_T4F_C4F_N3F_V4F\0" - "GL_T4F_V4F\0" - "GL_TABLE_TOO_LARGE_EXT\0" - "GL_TEXTURE\0" - "GL_TEXTURE0\0" - "GL_TEXTURE0_ARB\0" - "GL_TEXTURE1\0" - "GL_TEXTURE10\0" - "GL_TEXTURE10_ARB\0" - "GL_TEXTURE11\0" - "GL_TEXTURE11_ARB\0" - "GL_TEXTURE12\0" - "GL_TEXTURE12_ARB\0" - "GL_TEXTURE13\0" - "GL_TEXTURE13_ARB\0" - "GL_TEXTURE14\0" - "GL_TEXTURE14_ARB\0" - "GL_TEXTURE15\0" - "GL_TEXTURE15_ARB\0" - "GL_TEXTURE16\0" - "GL_TEXTURE16_ARB\0" - "GL_TEXTURE17\0" - "GL_TEXTURE17_ARB\0" - "GL_TEXTURE18\0" - "GL_TEXTURE18_ARB\0" - "GL_TEXTURE19\0" - "GL_TEXTURE19_ARB\0" - "GL_TEXTURE1_ARB\0" - "GL_TEXTURE2\0" - "GL_TEXTURE20\0" - "GL_TEXTURE20_ARB\0" - "GL_TEXTURE21\0" - "GL_TEXTURE21_ARB\0" - "GL_TEXTURE22\0" - "GL_TEXTURE22_ARB\0" - "GL_TEXTURE23\0" - "GL_TEXTURE23_ARB\0" - "GL_TEXTURE24\0" - "GL_TEXTURE24_ARB\0" - "GL_TEXTURE25\0" - "GL_TEXTURE25_ARB\0" - "GL_TEXTURE26\0" - "GL_TEXTURE26_ARB\0" - "GL_TEXTURE27\0" - "GL_TEXTURE27_ARB\0" - "GL_TEXTURE28\0" - "GL_TEXTURE28_ARB\0" - "GL_TEXTURE29\0" - "GL_TEXTURE29_ARB\0" - "GL_TEXTURE2_ARB\0" - "GL_TEXTURE3\0" - "GL_TEXTURE30\0" - "GL_TEXTURE30_ARB\0" - "GL_TEXTURE31\0" - "GL_TEXTURE31_ARB\0" - "GL_TEXTURE3_ARB\0" - "GL_TEXTURE4\0" - "GL_TEXTURE4_ARB\0" - "GL_TEXTURE5\0" - "GL_TEXTURE5_ARB\0" - "GL_TEXTURE6\0" - "GL_TEXTURE6_ARB\0" - "GL_TEXTURE7\0" - "GL_TEXTURE7_ARB\0" - "GL_TEXTURE8\0" - "GL_TEXTURE8_ARB\0" - "GL_TEXTURE9\0" - "GL_TEXTURE9_ARB\0" - "GL_TEXTURE_1D\0" - "GL_TEXTURE_1D_ARRAY_EXT\0" - "GL_TEXTURE_2D\0" - "GL_TEXTURE_2D_ARRAY_EXT\0" - "GL_TEXTURE_3D\0" - "GL_TEXTURE_3D_OES\0" - "GL_TEXTURE_ALPHA_SIZE\0" - "GL_TEXTURE_ALPHA_SIZE_EXT\0" - "GL_TEXTURE_BASE_LEVEL\0" - "GL_TEXTURE_BINDING_1D\0" - "GL_TEXTURE_BINDING_1D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_2D\0" - "GL_TEXTURE_BINDING_2D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_3D\0" - "GL_TEXTURE_BINDING_3D_OES\0" - "GL_TEXTURE_BINDING_CUBE_MAP\0" - "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0" - "GL_TEXTURE_BINDING_CUBE_MAP_OES\0" - "GL_TEXTURE_BINDING_RECTANGLE_ARB\0" - "GL_TEXTURE_BINDING_RECTANGLE_NV\0" - "GL_TEXTURE_BIT\0" - "GL_TEXTURE_BLUE_SIZE\0" - "GL_TEXTURE_BLUE_SIZE_EXT\0" - "GL_TEXTURE_BORDER\0" - "GL_TEXTURE_BORDER_COLOR\0" - "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0" - "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0" - "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0" - "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_TEXTURE_COLOR_TABLE_SGI\0" - "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0" - "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0" - "GL_TEXTURE_COMPARE_FUNC\0" - "GL_TEXTURE_COMPARE_FUNC_ARB\0" - "GL_TEXTURE_COMPARE_MODE\0" - "GL_TEXTURE_COMPARE_MODE_ARB\0" - "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0" - "GL_TEXTURE_COMPARE_SGIX\0" - "GL_TEXTURE_COMPONENTS\0" - "GL_TEXTURE_COMPRESSED\0" - "GL_TEXTURE_COMPRESSED_ARB\0" - "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0" - "GL_TEXTURE_COMPRESSION_HINT\0" - "GL_TEXTURE_COMPRESSION_HINT_ARB\0" - "GL_TEXTURE_COORD_ARRAY\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0" - "GL_TEXTURE_COORD_ARRAY_POINTER\0" - "GL_TEXTURE_COORD_ARRAY_SIZE\0" - "GL_TEXTURE_COORD_ARRAY_STRIDE\0" - "GL_TEXTURE_COORD_ARRAY_TYPE\0" - "GL_TEXTURE_CROP_RECT_OES\0" - "GL_TEXTURE_CUBE_MAP\0" - "GL_TEXTURE_CUBE_MAP_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_SEAMLESS\0" - "GL_TEXTURE_DEPTH\0" - "GL_TEXTURE_DEPTH_SIZE\0" - "GL_TEXTURE_DEPTH_SIZE_ARB\0" - "GL_TEXTURE_ENV\0" - "GL_TEXTURE_ENV_COLOR\0" - "GL_TEXTURE_ENV_MODE\0" - "GL_TEXTURE_FILTER_CONTROL\0" - "GL_TEXTURE_FILTER_CONTROL_EXT\0" - "GL_TEXTURE_GEN_MODE\0" - "GL_TEXTURE_GEN_MODE_OES\0" - "GL_TEXTURE_GEN_Q\0" - "GL_TEXTURE_GEN_R\0" - "GL_TEXTURE_GEN_S\0" - "GL_TEXTURE_GEN_STR_OES\0" - "GL_TEXTURE_GEN_T\0" - "GL_TEXTURE_GEQUAL_R_SGIX\0" - "GL_TEXTURE_GREEN_SIZE\0" - "GL_TEXTURE_GREEN_SIZE_EXT\0" - "GL_TEXTURE_HEIGHT\0" - "GL_TEXTURE_INDEX_SIZE_EXT\0" - "GL_TEXTURE_INTENSITY_SIZE\0" - "GL_TEXTURE_INTENSITY_SIZE_EXT\0" - "GL_TEXTURE_INTERNAL_FORMAT\0" - "GL_TEXTURE_LEQUAL_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS\0" - "GL_TEXTURE_LOD_BIAS_EXT\0" - "GL_TEXTURE_LOD_BIAS_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS_S_SGIX\0" - "GL_TEXTURE_LOD_BIAS_T_SGIX\0" - "GL_TEXTURE_LUMINANCE_SIZE\0" - "GL_TEXTURE_LUMINANCE_SIZE_EXT\0" - "GL_TEXTURE_MAG_FILTER\0" - "GL_TEXTURE_MATRIX\0" - "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_TEXTURE_MAX_CLAMP_R_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_S_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_T_SGIX\0" - "GL_TEXTURE_MAX_LEVEL\0" - "GL_TEXTURE_MAX_LOD\0" - "GL_TEXTURE_MIN_FILTER\0" - "GL_TEXTURE_MIN_LOD\0" - "GL_TEXTURE_PRIORITY\0" - "GL_TEXTURE_RANGE_LENGTH_APPLE\0" - "GL_TEXTURE_RANGE_POINTER_APPLE\0" - "GL_TEXTURE_RECTANGLE_ARB\0" - "GL_TEXTURE_RECTANGLE_NV\0" - "GL_TEXTURE_RED_SIZE\0" - "GL_TEXTURE_RED_SIZE_EXT\0" - "GL_TEXTURE_RESIDENT\0" - "GL_TEXTURE_STACK_DEPTH\0" - "GL_TEXTURE_STENCIL_SIZE\0" - "GL_TEXTURE_STENCIL_SIZE_EXT\0" - "GL_TEXTURE_STORAGE_HINT_APPLE\0" - "GL_TEXTURE_TOO_LARGE_EXT\0" - "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0" - "GL_TEXTURE_WIDTH\0" - "GL_TEXTURE_WRAP_R\0" - "GL_TEXTURE_WRAP_R_OES\0" - "GL_TEXTURE_WRAP_S\0" - "GL_TEXTURE_WRAP_T\0" - "GL_TIMEOUT_EXPIRED\0" - "GL_TIME_ELAPSED_EXT\0" - "GL_TRACK_MATRIX_NV\0" - "GL_TRACK_MATRIX_TRANSFORM_NV\0" - "GL_TRANSFORM_BIT\0" - "GL_TRANSFORM_FEEDBACK\0" - "GL_TRANSFORM_FEEDBACK_BINDING\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT\0" - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT\0" - "GL_TRANSPOSE_COLOR_MATRIX\0" - "GL_TRANSPOSE_COLOR_MATRIX_ARB\0" - "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0" - "GL_TRANSPOSE_NV\0" - "GL_TRANSPOSE_PROJECTION_MATRIX\0" - "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0" - "GL_TRANSPOSE_TEXTURE_MATRIX\0" - "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0" - "GL_TRIANGLES\0" - "GL_TRIANGLES_ADJACENCY_ARB\0" - "GL_TRIANGLE_FAN\0" - "GL_TRIANGLE_MESH_SUN\0" - "GL_TRIANGLE_STRIP\0" - "GL_TRIANGLE_STRIP_ADJACENCY_ARB\0" - "GL_TRUE\0" - "GL_UNDEFINED_APPLE\0" - "GL_UNPACK_ALIGNMENT\0" - "GL_UNPACK_IMAGE_HEIGHT\0" - "GL_UNPACK_LSB_FIRST\0" - "GL_UNPACK_ROW_LENGTH\0" - "GL_UNPACK_SKIP_IMAGES\0" - "GL_UNPACK_SKIP_PIXELS\0" - "GL_UNPACK_SKIP_ROWS\0" - "GL_UNPACK_SWAP_BYTES\0" - "GL_UNSIGNALED\0" - "GL_UNSIGNED_BYTE\0" - "GL_UNSIGNED_BYTE_2_3_3_REV\0" - "GL_UNSIGNED_BYTE_3_3_2\0" - "GL_UNSIGNED_INT\0" - "GL_UNSIGNED_INT_10_10_10_2\0" - "GL_UNSIGNED_INT_10_10_10_2_OES\0" - "GL_UNSIGNED_INT_24_8\0" - "GL_UNSIGNED_INT_24_8_EXT\0" - "GL_UNSIGNED_INT_24_8_NV\0" - "GL_UNSIGNED_INT_24_8_OES\0" - "GL_UNSIGNED_INT_2_10_10_10_REV\0" - "GL_UNSIGNED_INT_2_10_10_10_REV_EXT\0" - "GL_UNSIGNED_INT_8_8_8_8\0" - "GL_UNSIGNED_INT_8_8_8_8_REV\0" - "GL_UNSIGNED_NORMALIZED\0" - "GL_UNSIGNED_SHORT\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT\0" - "GL_UNSIGNED_SHORT_4_4_4_4\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT\0" - "GL_UNSIGNED_SHORT_5_5_5_1\0" - "GL_UNSIGNED_SHORT_5_6_5\0" - "GL_UNSIGNED_SHORT_5_6_5_REV\0" - "GL_UNSIGNED_SHORT_8_8_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_MESA\0" - "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_REV_MESA\0" - "GL_UPPER_LEFT\0" - "GL_V2F\0" - "GL_V3F\0" - "GL_VALIDATE_STATUS\0" - "GL_VENDOR\0" - "GL_VERSION\0" - "GL_VERTEX_ARRAY\0" - "GL_VERTEX_ARRAY_BINDING\0" - "GL_VERTEX_ARRAY_BINDING_APPLE\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ARRAY_POINTER\0" - "GL_VERTEX_ARRAY_SIZE\0" - "GL_VERTEX_ARRAY_STRIDE\0" - "GL_VERTEX_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY0_NV\0" - "GL_VERTEX_ATTRIB_ARRAY10_NV\0" - "GL_VERTEX_ATTRIB_ARRAY11_NV\0" - "GL_VERTEX_ATTRIB_ARRAY12_NV\0" - "GL_VERTEX_ATTRIB_ARRAY13_NV\0" - "GL_VERTEX_ATTRIB_ARRAY14_NV\0" - "GL_VERTEX_ATTRIB_ARRAY15_NV\0" - "GL_VERTEX_ATTRIB_ARRAY1_NV\0" - "GL_VERTEX_ATTRIB_ARRAY2_NV\0" - "GL_VERTEX_ATTRIB_ARRAY3_NV\0" - "GL_VERTEX_ATTRIB_ARRAY4_NV\0" - "GL_VERTEX_ATTRIB_ARRAY5_NV\0" - "GL_VERTEX_ATTRIB_ARRAY6_NV\0" - "GL_VERTEX_ATTRIB_ARRAY7_NV\0" - "GL_VERTEX_ATTRIB_ARRAY8_NV\0" - "GL_VERTEX_ATTRIB_ARRAY9_NV\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0" - "GL_VERTEX_BLEND_ARB\0" - "GL_VERTEX_PROGRAM_ARB\0" - "GL_VERTEX_PROGRAM_BINDING_NV\0" - "GL_VERTEX_PROGRAM_NV\0" - "GL_VERTEX_PROGRAM_POINT_SIZE\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0" - "GL_VERTEX_PROGRAM_TWO_SIDE\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0" - "GL_VERTEX_SHADER\0" - "GL_VERTEX_SHADER_ARB\0" - "GL_VERTEX_STATE_PROGRAM_NV\0" - "GL_VIEWPORT\0" - "GL_VIEWPORT_BIT\0" - "GL_VOLATILE_APPLE\0" - "GL_WAIT_FAILED\0" - "GL_WEIGHT_ARRAY_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_OES\0" - "GL_WEIGHT_ARRAY_OES\0" - "GL_WEIGHT_ARRAY_POINTER_ARB\0" - "GL_WEIGHT_ARRAY_POINTER_OES\0" - "GL_WEIGHT_ARRAY_SIZE_ARB\0" - "GL_WEIGHT_ARRAY_SIZE_OES\0" - "GL_WEIGHT_ARRAY_STRIDE_ARB\0" - "GL_WEIGHT_ARRAY_STRIDE_OES\0" - "GL_WEIGHT_ARRAY_TYPE_ARB\0" - "GL_WEIGHT_ARRAY_TYPE_OES\0" - "GL_WEIGHT_SUM_UNITY_ARB\0" - "GL_WRAP_BORDER_SUN\0" - "GL_WRITE_ONLY\0" - "GL_WRITE_ONLY_ARB\0" - "GL_WRITE_ONLY_OES\0" - "GL_XOR\0" - "GL_YCBCR_422_APPLE\0" - "GL_YCBCR_MESA\0" - "GL_ZERO\0" - "GL_ZOOM_X\0" - "GL_ZOOM_Y\0" - ; - -static const enum_elt all_enums[2065] = -{ - { 0, 0x00000600 }, /* GL_2D */ - { 6, 0x00001407 }, /* GL_2_BYTES */ - { 17, 0x00000601 }, /* GL_3D */ - { 23, 0x00000602 }, /* GL_3D_COLOR */ - { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */ - { 55, 0x00001408 }, /* GL_3_BYTES */ - { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */ - { 86, 0x00001409 }, /* GL_4_BYTES */ - { 97, 0x00000100 }, /* GL_ACCUM */ - { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */ - { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */ - { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */ - { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */ - { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */ - { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */ - { 224, 0x00008B89 }, /* GL_ACTIVE_ATTRIBUTES */ - { 245, 0x00008B8A }, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - { 276, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */ - { 303, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */ - { 321, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */ - { 343, 0x00008B86 }, /* GL_ACTIVE_UNIFORMS */ - { 362, 0x00008B87 }, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - { 391, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - { 418, 0x00000104 }, /* GL_ADD */ - { 425, 0x00008574 }, /* GL_ADD_SIGNED */ - { 439, 0x00008574 }, /* GL_ADD_SIGNED_ARB */ - { 457, 0x00008574 }, /* GL_ADD_SIGNED_EXT */ - { 475, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */ - { 503, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */ - { 531, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */ - { 550, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */ - { 576, 0x00001906 }, /* GL_ALPHA */ - { 585, 0x0000803D }, /* GL_ALPHA12 */ - { 596, 0x0000803D }, /* GL_ALPHA12_EXT */ - { 611, 0x0000803E }, /* GL_ALPHA16 */ - { 622, 0x0000803E }, /* GL_ALPHA16_EXT */ - { 637, 0x0000803B }, /* GL_ALPHA4 */ - { 647, 0x0000803B }, /* GL_ALPHA4_EXT */ - { 661, 0x0000803C }, /* GL_ALPHA8 */ - { 671, 0x0000803C }, /* GL_ALPHA8_EXT */ - { 685, 0x00000D1D }, /* GL_ALPHA_BIAS */ - { 699, 0x00000D55 }, /* GL_ALPHA_BITS */ - { 713, 0x00000D1C }, /* GL_ALPHA_SCALE */ - { 728, 0x00000BC0 }, /* GL_ALPHA_TEST */ - { 742, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */ - { 761, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */ - { 779, 0x0000911A }, /* GL_ALREADY_SIGNALED */ - { 799, 0x00000207 }, /* GL_ALWAYS */ - { 809, 0x00001200 }, /* GL_AMBIENT */ - { 820, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */ - { 843, 0x00001501 }, /* GL_AND */ - { 850, 0x00001504 }, /* GL_AND_INVERTED */ - { 866, 0x00001502 }, /* GL_AND_REVERSE */ - { 881, 0x00008892 }, /* GL_ARRAY_BUFFER */ - { 897, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */ - { 921, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */ - { 949, 0x00008B85 }, /* GL_ATTACHED_SHADERS */ - { 969, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */ - { 996, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */ - { 1020, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */ - { 1046, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */ - { 1070, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */ - { 1092, 0x00000D80 }, /* GL_AUTO_NORMAL */ - { 1107, 0x00000409 }, /* GL_AUX0 */ - { 1115, 0x0000040A }, /* GL_AUX1 */ - { 1123, 0x0000040B }, /* GL_AUX2 */ - { 1131, 0x0000040C }, /* GL_AUX3 */ - { 1139, 0x00000C00 }, /* GL_AUX_BUFFERS */ - { 1154, 0x00000405 }, /* GL_BACK */ - { 1162, 0x00000402 }, /* GL_BACK_LEFT */ - { 1175, 0x00000403 }, /* GL_BACK_RIGHT */ - { 1189, 0x000080E0 }, /* GL_BGR */ - { 1196, 0x000080E1 }, /* GL_BGRA */ - { 1204, 0x000080E1 }, /* GL_BGRA_EXT */ - { 1216, 0x00001A00 }, /* GL_BITMAP */ - { 1226, 0x00000704 }, /* GL_BITMAP_TOKEN */ - { 1242, 0x00000BE2 }, /* GL_BLEND */ - { 1251, 0x00008005 }, /* GL_BLEND_COLOR */ - { 1266, 0x00008005 }, /* GL_BLEND_COLOR_EXT */ - { 1285, 0x00000BE0 }, /* GL_BLEND_DST */ - { 1298, 0x000080CA }, /* GL_BLEND_DST_ALPHA */ - { 1317, 0x000080CA }, /* GL_BLEND_DST_ALPHA_OES */ - { 1340, 0x000080C8 }, /* GL_BLEND_DST_RGB */ - { 1357, 0x000080C8 }, /* GL_BLEND_DST_RGB_OES */ - { 1378, 0x00008009 }, /* GL_BLEND_EQUATION */ - { 1396, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */ - { 1420, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */ - { 1448, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_OES */ - { 1476, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */ - { 1498, 0x00008009 }, /* GL_BLEND_EQUATION_OES */ - { 1520, 0x00008009 }, /* GL_BLEND_EQUATION_RGB */ - { 1542, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */ - { 1568, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_OES */ - { 1594, 0x00000BE1 }, /* GL_BLEND_SRC */ - { 1607, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */ - { 1626, 0x000080CB }, /* GL_BLEND_SRC_ALPHA_OES */ - { 1649, 0x000080C9 }, /* GL_BLEND_SRC_RGB */ - { 1666, 0x000080C9 }, /* GL_BLEND_SRC_RGB_OES */ - { 1687, 0x00001905 }, /* GL_BLUE */ - { 1695, 0x00000D1B }, /* GL_BLUE_BIAS */ - { 1708, 0x00000D54 }, /* GL_BLUE_BITS */ - { 1721, 0x00000D1A }, /* GL_BLUE_SCALE */ - { 1735, 0x00008B56 }, /* GL_BOOL */ - { 1743, 0x00008B56 }, /* GL_BOOL_ARB */ - { 1755, 0x00008B57 }, /* GL_BOOL_VEC2 */ - { 1768, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */ - { 1785, 0x00008B58 }, /* GL_BOOL_VEC3 */ - { 1798, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */ - { 1815, 0x00008B59 }, /* GL_BOOL_VEC4 */ - { 1828, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */ - { 1845, 0x000088BB }, /* GL_BUFFER_ACCESS */ - { 1862, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */ - { 1883, 0x000088BB }, /* GL_BUFFER_ACCESS_OES */ - { 1904, 0x00008A13 }, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - { 1935, 0x000088BC }, /* GL_BUFFER_MAPPED */ - { 1952, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */ - { 1973, 0x000088BC }, /* GL_BUFFER_MAPPED_OES */ - { 1994, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */ - { 2016, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */ - { 2042, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_OES */ - { 2068, 0x000085B3 }, /* GL_BUFFER_OBJECT_APPLE */ - { 2091, 0x00008A12 }, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - { 2125, 0x00008764 }, /* GL_BUFFER_SIZE */ - { 2140, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */ - { 2159, 0x00008765 }, /* GL_BUFFER_USAGE */ - { 2175, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */ - { 2195, 0x0000877B }, /* GL_BUMP_ENVMAP_ATI */ - { 2214, 0x00008777 }, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - { 2240, 0x00008775 }, /* GL_BUMP_ROT_MATRIX_ATI */ - { 2263, 0x00008776 }, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - { 2291, 0x0000877C }, /* GL_BUMP_TARGET_ATI */ - { 2310, 0x00008778 }, /* GL_BUMP_TEX_UNITS_ATI */ - { 2332, 0x00001400 }, /* GL_BYTE */ - { 2340, 0x00002A24 }, /* GL_C3F_V3F */ - { 2351, 0x00002A26 }, /* GL_C4F_N3F_V3F */ - { 2366, 0x00002A22 }, /* GL_C4UB_V2F */ - { 2378, 0x00002A23 }, /* GL_C4UB_V3F */ - { 2390, 0x00000901 }, /* GL_CCW */ - { 2397, 0x00002900 }, /* GL_CLAMP */ - { 2406, 0x0000812D }, /* GL_CLAMP_TO_BORDER */ - { 2425, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */ - { 2448, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */ - { 2472, 0x0000812F }, /* GL_CLAMP_TO_EDGE */ - { 2489, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */ - { 2511, 0x00001500 }, /* GL_CLEAR */ - { 2520, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */ - { 2545, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */ - { 2574, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */ - { 2600, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - { 2629, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */ - { 2655, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */ - { 2682, 0x00003000 }, /* GL_CLIP_PLANE0 */ - { 2697, 0x00003001 }, /* GL_CLIP_PLANE1 */ - { 2712, 0x00003002 }, /* GL_CLIP_PLANE2 */ - { 2727, 0x00003003 }, /* GL_CLIP_PLANE3 */ - { 2742, 0x00003004 }, /* GL_CLIP_PLANE4 */ - { 2757, 0x00003005 }, /* GL_CLIP_PLANE5 */ - { 2772, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - { 2805, 0x00000A00 }, /* GL_COEFF */ - { 2814, 0x00001800 }, /* GL_COLOR */ - { 2823, 0x00008076 }, /* GL_COLOR_ARRAY */ - { 2838, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - { 2868, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 2902, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */ - { 2925, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */ - { 2945, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */ - { 2967, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */ - { 2987, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0 */ - { 3008, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */ - { 3033, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_OES */ - { 3058, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1 */ - { 3079, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10 */ - { 3101, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */ - { 3127, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11 */ - { 3149, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */ - { 3175, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12 */ - { 3197, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */ - { 3223, 0x00008CED }, /* GL_COLOR_ATTACHMENT13 */ - { 3245, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */ - { 3271, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14 */ - { 3293, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */ - { 3319, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15 */ - { 3341, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */ - { 3367, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */ - { 3392, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2 */ - { 3413, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */ - { 3438, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3 */ - { 3459, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */ - { 3484, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4 */ - { 3505, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */ - { 3530, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5 */ - { 3551, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */ - { 3576, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6 */ - { 3597, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */ - { 3622, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7 */ - { 3643, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */ - { 3668, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8 */ - { 3689, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */ - { 3714, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9 */ - { 3735, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */ - { 3760, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */ - { 3780, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */ - { 3801, 0x00001900 }, /* GL_COLOR_INDEX */ - { 3816, 0x00001603 }, /* GL_COLOR_INDEXES */ - { 3833, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */ - { 3851, 0x00000B57 }, /* GL_COLOR_MATERIAL */ - { 3869, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */ - { 3892, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */ - { 3920, 0x000080B1 }, /* GL_COLOR_MATRIX */ - { 3936, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */ - { 3956, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */ - { 3984, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 4016, 0x00008458 }, /* GL_COLOR_SUM */ - { 4029, 0x00008458 }, /* GL_COLOR_SUM_ARB */ - { 4046, 0x000080D0 }, /* GL_COLOR_TABLE */ - { 4061, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */ - { 4087, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */ - { 4117, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */ - { 4147, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */ - { 4167, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */ - { 4191, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */ - { 4216, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */ - { 4245, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */ - { 4274, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */ - { 4296, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */ - { 4322, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */ - { 4348, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */ - { 4374, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */ - { 4404, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */ - { 4434, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - { 4464, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */ - { 4498, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */ - { 4532, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - { 4562, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */ - { 4596, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */ - { 4630, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */ - { 4654, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */ - { 4682, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */ - { 4710, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */ - { 4731, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */ - { 4756, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */ - { 4777, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */ - { 4802, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */ - { 4827, 0x00000C23 }, /* GL_COLOR_WRITEMASK */ - { 4846, 0x00008570 }, /* GL_COMBINE */ - { 4857, 0x00008503 }, /* GL_COMBINE4 */ - { 4869, 0x00008572 }, /* GL_COMBINE_ALPHA */ - { 4886, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */ - { 4907, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */ - { 4928, 0x00008570 }, /* GL_COMBINE_ARB */ - { 4943, 0x00008570 }, /* GL_COMBINE_EXT */ - { 4958, 0x00008571 }, /* GL_COMBINE_RGB */ - { 4973, 0x00008571 }, /* GL_COMBINE_RGB_ARB */ - { 4992, 0x00008571 }, /* GL_COMBINE_RGB_EXT */ - { 5011, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */ - { 5047, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */ - { 5071, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */ - { 5099, 0x00001300 }, /* GL_COMPILE */ - { 5110, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */ - { 5133, 0x00008B81 }, /* GL_COMPILE_STATUS */ - { 5151, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */ - { 5171, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */ - { 5195, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */ - { 5219, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */ - { 5247, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */ - { 5271, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - { 5301, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */ - { 5335, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */ - { 5363, 0x000084ED }, /* GL_COMPRESSED_RGB */ - { 5381, 0x000084EE }, /* GL_COMPRESSED_RGBA */ - { 5400, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */ - { 5423, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - { 5452, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - { 5485, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - { 5518, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - { 5551, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */ - { 5573, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - { 5601, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - { 5633, 0x00008C4A }, /* GL_COMPRESSED_SLUMINANCE */ - { 5658, 0x00008C4B }, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - { 5689, 0x00008C48 }, /* GL_COMPRESSED_SRGB */ - { 5708, 0x00008C49 }, /* GL_COMPRESSED_SRGB_ALPHA */ - { 5733, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */ - { 5763, 0x0000911C }, /* GL_CONDITION_SATISFIED */ - { 5786, 0x00008576 }, /* GL_CONSTANT */ - { 5798, 0x00008003 }, /* GL_CONSTANT_ALPHA */ - { 5816, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */ - { 5838, 0x00008576 }, /* GL_CONSTANT_ARB */ - { 5854, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */ - { 5878, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */ - { 5900, 0x00008001 }, /* GL_CONSTANT_COLOR */ - { 5918, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */ - { 5940, 0x00008576 }, /* GL_CONSTANT_EXT */ - { 5956, 0x00008010 }, /* GL_CONVOLUTION_1D */ - { 5974, 0x00008011 }, /* GL_CONVOLUTION_2D */ - { 5992, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */ - { 6020, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */ - { 6051, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */ - { 6078, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */ - { 6109, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */ - { 6136, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */ - { 6167, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */ - { 6195, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */ - { 6227, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */ - { 6249, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */ - { 6275, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */ - { 6297, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */ - { 6323, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */ - { 6344, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */ - { 6369, 0x00008862 }, /* GL_COORD_REPLACE */ - { 6386, 0x00008862 }, /* GL_COORD_REPLACE_ARB */ - { 6407, 0x00008862 }, /* GL_COORD_REPLACE_NV */ - { 6427, 0x00008862 }, /* GL_COORD_REPLACE_OES */ - { 6448, 0x00001503 }, /* GL_COPY */ - { 6456, 0x0000150C }, /* GL_COPY_INVERTED */ - { 6473, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */ - { 6493, 0x00008F36 }, /* GL_COPY_READ_BUFFER */ - { 6513, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */ - { 6534, 0x00000B44 }, /* GL_CULL_FACE */ - { 6547, 0x00000B45 }, /* GL_CULL_FACE_MODE */ - { 6565, 0x000081AA }, /* GL_CULL_VERTEX_EXT */ - { 6584, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - { 6616, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - { 6651, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */ - { 6672, 0x00000001 }, /* GL_CURRENT_BIT */ - { 6687, 0x00000B00 }, /* GL_CURRENT_COLOR */ - { 6704, 0x00008453 }, /* GL_CURRENT_FOG_COORD */ - { 6725, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */ - { 6751, 0x00000B01 }, /* GL_CURRENT_INDEX */ - { 6768, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */ - { 6790, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */ - { 6818, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */ - { 6839, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - { 6873, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */ - { 6906, 0x00000B02 }, /* GL_CURRENT_NORMAL */ - { 6924, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - { 6954, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_OES */ - { 6984, 0x00008B8D }, /* GL_CURRENT_PROGRAM */ - { 7003, 0x00008865 }, /* GL_CURRENT_QUERY */ - { 7020, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */ - { 7041, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */ - { 7065, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */ - { 7092, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */ - { 7116, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */ - { 7143, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */ - { 7176, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - { 7210, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - { 7243, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */ - { 7270, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */ - { 7296, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */ - { 7321, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */ - { 7350, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */ - { 7372, 0x00000900 }, /* GL_CW */ - { 7378, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */ - { 7399, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */ - { 7420, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */ - { 7440, 0x00002101 }, /* GL_DECAL */ - { 7449, 0x00001E03 }, /* GL_DECR */ - { 7457, 0x00008508 }, /* GL_DECR_WRAP */ - { 7470, 0x00008508 }, /* GL_DECR_WRAP_EXT */ - { 7487, 0x00008B80 }, /* GL_DELETE_STATUS */ - { 7504, 0x00001801 }, /* GL_DEPTH */ - { 7513, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */ - { 7533, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */ - { 7557, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_OES */ - { 7581, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */ - { 7601, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */ - { 7625, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_OES */ - { 7649, 0x00000D1F }, /* GL_DEPTH_BIAS */ - { 7663, 0x00000D56 }, /* GL_DEPTH_BITS */ - { 7677, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */ - { 7697, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */ - { 7722, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */ - { 7742, 0x0000864F }, /* GL_DEPTH_CLAMP */ - { 7757, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */ - { 7775, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */ - { 7796, 0x00001902 }, /* GL_DEPTH_COMPONENT */ - { 7815, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */ - { 7836, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */ - { 7861, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_OES */ - { 7886, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */ - { 7912, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */ - { 7933, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */ - { 7958, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_OES */ - { 7983, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */ - { 8009, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */ - { 8030, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */ - { 8055, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_OES */ - { 8080, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */ - { 8106, 0x00000B74 }, /* GL_DEPTH_FUNC */ - { 8120, 0x00000B70 }, /* GL_DEPTH_RANGE */ - { 8135, 0x00000D1E }, /* GL_DEPTH_SCALE */ - { 8150, 0x000084F9 }, /* GL_DEPTH_STENCIL */ - { 8167, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */ - { 8195, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */ - { 8216, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */ - { 8236, 0x000084F9 }, /* GL_DEPTH_STENCIL_OES */ - { 8257, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - { 8285, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - { 8313, 0x00000B71 }, /* GL_DEPTH_TEST */ - { 8327, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */ - { 8349, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */ - { 8375, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */ - { 8394, 0x00001201 }, /* GL_DIFFUSE */ - { 8405, 0x00000BD0 }, /* GL_DITHER */ - { 8415, 0x00000A02 }, /* GL_DOMAIN */ - { 8425, 0x00001100 }, /* GL_DONT_CARE */ - { 8438, 0x000086AE }, /* GL_DOT3_RGB */ - { 8450, 0x000086AF }, /* GL_DOT3_RGBA */ - { 8463, 0x000086AF }, /* GL_DOT3_RGBA_ARB */ - { 8480, 0x00008741 }, /* GL_DOT3_RGBA_EXT */ - { 8497, 0x000086AE }, /* GL_DOT3_RGB_ARB */ - { 8513, 0x00008740 }, /* GL_DOT3_RGB_EXT */ - { 8529, 0x0000140A }, /* GL_DOUBLE */ - { 8539, 0x00000C32 }, /* GL_DOUBLEBUFFER */ - { 8555, 0x00000C01 }, /* GL_DRAW_BUFFER */ - { 8570, 0x00008825 }, /* GL_DRAW_BUFFER0 */ - { 8586, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */ - { 8606, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */ - { 8626, 0x00008826 }, /* GL_DRAW_BUFFER1 */ - { 8642, 0x0000882F }, /* GL_DRAW_BUFFER10 */ - { 8659, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */ - { 8680, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */ - { 8701, 0x00008830 }, /* GL_DRAW_BUFFER11 */ - { 8718, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */ - { 8739, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */ - { 8760, 0x00008831 }, /* GL_DRAW_BUFFER12 */ - { 8777, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */ - { 8798, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */ - { 8819, 0x00008832 }, /* GL_DRAW_BUFFER13 */ - { 8836, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */ - { 8857, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */ - { 8878, 0x00008833 }, /* GL_DRAW_BUFFER14 */ - { 8895, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */ - { 8916, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */ - { 8937, 0x00008834 }, /* GL_DRAW_BUFFER15 */ - { 8954, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */ - { 8975, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */ - { 8996, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */ - { 9016, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */ - { 9036, 0x00008827 }, /* GL_DRAW_BUFFER2 */ - { 9052, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */ - { 9072, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */ - { 9092, 0x00008828 }, /* GL_DRAW_BUFFER3 */ - { 9108, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */ - { 9128, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */ - { 9148, 0x00008829 }, /* GL_DRAW_BUFFER4 */ - { 9164, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */ - { 9184, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */ - { 9204, 0x0000882A }, /* GL_DRAW_BUFFER5 */ - { 9220, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */ - { 9240, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */ - { 9260, 0x0000882B }, /* GL_DRAW_BUFFER6 */ - { 9276, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */ - { 9296, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */ - { 9316, 0x0000882C }, /* GL_DRAW_BUFFER7 */ - { 9332, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */ - { 9352, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */ - { 9372, 0x0000882D }, /* GL_DRAW_BUFFER8 */ - { 9388, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */ - { 9408, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */ - { 9428, 0x0000882E }, /* GL_DRAW_BUFFER9 */ - { 9444, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */ - { 9464, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */ - { 9484, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */ - { 9504, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */ - { 9532, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */ - { 9564, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */ - { 9588, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */ - { 9608, 0x00000304 }, /* GL_DST_ALPHA */ - { 9621, 0x00000306 }, /* GL_DST_COLOR */ - { 9634, 0x0000877A }, /* GL_DU8DV8_ATI */ - { 9648, 0x00008779 }, /* GL_DUDV_ATI */ - { 9660, 0x000088EA }, /* GL_DYNAMIC_COPY */ - { 9676, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */ - { 9696, 0x000088E8 }, /* GL_DYNAMIC_DRAW */ - { 9712, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */ - { 9732, 0x000088E9 }, /* GL_DYNAMIC_READ */ - { 9748, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */ - { 9768, 0x00000B43 }, /* GL_EDGE_FLAG */ - { 9781, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */ - { 9800, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - { 9834, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */ - { 9872, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */ - { 9899, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - { 9925, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */ - { 9949, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - { 9981, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */ - { 10017, 0x00001600 }, /* GL_EMISSION */ - { 10029, 0x00002000 }, /* GL_ENABLE_BIT */ - { 10043, 0x00000202 }, /* GL_EQUAL */ - { 10052, 0x00001509 }, /* GL_EQUIV */ - { 10061, 0x00010000 }, /* GL_EVAL_BIT */ - { 10073, 0x00000800 }, /* GL_EXP */ - { 10080, 0x00000801 }, /* GL_EXP2 */ - { 10088, 0x00001F03 }, /* GL_EXTENSIONS */ - { 10102, 0x00002400 }, /* GL_EYE_LINEAR */ - { 10116, 0x00002502 }, /* GL_EYE_PLANE */ - { 10129, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */ - { 10154, 0x0000855B }, /* GL_EYE_RADIAL_NV */ - { 10171, 0x00000000 }, /* GL_FALSE */ - { 10180, 0x00001101 }, /* GL_FASTEST */ - { 10191, 0x00001C01 }, /* GL_FEEDBACK */ - { 10203, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */ - { 10230, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */ - { 10254, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */ - { 10278, 0x00001B02 }, /* GL_FILL */ - { 10286, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */ - { 10313, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */ - { 10344, 0x0000140C }, /* GL_FIXED */ - { 10353, 0x0000140C }, /* GL_FIXED_OES */ - { 10366, 0x00001D00 }, /* GL_FLAT */ - { 10374, 0x00001406 }, /* GL_FLOAT */ - { 10383, 0x00008B5A }, /* GL_FLOAT_MAT2 */ - { 10397, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */ - { 10415, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */ - { 10431, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */ - { 10447, 0x00008B5B }, /* GL_FLOAT_MAT3 */ - { 10461, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */ - { 10479, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */ - { 10495, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */ - { 10511, 0x00008B5C }, /* GL_FLOAT_MAT4 */ - { 10525, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */ - { 10543, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */ - { 10559, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */ - { 10575, 0x00008B50 }, /* GL_FLOAT_VEC2 */ - { 10589, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */ - { 10607, 0x00008B51 }, /* GL_FLOAT_VEC3 */ - { 10621, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */ - { 10639, 0x00008B52 }, /* GL_FLOAT_VEC4 */ - { 10653, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */ - { 10671, 0x00000B60 }, /* GL_FOG */ - { 10678, 0x00000080 }, /* GL_FOG_BIT */ - { 10689, 0x00000B66 }, /* GL_FOG_COLOR */ - { 10702, 0x00008451 }, /* GL_FOG_COORD */ - { 10715, 0x00008451 }, /* GL_FOG_COORDINATE */ - { 10733, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */ - { 10757, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - { 10796, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */ - { 10839, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - { 10871, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - { 10902, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - { 10931, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */ - { 10956, 0x00008457 }, /* GL_FOG_COORD_ARRAY */ - { 10975, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */ - { 11009, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */ - { 11036, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */ - { 11062, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */ - { 11086, 0x00008450 }, /* GL_FOG_COORD_SRC */ - { 11103, 0x00000B62 }, /* GL_FOG_DENSITY */ - { 11118, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */ - { 11142, 0x00000B64 }, /* GL_FOG_END */ - { 11153, 0x00000C54 }, /* GL_FOG_HINT */ - { 11165, 0x00000B61 }, /* GL_FOG_INDEX */ - { 11178, 0x00000B65 }, /* GL_FOG_MODE */ - { 11190, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */ - { 11209, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */ - { 11234, 0x00000B63 }, /* GL_FOG_START */ - { 11247, 0x00008452 }, /* GL_FRAGMENT_DEPTH */ - { 11265, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */ - { 11289, 0x00008B30 }, /* GL_FRAGMENT_SHADER */ - { 11308, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */ - { 11331, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - { 11366, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES */ - { 11405, 0x00008D40 }, /* GL_FRAMEBUFFER */ - { 11420, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - { 11457, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - { 11493, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - { 11534, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - { 11575, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - { 11612, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - { 11649, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ - { 11687, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - { 11725, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */ - { 11767, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES */ - { 11809, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - { 11847, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */ - { 11889, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES */ - { 11931, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - { 11966, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - { 12005, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */ - { 12054, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES */ - { 12103, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - { 12151, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */ - { 12203, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES */ - { 12255, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - { 12295, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ - { 12339, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - { 12379, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */ - { 12423, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES */ - { 12467, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */ - { 12490, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */ - { 12517, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_OES */ - { 12544, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */ - { 12568, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */ - { 12596, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_OES */ - { 12624, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */ - { 12647, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */ - { 12666, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - { 12703, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */ - { 12744, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES */ - { 12785, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS */ - { 12822, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - { 12863, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES */ - { 12904, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - { 12942, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */ - { 12984, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES */ - { 13026, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - { 13077, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - { 13115, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES */ - { 13153, 0x00008DA9 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - { 13195, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ - { 13239, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - { 13284, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */ - { 13333, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES */ - { 13382, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - { 13420, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */ - { 13462, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - { 13500, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */ - { 13542, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES */ - { 13584, 0x00008D40 }, /* GL_FRAMEBUFFER_OES */ - { 13603, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - { 13635, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */ - { 13660, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */ - { 13687, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */ - { 13718, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_OES */ - { 13749, 0x00000404 }, /* GL_FRONT */ - { 13758, 0x00000408 }, /* GL_FRONT_AND_BACK */ - { 13776, 0x00000B46 }, /* GL_FRONT_FACE */ - { 13790, 0x00000400 }, /* GL_FRONT_LEFT */ - { 13804, 0x00000401 }, /* GL_FRONT_RIGHT */ - { 13819, 0x00008006 }, /* GL_FUNC_ADD */ - { 13831, 0x00008006 }, /* GL_FUNC_ADD_EXT */ - { 13847, 0x00008006 }, /* GL_FUNC_ADD_OES */ - { 13863, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */ - { 13888, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */ - { 13917, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_OES */ - { 13946, 0x0000800A }, /* GL_FUNC_SUBTRACT */ - { 13963, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */ - { 13984, 0x0000800A }, /* GL_FUNC_SUBTRACT_OES */ - { 14005, 0x00008191 }, /* GL_GENERATE_MIPMAP */ - { 14024, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */ - { 14048, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */ - { 14077, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */ - { 14101, 0x00008DDB }, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - { 14128, 0x00008DDC }, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - { 14156, 0x00008DD9 }, /* GL_GEOMETRY_SHADER_ARB */ - { 14179, 0x00008DDA }, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - { 14208, 0x00000206 }, /* GL_GEQUAL */ - { 14218, 0x00000204 }, /* GL_GREATER */ - { 14229, 0x00001904 }, /* GL_GREEN */ - { 14238, 0x00000D19 }, /* GL_GREEN_BIAS */ - { 14252, 0x00000D53 }, /* GL_GREEN_BITS */ - { 14266, 0x00000D18 }, /* GL_GREEN_SCALE */ - { 14281, 0x0000140B }, /* GL_HALF_FLOAT */ - { 14295, 0x00008D61 }, /* GL_HALF_FLOAT_OES */ - { 14313, 0x00008DF2 }, /* GL_HIGH_FLOAT */ - { 14327, 0x00008DF5 }, /* GL_HIGH_INT */ - { 14339, 0x00008000 }, /* GL_HINT_BIT */ - { 14351, 0x00008024 }, /* GL_HISTOGRAM */ - { 14364, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ - { 14388, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ - { 14416, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ - { 14439, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ - { 14466, 0x00008024 }, /* GL_HISTOGRAM_EXT */ - { 14483, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ - { 14503, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ - { 14527, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ - { 14551, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ - { 14579, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - { 14607, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ - { 14639, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ - { 14661, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ - { 14687, 0x0000802D }, /* GL_HISTOGRAM_SINK */ - { 14705, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ - { 14727, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ - { 14746, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ - { 14769, 0x0000862A }, /* GL_IDENTITY_NV */ - { 14784, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ - { 14804, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ - { 14840, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - { 14880, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ - { 14914, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - { 14952, 0x00001E02 }, /* GL_INCR */ - { 14960, 0x00008507 }, /* GL_INCR_WRAP */ - { 14973, 0x00008507 }, /* GL_INCR_WRAP_EXT */ - { 14990, 0x00008222 }, /* GL_INDEX */ - { 14999, 0x00008077 }, /* GL_INDEX_ARRAY */ - { 15014, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - { 15044, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ - { 15078, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ - { 15101, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ - { 15123, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ - { 15143, 0x00000D51 }, /* GL_INDEX_BITS */ - { 15157, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ - { 15178, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ - { 15196, 0x00000C30 }, /* GL_INDEX_MODE */ - { 15210, 0x00000D13 }, /* GL_INDEX_OFFSET */ - { 15226, 0x00000D12 }, /* GL_INDEX_SHIFT */ - { 15241, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ - { 15260, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ - { 15279, 0x00001404 }, /* GL_INT */ - { 15286, 0x00008049 }, /* GL_INTENSITY */ - { 15299, 0x0000804C }, /* GL_INTENSITY12 */ - { 15314, 0x0000804C }, /* GL_INTENSITY12_EXT */ - { 15333, 0x0000804D }, /* GL_INTENSITY16 */ - { 15348, 0x0000804D }, /* GL_INTENSITY16_EXT */ - { 15367, 0x0000804A }, /* GL_INTENSITY4 */ - { 15381, 0x0000804A }, /* GL_INTENSITY4_EXT */ - { 15399, 0x0000804B }, /* GL_INTENSITY8 */ - { 15413, 0x0000804B }, /* GL_INTENSITY8_EXT */ - { 15431, 0x00008049 }, /* GL_INTENSITY_EXT */ - { 15448, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS_EXT */ - { 15475, 0x00008575 }, /* GL_INTERPOLATE */ - { 15490, 0x00008575 }, /* GL_INTERPOLATE_ARB */ - { 15509, 0x00008575 }, /* GL_INTERPOLATE_EXT */ - { 15528, 0x00008DF7 }, /* GL_INT_10_10_10_2_OES */ - { 15550, 0x00008B53 }, /* GL_INT_VEC2 */ - { 15562, 0x00008B53 }, /* GL_INT_VEC2_ARB */ - { 15578, 0x00008B54 }, /* GL_INT_VEC3 */ - { 15590, 0x00008B54 }, /* GL_INT_VEC3_ARB */ - { 15606, 0x00008B55 }, /* GL_INT_VEC4 */ - { 15618, 0x00008B55 }, /* GL_INT_VEC4_ARB */ - { 15634, 0x00000500 }, /* GL_INVALID_ENUM */ - { 15650, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - { 15683, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ - { 15720, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_OES */ - { 15757, 0x00000502 }, /* GL_INVALID_OPERATION */ - { 15778, 0x00000501 }, /* GL_INVALID_VALUE */ - { 15795, 0x0000862B }, /* GL_INVERSE_NV */ - { 15809, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ - { 15833, 0x0000150A }, /* GL_INVERT */ - { 15843, 0x00001E00 }, /* GL_KEEP */ - { 15851, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ - { 15877, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ - { 15907, 0x00000406 }, /* GL_LEFT */ - { 15915, 0x00000203 }, /* GL_LEQUAL */ - { 15925, 0x00000201 }, /* GL_LESS */ - { 15933, 0x00004000 }, /* GL_LIGHT0 */ - { 15943, 0x00004001 }, /* GL_LIGHT1 */ - { 15953, 0x00004002 }, /* GL_LIGHT2 */ - { 15963, 0x00004003 }, /* GL_LIGHT3 */ - { 15973, 0x00004004 }, /* GL_LIGHT4 */ - { 15983, 0x00004005 }, /* GL_LIGHT5 */ - { 15993, 0x00004006 }, /* GL_LIGHT6 */ - { 16003, 0x00004007 }, /* GL_LIGHT7 */ - { 16013, 0x00000B50 }, /* GL_LIGHTING */ - { 16025, 0x00000040 }, /* GL_LIGHTING_BIT */ - { 16041, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ - { 16064, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - { 16093, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ - { 16126, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - { 16154, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ - { 16178, 0x00001B01 }, /* GL_LINE */ - { 16186, 0x00002601 }, /* GL_LINEAR */ - { 16196, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ - { 16218, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - { 16248, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - { 16279, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ - { 16303, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ - { 16328, 0x00000001 }, /* GL_LINES */ - { 16337, 0x0000000A }, /* GL_LINES_ADJACENCY_ARB */ - { 16360, 0x00000004 }, /* GL_LINE_BIT */ - { 16372, 0x00000002 }, /* GL_LINE_LOOP */ - { 16385, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ - { 16405, 0x00000B20 }, /* GL_LINE_SMOOTH */ - { 16420, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ - { 16440, 0x00000B24 }, /* GL_LINE_STIPPLE */ - { 16456, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ - { 16480, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ - { 16503, 0x00000003 }, /* GL_LINE_STRIP */ - { 16517, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY_ARB */ - { 16545, 0x00000702 }, /* GL_LINE_TOKEN */ - { 16559, 0x00000B21 }, /* GL_LINE_WIDTH */ - { 16573, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ - { 16599, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ - { 16619, 0x00008B82 }, /* GL_LINK_STATUS */ - { 16634, 0x00000B32 }, /* GL_LIST_BASE */ - { 16647, 0x00020000 }, /* GL_LIST_BIT */ - { 16659, 0x00000B33 }, /* GL_LIST_INDEX */ - { 16673, 0x00000B30 }, /* GL_LIST_MODE */ - { 16686, 0x00000101 }, /* GL_LOAD */ - { 16694, 0x00000BF1 }, /* GL_LOGIC_OP */ - { 16706, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ - { 16723, 0x00008CA1 }, /* GL_LOWER_LEFT */ - { 16737, 0x00008DF0 }, /* GL_LOW_FLOAT */ - { 16750, 0x00008DF3 }, /* GL_LOW_INT */ - { 16761, 0x00001909 }, /* GL_LUMINANCE */ - { 16774, 0x00008041 }, /* GL_LUMINANCE12 */ - { 16789, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ - { 16812, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ - { 16839, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ - { 16861, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ - { 16887, 0x00008041 }, /* GL_LUMINANCE12_EXT */ - { 16906, 0x00008042 }, /* GL_LUMINANCE16 */ - { 16921, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ - { 16944, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ - { 16971, 0x00008042 }, /* GL_LUMINANCE16_EXT */ - { 16990, 0x0000803F }, /* GL_LUMINANCE4 */ - { 17004, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ - { 17025, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ - { 17050, 0x0000803F }, /* GL_LUMINANCE4_EXT */ - { 17068, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ - { 17089, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ - { 17114, 0x00008040 }, /* GL_LUMINANCE8 */ - { 17128, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ - { 17149, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ - { 17174, 0x00008040 }, /* GL_LUMINANCE8_EXT */ - { 17192, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ - { 17211, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ - { 17227, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ - { 17247, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ - { 17269, 0x00000D91 }, /* GL_MAP1_INDEX */ - { 17283, 0x00000D92 }, /* GL_MAP1_NORMAL */ - { 17298, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ - { 17322, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ - { 17346, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ - { 17370, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ - { 17394, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ - { 17411, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ - { 17428, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - { 17456, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - { 17485, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - { 17514, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - { 17543, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - { 17572, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - { 17601, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - { 17630, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - { 17658, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - { 17686, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - { 17714, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - { 17742, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - { 17770, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - { 17798, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - { 17826, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - { 17854, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - { 17882, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ - { 17898, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ - { 17918, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ - { 17940, 0x00000DB1 }, /* GL_MAP2_INDEX */ - { 17954, 0x00000DB2 }, /* GL_MAP2_NORMAL */ - { 17969, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ - { 17993, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ - { 18017, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ - { 18041, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ - { 18065, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ - { 18082, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ - { 18099, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - { 18127, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - { 18156, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - { 18185, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - { 18214, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - { 18243, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - { 18272, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - { 18301, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - { 18329, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - { 18357, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - { 18385, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - { 18413, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - { 18441, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - { 18469, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ - { 18497, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - { 18525, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - { 18553, 0x00000D10 }, /* GL_MAP_COLOR */ - { 18566, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ - { 18592, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ - { 18621, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ - { 18649, 0x00000001 }, /* GL_MAP_READ_BIT */ - { 18665, 0x00000D11 }, /* GL_MAP_STENCIL */ - { 18680, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ - { 18706, 0x00000002 }, /* GL_MAP_WRITE_BIT */ - { 18723, 0x000088C0 }, /* GL_MATRIX0_ARB */ - { 18738, 0x00008630 }, /* GL_MATRIX0_NV */ - { 18752, 0x000088CA }, /* GL_MATRIX10_ARB */ - { 18768, 0x000088CB }, /* GL_MATRIX11_ARB */ - { 18784, 0x000088CC }, /* GL_MATRIX12_ARB */ - { 18800, 0x000088CD }, /* GL_MATRIX13_ARB */ - { 18816, 0x000088CE }, /* GL_MATRIX14_ARB */ - { 18832, 0x000088CF }, /* GL_MATRIX15_ARB */ - { 18848, 0x000088D0 }, /* GL_MATRIX16_ARB */ - { 18864, 0x000088D1 }, /* GL_MATRIX17_ARB */ - { 18880, 0x000088D2 }, /* GL_MATRIX18_ARB */ - { 18896, 0x000088D3 }, /* GL_MATRIX19_ARB */ - { 18912, 0x000088C1 }, /* GL_MATRIX1_ARB */ - { 18927, 0x00008631 }, /* GL_MATRIX1_NV */ - { 18941, 0x000088D4 }, /* GL_MATRIX20_ARB */ - { 18957, 0x000088D5 }, /* GL_MATRIX21_ARB */ - { 18973, 0x000088D6 }, /* GL_MATRIX22_ARB */ - { 18989, 0x000088D7 }, /* GL_MATRIX23_ARB */ - { 19005, 0x000088D8 }, /* GL_MATRIX24_ARB */ - { 19021, 0x000088D9 }, /* GL_MATRIX25_ARB */ - { 19037, 0x000088DA }, /* GL_MATRIX26_ARB */ - { 19053, 0x000088DB }, /* GL_MATRIX27_ARB */ - { 19069, 0x000088DC }, /* GL_MATRIX28_ARB */ - { 19085, 0x000088DD }, /* GL_MATRIX29_ARB */ - { 19101, 0x000088C2 }, /* GL_MATRIX2_ARB */ - { 19116, 0x00008632 }, /* GL_MATRIX2_NV */ - { 19130, 0x000088DE }, /* GL_MATRIX30_ARB */ - { 19146, 0x000088DF }, /* GL_MATRIX31_ARB */ - { 19162, 0x000088C3 }, /* GL_MATRIX3_ARB */ - { 19177, 0x00008633 }, /* GL_MATRIX3_NV */ - { 19191, 0x000088C4 }, /* GL_MATRIX4_ARB */ - { 19206, 0x00008634 }, /* GL_MATRIX4_NV */ - { 19220, 0x000088C5 }, /* GL_MATRIX5_ARB */ - { 19235, 0x00008635 }, /* GL_MATRIX5_NV */ - { 19249, 0x000088C6 }, /* GL_MATRIX6_ARB */ - { 19264, 0x00008636 }, /* GL_MATRIX6_NV */ - { 19278, 0x000088C7 }, /* GL_MATRIX7_ARB */ - { 19293, 0x00008637 }, /* GL_MATRIX7_NV */ - { 19307, 0x000088C8 }, /* GL_MATRIX8_ARB */ - { 19322, 0x000088C9 }, /* GL_MATRIX9_ARB */ - { 19337, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ - { 19363, 0x00008B9E }, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - { 19404, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_OES */ - { 19430, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - { 19464, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_OES */ - { 19498, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - { 19529, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_OES */ - { 19560, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - { 19593, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_OES */ - { 19626, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - { 19657, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_OES */ - { 19688, 0x00000BA0 }, /* GL_MATRIX_MODE */ - { 19703, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ - { 19725, 0x00008840 }, /* GL_MATRIX_PALETTE_OES */ - { 19747, 0x00008008 }, /* GL_MAX */ - { 19754, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ - { 19777, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE_OES */ - { 19804, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - { 19836, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ - { 19862, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - { 19895, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - { 19921, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 19955, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ - { 19974, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ - { 19999, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ - { 20028, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - { 20060, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 20096, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - { 20132, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ - { 20172, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ - { 20198, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ - { 20228, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ - { 20253, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ - { 20282, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - { 20311, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ - { 20344, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES */ - { 20377, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ - { 20397, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ - { 20421, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ - { 20445, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ - { 20469, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ - { 20494, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ - { 20512, 0x00008008 }, /* GL_MAX_EXT */ - { 20523, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - { 20558, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ - { 20597, 0x00008DFD }, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - { 20629, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ - { 20665, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ - { 20705, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ - { 20749, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ - { 20788, 0x00008DDD }, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - { 20827, 0x00000D31 }, /* GL_MAX_LIGHTS */ - { 20841, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ - { 20861, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - { 20899, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - { 20928, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ - { 20952, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ - { 20980, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_OES */ - { 21008, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ - { 21031, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 21068, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 21104, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - { 21131, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - { 21160, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - { 21194, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ - { 21230, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - { 21257, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - { 21289, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - { 21325, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - { 21354, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - { 21383, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ - { 21411, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - { 21449, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 21493, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 21536, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 21570, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 21609, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 21646, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 21684, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 21727, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 21770, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - { 21800, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - { 21831, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 21867, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 21903, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ - { 21933, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ - { 21967, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ - { 22000, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ - { 22025, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ - { 22054, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_OES */ - { 22083, 0x00008D57 }, /* GL_MAX_SAMPLES */ - { 22098, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ - { 22117, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - { 22144, 0x00008504 }, /* GL_MAX_SHININESS_NV */ - { 22164, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ - { 22188, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ - { 22210, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ - { 22236, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - { 22263, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ - { 22294, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ - { 22318, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS_EXT */ - { 22346, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - { 22380, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ - { 22400, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ - { 22427, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ - { 22448, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ - { 22473, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ - { 22498, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - { 22533, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ - { 22586, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ - { 22633, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ - { 22683, 0x00008B4B }, /* GL_MAX_VARYING_COMPONENTS */ - { 22709, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ - { 22731, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ - { 22757, 0x00008DFC }, /* GL_MAX_VARYING_VECTORS */ - { 22780, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ - { 22802, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ - { 22828, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - { 22862, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ - { 22900, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - { 22933, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ - { 22970, 0x00008DFB }, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - { 23000, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ - { 23024, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_OES */ - { 23048, 0x00008DDE }, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - { 23085, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ - { 23106, 0x00008DF1 }, /* GL_MEDIUM_FLOAT */ - { 23122, 0x00008DF4 }, /* GL_MEDIUM_INT */ - { 23136, 0x00008007 }, /* GL_MIN */ - { 23143, 0x0000802E }, /* GL_MINMAX */ - { 23153, 0x0000802E }, /* GL_MINMAX_EXT */ - { 23167, 0x0000802F }, /* GL_MINMAX_FORMAT */ - { 23184, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ - { 23205, 0x00008030 }, /* GL_MINMAX_SINK */ - { 23220, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ - { 23239, 0x00008007 }, /* GL_MIN_EXT */ - { 23250, 0x00008370 }, /* GL_MIRRORED_REPEAT */ - { 23269, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ - { 23292, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ - { 23315, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ - { 23335, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ - { 23355, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - { 23385, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ - { 23413, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - { 23441, 0x00001700 }, /* GL_MODELVIEW */ - { 23454, 0x00001700 }, /* GL_MODELVIEW0_ARB */ - { 23472, 0x0000872A }, /* GL_MODELVIEW10_ARB */ - { 23491, 0x0000872B }, /* GL_MODELVIEW11_ARB */ - { 23510, 0x0000872C }, /* GL_MODELVIEW12_ARB */ - { 23529, 0x0000872D }, /* GL_MODELVIEW13_ARB */ - { 23548, 0x0000872E }, /* GL_MODELVIEW14_ARB */ - { 23567, 0x0000872F }, /* GL_MODELVIEW15_ARB */ - { 23586, 0x00008730 }, /* GL_MODELVIEW16_ARB */ - { 23605, 0x00008731 }, /* GL_MODELVIEW17_ARB */ - { 23624, 0x00008732 }, /* GL_MODELVIEW18_ARB */ - { 23643, 0x00008733 }, /* GL_MODELVIEW19_ARB */ - { 23662, 0x0000850A }, /* GL_MODELVIEW1_ARB */ - { 23680, 0x00008734 }, /* GL_MODELVIEW20_ARB */ - { 23699, 0x00008735 }, /* GL_MODELVIEW21_ARB */ - { 23718, 0x00008736 }, /* GL_MODELVIEW22_ARB */ - { 23737, 0x00008737 }, /* GL_MODELVIEW23_ARB */ - { 23756, 0x00008738 }, /* GL_MODELVIEW24_ARB */ - { 23775, 0x00008739 }, /* GL_MODELVIEW25_ARB */ - { 23794, 0x0000873A }, /* GL_MODELVIEW26_ARB */ - { 23813, 0x0000873B }, /* GL_MODELVIEW27_ARB */ - { 23832, 0x0000873C }, /* GL_MODELVIEW28_ARB */ - { 23851, 0x0000873D }, /* GL_MODELVIEW29_ARB */ - { 23870, 0x00008722 }, /* GL_MODELVIEW2_ARB */ - { 23888, 0x0000873E }, /* GL_MODELVIEW30_ARB */ - { 23907, 0x0000873F }, /* GL_MODELVIEW31_ARB */ - { 23926, 0x00008723 }, /* GL_MODELVIEW3_ARB */ - { 23944, 0x00008724 }, /* GL_MODELVIEW4_ARB */ - { 23962, 0x00008725 }, /* GL_MODELVIEW5_ARB */ - { 23980, 0x00008726 }, /* GL_MODELVIEW6_ARB */ - { 23998, 0x00008727 }, /* GL_MODELVIEW7_ARB */ - { 24016, 0x00008728 }, /* GL_MODELVIEW8_ARB */ - { 24034, 0x00008729 }, /* GL_MODELVIEW9_ARB */ - { 24052, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ - { 24072, 0x0000898D }, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 24114, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ - { 24141, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ - { 24166, 0x00002100 }, /* GL_MODULATE */ - { 24178, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ - { 24198, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ - { 24225, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ - { 24250, 0x00000103 }, /* GL_MULT */ - { 24258, 0x0000809D }, /* GL_MULTISAMPLE */ - { 24273, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ - { 24293, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ - { 24312, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ - { 24331, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ - { 24355, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ - { 24378, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - { 24408, 0x00002A25 }, /* GL_N3F_V3F */ - { 24419, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ - { 24439, 0x0000150E }, /* GL_NAND */ - { 24447, 0x00002600 }, /* GL_NEAREST */ - { 24458, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - { 24489, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - { 24521, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ - { 24546, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ - { 24572, 0x00000200 }, /* GL_NEVER */ - { 24581, 0x00001102 }, /* GL_NICEST */ - { 24591, 0x00000000 }, /* GL_NONE */ - { 24599, 0x00000000 }, /* GL_NONE_OES */ - { 24611, 0x00001505 }, /* GL_NOOP */ - { 24619, 0x00001508 }, /* GL_NOR */ - { 24626, 0x00000BA1 }, /* GL_NORMALIZE */ - { 24639, 0x00008075 }, /* GL_NORMAL_ARRAY */ - { 24655, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - { 24686, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ - { 24721, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ - { 24745, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ - { 24768, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ - { 24789, 0x00008511 }, /* GL_NORMAL_MAP */ - { 24803, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ - { 24821, 0x00008511 }, /* GL_NORMAL_MAP_NV */ - { 24838, 0x00008511 }, /* GL_NORMAL_MAP_OES */ - { 24856, 0x00000205 }, /* GL_NOTEQUAL */ - { 24868, 0x00000000 }, /* GL_NO_ERROR */ - { 24880, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - { 24914, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ - { 24952, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ - { 24986, 0x00008DF9 }, /* GL_NUM_SHADER_BINARY_FORMATS */ - { 25015, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ - { 25047, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ - { 25089, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ - { 25119, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ - { 25159, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ - { 25190, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ - { 25219, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ - { 25247, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ - { 25277, 0x00002401 }, /* GL_OBJECT_LINEAR */ - { 25294, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ - { 25320, 0x00002501 }, /* GL_OBJECT_PLANE */ - { 25336, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ - { 25371, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ - { 25393, 0x00009112 }, /* GL_OBJECT_TYPE */ - { 25408, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ - { 25427, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ - { 25457, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ - { 25478, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ - { 25506, 0x00000001 }, /* GL_ONE */ - { 25513, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - { 25541, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ - { 25573, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ - { 25601, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ - { 25633, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ - { 25656, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ - { 25679, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ - { 25702, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ - { 25725, 0x00008598 }, /* GL_OPERAND0_ALPHA */ - { 25743, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ - { 25765, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ - { 25787, 0x00008590 }, /* GL_OPERAND0_RGB */ - { 25803, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ - { 25823, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ - { 25843, 0x00008599 }, /* GL_OPERAND1_ALPHA */ - { 25861, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ - { 25883, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ - { 25905, 0x00008591 }, /* GL_OPERAND1_RGB */ - { 25921, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ - { 25941, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ - { 25961, 0x0000859A }, /* GL_OPERAND2_ALPHA */ - { 25979, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ - { 26001, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ - { 26023, 0x00008592 }, /* GL_OPERAND2_RGB */ - { 26039, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ - { 26059, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ - { 26079, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ - { 26100, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ - { 26119, 0x00001507 }, /* GL_OR */ - { 26125, 0x00000A01 }, /* GL_ORDER */ - { 26134, 0x0000150D }, /* GL_OR_INVERTED */ - { 26149, 0x0000150B }, /* GL_OR_REVERSE */ - { 26163, 0x00000505 }, /* GL_OUT_OF_MEMORY */ - { 26180, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ - { 26198, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ - { 26219, 0x00008758 }, /* GL_PACK_INVERT_MESA */ - { 26239, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ - { 26257, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ - { 26276, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ - { 26296, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ - { 26316, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ - { 26334, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ - { 26353, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ - { 26378, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ - { 26402, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ - { 26423, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ - { 26445, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ - { 26467, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ - { 26492, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ - { 26516, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ - { 26537, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ - { 26559, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ - { 26581, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ - { 26603, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ - { 26634, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ - { 26654, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - { 26679, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ - { 26699, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - { 26724, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ - { 26744, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - { 26769, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ - { 26789, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - { 26814, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ - { 26834, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - { 26859, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ - { 26879, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - { 26904, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ - { 26924, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - { 26949, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ - { 26969, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - { 26994, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ - { 27014, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - { 27039, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ - { 27059, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - { 27084, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ - { 27102, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ - { 27123, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ - { 27152, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ - { 27185, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ - { 27210, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ - { 27233, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - { 27264, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ - { 27299, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ - { 27326, 0x00001B00 }, /* GL_POINT */ - { 27335, 0x00000000 }, /* GL_POINTS */ - { 27345, 0x00000002 }, /* GL_POINT_BIT */ - { 27358, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ - { 27388, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ - { 27422, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ - { 27456, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ - { 27491, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ - { 27520, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ - { 27553, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ - { 27586, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ - { 27620, 0x00000B11 }, /* GL_POINT_SIZE */ - { 27634, 0x00008B9F }, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - { 27673, 0x00008B9C }, /* GL_POINT_SIZE_ARRAY_OES */ - { 27697, 0x0000898C }, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - { 27729, 0x0000898B }, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - { 27760, 0x0000898A }, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - { 27789, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ - { 27815, 0x00008127 }, /* GL_POINT_SIZE_MAX */ - { 27833, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ - { 27855, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ - { 27877, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ - { 27900, 0x00008126 }, /* GL_POINT_SIZE_MIN */ - { 27918, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ - { 27940, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ - { 27962, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ - { 27985, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ - { 28005, 0x00000B10 }, /* GL_POINT_SMOOTH */ - { 28021, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ - { 28042, 0x00008861 }, /* GL_POINT_SPRITE */ - { 28058, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ - { 28078, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ - { 28107, 0x00008861 }, /* GL_POINT_SPRITE_NV */ - { 28126, 0x00008861 }, /* GL_POINT_SPRITE_OES */ - { 28146, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ - { 28172, 0x00000701 }, /* GL_POINT_TOKEN */ - { 28187, 0x00000009 }, /* GL_POLYGON */ - { 28198, 0x00000008 }, /* GL_POLYGON_BIT */ - { 28213, 0x00000B40 }, /* GL_POLYGON_MODE */ - { 28229, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ - { 28252, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ - { 28277, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ - { 28300, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ - { 28323, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ - { 28347, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ - { 28371, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ - { 28389, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ - { 28412, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ - { 28431, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ - { 28454, 0x00000703 }, /* GL_POLYGON_TOKEN */ - { 28471, 0x00001203 }, /* GL_POSITION */ - { 28483, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - { 28515, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ - { 28551, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - { 28584, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ - { 28621, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - { 28652, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ - { 28687, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - { 28719, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ - { 28755, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - { 28788, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - { 28820, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ - { 28856, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - { 28889, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ - { 28926, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - { 28956, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ - { 28990, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - { 29021, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ - { 29056, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - { 29087, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ - { 29122, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - { 29154, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ - { 29190, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - { 29220, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ - { 29254, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - { 29285, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ - { 29320, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - { 29352, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - { 29383, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ - { 29418, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - { 29450, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ - { 29486, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ - { 29515, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ - { 29548, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ - { 29578, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ - { 29612, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - { 29651, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - { 29684, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - { 29724, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - { 29758, 0x00008578 }, /* GL_PREVIOUS */ - { 29770, 0x00008578 }, /* GL_PREVIOUS_ARB */ - { 29786, 0x00008578 }, /* GL_PREVIOUS_EXT */ - { 29802, 0x00008577 }, /* GL_PRIMARY_COLOR */ - { 29819, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ - { 29840, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ - { 29861, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED_EXT */ - { 29889, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 29922, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 29954, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ - { 29977, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS_OES */ - { 30007, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH_OES */ - { 30036, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ - { 30059, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ - { 30089, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ - { 30118, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ - { 30146, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ - { 30168, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - { 30196, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - { 30224, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ - { 30246, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ - { 30267, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 30307, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 30346, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 30376, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 30411, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 30444, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 30478, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 30517, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 30556, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ - { 30578, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ - { 30604, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ - { 30628, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE_ARB */ - { 30654, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ - { 30677, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ - { 30699, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ - { 30720, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ - { 30741, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ - { 30768, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 30800, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 30832, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - { 30867, 0x00001701 }, /* GL_PROJECTION */ - { 30881, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ - { 30902, 0x0000898E }, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 30945, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ - { 30971, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ - { 30991, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ - { 31015, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ - { 31036, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ - { 31055, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ - { 31078, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - { 31117, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - { 31155, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ - { 31175, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - { 31205, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ - { 31229, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ - { 31249, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - { 31279, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ - { 31303, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ - { 31323, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - { 31356, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ - { 31382, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ - { 31412, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - { 31443, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ - { 31473, 0x00008A1D }, /* GL_PURGEABLE_APPLE */ - { 31492, 0x00002003 }, /* GL_Q */ - { 31497, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ - { 31522, 0x00000007 }, /* GL_QUADS */ - { 31531, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - { 31575, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ - { 31623, 0x00008614 }, /* GL_QUAD_MESH_SUN */ - { 31640, 0x00000008 }, /* GL_QUAD_STRIP */ - { 31654, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - { 31684, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ - { 31711, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ - { 31733, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ - { 31759, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ - { 31779, 0x00008866 }, /* GL_QUERY_RESULT */ - { 31795, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ - { 31815, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ - { 31841, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ - { 31871, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ - { 31888, 0x00002002 }, /* GL_R */ - { 31893, 0x00002A10 }, /* GL_R3_G3_B2 */ - { 31905, 0x00008C89 }, /* GL_RASTERIZER_DISCARD_EXT */ - { 31931, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - { 31964, 0x00000C02 }, /* GL_READ_BUFFER */ - { 31979, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ - { 31999, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ - { 32027, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ - { 32059, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ - { 32083, 0x000088B8 }, /* GL_READ_ONLY */ - { 32096, 0x000088B8 }, /* GL_READ_ONLY_ARB */ - { 32113, 0x000088BA }, /* GL_READ_WRITE */ - { 32127, 0x000088BA }, /* GL_READ_WRITE_ARB */ - { 32145, 0x00001903 }, /* GL_RED */ - { 32152, 0x00008016 }, /* GL_REDUCE */ - { 32162, 0x00008016 }, /* GL_REDUCE_EXT */ - { 32176, 0x00000D15 }, /* GL_RED_BIAS */ - { 32188, 0x00000D52 }, /* GL_RED_BITS */ - { 32200, 0x00000D14 }, /* GL_RED_SCALE */ - { 32213, 0x00008512 }, /* GL_REFLECTION_MAP */ - { 32231, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ - { 32253, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ - { 32274, 0x00008512 }, /* GL_REFLECTION_MAP_OES */ - { 32296, 0x00008A19 }, /* GL_RELEASED_APPLE */ - { 32314, 0x00001C00 }, /* GL_RENDER */ - { 32324, 0x00008D41 }, /* GL_RENDERBUFFER */ - { 32340, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ - { 32367, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE_OES */ - { 32398, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ - { 32422, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ - { 32450, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_OES */ - { 32478, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ - { 32504, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE_OES */ - { 32534, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ - { 32561, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE_OES */ - { 32592, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ - { 32612, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ - { 32639, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE_OES */ - { 32670, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ - { 32693, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ - { 32720, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_OES */ - { 32747, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - { 32779, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ - { 32815, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ - { 32851, 0x00008D41 }, /* GL_RENDERBUFFER_OES */ - { 32871, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ - { 32896, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE_OES */ - { 32925, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ - { 32949, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ - { 32977, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ - { 33006, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE_OES */ - { 33039, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ - { 33061, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ - { 33087, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_OES */ - { 33113, 0x00001F01 }, /* GL_RENDERER */ - { 33125, 0x00000C40 }, /* GL_RENDER_MODE */ - { 33140, 0x00002901 }, /* GL_REPEAT */ - { 33150, 0x00001E01 }, /* GL_REPLACE */ - { 33161, 0x00008062 }, /* GL_REPLACE_EXT */ - { 33176, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ - { 33199, 0x0000803A }, /* GL_RESCALE_NORMAL */ - { 33217, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ - { 33239, 0x00008A1B }, /* GL_RETAINED_APPLE */ - { 33257, 0x00000102 }, /* GL_RETURN */ - { 33267, 0x00001907 }, /* GL_RGB */ - { 33274, 0x00008052 }, /* GL_RGB10 */ - { 33283, 0x00008059 }, /* GL_RGB10_A2 */ - { 33295, 0x00008059 }, /* GL_RGB10_A2_EXT */ - { 33311, 0x00008052 }, /* GL_RGB10_EXT */ - { 33324, 0x00008053 }, /* GL_RGB12 */ - { 33333, 0x00008053 }, /* GL_RGB12_EXT */ - { 33346, 0x00008054 }, /* GL_RGB16 */ - { 33355, 0x00008054 }, /* GL_RGB16_EXT */ - { 33368, 0x0000804E }, /* GL_RGB2_EXT */ - { 33380, 0x0000804F }, /* GL_RGB4 */ - { 33388, 0x0000804F }, /* GL_RGB4_EXT */ - { 33400, 0x000083A1 }, /* GL_RGB4_S3TC */ - { 33413, 0x00008050 }, /* GL_RGB5 */ - { 33421, 0x00008D62 }, /* GL_RGB565 */ - { 33431, 0x00008D62 }, /* GL_RGB565_OES */ - { 33445, 0x00008057 }, /* GL_RGB5_A1 */ - { 33456, 0x00008057 }, /* GL_RGB5_A1_EXT */ - { 33471, 0x00008057 }, /* GL_RGB5_A1_OES */ - { 33486, 0x00008050 }, /* GL_RGB5_EXT */ - { 33498, 0x00008051 }, /* GL_RGB8 */ - { 33506, 0x00008051 }, /* GL_RGB8_EXT */ - { 33518, 0x00008051 }, /* GL_RGB8_OES */ - { 33530, 0x00001908 }, /* GL_RGBA */ - { 33538, 0x0000805A }, /* GL_RGBA12 */ - { 33548, 0x0000805A }, /* GL_RGBA12_EXT */ - { 33562, 0x0000805B }, /* GL_RGBA16 */ - { 33572, 0x0000805B }, /* GL_RGBA16_EXT */ - { 33586, 0x00008055 }, /* GL_RGBA2 */ - { 33595, 0x00008055 }, /* GL_RGBA2_EXT */ - { 33608, 0x00008056 }, /* GL_RGBA4 */ - { 33617, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ - { 33636, 0x00008056 }, /* GL_RGBA4_EXT */ - { 33649, 0x00008056 }, /* GL_RGBA4_OES */ - { 33662, 0x000083A3 }, /* GL_RGBA4_S3TC */ - { 33676, 0x00008058 }, /* GL_RGBA8 */ - { 33685, 0x00008058 }, /* GL_RGBA8_EXT */ - { 33698, 0x00008058 }, /* GL_RGBA8_OES */ - { 33711, 0x00008F97 }, /* GL_RGBA8_SNORM */ - { 33726, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ - { 33744, 0x00000C31 }, /* GL_RGBA_MODE */ - { 33757, 0x000083A2 }, /* GL_RGBA_S3TC */ - { 33770, 0x00008F93 }, /* GL_RGBA_SNORM */ - { 33784, 0x000083A0 }, /* GL_RGB_S3TC */ - { 33796, 0x00008573 }, /* GL_RGB_SCALE */ - { 33809, 0x00008573 }, /* GL_RGB_SCALE_ARB */ - { 33826, 0x00008573 }, /* GL_RGB_SCALE_EXT */ - { 33843, 0x00000407 }, /* GL_RIGHT */ - { 33852, 0x00002000 }, /* GL_S */ - { 33857, 0x00008B5D }, /* GL_SAMPLER_1D */ - { 33871, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ - { 33892, 0x00008B5E }, /* GL_SAMPLER_2D */ - { 33906, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ - { 33927, 0x00008B5F }, /* GL_SAMPLER_3D */ - { 33941, 0x00008B5F }, /* GL_SAMPLER_3D_OES */ - { 33959, 0x00008B60 }, /* GL_SAMPLER_CUBE */ - { 33975, 0x000080A9 }, /* GL_SAMPLES */ - { 33986, 0x000086B4 }, /* GL_SAMPLES_3DFX */ - { 34002, 0x000080A9 }, /* GL_SAMPLES_ARB */ - { 34017, 0x00008914 }, /* GL_SAMPLES_PASSED */ - { 34035, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ - { 34057, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - { 34085, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ - { 34117, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ - { 34140, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ - { 34167, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ - { 34185, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ - { 34208, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ - { 34230, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ - { 34249, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ - { 34272, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ - { 34298, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ - { 34328, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ - { 34353, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ - { 34382, 0x00080000 }, /* GL_SCISSOR_BIT */ - { 34397, 0x00000C10 }, /* GL_SCISSOR_BOX */ - { 34412, 0x00000C11 }, /* GL_SCISSOR_TEST */ - { 34428, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ - { 34453, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - { 34493, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 34537, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - { 34570, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - { 34600, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - { 34632, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - { 34662, 0x00001C02 }, /* GL_SELECT */ - { 34672, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ - { 34700, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ - { 34725, 0x00008012 }, /* GL_SEPARABLE_2D */ - { 34741, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS_EXT */ - { 34765, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ - { 34792, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ - { 34823, 0x0000150F }, /* GL_SET */ - { 34830, 0x00008DF8 }, /* GL_SHADER_BINARY_FORMATS */ - { 34855, 0x00008DFA }, /* GL_SHADER_COMPILER */ - { 34874, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ - { 34895, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ - { 34919, 0x00008B4F }, /* GL_SHADER_TYPE */ - { 34934, 0x00000B54 }, /* GL_SHADE_MODEL */ - { 34949, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ - { 34977, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ - { 35000, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - { 35030, 0x00001601 }, /* GL_SHININESS */ - { 35043, 0x00001402 }, /* GL_SHORT */ - { 35052, 0x00009119 }, /* GL_SIGNALED */ - { 35064, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ - { 35085, 0x000081F9 }, /* GL_SINGLE_COLOR */ - { 35101, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ - { 35121, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ - { 35140, 0x00008C46 }, /* GL_SLUMINANCE */ - { 35154, 0x00008C47 }, /* GL_SLUMINANCE8 */ - { 35169, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ - { 35191, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ - { 35211, 0x00001D01 }, /* GL_SMOOTH */ - { 35221, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ - { 35254, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ - { 35281, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ - { 35314, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ - { 35341, 0x00008588 }, /* GL_SOURCE0_ALPHA */ - { 35358, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ - { 35379, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ - { 35400, 0x00008580 }, /* GL_SOURCE0_RGB */ - { 35415, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ - { 35434, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ - { 35453, 0x00008589 }, /* GL_SOURCE1_ALPHA */ - { 35470, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ - { 35491, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ - { 35512, 0x00008581 }, /* GL_SOURCE1_RGB */ - { 35527, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ - { 35546, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ - { 35565, 0x0000858A }, /* GL_SOURCE2_ALPHA */ - { 35582, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ - { 35603, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ - { 35624, 0x00008582 }, /* GL_SOURCE2_RGB */ - { 35639, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ - { 35658, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ - { 35677, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ - { 35697, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ - { 35715, 0x00001202 }, /* GL_SPECULAR */ - { 35727, 0x00002402 }, /* GL_SPHERE_MAP */ - { 35741, 0x00001206 }, /* GL_SPOT_CUTOFF */ - { 35756, 0x00001204 }, /* GL_SPOT_DIRECTION */ - { 35774, 0x00001205 }, /* GL_SPOT_EXPONENT */ - { 35791, 0x00008588 }, /* GL_SRC0_ALPHA */ - { 35805, 0x00008580 }, /* GL_SRC0_RGB */ - { 35817, 0x00008589 }, /* GL_SRC1_ALPHA */ - { 35831, 0x00008581 }, /* GL_SRC1_RGB */ - { 35843, 0x0000858A }, /* GL_SRC2_ALPHA */ - { 35857, 0x00008582 }, /* GL_SRC2_RGB */ - { 35869, 0x00000302 }, /* GL_SRC_ALPHA */ - { 35882, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ - { 35904, 0x00000300 }, /* GL_SRC_COLOR */ - { 35917, 0x00008C40 }, /* GL_SRGB */ - { 35925, 0x00008C41 }, /* GL_SRGB8 */ - { 35934, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ - { 35950, 0x00008C42 }, /* GL_SRGB_ALPHA */ - { 35964, 0x00000503 }, /* GL_STACK_OVERFLOW */ - { 35982, 0x00000504 }, /* GL_STACK_UNDERFLOW */ - { 36001, 0x000088E6 }, /* GL_STATIC_COPY */ - { 36016, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ - { 36035, 0x000088E4 }, /* GL_STATIC_DRAW */ - { 36050, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ - { 36069, 0x000088E5 }, /* GL_STATIC_READ */ - { 36084, 0x000088E5 }, /* GL_STATIC_READ_ARB */ - { 36103, 0x00001802 }, /* GL_STENCIL */ - { 36114, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ - { 36136, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ - { 36162, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_OES */ - { 36188, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ - { 36209, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ - { 36234, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ - { 36255, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ - { 36280, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - { 36312, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ - { 36348, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - { 36380, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ - { 36416, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ - { 36436, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ - { 36463, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ - { 36489, 0x00000D57 }, /* GL_STENCIL_BITS */ - { 36505, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ - { 36527, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ - { 36550, 0x00000B94 }, /* GL_STENCIL_FAIL */ - { 36566, 0x00000B92 }, /* GL_STENCIL_FUNC */ - { 36582, 0x00001901 }, /* GL_STENCIL_INDEX */ - { 36599, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ - { 36617, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ - { 36636, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ - { 36659, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ - { 36681, 0x00008D46 }, /* GL_STENCIL_INDEX1_OES */ - { 36703, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ - { 36721, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ - { 36743, 0x00008D47 }, /* GL_STENCIL_INDEX4_OES */ - { 36765, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ - { 36783, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ - { 36805, 0x00008D48 }, /* GL_STENCIL_INDEX8_OES */ - { 36827, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ - { 36848, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ - { 36875, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ - { 36902, 0x00000B97 }, /* GL_STENCIL_REF */ - { 36917, 0x00000B90 }, /* GL_STENCIL_TEST */ - { 36933, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - { 36962, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ - { 36984, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ - { 37005, 0x00000C33 }, /* GL_STEREO */ - { 37015, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ - { 37039, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ - { 37064, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ - { 37088, 0x000088E2 }, /* GL_STREAM_COPY */ - { 37103, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ - { 37122, 0x000088E0 }, /* GL_STREAM_DRAW */ - { 37137, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ - { 37156, 0x000088E1 }, /* GL_STREAM_READ */ - { 37171, 0x000088E1 }, /* GL_STREAM_READ_ARB */ - { 37190, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ - { 37207, 0x000084E7 }, /* GL_SUBTRACT */ - { 37219, 0x000084E7 }, /* GL_SUBTRACT_ARB */ - { 37235, 0x00009113 }, /* GL_SYNC_CONDITION */ - { 37253, 0x00009116 }, /* GL_SYNC_FENCE */ - { 37267, 0x00009115 }, /* GL_SYNC_FLAGS */ - { 37281, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ - { 37308, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - { 37338, 0x00009114 }, /* GL_SYNC_STATUS */ - { 37353, 0x00002001 }, /* GL_T */ - { 37358, 0x00002A2A }, /* GL_T2F_C3F_V3F */ - { 37373, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ - { 37392, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ - { 37408, 0x00002A2B }, /* GL_T2F_N3F_V3F */ - { 37423, 0x00002A27 }, /* GL_T2F_V3F */ - { 37434, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ - { 37453, 0x00002A28 }, /* GL_T4F_V4F */ - { 37464, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ - { 37487, 0x00001702 }, /* GL_TEXTURE */ - { 37498, 0x000084C0 }, /* GL_TEXTURE0 */ - { 37510, 0x000084C0 }, /* GL_TEXTURE0_ARB */ - { 37526, 0x000084C1 }, /* GL_TEXTURE1 */ - { 37538, 0x000084CA }, /* GL_TEXTURE10 */ - { 37551, 0x000084CA }, /* GL_TEXTURE10_ARB */ - { 37568, 0x000084CB }, /* GL_TEXTURE11 */ - { 37581, 0x000084CB }, /* GL_TEXTURE11_ARB */ - { 37598, 0x000084CC }, /* GL_TEXTURE12 */ - { 37611, 0x000084CC }, /* GL_TEXTURE12_ARB */ - { 37628, 0x000084CD }, /* GL_TEXTURE13 */ - { 37641, 0x000084CD }, /* GL_TEXTURE13_ARB */ - { 37658, 0x000084CE }, /* GL_TEXTURE14 */ - { 37671, 0x000084CE }, /* GL_TEXTURE14_ARB */ - { 37688, 0x000084CF }, /* GL_TEXTURE15 */ - { 37701, 0x000084CF }, /* GL_TEXTURE15_ARB */ - { 37718, 0x000084D0 }, /* GL_TEXTURE16 */ - { 37731, 0x000084D0 }, /* GL_TEXTURE16_ARB */ - { 37748, 0x000084D1 }, /* GL_TEXTURE17 */ - { 37761, 0x000084D1 }, /* GL_TEXTURE17_ARB */ - { 37778, 0x000084D2 }, /* GL_TEXTURE18 */ - { 37791, 0x000084D2 }, /* GL_TEXTURE18_ARB */ - { 37808, 0x000084D3 }, /* GL_TEXTURE19 */ - { 37821, 0x000084D3 }, /* GL_TEXTURE19_ARB */ - { 37838, 0x000084C1 }, /* GL_TEXTURE1_ARB */ - { 37854, 0x000084C2 }, /* GL_TEXTURE2 */ - { 37866, 0x000084D4 }, /* GL_TEXTURE20 */ - { 37879, 0x000084D4 }, /* GL_TEXTURE20_ARB */ - { 37896, 0x000084D5 }, /* GL_TEXTURE21 */ - { 37909, 0x000084D5 }, /* GL_TEXTURE21_ARB */ - { 37926, 0x000084D6 }, /* GL_TEXTURE22 */ - { 37939, 0x000084D6 }, /* GL_TEXTURE22_ARB */ - { 37956, 0x000084D7 }, /* GL_TEXTURE23 */ - { 37969, 0x000084D7 }, /* GL_TEXTURE23_ARB */ - { 37986, 0x000084D8 }, /* GL_TEXTURE24 */ - { 37999, 0x000084D8 }, /* GL_TEXTURE24_ARB */ - { 38016, 0x000084D9 }, /* GL_TEXTURE25 */ - { 38029, 0x000084D9 }, /* GL_TEXTURE25_ARB */ - { 38046, 0x000084DA }, /* GL_TEXTURE26 */ - { 38059, 0x000084DA }, /* GL_TEXTURE26_ARB */ - { 38076, 0x000084DB }, /* GL_TEXTURE27 */ - { 38089, 0x000084DB }, /* GL_TEXTURE27_ARB */ - { 38106, 0x000084DC }, /* GL_TEXTURE28 */ - { 38119, 0x000084DC }, /* GL_TEXTURE28_ARB */ - { 38136, 0x000084DD }, /* GL_TEXTURE29 */ - { 38149, 0x000084DD }, /* GL_TEXTURE29_ARB */ - { 38166, 0x000084C2 }, /* GL_TEXTURE2_ARB */ - { 38182, 0x000084C3 }, /* GL_TEXTURE3 */ - { 38194, 0x000084DE }, /* GL_TEXTURE30 */ - { 38207, 0x000084DE }, /* GL_TEXTURE30_ARB */ - { 38224, 0x000084DF }, /* GL_TEXTURE31 */ - { 38237, 0x000084DF }, /* GL_TEXTURE31_ARB */ - { 38254, 0x000084C3 }, /* GL_TEXTURE3_ARB */ - { 38270, 0x000084C4 }, /* GL_TEXTURE4 */ - { 38282, 0x000084C4 }, /* GL_TEXTURE4_ARB */ - { 38298, 0x000084C5 }, /* GL_TEXTURE5 */ - { 38310, 0x000084C5 }, /* GL_TEXTURE5_ARB */ - { 38326, 0x000084C6 }, /* GL_TEXTURE6 */ - { 38338, 0x000084C6 }, /* GL_TEXTURE6_ARB */ - { 38354, 0x000084C7 }, /* GL_TEXTURE7 */ - { 38366, 0x000084C7 }, /* GL_TEXTURE7_ARB */ - { 38382, 0x000084C8 }, /* GL_TEXTURE8 */ - { 38394, 0x000084C8 }, /* GL_TEXTURE8_ARB */ - { 38410, 0x000084C9 }, /* GL_TEXTURE9 */ - { 38422, 0x000084C9 }, /* GL_TEXTURE9_ARB */ - { 38438, 0x00000DE0 }, /* GL_TEXTURE_1D */ - { 38452, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ - { 38476, 0x00000DE1 }, /* GL_TEXTURE_2D */ - { 38490, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ - { 38514, 0x0000806F }, /* GL_TEXTURE_3D */ - { 38528, 0x0000806F }, /* GL_TEXTURE_3D_OES */ - { 38546, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ - { 38568, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ - { 38594, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ - { 38616, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ - { 38638, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - { 38670, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ - { 38692, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - { 38724, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ - { 38746, 0x0000806A }, /* GL_TEXTURE_BINDING_3D_OES */ - { 38772, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ - { 38800, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ - { 38832, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_OES */ - { 38864, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - { 38897, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ - { 38929, 0x00040000 }, /* GL_TEXTURE_BIT */ - { 38944, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ - { 38965, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ - { 38990, 0x00001005 }, /* GL_TEXTURE_BORDER */ - { 39008, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ - { 39032, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - { 39063, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - { 39093, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - { 39123, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - { 39158, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - { 39189, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 39227, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ - { 39254, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - { 39286, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - { 39320, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ - { 39344, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ - { 39372, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ - { 39396, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ - { 39424, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - { 39457, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ - { 39481, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ - { 39503, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ - { 39525, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ - { 39551, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ - { 39585, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - { 39618, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ - { 39655, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ - { 39683, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ - { 39715, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ - { 39738, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - { 39776, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ - { 39818, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - { 39849, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - { 39877, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - { 39907, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - { 39935, 0x00008B9D }, /* GL_TEXTURE_CROP_RECT_OES */ - { 39960, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ - { 39980, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ - { 40004, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - { 40035, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ - { 40070, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES */ - { 40105, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - { 40136, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ - { 40171, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES */ - { 40206, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - { 40237, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ - { 40272, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES */ - { 40307, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_OES */ - { 40331, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - { 40362, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ - { 40397, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES */ - { 40432, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - { 40463, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ - { 40498, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES */ - { 40533, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - { 40564, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ - { 40599, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ - { 40634, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - { 40663, 0x00008071 }, /* GL_TEXTURE_DEPTH */ - { 40680, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ - { 40702, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ - { 40728, 0x00002300 }, /* GL_TEXTURE_ENV */ - { 40743, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ - { 40764, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ - { 40784, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ - { 40810, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL_EXT */ - { 40840, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ - { 40860, 0x00002500 }, /* GL_TEXTURE_GEN_MODE_OES */ - { 40884, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ - { 40901, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ - { 40918, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ - { 40935, 0x00008D60 }, /* GL_TEXTURE_GEN_STR_OES */ - { 40958, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ - { 40975, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ - { 41000, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ - { 41022, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ - { 41048, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ - { 41066, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ - { 41092, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ - { 41118, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ - { 41148, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ - { 41175, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ - { 41200, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ - { 41220, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ - { 41244, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - { 41271, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - { 41298, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - { 41325, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ - { 41351, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ - { 41381, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ - { 41403, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ - { 41421, 0x0000898F }, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 41461, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - { 41491, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - { 41519, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - { 41547, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - { 41575, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ - { 41596, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ - { 41615, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ - { 41637, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ - { 41656, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ - { 41676, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - { 41706, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - { 41737, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ - { 41762, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ - { 41786, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ - { 41806, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ - { 41830, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ - { 41850, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ - { 41873, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ - { 41897, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ - { 41925, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - { 41955, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ - { 41980, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - { 42014, 0x00001000 }, /* GL_TEXTURE_WIDTH */ - { 42031, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ - { 42049, 0x00008072 }, /* GL_TEXTURE_WRAP_R_OES */ - { 42071, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ - { 42089, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ - { 42107, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ - { 42126, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ - { 42146, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ - { 42165, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - { 42194, 0x00001000 }, /* GL_TRANSFORM_BIT */ - { 42211, 0x00008E22 }, /* GL_TRANSFORM_FEEDBACK */ - { 42233, 0x00008E25 }, /* GL_TRANSFORM_FEEDBACK_BINDING */ - { 42263, 0x00008E24 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - { 42299, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ - { 42340, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ - { 42373, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ - { 42411, 0x00008E23 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - { 42447, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ - { 42485, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ - { 42524, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ - { 42569, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ - { 42604, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ - { 42649, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ - { 42675, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ - { 42705, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - { 42737, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - { 42767, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ - { 42801, 0x0000862C }, /* GL_TRANSPOSE_NV */ - { 42817, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - { 42848, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ - { 42883, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - { 42911, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ - { 42943, 0x00000004 }, /* GL_TRIANGLES */ - { 42956, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY_ARB */ - { 42983, 0x00000006 }, /* GL_TRIANGLE_FAN */ - { 42999, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ - { 43020, 0x00000005 }, /* GL_TRIANGLE_STRIP */ - { 43038, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ - { 43070, 0x00000001 }, /* GL_TRUE */ - { 43078, 0x00008A1C }, /* GL_UNDEFINED_APPLE */ - { 43097, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ - { 43117, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ - { 43140, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ - { 43160, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ - { 43181, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ - { 43203, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ - { 43225, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ - { 43245, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ - { 43266, 0x00009118 }, /* GL_UNSIGNALED */ - { 43280, 0x00001401 }, /* GL_UNSIGNED_BYTE */ - { 43297, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - { 43324, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ - { 43347, 0x00001405 }, /* GL_UNSIGNED_INT */ - { 43363, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ - { 43390, 0x00008DF6 }, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - { 43421, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ - { 43442, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ - { 43467, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ - { 43491, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_OES */ - { 43516, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - { 43547, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV_EXT */ - { 43582, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ - { 43606, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - { 43634, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ - { 43657, 0x00001403 }, /* GL_UNSIGNED_SHORT */ - { 43675, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - { 43705, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT */ - { 43739, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - { 43765, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - { 43795, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT */ - { 43829, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - { 43855, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ - { 43879, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - { 43907, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - { 43935, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ - { 43962, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - { 43994, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ - { 44025, 0x00008CA2 }, /* GL_UPPER_LEFT */ - { 44039, 0x00002A20 }, /* GL_V2F */ - { 44046, 0x00002A21 }, /* GL_V3F */ - { 44053, 0x00008B83 }, /* GL_VALIDATE_STATUS */ - { 44072, 0x00001F00 }, /* GL_VENDOR */ - { 44082, 0x00001F02 }, /* GL_VERSION */ - { 44093, 0x00008074 }, /* GL_VERTEX_ARRAY */ - { 44109, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ - { 44133, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ - { 44163, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - { 44194, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ - { 44229, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ - { 44253, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ - { 44274, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ - { 44297, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ - { 44318, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - { 44345, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - { 44373, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - { 44401, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - { 44429, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - { 44457, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - { 44485, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - { 44513, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - { 44540, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - { 44567, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - { 44594, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - { 44621, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - { 44648, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - { 44675, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - { 44702, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - { 44729, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - { 44756, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - { 44794, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ - { 44836, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - { 44867, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ - { 44902, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - { 44936, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ - { 44974, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - { 45005, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ - { 45040, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - { 45068, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ - { 45100, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - { 45130, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ - { 45164, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - { 45192, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ - { 45224, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ - { 45244, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ - { 45266, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ - { 45295, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ - { 45316, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - { 45345, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ - { 45378, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ - { 45410, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - { 45437, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ - { 45468, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - { 45498, 0x00008B31 }, /* GL_VERTEX_SHADER */ - { 45515, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ - { 45536, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ - { 45563, 0x00000BA2 }, /* GL_VIEWPORT */ - { 45575, 0x00000800 }, /* GL_VIEWPORT_BIT */ - { 45591, 0x00008A1A }, /* GL_VOLATILE_APPLE */ - { 45609, 0x0000911D }, /* GL_WAIT_FAILED */ - { 45624, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ - { 45644, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - { 45675, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ - { 45710, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_OES */ - { 45745, 0x000086AD }, /* GL_WEIGHT_ARRAY_OES */ - { 45765, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - { 45793, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_OES */ - { 45821, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - { 45846, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_OES */ - { 45871, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - { 45898, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_OES */ - { 45925, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - { 45950, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_OES */ - { 45975, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ - { 45999, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ - { 46018, 0x000088B9 }, /* GL_WRITE_ONLY */ - { 46032, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ - { 46050, 0x000088B9 }, /* GL_WRITE_ONLY_OES */ - { 46068, 0x00001506 }, /* GL_XOR */ - { 46075, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ - { 46094, 0x00008757 }, /* GL_YCBCR_MESA */ - { 46108, 0x00000000 }, /* GL_ZERO */ - { 46116, 0x00000D16 }, /* GL_ZOOM_X */ - { 46126, 0x00000D17 }, /* GL_ZOOM_Y */ -}; - -static const unsigned reduced_enums[1423] = -{ - 500, /* GL_FALSE */ - 760, /* GL_LINES */ - 763, /* GL_LINE_LOOP */ - 770, /* GL_LINE_STRIP */ - 1934, /* GL_TRIANGLES */ - 1938, /* GL_TRIANGLE_STRIP */ - 1936, /* GL_TRIANGLE_FAN */ - 1393, /* GL_QUADS */ - 1397, /* GL_QUAD_STRIP */ - 1273, /* GL_POLYGON */ - 761, /* GL_LINES_ADJACENCY_ARB */ - 771, /* GL_LINE_STRIP_ADJACENCY_ARB */ - 1935, /* GL_TRIANGLES_ADJACENCY_ARB */ - 1939, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ - 1285, /* GL_POLYGON_STIPPLE_BIT */ - 1228, /* GL_PIXEL_MODE_BIT */ - 747, /* GL_LIGHTING_BIT */ - 532, /* GL_FOG_BIT */ - 8, /* GL_ACCUM */ - 781, /* GL_LOAD */ - 1471, /* GL_RETURN */ - 1096, /* GL_MULT */ - 23, /* GL_ADD */ - 1112, /* GL_NEVER */ - 737, /* GL_LESS */ - 490, /* GL_EQUAL */ - 736, /* GL_LEQUAL */ - 649, /* GL_GREATER */ - 1129, /* GL_NOTEQUAL */ - 648, /* GL_GEQUAL */ - 47, /* GL_ALWAYS */ - 1622, /* GL_SRC_COLOR */ - 1161, /* GL_ONE_MINUS_SRC_COLOR */ - 1620, /* GL_SRC_ALPHA */ - 1160, /* GL_ONE_MINUS_SRC_ALPHA */ - 469, /* GL_DST_ALPHA */ - 1158, /* GL_ONE_MINUS_DST_ALPHA */ - 470, /* GL_DST_COLOR */ - 1159, /* GL_ONE_MINUS_DST_COLOR */ - 1621, /* GL_SRC_ALPHA_SATURATE */ - 629, /* GL_FRONT_LEFT */ - 630, /* GL_FRONT_RIGHT */ - 69, /* GL_BACK_LEFT */ - 70, /* GL_BACK_RIGHT */ - 626, /* GL_FRONT */ - 68, /* GL_BACK */ - 735, /* GL_LEFT */ - 1519, /* GL_RIGHT */ - 627, /* GL_FRONT_AND_BACK */ - 63, /* GL_AUX0 */ - 64, /* GL_AUX1 */ - 65, /* GL_AUX2 */ - 66, /* GL_AUX3 */ - 723, /* GL_INVALID_ENUM */ - 728, /* GL_INVALID_VALUE */ - 727, /* GL_INVALID_OPERATION */ - 1627, /* GL_STACK_OVERFLOW */ - 1628, /* GL_STACK_UNDERFLOW */ - 1186, /* GL_OUT_OF_MEMORY */ - 724, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - 0, /* GL_2D */ - 2, /* GL_3D */ - 3, /* GL_3D_COLOR */ - 4, /* GL_3D_COLOR_TEXTURE */ - 6, /* GL_4D_COLOR_TEXTURE */ - 1206, /* GL_PASS_THROUGH_TOKEN */ - 1272, /* GL_POINT_TOKEN */ - 772, /* GL_LINE_TOKEN */ - 1286, /* GL_POLYGON_TOKEN */ - 75, /* GL_BITMAP_TOKEN */ - 468, /* GL_DRAW_PIXEL_TOKEN */ - 315, /* GL_COPY_PIXEL_TOKEN */ - 764, /* GL_LINE_RESET_TOKEN */ - 493, /* GL_EXP */ - 494, /* GL_EXP2 */ - 352, /* GL_CW */ - 137, /* GL_CCW */ - 158, /* GL_COEFF */ - 1183, /* GL_ORDER */ - 405, /* GL_DOMAIN */ - 325, /* GL_CURRENT_COLOR */ - 328, /* GL_CURRENT_INDEX */ - 334, /* GL_CURRENT_NORMAL */ - 348, /* GL_CURRENT_TEXTURE_COORDS */ - 340, /* GL_CURRENT_RASTER_COLOR */ - 342, /* GL_CURRENT_RASTER_INDEX */ - 346, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - 343, /* GL_CURRENT_RASTER_POSITION */ - 344, /* GL_CURRENT_RASTER_POSITION_VALID */ - 341, /* GL_CURRENT_RASTER_DISTANCE */ - 1264, /* GL_POINT_SMOOTH */ - 1248, /* GL_POINT_SIZE */ - 1263, /* GL_POINT_SIZE_RANGE */ - 1254, /* GL_POINT_SIZE_GRANULARITY */ - 765, /* GL_LINE_SMOOTH */ - 773, /* GL_LINE_WIDTH */ - 775, /* GL_LINE_WIDTH_RANGE */ - 774, /* GL_LINE_WIDTH_GRANULARITY */ - 767, /* GL_LINE_STIPPLE */ - 768, /* GL_LINE_STIPPLE_PATTERN */ - 769, /* GL_LINE_STIPPLE_REPEAT */ - 780, /* GL_LIST_MODE */ - 963, /* GL_MAX_LIST_NESTING */ - 777, /* GL_LIST_BASE */ - 779, /* GL_LIST_INDEX */ - 1275, /* GL_POLYGON_MODE */ - 1282, /* GL_POLYGON_SMOOTH */ - 1284, /* GL_POLYGON_STIPPLE */ - 479, /* GL_EDGE_FLAG */ - 318, /* GL_CULL_FACE */ - 319, /* GL_CULL_FACE_MODE */ - 628, /* GL_FRONT_FACE */ - 746, /* GL_LIGHTING */ - 751, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - 752, /* GL_LIGHT_MODEL_TWO_SIDE */ - 748, /* GL_LIGHT_MODEL_AMBIENT */ - 1569, /* GL_SHADE_MODEL */ - 206, /* GL_COLOR_MATERIAL_FACE */ - 207, /* GL_COLOR_MATERIAL_PARAMETER */ - 205, /* GL_COLOR_MATERIAL */ - 531, /* GL_FOG */ - 553, /* GL_FOG_INDEX */ - 549, /* GL_FOG_DENSITY */ - 557, /* GL_FOG_START */ - 551, /* GL_FOG_END */ - 554, /* GL_FOG_MODE */ - 533, /* GL_FOG_COLOR */ - 390, /* GL_DEPTH_RANGE */ - 399, /* GL_DEPTH_TEST */ - 402, /* GL_DEPTH_WRITEMASK */ - 375, /* GL_DEPTH_CLEAR_VALUE */ - 389, /* GL_DEPTH_FUNC */ - 12, /* GL_ACCUM_CLEAR_VALUE */ - 1671, /* GL_STENCIL_TEST */ - 1652, /* GL_STENCIL_CLEAR_VALUE */ - 1654, /* GL_STENCIL_FUNC */ - 1673, /* GL_STENCIL_VALUE_MASK */ - 1653, /* GL_STENCIL_FAIL */ - 1668, /* GL_STENCIL_PASS_DEPTH_FAIL */ - 1669, /* GL_STENCIL_PASS_DEPTH_PASS */ - 1670, /* GL_STENCIL_REF */ - 1674, /* GL_STENCIL_WRITEMASK */ - 922, /* GL_MATRIX_MODE */ - 1118, /* GL_NORMALIZE */ - 2037, /* GL_VIEWPORT */ - 1091, /* GL_MODELVIEW_STACK_DEPTH */ - 1370, /* GL_PROJECTION_STACK_DEPTH */ - 1896, /* GL_TEXTURE_STACK_DEPTH */ - 1088, /* GL_MODELVIEW_MATRIX */ - 1368, /* GL_PROJECTION_MATRIX */ - 1878, /* GL_TEXTURE_MATRIX */ - 61, /* GL_ATTRIB_STACK_DEPTH */ - 148, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - 43, /* GL_ALPHA_TEST */ - 44, /* GL_ALPHA_TEST_FUNC */ - 45, /* GL_ALPHA_TEST_REF */ - 404, /* GL_DITHER */ - 79, /* GL_BLEND_DST */ - 93, /* GL_BLEND_SRC */ - 76, /* GL_BLEND */ - 783, /* GL_LOGIC_OP_MODE */ - 695, /* GL_INDEX_LOGIC_OP */ - 204, /* GL_COLOR_LOGIC_OP */ - 67, /* GL_AUX_BUFFERS */ - 415, /* GL_DRAW_BUFFER */ - 1412, /* GL_READ_BUFFER */ - 1547, /* GL_SCISSOR_BOX */ - 1548, /* GL_SCISSOR_TEST */ - 694, /* GL_INDEX_CLEAR_VALUE */ - 699, /* GL_INDEX_WRITEMASK */ - 201, /* GL_COLOR_CLEAR_VALUE */ - 243, /* GL_COLOR_WRITEMASK */ - 696, /* GL_INDEX_MODE */ - 1512, /* GL_RGBA_MODE */ - 414, /* GL_DOUBLEBUFFER */ - 1675, /* GL_STEREO */ - 1463, /* GL_RENDER_MODE */ - 1207, /* GL_PERSPECTIVE_CORRECTION_HINT */ - 1265, /* GL_POINT_SMOOTH_HINT */ - 766, /* GL_LINE_SMOOTH_HINT */ - 1283, /* GL_POLYGON_SMOOTH_HINT */ - 552, /* GL_FOG_HINT */ - 1858, /* GL_TEXTURE_GEN_S */ - 1860, /* GL_TEXTURE_GEN_T */ - 1857, /* GL_TEXTURE_GEN_R */ - 1856, /* GL_TEXTURE_GEN_Q */ - 1220, /* GL_PIXEL_MAP_I_TO_I */ - 1226, /* GL_PIXEL_MAP_S_TO_S */ - 1222, /* GL_PIXEL_MAP_I_TO_R */ - 1218, /* GL_PIXEL_MAP_I_TO_G */ - 1216, /* GL_PIXEL_MAP_I_TO_B */ - 1214, /* GL_PIXEL_MAP_I_TO_A */ - 1224, /* GL_PIXEL_MAP_R_TO_R */ - 1212, /* GL_PIXEL_MAP_G_TO_G */ - 1210, /* GL_PIXEL_MAP_B_TO_B */ - 1208, /* GL_PIXEL_MAP_A_TO_A */ - 1221, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - 1227, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - 1223, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - 1219, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - 1217, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - 1215, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - 1225, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - 1213, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - 1211, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - 1209, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - 1949, /* GL_UNPACK_SWAP_BYTES */ - 1944, /* GL_UNPACK_LSB_FIRST */ - 1945, /* GL_UNPACK_ROW_LENGTH */ - 1948, /* GL_UNPACK_SKIP_ROWS */ - 1947, /* GL_UNPACK_SKIP_PIXELS */ - 1942, /* GL_UNPACK_ALIGNMENT */ - 1195, /* GL_PACK_SWAP_BYTES */ - 1190, /* GL_PACK_LSB_FIRST */ - 1191, /* GL_PACK_ROW_LENGTH */ - 1194, /* GL_PACK_SKIP_ROWS */ - 1193, /* GL_PACK_SKIP_PIXELS */ - 1187, /* GL_PACK_ALIGNMENT */ - 863, /* GL_MAP_COLOR */ - 868, /* GL_MAP_STENCIL */ - 698, /* GL_INDEX_SHIFT */ - 697, /* GL_INDEX_OFFSET */ - 1426, /* GL_RED_SCALE */ - 1424, /* GL_RED_BIAS */ - 2063, /* GL_ZOOM_X */ - 2064, /* GL_ZOOM_Y */ - 653, /* GL_GREEN_SCALE */ - 651, /* GL_GREEN_BIAS */ - 101, /* GL_BLUE_SCALE */ - 99, /* GL_BLUE_BIAS */ - 42, /* GL_ALPHA_SCALE */ - 40, /* GL_ALPHA_BIAS */ - 391, /* GL_DEPTH_SCALE */ - 368, /* GL_DEPTH_BIAS */ - 952, /* GL_MAX_EVAL_ORDER */ - 962, /* GL_MAX_LIGHTS */ - 933, /* GL_MAX_CLIP_PLANES */ - 1013, /* GL_MAX_TEXTURE_SIZE */ - 969, /* GL_MAX_PIXEL_MAP_TABLE */ - 929, /* GL_MAX_ATTRIB_STACK_DEPTH */ - 965, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - 966, /* GL_MAX_NAME_STACK_DEPTH */ - 995, /* GL_MAX_PROJECTION_STACK_DEPTH */ - 1014, /* GL_MAX_TEXTURE_STACK_DEPTH */ - 1036, /* GL_MAX_VIEWPORT_DIMS */ - 930, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - 1685, /* GL_SUBPIXEL_BITS */ - 693, /* GL_INDEX_BITS */ - 1425, /* GL_RED_BITS */ - 652, /* GL_GREEN_BITS */ - 100, /* GL_BLUE_BITS */ - 41, /* GL_ALPHA_BITS */ - 369, /* GL_DEPTH_BITS */ - 1650, /* GL_STENCIL_BITS */ - 14, /* GL_ACCUM_RED_BITS */ - 13, /* GL_ACCUM_GREEN_BITS */ - 10, /* GL_ACCUM_BLUE_BITS */ - 9, /* GL_ACCUM_ALPHA_BITS */ - 1105, /* GL_NAME_STACK_DEPTH */ - 62, /* GL_AUTO_NORMAL */ - 809, /* GL_MAP1_COLOR_4 */ - 812, /* GL_MAP1_INDEX */ - 813, /* GL_MAP1_NORMAL */ - 814, /* GL_MAP1_TEXTURE_COORD_1 */ - 815, /* GL_MAP1_TEXTURE_COORD_2 */ - 816, /* GL_MAP1_TEXTURE_COORD_3 */ - 817, /* GL_MAP1_TEXTURE_COORD_4 */ - 818, /* GL_MAP1_VERTEX_3 */ - 819, /* GL_MAP1_VERTEX_4 */ - 836, /* GL_MAP2_COLOR_4 */ - 839, /* GL_MAP2_INDEX */ - 840, /* GL_MAP2_NORMAL */ - 841, /* GL_MAP2_TEXTURE_COORD_1 */ - 842, /* GL_MAP2_TEXTURE_COORD_2 */ - 843, /* GL_MAP2_TEXTURE_COORD_3 */ - 844, /* GL_MAP2_TEXTURE_COORD_4 */ - 845, /* GL_MAP2_VERTEX_3 */ - 846, /* GL_MAP2_VERTEX_4 */ - 810, /* GL_MAP1_GRID_DOMAIN */ - 811, /* GL_MAP1_GRID_SEGMENTS */ - 837, /* GL_MAP2_GRID_DOMAIN */ - 838, /* GL_MAP2_GRID_SEGMENTS */ - 1768, /* GL_TEXTURE_1D */ - 1770, /* GL_TEXTURE_2D */ - 503, /* GL_FEEDBACK_BUFFER_POINTER */ - 504, /* GL_FEEDBACK_BUFFER_SIZE */ - 505, /* GL_FEEDBACK_BUFFER_TYPE */ - 1557, /* GL_SELECTION_BUFFER_POINTER */ - 1558, /* GL_SELECTION_BUFFER_SIZE */ - 1902, /* GL_TEXTURE_WIDTH */ - 1864, /* GL_TEXTURE_HEIGHT */ - 1808, /* GL_TEXTURE_COMPONENTS */ - 1792, /* GL_TEXTURE_BORDER_COLOR */ - 1791, /* GL_TEXTURE_BORDER */ - 406, /* GL_DONT_CARE */ - 501, /* GL_FASTEST */ - 1113, /* GL_NICEST */ - 48, /* GL_AMBIENT */ - 403, /* GL_DIFFUSE */ - 1609, /* GL_SPECULAR */ - 1287, /* GL_POSITION */ - 1612, /* GL_SPOT_DIRECTION */ - 1613, /* GL_SPOT_EXPONENT */ - 1611, /* GL_SPOT_CUTOFF */ - 288, /* GL_CONSTANT_ATTENUATION */ - 755, /* GL_LINEAR_ATTENUATION */ - 1392, /* GL_QUADRATIC_ATTENUATION */ - 257, /* GL_COMPILE */ - 258, /* GL_COMPILE_AND_EXECUTE */ - 132, /* GL_BYTE */ - 1951, /* GL_UNSIGNED_BYTE */ - 1574, /* GL_SHORT */ - 1966, /* GL_UNSIGNED_SHORT */ - 701, /* GL_INT */ - 1954, /* GL_UNSIGNED_INT */ - 512, /* GL_FLOAT */ - 1, /* GL_2_BYTES */ - 5, /* GL_3_BYTES */ - 7, /* GL_4_BYTES */ - 413, /* GL_DOUBLE */ - 654, /* GL_HALF_FLOAT */ - 509, /* GL_FIXED */ - 144, /* GL_CLEAR */ - 50, /* GL_AND */ - 52, /* GL_AND_REVERSE */ - 313, /* GL_COPY */ - 51, /* GL_AND_INVERTED */ - 1116, /* GL_NOOP */ - 2059, /* GL_XOR */ - 1182, /* GL_OR */ - 1117, /* GL_NOR */ - 491, /* GL_EQUIV */ - 731, /* GL_INVERT */ - 1185, /* GL_OR_REVERSE */ - 314, /* GL_COPY_INVERTED */ - 1184, /* GL_OR_INVERTED */ - 1106, /* GL_NAND */ - 1563, /* GL_SET */ - 488, /* GL_EMISSION */ - 1573, /* GL_SHININESS */ - 49, /* GL_AMBIENT_AND_DIFFUSE */ - 203, /* GL_COLOR_INDEXES */ - 1055, /* GL_MODELVIEW */ - 1367, /* GL_PROJECTION */ - 1703, /* GL_TEXTURE */ - 159, /* GL_COLOR */ - 361, /* GL_DEPTH */ - 1635, /* GL_STENCIL */ - 202, /* GL_COLOR_INDEX */ - 1655, /* GL_STENCIL_INDEX */ - 376, /* GL_DEPTH_COMPONENT */ - 1421, /* GL_RED */ - 650, /* GL_GREEN */ - 98, /* GL_BLUE */ - 31, /* GL_ALPHA */ - 1472, /* GL_RGB */ - 1495, /* GL_RGBA */ - 787, /* GL_LUMINANCE */ - 808, /* GL_LUMINANCE_ALPHA */ - 74, /* GL_BITMAP */ - 1237, /* GL_POINT */ - 753, /* GL_LINE */ - 506, /* GL_FILL */ - 1432, /* GL_RENDER */ - 502, /* GL_FEEDBACK */ - 1556, /* GL_SELECT */ - 511, /* GL_FLAT */ - 1584, /* GL_SMOOTH */ - 732, /* GL_KEEP */ - 1465, /* GL_REPLACE */ - 683, /* GL_INCR */ - 357, /* GL_DECR */ - 1983, /* GL_VENDOR */ - 1462, /* GL_RENDERER */ - 1984, /* GL_VERSION */ - 495, /* GL_EXTENSIONS */ - 1520, /* GL_S */ - 1694, /* GL_T */ - 1408, /* GL_R */ - 1391, /* GL_Q */ - 1092, /* GL_MODULATE */ - 356, /* GL_DECAL */ - 1851, /* GL_TEXTURE_ENV_MODE */ - 1850, /* GL_TEXTURE_ENV_COLOR */ - 1849, /* GL_TEXTURE_ENV */ - 496, /* GL_EYE_LINEAR */ - 1143, /* GL_OBJECT_LINEAR */ - 1610, /* GL_SPHERE_MAP */ - 1854, /* GL_TEXTURE_GEN_MODE */ - 1145, /* GL_OBJECT_PLANE */ - 497, /* GL_EYE_PLANE */ - 1107, /* GL_NEAREST */ - 754, /* GL_LINEAR */ - 1111, /* GL_NEAREST_MIPMAP_NEAREST */ - 759, /* GL_LINEAR_MIPMAP_NEAREST */ - 1110, /* GL_NEAREST_MIPMAP_LINEAR */ - 758, /* GL_LINEAR_MIPMAP_LINEAR */ - 1877, /* GL_TEXTURE_MAG_FILTER */ - 1886, /* GL_TEXTURE_MIN_FILTER */ - 1905, /* GL_TEXTURE_WRAP_S */ - 1906, /* GL_TEXTURE_WRAP_T */ - 138, /* GL_CLAMP */ - 1464, /* GL_REPEAT */ - 1281, /* GL_POLYGON_OFFSET_UNITS */ - 1280, /* GL_POLYGON_OFFSET_POINT */ - 1279, /* GL_POLYGON_OFFSET_LINE */ - 1409, /* GL_R3_G3_B2 */ - 1980, /* GL_V2F */ - 1981, /* GL_V3F */ - 135, /* GL_C4UB_V2F */ - 136, /* GL_C4UB_V3F */ - 133, /* GL_C3F_V3F */ - 1104, /* GL_N3F_V3F */ - 134, /* GL_C4F_N3F_V3F */ - 1699, /* GL_T2F_V3F */ - 1701, /* GL_T4F_V4F */ - 1697, /* GL_T2F_C4UB_V3F */ - 1695, /* GL_T2F_C3F_V3F */ - 1698, /* GL_T2F_N3F_V3F */ - 1696, /* GL_T2F_C4F_N3F_V3F */ - 1700, /* GL_T4F_C4F_N3F_V4F */ - 151, /* GL_CLIP_PLANE0 */ - 152, /* GL_CLIP_PLANE1 */ - 153, /* GL_CLIP_PLANE2 */ - 154, /* GL_CLIP_PLANE3 */ - 155, /* GL_CLIP_PLANE4 */ - 156, /* GL_CLIP_PLANE5 */ - 738, /* GL_LIGHT0 */ - 739, /* GL_LIGHT1 */ - 740, /* GL_LIGHT2 */ - 741, /* GL_LIGHT3 */ - 742, /* GL_LIGHT4 */ - 743, /* GL_LIGHT5 */ - 744, /* GL_LIGHT6 */ - 745, /* GL_LIGHT7 */ - 658, /* GL_HINT_BIT */ - 290, /* GL_CONSTANT_COLOR */ - 1156, /* GL_ONE_MINUS_CONSTANT_COLOR */ - 285, /* GL_CONSTANT_ALPHA */ - 1154, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - 77, /* GL_BLEND_COLOR */ - 631, /* GL_FUNC_ADD */ - 1039, /* GL_MIN */ - 925, /* GL_MAX */ - 84, /* GL_BLEND_EQUATION */ - 637, /* GL_FUNC_SUBTRACT */ - 634, /* GL_FUNC_REVERSE_SUBTRACT */ - 293, /* GL_CONVOLUTION_1D */ - 294, /* GL_CONVOLUTION_2D */ - 1559, /* GL_SEPARABLE_2D */ - 297, /* GL_CONVOLUTION_BORDER_MODE */ - 301, /* GL_CONVOLUTION_FILTER_SCALE */ - 299, /* GL_CONVOLUTION_FILTER_BIAS */ - 1422, /* GL_REDUCE */ - 303, /* GL_CONVOLUTION_FORMAT */ - 307, /* GL_CONVOLUTION_WIDTH */ - 305, /* GL_CONVOLUTION_HEIGHT */ - 942, /* GL_MAX_CONVOLUTION_WIDTH */ - 940, /* GL_MAX_CONVOLUTION_HEIGHT */ - 1320, /* GL_POST_CONVOLUTION_RED_SCALE */ - 1316, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - 1311, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - 1307, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - 1318, /* GL_POST_CONVOLUTION_RED_BIAS */ - 1314, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - 1309, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - 1305, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - 659, /* GL_HISTOGRAM */ - 1374, /* GL_PROXY_HISTOGRAM */ - 675, /* GL_HISTOGRAM_WIDTH */ - 665, /* GL_HISTOGRAM_FORMAT */ - 671, /* GL_HISTOGRAM_RED_SIZE */ - 667, /* GL_HISTOGRAM_GREEN_SIZE */ - 662, /* GL_HISTOGRAM_BLUE_SIZE */ - 660, /* GL_HISTOGRAM_ALPHA_SIZE */ - 669, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - 673, /* GL_HISTOGRAM_SINK */ - 1040, /* GL_MINMAX */ - 1042, /* GL_MINMAX_FORMAT */ - 1044, /* GL_MINMAX_SINK */ - 1702, /* GL_TABLE_TOO_LARGE_EXT */ - 1953, /* GL_UNSIGNED_BYTE_3_3_2 */ - 1969, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - 1972, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - 1963, /* GL_UNSIGNED_INT_8_8_8_8 */ - 1955, /* GL_UNSIGNED_INT_10_10_10_2 */ - 1278, /* GL_POLYGON_OFFSET_FILL */ - 1277, /* GL_POLYGON_OFFSET_FACTOR */ - 1276, /* GL_POLYGON_OFFSET_BIAS */ - 1468, /* GL_RESCALE_NORMAL */ - 36, /* GL_ALPHA4 */ - 38, /* GL_ALPHA8 */ - 32, /* GL_ALPHA12 */ - 34, /* GL_ALPHA16 */ - 798, /* GL_LUMINANCE4 */ - 804, /* GL_LUMINANCE8 */ - 788, /* GL_LUMINANCE12 */ - 794, /* GL_LUMINANCE16 */ - 799, /* GL_LUMINANCE4_ALPHA4 */ - 802, /* GL_LUMINANCE6_ALPHA2 */ - 805, /* GL_LUMINANCE8_ALPHA8 */ - 791, /* GL_LUMINANCE12_ALPHA4 */ - 789, /* GL_LUMINANCE12_ALPHA12 */ - 795, /* GL_LUMINANCE16_ALPHA16 */ - 702, /* GL_INTENSITY */ - 707, /* GL_INTENSITY4 */ - 709, /* GL_INTENSITY8 */ - 703, /* GL_INTENSITY12 */ - 705, /* GL_INTENSITY16 */ - 1481, /* GL_RGB2_EXT */ - 1482, /* GL_RGB4 */ - 1485, /* GL_RGB5 */ - 1492, /* GL_RGB8 */ - 1473, /* GL_RGB10 */ - 1477, /* GL_RGB12 */ - 1479, /* GL_RGB16 */ - 1500, /* GL_RGBA2 */ - 1502, /* GL_RGBA4 */ - 1488, /* GL_RGB5_A1 */ - 1507, /* GL_RGBA8 */ - 1474, /* GL_RGB10_A2 */ - 1496, /* GL_RGBA12 */ - 1498, /* GL_RGBA16 */ - 1893, /* GL_TEXTURE_RED_SIZE */ - 1862, /* GL_TEXTURE_GREEN_SIZE */ - 1789, /* GL_TEXTURE_BLUE_SIZE */ - 1774, /* GL_TEXTURE_ALPHA_SIZE */ - 1875, /* GL_TEXTURE_LUMINANCE_SIZE */ - 1866, /* GL_TEXTURE_INTENSITY_SIZE */ - 1466, /* GL_REPLACE_EXT */ - 1378, /* GL_PROXY_TEXTURE_1D */ - 1381, /* GL_PROXY_TEXTURE_2D */ - 1900, /* GL_TEXTURE_TOO_LARGE_EXT */ - 1888, /* GL_TEXTURE_PRIORITY */ - 1895, /* GL_TEXTURE_RESIDENT */ - 1777, /* GL_TEXTURE_BINDING_1D */ - 1779, /* GL_TEXTURE_BINDING_2D */ - 1781, /* GL_TEXTURE_BINDING_3D */ - 1192, /* GL_PACK_SKIP_IMAGES */ - 1188, /* GL_PACK_IMAGE_HEIGHT */ - 1946, /* GL_UNPACK_SKIP_IMAGES */ - 1943, /* GL_UNPACK_IMAGE_HEIGHT */ - 1772, /* GL_TEXTURE_3D */ - 1384, /* GL_PROXY_TEXTURE_3D */ - 1846, /* GL_TEXTURE_DEPTH */ - 1903, /* GL_TEXTURE_WRAP_R */ - 926, /* GL_MAX_3D_TEXTURE_SIZE */ - 1985, /* GL_VERTEX_ARRAY */ - 1119, /* GL_NORMAL_ARRAY */ - 160, /* GL_COLOR_ARRAY */ - 687, /* GL_INDEX_ARRAY */ - 1816, /* GL_TEXTURE_COORD_ARRAY */ - 480, /* GL_EDGE_FLAG_ARRAY */ - 1991, /* GL_VERTEX_ARRAY_SIZE */ - 1993, /* GL_VERTEX_ARRAY_TYPE */ - 1992, /* GL_VERTEX_ARRAY_STRIDE */ - 1124, /* GL_NORMAL_ARRAY_TYPE */ - 1123, /* GL_NORMAL_ARRAY_STRIDE */ - 164, /* GL_COLOR_ARRAY_SIZE */ - 166, /* GL_COLOR_ARRAY_TYPE */ - 165, /* GL_COLOR_ARRAY_STRIDE */ - 692, /* GL_INDEX_ARRAY_TYPE */ - 691, /* GL_INDEX_ARRAY_STRIDE */ - 1820, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - 1822, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - 1821, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - 484, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - 1990, /* GL_VERTEX_ARRAY_POINTER */ - 1122, /* GL_NORMAL_ARRAY_POINTER */ - 163, /* GL_COLOR_ARRAY_POINTER */ - 690, /* GL_INDEX_ARRAY_POINTER */ - 1819, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - 483, /* GL_EDGE_FLAG_ARRAY_POINTER */ - 1097, /* GL_MULTISAMPLE */ - 1533, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - 1535, /* GL_SAMPLE_ALPHA_TO_ONE */ - 1540, /* GL_SAMPLE_COVERAGE */ - 1537, /* GL_SAMPLE_BUFFERS */ - 1528, /* GL_SAMPLES */ - 1544, /* GL_SAMPLE_COVERAGE_VALUE */ - 1542, /* GL_SAMPLE_COVERAGE_INVERT */ - 208, /* GL_COLOR_MATRIX */ - 210, /* GL_COLOR_MATRIX_STACK_DEPTH */ - 936, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - 1303, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - 1299, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - 1294, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - 1290, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - 1301, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - 1297, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - 1292, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - 1288, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - 1799, /* GL_TEXTURE_COLOR_TABLE_SGI */ - 1385, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - 1801, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - 82, /* GL_BLEND_DST_RGB */ - 96, /* GL_BLEND_SRC_RGB */ - 80, /* GL_BLEND_DST_ALPHA */ - 94, /* GL_BLEND_SRC_ALPHA */ - 214, /* GL_COLOR_TABLE */ - 1313, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - 1296, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - 1373, /* GL_PROXY_COLOR_TABLE */ - 1377, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - 1376, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - 238, /* GL_COLOR_TABLE_SCALE */ - 218, /* GL_COLOR_TABLE_BIAS */ - 223, /* GL_COLOR_TABLE_FORMAT */ - 240, /* GL_COLOR_TABLE_WIDTH */ - 235, /* GL_COLOR_TABLE_RED_SIZE */ - 226, /* GL_COLOR_TABLE_GREEN_SIZE */ - 220, /* GL_COLOR_TABLE_BLUE_SIZE */ - 215, /* GL_COLOR_TABLE_ALPHA_SIZE */ - 232, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - 229, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - 71, /* GL_BGR */ - 72, /* GL_BGRA */ - 951, /* GL_MAX_ELEMENTS_VERTICES */ - 950, /* GL_MAX_ELEMENTS_INDICES */ - 1865, /* GL_TEXTURE_INDEX_SIZE_EXT */ - 157, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - 1259, /* GL_POINT_SIZE_MIN */ - 1255, /* GL_POINT_SIZE_MAX */ - 1244, /* GL_POINT_FADE_THRESHOLD_SIZE */ - 1240, /* GL_POINT_DISTANCE_ATTENUATION */ - 139, /* GL_CLAMP_TO_BORDER */ - 142, /* GL_CLAMP_TO_EDGE */ - 1887, /* GL_TEXTURE_MIN_LOD */ - 1885, /* GL_TEXTURE_MAX_LOD */ - 1776, /* GL_TEXTURE_BASE_LEVEL */ - 1884, /* GL_TEXTURE_MAX_LEVEL */ - 678, /* GL_IGNORE_BORDER_HP */ - 289, /* GL_CONSTANT_BORDER_HP */ - 1467, /* GL_REPLICATE_BORDER_HP */ - 295, /* GL_CONVOLUTION_BORDER_COLOR */ - 1151, /* GL_OCCLUSION_TEST_HP */ - 1152, /* GL_OCCLUSION_TEST_RESULT_HP */ - 756, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - 1793, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - 1795, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - 1797, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - 1798, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1796, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - 1794, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - 931, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - 932, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1323, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - 1325, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - 1322, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - 1324, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - 1873, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - 1874, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - 1872, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - 640, /* GL_GENERATE_MIPMAP */ - 641, /* GL_GENERATE_MIPMAP_HINT */ - 555, /* GL_FOG_OFFSET_SGIX */ - 556, /* GL_FOG_OFFSET_VALUE_SGIX */ - 1807, /* GL_TEXTURE_COMPARE_SGIX */ - 1806, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - 1869, /* GL_TEXTURE_LEQUAL_R_SGIX */ - 1861, /* GL_TEXTURE_GEQUAL_R_SGIX */ - 377, /* GL_DEPTH_COMPONENT16 */ - 381, /* GL_DEPTH_COMPONENT24 */ - 385, /* GL_DEPTH_COMPONENT32 */ - 320, /* GL_CULL_VERTEX_EXT */ - 322, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - 321, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - 2055, /* GL_WRAP_BORDER_SUN */ - 1800, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - 749, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - 1577, /* GL_SINGLE_COLOR */ - 1561, /* GL_SEPARATE_SPECULAR_COLOR */ - 1572, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - 567, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - 568, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - 578, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - 570, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - 566, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - 565, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - 569, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - 579, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - 596, /* GL_FRAMEBUFFER_DEFAULT */ - 622, /* GL_FRAMEBUFFER_UNDEFINED */ - 393, /* GL_DEPTH_STENCIL_ATTACHMENT */ - 686, /* GL_INDEX */ - 1952, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - 1973, /* GL_UNSIGNED_SHORT_5_6_5 */ - 1974, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - 1970, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - 1967, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - 1964, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - 1961, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - 1882, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - 1883, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - 1881, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - 1047, /* GL_MIRRORED_REPEAT */ - 1515, /* GL_RGB_S3TC */ - 1484, /* GL_RGB4_S3TC */ - 1513, /* GL_RGBA_S3TC */ - 1506, /* GL_RGBA4_S3TC */ - 1511, /* GL_RGBA_DXT5_S3TC */ - 1503, /* GL_RGBA4_DXT5_S3TC */ - 277, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - 272, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - 273, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - 274, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - 1109, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - 1108, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - 757, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - 542, /* GL_FOG_COORDINATE_SOURCE */ - 534, /* GL_FOG_COORD */ - 558, /* GL_FRAGMENT_DEPTH */ - 326, /* GL_CURRENT_FOG_COORD */ - 541, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - 540, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - 539, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - 536, /* GL_FOG_COORDINATE_ARRAY */ - 212, /* GL_COLOR_SUM */ - 347, /* GL_CURRENT_SECONDARY_COLOR */ - 1553, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - 1555, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - 1554, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - 1552, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - 1549, /* GL_SECONDARY_COLOR_ARRAY */ - 345, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - 28, /* GL_ALIASED_POINT_SIZE_RANGE */ - 27, /* GL_ALIASED_LINE_WIDTH_RANGE */ - 1704, /* GL_TEXTURE0 */ - 1706, /* GL_TEXTURE1 */ - 1728, /* GL_TEXTURE2 */ - 1750, /* GL_TEXTURE3 */ - 1756, /* GL_TEXTURE4 */ - 1758, /* GL_TEXTURE5 */ - 1760, /* GL_TEXTURE6 */ - 1762, /* GL_TEXTURE7 */ - 1764, /* GL_TEXTURE8 */ - 1766, /* GL_TEXTURE9 */ - 1707, /* GL_TEXTURE10 */ - 1709, /* GL_TEXTURE11 */ - 1711, /* GL_TEXTURE12 */ - 1713, /* GL_TEXTURE13 */ - 1715, /* GL_TEXTURE14 */ - 1717, /* GL_TEXTURE15 */ - 1719, /* GL_TEXTURE16 */ - 1721, /* GL_TEXTURE17 */ - 1723, /* GL_TEXTURE18 */ - 1725, /* GL_TEXTURE19 */ - 1729, /* GL_TEXTURE20 */ - 1731, /* GL_TEXTURE21 */ - 1733, /* GL_TEXTURE22 */ - 1735, /* GL_TEXTURE23 */ - 1737, /* GL_TEXTURE24 */ - 1739, /* GL_TEXTURE25 */ - 1741, /* GL_TEXTURE26 */ - 1743, /* GL_TEXTURE27 */ - 1745, /* GL_TEXTURE28 */ - 1747, /* GL_TEXTURE29 */ - 1751, /* GL_TEXTURE30 */ - 1753, /* GL_TEXTURE31 */ - 18, /* GL_ACTIVE_TEXTURE */ - 145, /* GL_CLIENT_ACTIVE_TEXTURE */ - 1015, /* GL_MAX_TEXTURE_UNITS */ - 1927, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - 1930, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - 1932, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - 1924, /* GL_TRANSPOSE_COLOR_MATRIX */ - 1686, /* GL_SUBTRACT */ - 998, /* GL_MAX_RENDERBUFFER_SIZE */ - 260, /* GL_COMPRESSED_ALPHA */ - 264, /* GL_COMPRESSED_LUMINANCE */ - 265, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - 262, /* GL_COMPRESSED_INTENSITY */ - 268, /* GL_COMPRESSED_RGB */ - 269, /* GL_COMPRESSED_RGBA */ - 1814, /* GL_TEXTURE_COMPRESSION_HINT */ - 1891, /* GL_TEXTURE_RECTANGLE_ARB */ - 1786, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - 1388, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - 996, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ - 392, /* GL_DEPTH_STENCIL */ - 1957, /* GL_UNSIGNED_INT_24_8 */ - 1010, /* GL_MAX_TEXTURE_LOD_BIAS */ - 1880, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - 1012, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - 1852, /* GL_TEXTURE_FILTER_CONTROL */ - 1870, /* GL_TEXTURE_LOD_BIAS */ - 245, /* GL_COMBINE4 */ - 1004, /* GL_MAX_SHININESS_NV */ - 1005, /* GL_MAX_SPOT_EXPONENT_NV */ - 684, /* GL_INCR_WRAP */ - 358, /* GL_DECR_WRAP */ - 1067, /* GL_MODELVIEW1_ARB */ - 1125, /* GL_NORMAL_MAP */ - 1427, /* GL_REFLECTION_MAP */ - 1824, /* GL_TEXTURE_CUBE_MAP */ - 1783, /* GL_TEXTURE_BINDING_CUBE_MAP */ - 1836, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - 1826, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - 1839, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - 1829, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - 1842, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - 1832, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - 1386, /* GL_PROXY_TEXTURE_CUBE_MAP */ - 944, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - 1103, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - 550, /* GL_FOG_DISTANCE_MODE_NV */ - 499, /* GL_EYE_RADIAL_NV */ - 498, /* GL_EYE_PLANE_ABSOLUTE_NV */ - 244, /* GL_COMBINE */ - 251, /* GL_COMBINE_RGB */ - 246, /* GL_COMBINE_ALPHA */ - 1516, /* GL_RGB_SCALE */ - 24, /* GL_ADD_SIGNED */ - 713, /* GL_INTERPOLATE */ - 284, /* GL_CONSTANT */ - 1329, /* GL_PRIMARY_COLOR */ - 1326, /* GL_PREVIOUS */ - 1592, /* GL_SOURCE0_RGB */ - 1598, /* GL_SOURCE1_RGB */ - 1604, /* GL_SOURCE2_RGB */ - 1608, /* GL_SOURCE3_RGB_NV */ - 1589, /* GL_SOURCE0_ALPHA */ - 1595, /* GL_SOURCE1_ALPHA */ - 1601, /* GL_SOURCE2_ALPHA */ - 1607, /* GL_SOURCE3_ALPHA_NV */ - 1165, /* GL_OPERAND0_RGB */ - 1171, /* GL_OPERAND1_RGB */ - 1177, /* GL_OPERAND2_RGB */ - 1181, /* GL_OPERAND3_RGB_NV */ - 1162, /* GL_OPERAND0_ALPHA */ - 1168, /* GL_OPERAND1_ALPHA */ - 1174, /* GL_OPERAND2_ALPHA */ - 1180, /* GL_OPERAND3_ALPHA_NV */ - 120, /* GL_BUFFER_OBJECT_APPLE */ - 1986, /* GL_VERTEX_ARRAY_BINDING */ - 1889, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - 1890, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - 2060, /* GL_YCBCR_422_APPLE */ - 1975, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - 1977, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - 1899, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - 1677, /* GL_STORAGE_PRIVATE_APPLE */ - 1676, /* GL_STORAGE_CACHED_APPLE */ - 1678, /* GL_STORAGE_SHARED_APPLE */ - 1579, /* GL_SLICE_ACCUM_SUN */ - 1396, /* GL_QUAD_MESH_SUN */ - 1937, /* GL_TRIANGLE_MESH_SUN */ - 2025, /* GL_VERTEX_PROGRAM_ARB */ - 2036, /* GL_VERTEX_STATE_PROGRAM_NV */ - 2012, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - 2018, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - 2020, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - 2022, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - 349, /* GL_CURRENT_VERTEX_ATTRIB */ - 1345, /* GL_PROGRAM_LENGTH_ARB */ - 1360, /* GL_PROGRAM_STRING_ARB */ - 1090, /* GL_MODELVIEW_PROJECTION_NV */ - 677, /* GL_IDENTITY_NV */ - 729, /* GL_INVERSE_NV */ - 1929, /* GL_TRANSPOSE_NV */ - 730, /* GL_INVERSE_TRANSPOSE_NV */ - 982, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - 981, /* GL_MAX_PROGRAM_MATRICES_ARB */ - 872, /* GL_MATRIX0_NV */ - 884, /* GL_MATRIX1_NV */ - 896, /* GL_MATRIX2_NV */ - 900, /* GL_MATRIX3_NV */ - 902, /* GL_MATRIX4_NV */ - 904, /* GL_MATRIX5_NV */ - 906, /* GL_MATRIX6_NV */ - 908, /* GL_MATRIX7_NV */ - 332, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - 329, /* GL_CURRENT_MATRIX_ARB */ - 2028, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - 2031, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - 1357, /* GL_PROGRAM_PARAMETER_NV */ - 2016, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - 1362, /* GL_PROGRAM_TARGET_NV */ - 1359, /* GL_PROGRAM_RESIDENT_NV */ - 1909, /* GL_TRACK_MATRIX_NV */ - 1910, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - 2026, /* GL_VERTEX_PROGRAM_BINDING_NV */ - 1339, /* GL_PROGRAM_ERROR_POSITION_ARB */ - 373, /* GL_DEPTH_CLAMP */ - 1994, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - 2001, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - 2002, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - 2003, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - 2004, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - 2005, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - 2006, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - 2007, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - 2008, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - 2009, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - 1995, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - 1996, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - 1997, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - 1998, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - 1999, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - 2000, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - 820, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - 827, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - 828, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - 829, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - 830, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - 831, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - 832, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - 833, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - 834, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - 835, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - 821, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - 822, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - 823, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - 824, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - 825, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - 826, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - 847, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - 854, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - 855, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - 856, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - 857, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - 858, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - 859, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - 1338, /* GL_PROGRAM_BINDING_ARB */ - 861, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - 862, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - 848, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - 849, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - 850, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - 851, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - 852, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - 853, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - 1812, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - 1809, /* GL_TEXTURE_COMPRESSED */ - 1131, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - 282, /* GL_COMPRESSED_TEXTURE_FORMATS */ - 1033, /* GL_MAX_VERTEX_UNITS_ARB */ - 22, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - 2054, /* GL_WEIGHT_SUM_UNITY_ARB */ - 2024, /* GL_VERTEX_BLEND_ARB */ - 351, /* GL_CURRENT_WEIGHT_ARB */ - 2052, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - 2050, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - 2048, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - 2046, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - 2041, /* GL_WEIGHT_ARRAY_ARB */ - 407, /* GL_DOT3_RGB */ - 408, /* GL_DOT3_RGBA */ - 276, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - 271, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - 1098, /* GL_MULTISAMPLE_3DFX */ - 1538, /* GL_SAMPLE_BUFFERS_3DFX */ - 1529, /* GL_SAMPLES_3DFX */ - 1078, /* GL_MODELVIEW2_ARB */ - 1081, /* GL_MODELVIEW3_ARB */ - 1082, /* GL_MODELVIEW4_ARB */ - 1083, /* GL_MODELVIEW5_ARB */ - 1084, /* GL_MODELVIEW6_ARB */ - 1085, /* GL_MODELVIEW7_ARB */ - 1086, /* GL_MODELVIEW8_ARB */ - 1087, /* GL_MODELVIEW9_ARB */ - 1057, /* GL_MODELVIEW10_ARB */ - 1058, /* GL_MODELVIEW11_ARB */ - 1059, /* GL_MODELVIEW12_ARB */ - 1060, /* GL_MODELVIEW13_ARB */ - 1061, /* GL_MODELVIEW14_ARB */ - 1062, /* GL_MODELVIEW15_ARB */ - 1063, /* GL_MODELVIEW16_ARB */ - 1064, /* GL_MODELVIEW17_ARB */ - 1065, /* GL_MODELVIEW18_ARB */ - 1066, /* GL_MODELVIEW19_ARB */ - 1068, /* GL_MODELVIEW20_ARB */ - 1069, /* GL_MODELVIEW21_ARB */ - 1070, /* GL_MODELVIEW22_ARB */ - 1071, /* GL_MODELVIEW23_ARB */ - 1072, /* GL_MODELVIEW24_ARB */ - 1073, /* GL_MODELVIEW25_ARB */ - 1074, /* GL_MODELVIEW26_ARB */ - 1075, /* GL_MODELVIEW27_ARB */ - 1076, /* GL_MODELVIEW28_ARB */ - 1077, /* GL_MODELVIEW29_ARB */ - 1079, /* GL_MODELVIEW30_ARB */ - 1080, /* GL_MODELVIEW31_ARB */ - 412, /* GL_DOT3_RGB_EXT */ - 410, /* GL_DOT3_RGBA_EXT */ - 1051, /* GL_MIRROR_CLAMP_EXT */ - 1054, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - 1093, /* GL_MODULATE_ADD_ATI */ - 1094, /* GL_MODULATE_SIGNED_ADD_ATI */ - 1095, /* GL_MODULATE_SUBTRACT_ATI */ - 2061, /* GL_YCBCR_MESA */ - 1189, /* GL_PACK_INVERT_MESA */ - 354, /* GL_DEBUG_OBJECT_MESA */ - 355, /* GL_DEBUG_PRINT_MESA */ - 353, /* GL_DEBUG_ASSERT_MESA */ - 122, /* GL_BUFFER_SIZE */ - 124, /* GL_BUFFER_USAGE */ - 128, /* GL_BUMP_ROT_MATRIX_ATI */ - 129, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - 127, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - 131, /* GL_BUMP_TEX_UNITS_ATI */ - 472, /* GL_DUDV_ATI */ - 471, /* GL_DU8DV8_ATI */ - 126, /* GL_BUMP_ENVMAP_ATI */ - 130, /* GL_BUMP_TARGET_ATI */ - 1133, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ - 1336, /* GL_PROGRAM_BINARY_FORMATS_OES */ - 1641, /* GL_STENCIL_BACK_FUNC */ - 1639, /* GL_STENCIL_BACK_FAIL */ - 1643, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - 1645, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - 559, /* GL_FRAGMENT_PROGRAM_ARB */ - 1334, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1365, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1364, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1348, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1354, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1353, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 971, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 994, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 993, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - 984, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 990, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 989, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 947, /* GL_MAX_DRAW_BUFFERS */ - 416, /* GL_DRAW_BUFFER0 */ - 419, /* GL_DRAW_BUFFER1 */ - 440, /* GL_DRAW_BUFFER2 */ - 443, /* GL_DRAW_BUFFER3 */ - 446, /* GL_DRAW_BUFFER4 */ - 449, /* GL_DRAW_BUFFER5 */ - 452, /* GL_DRAW_BUFFER6 */ - 455, /* GL_DRAW_BUFFER7 */ - 458, /* GL_DRAW_BUFFER8 */ - 461, /* GL_DRAW_BUFFER9 */ - 420, /* GL_DRAW_BUFFER10 */ - 423, /* GL_DRAW_BUFFER11 */ - 426, /* GL_DRAW_BUFFER12 */ - 429, /* GL_DRAW_BUFFER13 */ - 432, /* GL_DRAW_BUFFER14 */ - 435, /* GL_DRAW_BUFFER15 */ - 85, /* GL_BLEND_EQUATION_ALPHA */ - 923, /* GL_MATRIX_PALETTE_ARB */ - 964, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - 967, /* GL_MAX_PALETTE_MATRICES_ARB */ - 335, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - 911, /* GL_MATRIX_INDEX_ARRAY_ARB */ - 330, /* GL_CURRENT_MATRIX_INDEX_ARB */ - 916, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - 920, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - 918, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - 914, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - 1847, /* GL_TEXTURE_DEPTH_SIZE */ - 400, /* GL_DEPTH_TEXTURE_MODE */ - 1804, /* GL_TEXTURE_COMPARE_MODE */ - 1802, /* GL_TEXTURE_COMPARE_FUNC */ - 255, /* GL_COMPARE_R_TO_TEXTURE */ - 1266, /* GL_POINT_SPRITE */ - 309, /* GL_COORD_REPLACE */ - 1271, /* GL_POINT_SPRITE_R_MODE_NV */ - 1400, /* GL_QUERY_COUNTER_BITS */ - 338, /* GL_CURRENT_QUERY */ - 1403, /* GL_QUERY_RESULT */ - 1405, /* GL_QUERY_RESULT_AVAILABLE */ - 1026, /* GL_MAX_VERTEX_ATTRIBS */ - 2014, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - 398, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - 397, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - 1006, /* GL_MAX_TEXTURE_COORDS */ - 1008, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - 1341, /* GL_PROGRAM_ERROR_STRING_ARB */ - 1343, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - 1342, /* GL_PROGRAM_FORMAT_ARB */ - 1901, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - 371, /* GL_DEPTH_BOUNDS_TEST_EXT */ - 370, /* GL_DEPTH_BOUNDS_EXT */ - 53, /* GL_ARRAY_BUFFER */ - 485, /* GL_ELEMENT_ARRAY_BUFFER */ - 54, /* GL_ARRAY_BUFFER_BINDING */ - 486, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - 1988, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - 1120, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - 161, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - 688, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - 1817, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - 481, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - 1550, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - 537, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - 2042, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - 2010, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - 1344, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - 977, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - 1350, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 986, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1363, /* GL_PROGRAM_TEMPORARIES_ARB */ - 992, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - 1352, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 988, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1356, /* GL_PROGRAM_PARAMETERS_ARB */ - 991, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - 1351, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - 987, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1335, /* GL_PROGRAM_ATTRIBS_ARB */ - 972, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - 1349, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - 985, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1333, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - 970, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1347, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 983, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 978, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - 974, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - 1366, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - 1926, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - 1417, /* GL_READ_ONLY */ - 2056, /* GL_WRITE_ONLY */ - 1419, /* GL_READ_WRITE */ - 110, /* GL_BUFFER_ACCESS */ - 114, /* GL_BUFFER_MAPPED */ - 117, /* GL_BUFFER_MAP_POINTER */ - 1908, /* GL_TIME_ELAPSED_EXT */ - 871, /* GL_MATRIX0_ARB */ - 883, /* GL_MATRIX1_ARB */ - 895, /* GL_MATRIX2_ARB */ - 899, /* GL_MATRIX3_ARB */ - 901, /* GL_MATRIX4_ARB */ - 903, /* GL_MATRIX5_ARB */ - 905, /* GL_MATRIX6_ARB */ - 907, /* GL_MATRIX7_ARB */ - 909, /* GL_MATRIX8_ARB */ - 910, /* GL_MATRIX9_ARB */ - 873, /* GL_MATRIX10_ARB */ - 874, /* GL_MATRIX11_ARB */ - 875, /* GL_MATRIX12_ARB */ - 876, /* GL_MATRIX13_ARB */ - 877, /* GL_MATRIX14_ARB */ - 878, /* GL_MATRIX15_ARB */ - 879, /* GL_MATRIX16_ARB */ - 880, /* GL_MATRIX17_ARB */ - 881, /* GL_MATRIX18_ARB */ - 882, /* GL_MATRIX19_ARB */ - 885, /* GL_MATRIX20_ARB */ - 886, /* GL_MATRIX21_ARB */ - 887, /* GL_MATRIX22_ARB */ - 888, /* GL_MATRIX23_ARB */ - 889, /* GL_MATRIX24_ARB */ - 890, /* GL_MATRIX25_ARB */ - 891, /* GL_MATRIX26_ARB */ - 892, /* GL_MATRIX27_ARB */ - 893, /* GL_MATRIX28_ARB */ - 894, /* GL_MATRIX29_ARB */ - 897, /* GL_MATRIX30_ARB */ - 898, /* GL_MATRIX31_ARB */ - 1681, /* GL_STREAM_DRAW */ - 1683, /* GL_STREAM_READ */ - 1679, /* GL_STREAM_COPY */ - 1631, /* GL_STATIC_DRAW */ - 1633, /* GL_STATIC_READ */ - 1629, /* GL_STATIC_COPY */ - 475, /* GL_DYNAMIC_DRAW */ - 477, /* GL_DYNAMIC_READ */ - 473, /* GL_DYNAMIC_COPY */ - 1229, /* GL_PIXEL_PACK_BUFFER */ - 1233, /* GL_PIXEL_UNPACK_BUFFER */ - 1230, /* GL_PIXEL_PACK_BUFFER_BINDING */ - 1234, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - 362, /* GL_DEPTH24_STENCIL8 */ - 1897, /* GL_TEXTURE_STENCIL_SIZE */ - 1845, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - 973, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - 976, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - 980, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - 979, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - 928, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - 1672, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - 17, /* GL_ACTIVE_STENCIL_FACE_EXT */ - 1052, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - 1531, /* GL_SAMPLES_PASSED */ - 1253, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - 1252, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - 1251, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - 1089, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - 1369, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - 1879, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - 121, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - 113, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - 1431, /* GL_RELEASED_APPLE */ - 2039, /* GL_VOLATILE_APPLE */ - 1470, /* GL_RETAINED_APPLE */ - 1941, /* GL_UNDEFINED_APPLE */ - 1390, /* GL_PURGEABLE_APPLE */ - 560, /* GL_FRAGMENT_SHADER */ - 2034, /* GL_VERTEX_SHADER */ - 1355, /* GL_PROGRAM_OBJECT_ARB */ - 1566, /* GL_SHADER_OBJECT_ARB */ - 954, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - 1030, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - 1023, /* GL_MAX_VARYING_FLOATS */ - 1028, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - 938, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - 1149, /* GL_OBJECT_TYPE_ARB */ - 1568, /* GL_SHADER_TYPE */ - 525, /* GL_FLOAT_VEC2 */ - 527, /* GL_FLOAT_VEC3 */ - 529, /* GL_FLOAT_VEC4 */ - 717, /* GL_INT_VEC2 */ - 719, /* GL_INT_VEC3 */ - 721, /* GL_INT_VEC4 */ - 102, /* GL_BOOL */ - 104, /* GL_BOOL_VEC2 */ - 106, /* GL_BOOL_VEC3 */ - 108, /* GL_BOOL_VEC4 */ - 513, /* GL_FLOAT_MAT2 */ - 517, /* GL_FLOAT_MAT3 */ - 521, /* GL_FLOAT_MAT4 */ - 1521, /* GL_SAMPLER_1D */ - 1523, /* GL_SAMPLER_2D */ - 1525, /* GL_SAMPLER_3D */ - 1527, /* GL_SAMPLER_CUBE */ - 1522, /* GL_SAMPLER_1D_SHADOW */ - 1524, /* GL_SAMPLER_2D_SHADOW */ - 515, /* GL_FLOAT_MAT2x3 */ - 516, /* GL_FLOAT_MAT2x4 */ - 519, /* GL_FLOAT_MAT3x2 */ - 520, /* GL_FLOAT_MAT3x4 */ - 523, /* GL_FLOAT_MAT4x2 */ - 524, /* GL_FLOAT_MAT4x3 */ - 360, /* GL_DELETE_STATUS */ - 259, /* GL_COMPILE_STATUS */ - 776, /* GL_LINK_STATUS */ - 1982, /* GL_VALIDATE_STATUS */ - 700, /* GL_INFO_LOG_LENGTH */ - 56, /* GL_ATTACHED_SHADERS */ - 20, /* GL_ACTIVE_UNIFORMS */ - 21, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - 1567, /* GL_SHADER_SOURCE_LENGTH */ - 15, /* GL_ACTIVE_ATTRIBUTES */ - 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - 562, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - 1570, /* GL_SHADING_LANGUAGE_VERSION */ - 337, /* GL_CURRENT_PROGRAM */ - 1198, /* GL_PALETTE4_RGB8_OES */ - 1200, /* GL_PALETTE4_RGBA8_OES */ - 1196, /* GL_PALETTE4_R5_G6_B5_OES */ - 1199, /* GL_PALETTE4_RGBA4_OES */ - 1197, /* GL_PALETTE4_RGB5_A1_OES */ - 1203, /* GL_PALETTE8_RGB8_OES */ - 1205, /* GL_PALETTE8_RGBA8_OES */ - 1201, /* GL_PALETTE8_R5_G6_B5_OES */ - 1204, /* GL_PALETTE8_RGBA4_OES */ - 1202, /* GL_PALETTE8_RGB5_A1_OES */ - 682, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - 680, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - 1250, /* GL_POINT_SIZE_ARRAY_OES */ - 1823, /* GL_TEXTURE_CROP_RECT_OES */ - 912, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - 1249, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - 1965, /* GL_UNSIGNED_NORMALIZED */ - 1769, /* GL_TEXTURE_1D_ARRAY_EXT */ - 1379, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - 1771, /* GL_TEXTURE_2D_ARRAY_EXT */ - 1382, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - 1778, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - 1780, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - 958, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ - 1623, /* GL_SRGB */ - 1624, /* GL_SRGB8 */ - 1626, /* GL_SRGB_ALPHA */ - 1625, /* GL_SRGB8_ALPHA8 */ - 1583, /* GL_SLUMINANCE_ALPHA */ - 1582, /* GL_SLUMINANCE8_ALPHA8 */ - 1580, /* GL_SLUMINANCE */ - 1581, /* GL_SLUMINANCE8 */ - 280, /* GL_COMPRESSED_SRGB */ - 281, /* GL_COMPRESSED_SRGB_ALPHA */ - 278, /* GL_COMPRESSED_SLUMINANCE */ - 279, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - 1923, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ - 1917, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ - 1021, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ - 1922, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ - 1920, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ - 1919, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ - 1332, /* GL_PRIMITIVES_GENERATED_EXT */ - 1921, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ - 1410, /* GL_RASTERIZER_DISCARD_EXT */ - 1019, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ - 1020, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ - 712, /* GL_INTERLEAVED_ATTRIBS_EXT */ - 1560, /* GL_SEPARATE_ATTRIBS_EXT */ - 1916, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ - 1915, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ - 1268, /* GL_POINT_SPRITE_COORD_ORIGIN */ - 784, /* GL_LOWER_LEFT */ - 1979, /* GL_UPPER_LEFT */ - 1647, /* GL_STENCIL_BACK_REF */ - 1648, /* GL_STENCIL_BACK_VALUE_MASK */ - 1649, /* GL_STENCIL_BACK_WRITEMASK */ - 465, /* GL_DRAW_FRAMEBUFFER_BINDING */ - 1436, /* GL_RENDERBUFFER_BINDING */ - 1413, /* GL_READ_FRAMEBUFFER */ - 464, /* GL_DRAW_FRAMEBUFFER */ - 1414, /* GL_READ_FRAMEBUFFER_BINDING */ - 1455, /* GL_RENDERBUFFER_SAMPLES */ - 575, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - 572, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - 587, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - 582, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - 585, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - 593, /* GL_FRAMEBUFFER_COMPLETE */ - 598, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - 612, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - 607, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - 602, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - 608, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - 604, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - 617, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - 623, /* GL_FRAMEBUFFER_UNSUPPORTED */ - 621, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - 934, /* GL_MAX_COLOR_ATTACHMENTS */ - 167, /* GL_COLOR_ATTACHMENT0 */ - 170, /* GL_COLOR_ATTACHMENT1 */ - 184, /* GL_COLOR_ATTACHMENT2 */ - 186, /* GL_COLOR_ATTACHMENT3 */ - 188, /* GL_COLOR_ATTACHMENT4 */ - 190, /* GL_COLOR_ATTACHMENT5 */ - 192, /* GL_COLOR_ATTACHMENT6 */ - 194, /* GL_COLOR_ATTACHMENT7 */ - 196, /* GL_COLOR_ATTACHMENT8 */ - 198, /* GL_COLOR_ATTACHMENT9 */ - 171, /* GL_COLOR_ATTACHMENT10 */ - 173, /* GL_COLOR_ATTACHMENT11 */ - 175, /* GL_COLOR_ATTACHMENT12 */ - 177, /* GL_COLOR_ATTACHMENT13 */ - 179, /* GL_COLOR_ATTACHMENT14 */ - 181, /* GL_COLOR_ATTACHMENT15 */ - 365, /* GL_DEPTH_ATTACHMENT */ - 1636, /* GL_STENCIL_ATTACHMENT */ - 564, /* GL_FRAMEBUFFER */ - 1433, /* GL_RENDERBUFFER */ - 1459, /* GL_RENDERBUFFER_WIDTH */ - 1446, /* GL_RENDERBUFFER_HEIGHT */ - 1449, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - 1667, /* GL_STENCIL_INDEX_EXT */ - 1656, /* GL_STENCIL_INDEX1 */ - 1661, /* GL_STENCIL_INDEX4 */ - 1664, /* GL_STENCIL_INDEX8 */ - 1657, /* GL_STENCIL_INDEX16 */ - 1453, /* GL_RENDERBUFFER_RED_SIZE */ - 1444, /* GL_RENDERBUFFER_GREEN_SIZE */ - 1439, /* GL_RENDERBUFFER_BLUE_SIZE */ - 1434, /* GL_RENDERBUFFER_ALPHA_SIZE */ - 1441, /* GL_RENDERBUFFER_DEPTH_SIZE */ - 1457, /* GL_RENDERBUFFER_STENCIL_SIZE */ - 615, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - 1001, /* GL_MAX_SAMPLES */ - 1859, /* GL_TEXTURE_GEN_STR_OES */ - 655, /* GL_HALF_FLOAT_OES */ - 1487, /* GL_RGB565_OES */ - 571, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ - 611, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ - 610, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - 646, /* GL_GEOMETRY_SHADER_ARB */ - 647, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - 644, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - 645, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - 961, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - 1035, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - 960, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ - 957, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ - 959, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ - 785, /* GL_LOW_FLOAT */ - 1037, /* GL_MEDIUM_FLOAT */ - 656, /* GL_HIGH_FLOAT */ - 786, /* GL_LOW_INT */ - 1038, /* GL_MEDIUM_INT */ - 657, /* GL_HIGH_INT */ - 1956, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - 716, /* GL_INT_10_10_10_2_OES */ - 1564, /* GL_SHADER_BINARY_FORMATS */ - 1134, /* GL_NUM_SHADER_BINARY_FORMATS */ - 1565, /* GL_SHADER_COMPILER */ - 1032, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - 1025, /* GL_MAX_VARYING_VECTORS */ - 956, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - 1407, /* GL_QUERY_WAIT_NV */ - 1402, /* GL_QUERY_NO_WAIT_NV */ - 1399, /* GL_QUERY_BY_REGION_WAIT_NV */ - 1398, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - 1912, /* GL_TRANSFORM_FEEDBACK */ - 1918, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - 1914, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - 1913, /* GL_TRANSFORM_FEEDBACK_BINDING */ - 1394, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - 507, /* GL_FIRST_VERTEX_CONVENTION */ - 733, /* GL_LAST_VERTEX_CONVENTION */ - 1371, /* GL_PROVOKING_VERTEX */ - 316, /* GL_COPY_READ_BUFFER */ - 317, /* GL_COPY_WRITE_BUFFER */ - 1514, /* GL_RGBA_SNORM */ - 1510, /* GL_RGBA8_SNORM */ - 1576, /* GL_SIGNED_NORMALIZED */ - 1003, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - 1148, /* GL_OBJECT_TYPE */ - 1688, /* GL_SYNC_CONDITION */ - 1693, /* GL_SYNC_STATUS */ - 1690, /* GL_SYNC_FLAGS */ - 1689, /* GL_SYNC_FENCE */ - 1692, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - 1950, /* GL_UNSIGNALED */ - 1575, /* GL_SIGNALED */ - 46, /* GL_ALREADY_SIGNALED */ - 1907, /* GL_TIMEOUT_EXPIRED */ - 283, /* GL_CONDITION_SATISFIED */ - 2040, /* GL_WAIT_FAILED */ - 492, /* GL_EVAL_BIT */ - 1411, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - 778, /* GL_LIST_BIT */ - 1788, /* GL_TEXTURE_BIT */ - 1546, /* GL_SCISSOR_BIT */ - 29, /* GL_ALL_ATTRIB_BITS */ - 1100, /* GL_MULTISAMPLE_BIT */ - 30, /* GL_ALL_CLIENT_ATTRIB_BITS */ -}; - -typedef int (*cfunc)(const void *, const void *); - -/** - * Compare a key name to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an element of the \c all_enums array. - */ -static int compar_name( const char *a, const enum_elt *b ) -{ - return strcmp( a, & enum_string_table[ b->offset ] ); -} - -/** - * Compare a key enum value to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an index into the \c all_enums array. - */ -static int compar_nr( const int *a, const unsigned *b ) -{ - return a[0] - all_enums[*b].n; -} - - -static char token_tmp[20]; - -const char *_mesa_lookup_enum_by_nr( int nr ) -{ - unsigned * i; - - i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, - Elements(reduced_enums), - sizeof(reduced_enums[0]), - (cfunc) compar_nr); - - if ( i != NULL ) { - return & enum_string_table[ all_enums[ *i ].offset ]; - } - else { - /* this is not re-entrant safe, no big deal here */ - _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); - token_tmp[sizeof(token_tmp) - 1] = '\0'; - return token_tmp; - } -} - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char *_mesa_lookup_prim_by_nr( int nr ) -{ - switch (nr) { - case GL_POINTS: return "GL_POINTS"; - case GL_LINES: return "GL_LINES"; - case GL_LINE_STRIP: return "GL_LINE_STRIP"; - case GL_LINE_LOOP: return "GL_LINE_LOOP"; - case GL_TRIANGLES: return "GL_TRIANGLES"; - case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; - case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; - case GL_QUADS: return "GL_QUADS"; - case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; - case GL_POLYGON: return "GL_POLYGON"; - case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; - default: return ""; - } -} - - - -int _mesa_lookup_enum_by_name( const char *symbol ) -{ - enum_elt * f = NULL; - - if ( symbol != NULL ) { - f = (enum_elt *) _mesa_bsearch(symbol, all_enums, - Elements(all_enums), - sizeof( enum_elt ), - (cfunc) compar_name); - } - - return (f != NULL) ? f->n : -1; -} - - +/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */ + +/* + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "main/glheader.h" +#include "main/mfeatures.h" +#include "main/enums.h" +#include "main/imports.h" + +typedef struct { + size_t offset; + int n; +} enum_elt; + +LONGSTRING static const char enum_string_table[] = + "GL_2D\0" + "GL_2_BYTES\0" + "GL_3D\0" + "GL_3D_COLOR\0" + "GL_3D_COLOR_TEXTURE\0" + "GL_3_BYTES\0" + "GL_4D_COLOR_TEXTURE\0" + "GL_4_BYTES\0" + "GL_ACCUM\0" + "GL_ACCUM_ALPHA_BITS\0" + "GL_ACCUM_BLUE_BITS\0" + "GL_ACCUM_BUFFER_BIT\0" + "GL_ACCUM_CLEAR_VALUE\0" + "GL_ACCUM_GREEN_BITS\0" + "GL_ACCUM_RED_BITS\0" + "GL_ACTIVE_ATTRIBUTES\0" + "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH\0" + "GL_ACTIVE_PROGRAM_EXT\0" + "GL_ACTIVE_STENCIL_FACE_EXT\0" + "GL_ACTIVE_TEXTURE\0" + "GL_ACTIVE_TEXTURE_ARB\0" + "GL_ACTIVE_UNIFORMS\0" + "GL_ACTIVE_UNIFORM_MAX_LENGTH\0" + "GL_ACTIVE_VERTEX_UNITS_ARB\0" + "GL_ADD\0" + "GL_ADD_SIGNED\0" + "GL_ADD_SIGNED_ARB\0" + "GL_ADD_SIGNED_EXT\0" + "GL_ALIASED_LINE_WIDTH_RANGE\0" + "GL_ALIASED_POINT_SIZE_RANGE\0" + "GL_ALL_ATTRIB_BITS\0" + "GL_ALL_CLIENT_ATTRIB_BITS\0" + "GL_ALPHA\0" + "GL_ALPHA12\0" + "GL_ALPHA12_EXT\0" + "GL_ALPHA16\0" + "GL_ALPHA16I_EXT\0" + "GL_ALPHA16UI_EXT\0" + "GL_ALPHA16_EXT\0" + "GL_ALPHA32I_EXT\0" + "GL_ALPHA32UI_EXT\0" + "GL_ALPHA4\0" + "GL_ALPHA4_EXT\0" + "GL_ALPHA8\0" + "GL_ALPHA8I_EXT\0" + "GL_ALPHA8UI_EXT\0" + "GL_ALPHA8_EXT\0" + "GL_ALPHA_BIAS\0" + "GL_ALPHA_BITS\0" + "GL_ALPHA_INTEGER_EXT\0" + "GL_ALPHA_SCALE\0" + "GL_ALPHA_TEST\0" + "GL_ALPHA_TEST_FUNC\0" + "GL_ALPHA_TEST_REF\0" + "GL_ALREADY_SIGNALED\0" + "GL_ALWAYS\0" + "GL_AMBIENT\0" + "GL_AMBIENT_AND_DIFFUSE\0" + "GL_AND\0" + "GL_AND_INVERTED\0" + "GL_AND_REVERSE\0" + "GL_ARRAY_BUFFER\0" + "GL_ARRAY_BUFFER_BINDING\0" + "GL_ARRAY_BUFFER_BINDING_ARB\0" + "GL_ATTACHED_SHADERS\0" + "GL_ATTRIB_ARRAY_POINTER_NV\0" + "GL_ATTRIB_ARRAY_SIZE_NV\0" + "GL_ATTRIB_ARRAY_STRIDE_NV\0" + "GL_ATTRIB_ARRAY_TYPE_NV\0" + "GL_ATTRIB_STACK_DEPTH\0" + "GL_AUTO_NORMAL\0" + "GL_AUX0\0" + "GL_AUX1\0" + "GL_AUX2\0" + "GL_AUX3\0" + "GL_AUX_BUFFERS\0" + "GL_BACK\0" + "GL_BACK_LEFT\0" + "GL_BACK_RIGHT\0" + "GL_BGR\0" + "GL_BGRA\0" + "GL_BGRA_EXT\0" + "GL_BGRA_INTEGER\0" + "GL_BGRA_INTEGER_EXT\0" + "GL_BGR_INTEGER\0" + "GL_BGR_INTEGER_EXT\0" + "GL_BITMAP\0" + "GL_BITMAP_TOKEN\0" + "GL_BLEND\0" + "GL_BLEND_COLOR\0" + "GL_BLEND_COLOR_EXT\0" + "GL_BLEND_DST\0" + "GL_BLEND_DST_ALPHA\0" + "GL_BLEND_DST_ALPHA_OES\0" + "GL_BLEND_DST_RGB\0" + "GL_BLEND_DST_RGB_OES\0" + "GL_BLEND_EQUATION\0" + "GL_BLEND_EQUATION_ALPHA\0" + "GL_BLEND_EQUATION_ALPHA_EXT\0" + "GL_BLEND_EQUATION_ALPHA_OES\0" + "GL_BLEND_EQUATION_EXT\0" + "GL_BLEND_EQUATION_OES\0" + "GL_BLEND_EQUATION_RGB\0" + "GL_BLEND_EQUATION_RGB_EXT\0" + "GL_BLEND_EQUATION_RGB_OES\0" + "GL_BLEND_SRC\0" + "GL_BLEND_SRC_ALPHA\0" + "GL_BLEND_SRC_ALPHA_OES\0" + "GL_BLEND_SRC_RGB\0" + "GL_BLEND_SRC_RGB_OES\0" + "GL_BLUE\0" + "GL_BLUE_BIAS\0" + "GL_BLUE_BITS\0" + "GL_BLUE_INTEGER\0" + "GL_BLUE_INTEGER_EXT\0" + "GL_BLUE_SCALE\0" + "GL_BOOL\0" + "GL_BOOL_ARB\0" + "GL_BOOL_VEC2\0" + "GL_BOOL_VEC2_ARB\0" + "GL_BOOL_VEC3\0" + "GL_BOOL_VEC3_ARB\0" + "GL_BOOL_VEC4\0" + "GL_BOOL_VEC4_ARB\0" + "GL_BUFFER_ACCESS\0" + "GL_BUFFER_ACCESS_ARB\0" + "GL_BUFFER_ACCESS_FLAGS\0" + "GL_BUFFER_ACCESS_OES\0" + "GL_BUFFER_FLUSHING_UNMAP_APPLE\0" + "GL_BUFFER_MAPPED\0" + "GL_BUFFER_MAPPED_ARB\0" + "GL_BUFFER_MAPPED_OES\0" + "GL_BUFFER_MAP_LENGTH\0" + "GL_BUFFER_MAP_OFFSET\0" + "GL_BUFFER_MAP_POINTER\0" + "GL_BUFFER_MAP_POINTER_ARB\0" + "GL_BUFFER_MAP_POINTER_OES\0" + "GL_BUFFER_OBJECT_APPLE\0" + "GL_BUFFER_SERIALIZED_MODIFY_APPLE\0" + "GL_BUFFER_SIZE\0" + "GL_BUFFER_SIZE_ARB\0" + "GL_BUFFER_USAGE\0" + "GL_BUFFER_USAGE_ARB\0" + "GL_BUMP_ENVMAP_ATI\0" + "GL_BUMP_NUM_TEX_UNITS_ATI\0" + "GL_BUMP_ROT_MATRIX_ATI\0" + "GL_BUMP_ROT_MATRIX_SIZE_ATI\0" + "GL_BUMP_TARGET_ATI\0" + "GL_BUMP_TEX_UNITS_ATI\0" + "GL_BYTE\0" + "GL_C3F_V3F\0" + "GL_C4F_N3F_V3F\0" + "GL_C4UB_V2F\0" + "GL_C4UB_V3F\0" + "GL_CCW\0" + "GL_CLAMP\0" + "GL_CLAMP_READ_COLOR\0" + "GL_CLAMP_TO_BORDER\0" + "GL_CLAMP_TO_BORDER_ARB\0" + "GL_CLAMP_TO_BORDER_SGIS\0" + "GL_CLAMP_TO_EDGE\0" + "GL_CLAMP_TO_EDGE_SGIS\0" + "GL_CLEAR\0" + "GL_CLIENT_ACTIVE_TEXTURE\0" + "GL_CLIENT_ACTIVE_TEXTURE_ARB\0" + "GL_CLIENT_ALL_ATTRIB_BITS\0" + "GL_CLIENT_ATTRIB_STACK_DEPTH\0" + "GL_CLIENT_PIXEL_STORE_BIT\0" + "GL_CLIENT_VERTEX_ARRAY_BIT\0" + "GL_CLIP_DISTANCE0\0" + "GL_CLIP_DISTANCE1\0" + "GL_CLIP_DISTANCE2\0" + "GL_CLIP_DISTANCE3\0" + "GL_CLIP_DISTANCE4\0" + "GL_CLIP_DISTANCE5\0" + "GL_CLIP_DISTANCE6\0" + "GL_CLIP_DISTANCE7\0" + "GL_CLIP_PLANE0\0" + "GL_CLIP_PLANE1\0" + "GL_CLIP_PLANE2\0" + "GL_CLIP_PLANE3\0" + "GL_CLIP_PLANE4\0" + "GL_CLIP_PLANE5\0" + "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0" + "GL_COEFF\0" + "GL_COLOR\0" + "GL_COLOR_ARRAY\0" + "GL_COLOR_ARRAY_BUFFER_BINDING\0" + "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0" + "GL_COLOR_ARRAY_POINTER\0" + "GL_COLOR_ARRAY_SIZE\0" + "GL_COLOR_ARRAY_STRIDE\0" + "GL_COLOR_ARRAY_TYPE\0" + "GL_COLOR_ATTACHMENT0\0" + "GL_COLOR_ATTACHMENT0_EXT\0" + "GL_COLOR_ATTACHMENT0_OES\0" + "GL_COLOR_ATTACHMENT1\0" + "GL_COLOR_ATTACHMENT10\0" + "GL_COLOR_ATTACHMENT10_EXT\0" + "GL_COLOR_ATTACHMENT11\0" + "GL_COLOR_ATTACHMENT11_EXT\0" + "GL_COLOR_ATTACHMENT12\0" + "GL_COLOR_ATTACHMENT12_EXT\0" + "GL_COLOR_ATTACHMENT13\0" + "GL_COLOR_ATTACHMENT13_EXT\0" + "GL_COLOR_ATTACHMENT14\0" + "GL_COLOR_ATTACHMENT14_EXT\0" + "GL_COLOR_ATTACHMENT15\0" + "GL_COLOR_ATTACHMENT15_EXT\0" + "GL_COLOR_ATTACHMENT1_EXT\0" + "GL_COLOR_ATTACHMENT2\0" + "GL_COLOR_ATTACHMENT2_EXT\0" + "GL_COLOR_ATTACHMENT3\0" + "GL_COLOR_ATTACHMENT3_EXT\0" + "GL_COLOR_ATTACHMENT4\0" + "GL_COLOR_ATTACHMENT4_EXT\0" + "GL_COLOR_ATTACHMENT5\0" + "GL_COLOR_ATTACHMENT5_EXT\0" + "GL_COLOR_ATTACHMENT6\0" + "GL_COLOR_ATTACHMENT6_EXT\0" + "GL_COLOR_ATTACHMENT7\0" + "GL_COLOR_ATTACHMENT7_EXT\0" + "GL_COLOR_ATTACHMENT8\0" + "GL_COLOR_ATTACHMENT8_EXT\0" + "GL_COLOR_ATTACHMENT9\0" + "GL_COLOR_ATTACHMENT9_EXT\0" + "GL_COLOR_BUFFER_BIT\0" + "GL_COLOR_CLEAR_VALUE\0" + "GL_COLOR_INDEX\0" + "GL_COLOR_INDEXES\0" + "GL_COLOR_LOGIC_OP\0" + "GL_COLOR_MATERIAL\0" + "GL_COLOR_MATERIAL_FACE\0" + "GL_COLOR_MATERIAL_PARAMETER\0" + "GL_COLOR_MATRIX\0" + "GL_COLOR_MATRIX_SGI\0" + "GL_COLOR_MATRIX_STACK_DEPTH\0" + "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0" + "GL_COLOR_SUM\0" + "GL_COLOR_SUM_ARB\0" + "GL_COLOR_TABLE\0" + "GL_COLOR_TABLE_ALPHA_SIZE\0" + "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0" + "GL_COLOR_TABLE_ALPHA_SIZE_SGI\0" + "GL_COLOR_TABLE_BIAS\0" + "GL_COLOR_TABLE_BIAS_SGI\0" + "GL_COLOR_TABLE_BLUE_SIZE\0" + "GL_COLOR_TABLE_BLUE_SIZE_EXT\0" + "GL_COLOR_TABLE_BLUE_SIZE_SGI\0" + "GL_COLOR_TABLE_FORMAT\0" + "GL_COLOR_TABLE_FORMAT_EXT\0" + "GL_COLOR_TABLE_FORMAT_SGI\0" + "GL_COLOR_TABLE_GREEN_SIZE\0" + "GL_COLOR_TABLE_GREEN_SIZE_EXT\0" + "GL_COLOR_TABLE_GREEN_SIZE_SGI\0" + "GL_COLOR_TABLE_INTENSITY_SIZE\0" + "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0" + "GL_COLOR_TABLE_INTENSITY_SIZE_SGI\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE_SGI\0" + "GL_COLOR_TABLE_RED_SIZE\0" + "GL_COLOR_TABLE_RED_SIZE_EXT\0" + "GL_COLOR_TABLE_RED_SIZE_SGI\0" + "GL_COLOR_TABLE_SCALE\0" + "GL_COLOR_TABLE_SCALE_SGI\0" + "GL_COLOR_TABLE_WIDTH\0" + "GL_COLOR_TABLE_WIDTH_EXT\0" + "GL_COLOR_TABLE_WIDTH_SGI\0" + "GL_COLOR_WRITEMASK\0" + "GL_COMBINE\0" + "GL_COMBINE4\0" + "GL_COMBINE_ALPHA\0" + "GL_COMBINE_ALPHA_ARB\0" + "GL_COMBINE_ALPHA_EXT\0" + "GL_COMBINE_ARB\0" + "GL_COMBINE_EXT\0" + "GL_COMBINE_RGB\0" + "GL_COMBINE_RGB_ARB\0" + "GL_COMBINE_RGB_EXT\0" + "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT\0" + "GL_COMPARE_REF_TO_TEXTURE\0" + "GL_COMPARE_R_TO_TEXTURE\0" + "GL_COMPARE_R_TO_TEXTURE_ARB\0" + "GL_COMPILE\0" + "GL_COMPILE_AND_EXECUTE\0" + "GL_COMPILE_STATUS\0" + "GL_COMPRESSED_ALPHA\0" + "GL_COMPRESSED_ALPHA_ARB\0" + "GL_COMPRESSED_INTENSITY\0" + "GL_COMPRESSED_INTENSITY_ARB\0" + "GL_COMPRESSED_LUMINANCE\0" + "GL_COMPRESSED_LUMINANCE_ALPHA\0" + "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0" + "GL_COMPRESSED_LUMINANCE_ARB\0" + "GL_COMPRESSED_RED\0" + "GL_COMPRESSED_RG\0" + "GL_COMPRESSED_RGB\0" + "GL_COMPRESSED_RGBA\0" + "GL_COMPRESSED_RGBA_ARB\0" + "GL_COMPRESSED_RGBA_FXT1_3DFX\0" + "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0" + "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0" + "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0" + "GL_COMPRESSED_RGB_ARB\0" + "GL_COMPRESSED_RGB_FXT1_3DFX\0" + "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0" + "GL_COMPRESSED_SLUMINANCE\0" + "GL_COMPRESSED_SLUMINANCE_ALPHA\0" + "GL_COMPRESSED_SRGB\0" + "GL_COMPRESSED_SRGB_ALPHA\0" + "GL_COMPRESSED_TEXTURE_FORMATS\0" + "GL_CONDITION_SATISFIED\0" + "GL_CONSTANT\0" + "GL_CONSTANT_ALPHA\0" + "GL_CONSTANT_ALPHA_EXT\0" + "GL_CONSTANT_ARB\0" + "GL_CONSTANT_ATTENUATION\0" + "GL_CONSTANT_BORDER_HP\0" + "GL_CONSTANT_COLOR\0" + "GL_CONSTANT_COLOR_EXT\0" + "GL_CONSTANT_EXT\0" + "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT\0" + "GL_CONTEXT_CORE_PROFILE_BIT\0" + "GL_CONTEXT_FLAGS\0" + "GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT\0" + "GL_CONTEXT_PROFILE_MASK\0" + "GL_CONVOLUTION_1D\0" + "GL_CONVOLUTION_2D\0" + "GL_CONVOLUTION_BORDER_COLOR\0" + "GL_CONVOLUTION_BORDER_COLOR_HP\0" + "GL_CONVOLUTION_BORDER_MODE\0" + "GL_CONVOLUTION_BORDER_MODE_EXT\0" + "GL_CONVOLUTION_FILTER_BIAS\0" + "GL_CONVOLUTION_FILTER_BIAS_EXT\0" + "GL_CONVOLUTION_FILTER_SCALE\0" + "GL_CONVOLUTION_FILTER_SCALE_EXT\0" + "GL_CONVOLUTION_FORMAT\0" + "GL_CONVOLUTION_FORMAT_EXT\0" + "GL_CONVOLUTION_HEIGHT\0" + "GL_CONVOLUTION_HEIGHT_EXT\0" + "GL_CONVOLUTION_WIDTH\0" + "GL_CONVOLUTION_WIDTH_EXT\0" + "GL_COORD_REPLACE\0" + "GL_COORD_REPLACE_ARB\0" + "GL_COORD_REPLACE_NV\0" + "GL_COORD_REPLACE_OES\0" + "GL_COPY\0" + "GL_COPY_INVERTED\0" + "GL_COPY_PIXEL_TOKEN\0" + "GL_COPY_READ_BUFFER\0" + "GL_COPY_WRITE_BUFFER\0" + "GL_CULL_FACE\0" + "GL_CULL_FACE_MODE\0" + "GL_CULL_VERTEX_EXT\0" + "GL_CULL_VERTEX_EYE_POSITION_EXT\0" + "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0" + "GL_CURRENT_ATTRIB_NV\0" + "GL_CURRENT_BIT\0" + "GL_CURRENT_COLOR\0" + "GL_CURRENT_FOG_COORD\0" + "GL_CURRENT_FOG_COORDINATE\0" + "GL_CURRENT_INDEX\0" + "GL_CURRENT_MATRIX_ARB\0" + "GL_CURRENT_MATRIX_INDEX_ARB\0" + "GL_CURRENT_MATRIX_NV\0" + "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0" + "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0" + "GL_CURRENT_NORMAL\0" + "GL_CURRENT_PALETTE_MATRIX_ARB\0" + "GL_CURRENT_PALETTE_MATRIX_OES\0" + "GL_CURRENT_PROGRAM\0" + "GL_CURRENT_QUERY\0" + "GL_CURRENT_QUERY_ARB\0" + "GL_CURRENT_RASTER_COLOR\0" + "GL_CURRENT_RASTER_DISTANCE\0" + "GL_CURRENT_RASTER_INDEX\0" + "GL_CURRENT_RASTER_POSITION\0" + "GL_CURRENT_RASTER_POSITION_VALID\0" + "GL_CURRENT_RASTER_SECONDARY_COLOR\0" + "GL_CURRENT_RASTER_TEXTURE_COORDS\0" + "GL_CURRENT_SECONDARY_COLOR\0" + "GL_CURRENT_TEXTURE_COORDS\0" + "GL_CURRENT_VERTEX_ATTRIB\0" + "GL_CURRENT_VERTEX_ATTRIB_ARB\0" + "GL_CURRENT_WEIGHT_ARB\0" + "GL_CW\0" + "GL_DEBUG_ASSERT_MESA\0" + "GL_DEBUG_OBJECT_MESA\0" + "GL_DEBUG_PRINT_MESA\0" + "GL_DECAL\0" + "GL_DECR\0" + "GL_DECR_WRAP\0" + "GL_DECR_WRAP_EXT\0" + "GL_DELETE_STATUS\0" + "GL_DEPTH\0" + "GL_DEPTH24_STENCIL8\0" + "GL_DEPTH24_STENCIL8_EXT\0" + "GL_DEPTH24_STENCIL8_OES\0" + "GL_DEPTH_ATTACHMENT\0" + "GL_DEPTH_ATTACHMENT_EXT\0" + "GL_DEPTH_ATTACHMENT_OES\0" + "GL_DEPTH_BIAS\0" + "GL_DEPTH_BITS\0" + "GL_DEPTH_BOUNDS_EXT\0" + "GL_DEPTH_BOUNDS_TEST_EXT\0" + "GL_DEPTH_BUFFER\0" + "GL_DEPTH_BUFFER_BIT\0" + "GL_DEPTH_CLAMP\0" + "GL_DEPTH_CLAMP_NV\0" + "GL_DEPTH_CLEAR_VALUE\0" + "GL_DEPTH_COMPONENT\0" + "GL_DEPTH_COMPONENT16\0" + "GL_DEPTH_COMPONENT16_ARB\0" + "GL_DEPTH_COMPONENT16_OES\0" + "GL_DEPTH_COMPONENT16_SGIX\0" + "GL_DEPTH_COMPONENT24\0" + "GL_DEPTH_COMPONENT24_ARB\0" + "GL_DEPTH_COMPONENT24_OES\0" + "GL_DEPTH_COMPONENT24_SGIX\0" + "GL_DEPTH_COMPONENT32\0" + "GL_DEPTH_COMPONENT32_ARB\0" + "GL_DEPTH_COMPONENT32_OES\0" + "GL_DEPTH_COMPONENT32_SGIX\0" + "GL_DEPTH_FUNC\0" + "GL_DEPTH_RANGE\0" + "GL_DEPTH_SCALE\0" + "GL_DEPTH_STENCIL\0" + "GL_DEPTH_STENCIL_ATTACHMENT\0" + "GL_DEPTH_STENCIL_EXT\0" + "GL_DEPTH_STENCIL_NV\0" + "GL_DEPTH_STENCIL_OES\0" + "GL_DEPTH_STENCIL_TO_BGRA_NV\0" + "GL_DEPTH_STENCIL_TO_RGBA_NV\0" + "GL_DEPTH_TEST\0" + "GL_DEPTH_TEXTURE_MODE\0" + "GL_DEPTH_TEXTURE_MODE_ARB\0" + "GL_DEPTH_WRITEMASK\0" + "GL_DIFFUSE\0" + "GL_DITHER\0" + "GL_DOMAIN\0" + "GL_DONT_CARE\0" + "GL_DOT3_RGB\0" + "GL_DOT3_RGBA\0" + "GL_DOT3_RGBA_ARB\0" + "GL_DOT3_RGBA_EXT\0" + "GL_DOT3_RGB_ARB\0" + "GL_DOT3_RGB_EXT\0" + "GL_DOUBLE\0" + "GL_DOUBLEBUFFER\0" + "GL_DRAW_BUFFER\0" + "GL_DRAW_BUFFER0\0" + "GL_DRAW_BUFFER0_ARB\0" + "GL_DRAW_BUFFER0_ATI\0" + "GL_DRAW_BUFFER1\0" + "GL_DRAW_BUFFER10\0" + "GL_DRAW_BUFFER10_ARB\0" + "GL_DRAW_BUFFER10_ATI\0" + "GL_DRAW_BUFFER11\0" + "GL_DRAW_BUFFER11_ARB\0" + "GL_DRAW_BUFFER11_ATI\0" + "GL_DRAW_BUFFER12\0" + "GL_DRAW_BUFFER12_ARB\0" + "GL_DRAW_BUFFER12_ATI\0" + "GL_DRAW_BUFFER13\0" + "GL_DRAW_BUFFER13_ARB\0" + "GL_DRAW_BUFFER13_ATI\0" + "GL_DRAW_BUFFER14\0" + "GL_DRAW_BUFFER14_ARB\0" + "GL_DRAW_BUFFER14_ATI\0" + "GL_DRAW_BUFFER15\0" + "GL_DRAW_BUFFER15_ARB\0" + "GL_DRAW_BUFFER15_ATI\0" + "GL_DRAW_BUFFER1_ARB\0" + "GL_DRAW_BUFFER1_ATI\0" + "GL_DRAW_BUFFER2\0" + "GL_DRAW_BUFFER2_ARB\0" + "GL_DRAW_BUFFER2_ATI\0" + "GL_DRAW_BUFFER3\0" + "GL_DRAW_BUFFER3_ARB\0" + "GL_DRAW_BUFFER3_ATI\0" + "GL_DRAW_BUFFER4\0" + "GL_DRAW_BUFFER4_ARB\0" + "GL_DRAW_BUFFER4_ATI\0" + "GL_DRAW_BUFFER5\0" + "GL_DRAW_BUFFER5_ARB\0" + "GL_DRAW_BUFFER5_ATI\0" + "GL_DRAW_BUFFER6\0" + "GL_DRAW_BUFFER6_ARB\0" + "GL_DRAW_BUFFER6_ATI\0" + "GL_DRAW_BUFFER7\0" + "GL_DRAW_BUFFER7_ARB\0" + "GL_DRAW_BUFFER7_ATI\0" + "GL_DRAW_BUFFER8\0" + "GL_DRAW_BUFFER8_ARB\0" + "GL_DRAW_BUFFER8_ATI\0" + "GL_DRAW_BUFFER9\0" + "GL_DRAW_BUFFER9_ARB\0" + "GL_DRAW_BUFFER9_ATI\0" + "GL_DRAW_FRAMEBUFFER\0" + "GL_DRAW_FRAMEBUFFER_BINDING\0" + "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0" + "GL_DRAW_FRAMEBUFFER_EXT\0" + "GL_DRAW_PIXEL_TOKEN\0" + "GL_DST_ALPHA\0" + "GL_DST_COLOR\0" + "GL_DU8DV8_ATI\0" + "GL_DUDV_ATI\0" + "GL_DYNAMIC_COPY\0" + "GL_DYNAMIC_COPY_ARB\0" + "GL_DYNAMIC_DRAW\0" + "GL_DYNAMIC_DRAW_ARB\0" + "GL_DYNAMIC_READ\0" + "GL_DYNAMIC_READ_ARB\0" + "GL_EDGE_FLAG\0" + "GL_EDGE_FLAG_ARRAY\0" + "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0" + "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0" + "GL_EDGE_FLAG_ARRAY_POINTER\0" + "GL_EDGE_FLAG_ARRAY_STRIDE\0" + "GL_ELEMENT_ARRAY_BUFFER\0" + "GL_ELEMENT_ARRAY_BUFFER_BINDING\0" + "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0" + "GL_EMISSION\0" + "GL_ENABLE_BIT\0" + "GL_EQUAL\0" + "GL_EQUIV\0" + "GL_EVAL_BIT\0" + "GL_EXP\0" + "GL_EXP2\0" + "GL_EXTENSIONS\0" + "GL_EYE_LINEAR\0" + "GL_EYE_PLANE\0" + "GL_EYE_PLANE_ABSOLUTE_NV\0" + "GL_EYE_RADIAL_NV\0" + "GL_FALSE\0" + "GL_FASTEST\0" + "GL_FEEDBACK\0" + "GL_FEEDBACK_BUFFER_POINTER\0" + "GL_FEEDBACK_BUFFER_SIZE\0" + "GL_FEEDBACK_BUFFER_TYPE\0" + "GL_FILL\0" + "GL_FIRST_VERTEX_CONVENTION\0" + "GL_FIRST_VERTEX_CONVENTION_EXT\0" + "GL_FIXED\0" + "GL_FIXED_OES\0" + "GL_FIXED_ONLY\0" + "GL_FLAT\0" + "GL_FLOAT\0" + "GL_FLOAT_MAT2\0" + "GL_FLOAT_MAT2_ARB\0" + "GL_FLOAT_MAT2x3\0" + "GL_FLOAT_MAT2x4\0" + "GL_FLOAT_MAT3\0" + "GL_FLOAT_MAT3_ARB\0" + "GL_FLOAT_MAT3x2\0" + "GL_FLOAT_MAT3x4\0" + "GL_FLOAT_MAT4\0" + "GL_FLOAT_MAT4_ARB\0" + "GL_FLOAT_MAT4x2\0" + "GL_FLOAT_MAT4x3\0" + "GL_FLOAT_VEC2\0" + "GL_FLOAT_VEC2_ARB\0" + "GL_FLOAT_VEC3\0" + "GL_FLOAT_VEC3_ARB\0" + "GL_FLOAT_VEC4\0" + "GL_FLOAT_VEC4_ARB\0" + "GL_FOG\0" + "GL_FOG_BIT\0" + "GL_FOG_COLOR\0" + "GL_FOG_COORD\0" + "GL_FOG_COORDINATE\0" + "GL_FOG_COORDINATE_ARRAY\0" + "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0" + "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0" + "GL_FOG_COORDINATE_ARRAY_POINTER\0" + "GL_FOG_COORDINATE_ARRAY_STRIDE\0" + "GL_FOG_COORDINATE_ARRAY_TYPE\0" + "GL_FOG_COORDINATE_SOURCE\0" + "GL_FOG_COORD_ARRAY\0" + "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0" + "GL_FOG_COORD_ARRAY_POINTER\0" + "GL_FOG_COORD_ARRAY_STRIDE\0" + "GL_FOG_COORD_ARRAY_TYPE\0" + "GL_FOG_COORD_SRC\0" + "GL_FOG_DENSITY\0" + "GL_FOG_DISTANCE_MODE_NV\0" + "GL_FOG_END\0" + "GL_FOG_HINT\0" + "GL_FOG_INDEX\0" + "GL_FOG_MODE\0" + "GL_FOG_OFFSET_SGIX\0" + "GL_FOG_OFFSET_VALUE_SGIX\0" + "GL_FOG_START\0" + "GL_FRAGMENT_DEPTH\0" + "GL_FRAGMENT_PROGRAM_ARB\0" + "GL_FRAGMENT_SHADER\0" + "GL_FRAGMENT_SHADER_ARB\0" + "GL_FRAGMENT_SHADER_DERIVATIVE_HINT\0" + "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES\0" + "GL_FRAMEBUFFER\0" + "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING\0" + "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE\0" + "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_LAYERED\0" + "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES\0" + "GL_FRAMEBUFFER_BINDING\0" + "GL_FRAMEBUFFER_BINDING_EXT\0" + "GL_FRAMEBUFFER_BINDING_OES\0" + "GL_FRAMEBUFFER_COMPLETE\0" + "GL_FRAMEBUFFER_COMPLETE_EXT\0" + "GL_FRAMEBUFFER_COMPLETE_OES\0" + "GL_FRAMEBUFFER_DEFAULT\0" + "GL_FRAMEBUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0" + "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES\0" + "GL_FRAMEBUFFER_OES\0" + "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0" + "GL_FRAMEBUFFER_UNDEFINED\0" + "GL_FRAMEBUFFER_UNSUPPORTED\0" + "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0" + "GL_FRAMEBUFFER_UNSUPPORTED_OES\0" + "GL_FRONT\0" + "GL_FRONT_AND_BACK\0" + "GL_FRONT_FACE\0" + "GL_FRONT_LEFT\0" + "GL_FRONT_RIGHT\0" + "GL_FUNC_ADD\0" + "GL_FUNC_ADD_EXT\0" + "GL_FUNC_ADD_OES\0" + "GL_FUNC_REVERSE_SUBTRACT\0" + "GL_FUNC_REVERSE_SUBTRACT_EXT\0" + "GL_FUNC_REVERSE_SUBTRACT_OES\0" + "GL_FUNC_SUBTRACT\0" + "GL_FUNC_SUBTRACT_EXT\0" + "GL_FUNC_SUBTRACT_OES\0" + "GL_GENERATE_MIPMAP\0" + "GL_GENERATE_MIPMAP_HINT\0" + "GL_GENERATE_MIPMAP_HINT_SGIS\0" + "GL_GENERATE_MIPMAP_SGIS\0" + "GL_GEOMETRY_INPUT_TYPE\0" + "GL_GEOMETRY_INPUT_TYPE_ARB\0" + "GL_GEOMETRY_OUTPUT_TYPE\0" + "GL_GEOMETRY_OUTPUT_TYPE_ARB\0" + "GL_GEOMETRY_SHADER\0" + "GL_GEOMETRY_SHADER_ARB\0" + "GL_GEOMETRY_VERTICES_OUT\0" + "GL_GEOMETRY_VERTICES_OUT_ARB\0" + "GL_GEQUAL\0" + "GL_GREATER\0" + "GL_GREEN\0" + "GL_GREEN_BIAS\0" + "GL_GREEN_BITS\0" + "GL_GREEN_INTEGER\0" + "GL_GREEN_INTEGER_EXT\0" + "GL_GREEN_SCALE\0" + "GL_HALF_FLOAT\0" + "GL_HALF_FLOAT_OES\0" + "GL_HIGH_FLOAT\0" + "GL_HIGH_INT\0" + "GL_HINT_BIT\0" + "GL_HISTOGRAM\0" + "GL_HISTOGRAM_ALPHA_SIZE\0" + "GL_HISTOGRAM_ALPHA_SIZE_EXT\0" + "GL_HISTOGRAM_BLUE_SIZE\0" + "GL_HISTOGRAM_BLUE_SIZE_EXT\0" + "GL_HISTOGRAM_EXT\0" + "GL_HISTOGRAM_FORMAT\0" + "GL_HISTOGRAM_FORMAT_EXT\0" + "GL_HISTOGRAM_GREEN_SIZE\0" + "GL_HISTOGRAM_GREEN_SIZE_EXT\0" + "GL_HISTOGRAM_LUMINANCE_SIZE\0" + "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0" + "GL_HISTOGRAM_RED_SIZE\0" + "GL_HISTOGRAM_RED_SIZE_EXT\0" + "GL_HISTOGRAM_SINK\0" + "GL_HISTOGRAM_SINK_EXT\0" + "GL_HISTOGRAM_WIDTH\0" + "GL_HISTOGRAM_WIDTH_EXT\0" + "GL_IDENTITY_NV\0" + "GL_IGNORE_BORDER_HP\0" + "GL_IMPLEMENTATION_COLOR_READ_FORMAT\0" + "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0" + "GL_IMPLEMENTATION_COLOR_READ_TYPE\0" + "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0" + "GL_INCR\0" + "GL_INCR_WRAP\0" + "GL_INCR_WRAP_EXT\0" + "GL_INDEX\0" + "GL_INDEX_ARRAY\0" + "GL_INDEX_ARRAY_BUFFER_BINDING\0" + "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0" + "GL_INDEX_ARRAY_POINTER\0" + "GL_INDEX_ARRAY_STRIDE\0" + "GL_INDEX_ARRAY_TYPE\0" + "GL_INDEX_BITS\0" + "GL_INDEX_CLEAR_VALUE\0" + "GL_INDEX_LOGIC_OP\0" + "GL_INDEX_MODE\0" + "GL_INDEX_OFFSET\0" + "GL_INDEX_SHIFT\0" + "GL_INDEX_WRITEMASK\0" + "GL_INFO_LOG_LENGTH\0" + "GL_INT\0" + "GL_INTENSITY\0" + "GL_INTENSITY12\0" + "GL_INTENSITY12_EXT\0" + "GL_INTENSITY16\0" + "GL_INTENSITY16I_EXT\0" + "GL_INTENSITY16UI_EXT\0" + "GL_INTENSITY16_EXT\0" + "GL_INTENSITY32I_EXT\0" + "GL_INTENSITY32UI_EXT\0" + "GL_INTENSITY4\0" + "GL_INTENSITY4_EXT\0" + "GL_INTENSITY8\0" + "GL_INTENSITY8I_EXT\0" + "GL_INTENSITY8UI_EXT\0" + "GL_INTENSITY8_EXT\0" + "GL_INTENSITY_EXT\0" + "GL_INTERLEAVED_ATTRIBS\0" + "GL_INTERLEAVED_ATTRIBS_EXT\0" + "GL_INTERPOLATE\0" + "GL_INTERPOLATE_ARB\0" + "GL_INTERPOLATE_EXT\0" + "GL_INT_10_10_10_2_OES\0" + "GL_INT_SAMPLER_1D\0" + "GL_INT_SAMPLER_1D_ARRAY\0" + "GL_INT_SAMPLER_1D_ARRAY_EXT\0" + "GL_INT_SAMPLER_1D_EXT\0" + "GL_INT_SAMPLER_2D\0" + "GL_INT_SAMPLER_2D_ARRAY\0" + "GL_INT_SAMPLER_2D_ARRAY_EXT\0" + "GL_INT_SAMPLER_2D_EXT\0" + "GL_INT_SAMPLER_2D_RECT\0" + "GL_INT_SAMPLER_2D_RECT_EXT\0" + "GL_INT_SAMPLER_3D\0" + "GL_INT_SAMPLER_3D_EXT\0" + "GL_INT_SAMPLER_BUFFER\0" + "GL_INT_SAMPLER_BUFFER_EXT\0" + "GL_INT_SAMPLER_CUBE\0" + "GL_INT_SAMPLER_CUBE_EXT\0" + "GL_INT_VEC2\0" + "GL_INT_VEC2_ARB\0" + "GL_INT_VEC3\0" + "GL_INT_VEC3_ARB\0" + "GL_INT_VEC4\0" + "GL_INT_VEC4_ARB\0" + "GL_INVALID_ENUM\0" + "GL_INVALID_FRAMEBUFFER_OPERATION\0" + "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0" + "GL_INVALID_FRAMEBUFFER_OPERATION_OES\0" + "GL_INVALID_OPERATION\0" + "GL_INVALID_VALUE\0" + "GL_INVERSE_NV\0" + "GL_INVERSE_TRANSPOSE_NV\0" + "GL_INVERT\0" + "GL_KEEP\0" + "GL_LAST_VERTEX_CONVENTION\0" + "GL_LAST_VERTEX_CONVENTION_EXT\0" + "GL_LEFT\0" + "GL_LEQUAL\0" + "GL_LESS\0" + "GL_LIGHT0\0" + "GL_LIGHT1\0" + "GL_LIGHT2\0" + "GL_LIGHT3\0" + "GL_LIGHT4\0" + "GL_LIGHT5\0" + "GL_LIGHT6\0" + "GL_LIGHT7\0" + "GL_LIGHTING\0" + "GL_LIGHTING_BIT\0" + "GL_LIGHT_MODEL_AMBIENT\0" + "GL_LIGHT_MODEL_COLOR_CONTROL\0" + "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0" + "GL_LIGHT_MODEL_LOCAL_VIEWER\0" + "GL_LIGHT_MODEL_TWO_SIDE\0" + "GL_LINE\0" + "GL_LINEAR\0" + "GL_LINEAR_ATTENUATION\0" + "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0" + "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0" + "GL_LINEAR_MIPMAP_LINEAR\0" + "GL_LINEAR_MIPMAP_NEAREST\0" + "GL_LINES\0" + "GL_LINES_ADJACENCY\0" + "GL_LINES_ADJACENCY_ARB\0" + "GL_LINE_BIT\0" + "GL_LINE_LOOP\0" + "GL_LINE_RESET_TOKEN\0" + "GL_LINE_SMOOTH\0" + "GL_LINE_SMOOTH_HINT\0" + "GL_LINE_STIPPLE\0" + "GL_LINE_STIPPLE_PATTERN\0" + "GL_LINE_STIPPLE_REPEAT\0" + "GL_LINE_STRIP\0" + "GL_LINE_STRIP_ADJACENCY\0" + "GL_LINE_STRIP_ADJACENCY_ARB\0" + "GL_LINE_TOKEN\0" + "GL_LINE_WIDTH\0" + "GL_LINE_WIDTH_GRANULARITY\0" + "GL_LINE_WIDTH_RANGE\0" + "GL_LINK_STATUS\0" + "GL_LIST_BASE\0" + "GL_LIST_BIT\0" + "GL_LIST_INDEX\0" + "GL_LIST_MODE\0" + "GL_LOAD\0" + "GL_LOGIC_OP\0" + "GL_LOGIC_OP_MODE\0" + "GL_LOWER_LEFT\0" + "GL_LOW_FLOAT\0" + "GL_LOW_INT\0" + "GL_LUMINANCE\0" + "GL_LUMINANCE12\0" + "GL_LUMINANCE12_ALPHA12\0" + "GL_LUMINANCE12_ALPHA12_EXT\0" + "GL_LUMINANCE12_ALPHA4\0" + "GL_LUMINANCE12_ALPHA4_EXT\0" + "GL_LUMINANCE12_EXT\0" + "GL_LUMINANCE16\0" + "GL_LUMINANCE16I_EXT\0" + "GL_LUMINANCE16UI_EXT\0" + "GL_LUMINANCE16_ALPHA16\0" + "GL_LUMINANCE16_ALPHA16_EXT\0" + "GL_LUMINANCE16_EXT\0" + "GL_LUMINANCE32I_EXT\0" + "GL_LUMINANCE32UI_EXT\0" + "GL_LUMINANCE4\0" + "GL_LUMINANCE4_ALPHA4\0" + "GL_LUMINANCE4_ALPHA4_EXT\0" + "GL_LUMINANCE4_EXT\0" + "GL_LUMINANCE6_ALPHA2\0" + "GL_LUMINANCE6_ALPHA2_EXT\0" + "GL_LUMINANCE8\0" + "GL_LUMINANCE8I_EXT\0" + "GL_LUMINANCE8UI_EXT\0" + "GL_LUMINANCE8_ALPHA8\0" + "GL_LUMINANCE8_ALPHA8_EXT\0" + "GL_LUMINANCE8_EXT\0" + "GL_LUMINANCE_ALPHA\0" + "GL_LUMINANCE_ALPHA16I_EXT\0" + "GL_LUMINANCE_ALPHA16UI_EXT\0" + "GL_LUMINANCE_ALPHA32I_EXT\0" + "GL_LUMINANCE_ALPHA32UI_EXT\0" + "GL_LUMINANCE_ALPHA8I_EXT\0" + "GL_LUMINANCE_ALPHA8UI_EXT\0" + "GL_LUMINANCE_ALPHA_INTEGER_EXT\0" + "GL_LUMINANCE_INTEGER_EXT\0" + "GL_MAJOR_VERSION\0" + "GL_MAP1_COLOR_4\0" + "GL_MAP1_GRID_DOMAIN\0" + "GL_MAP1_GRID_SEGMENTS\0" + "GL_MAP1_INDEX\0" + "GL_MAP1_NORMAL\0" + "GL_MAP1_TEXTURE_COORD_1\0" + "GL_MAP1_TEXTURE_COORD_2\0" + "GL_MAP1_TEXTURE_COORD_3\0" + "GL_MAP1_TEXTURE_COORD_4\0" + "GL_MAP1_VERTEX_3\0" + "GL_MAP1_VERTEX_4\0" + "GL_MAP1_VERTEX_ATTRIB0_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB10_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB11_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB12_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB13_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB14_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB15_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB1_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB2_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB3_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB4_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB5_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB6_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB7_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB8_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB9_4_NV\0" + "GL_MAP2_COLOR_4\0" + "GL_MAP2_GRID_DOMAIN\0" + "GL_MAP2_GRID_SEGMENTS\0" + "GL_MAP2_INDEX\0" + "GL_MAP2_NORMAL\0" + "GL_MAP2_TEXTURE_COORD_1\0" + "GL_MAP2_TEXTURE_COORD_2\0" + "GL_MAP2_TEXTURE_COORD_3\0" + "GL_MAP2_TEXTURE_COORD_4\0" + "GL_MAP2_VERTEX_3\0" + "GL_MAP2_VERTEX_4\0" + "GL_MAP2_VERTEX_ATTRIB0_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB10_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB11_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB12_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB13_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB14_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB15_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB1_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB2_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB3_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB4_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB5_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB6_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB7_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB8_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB9_4_NV\0" + "GL_MAP_COLOR\0" + "GL_MAP_FLUSH_EXPLICIT_BIT\0" + "GL_MAP_INVALIDATE_BUFFER_BIT\0" + "GL_MAP_INVALIDATE_RANGE_BIT\0" + "GL_MAP_READ_BIT\0" + "GL_MAP_STENCIL\0" + "GL_MAP_UNSYNCHRONIZED_BIT\0" + "GL_MAP_WRITE_BIT\0" + "GL_MATRIX0_ARB\0" + "GL_MATRIX0_NV\0" + "GL_MATRIX10_ARB\0" + "GL_MATRIX11_ARB\0" + "GL_MATRIX12_ARB\0" + "GL_MATRIX13_ARB\0" + "GL_MATRIX14_ARB\0" + "GL_MATRIX15_ARB\0" + "GL_MATRIX16_ARB\0" + "GL_MATRIX17_ARB\0" + "GL_MATRIX18_ARB\0" + "GL_MATRIX19_ARB\0" + "GL_MATRIX1_ARB\0" + "GL_MATRIX1_NV\0" + "GL_MATRIX20_ARB\0" + "GL_MATRIX21_ARB\0" + "GL_MATRIX22_ARB\0" + "GL_MATRIX23_ARB\0" + "GL_MATRIX24_ARB\0" + "GL_MATRIX25_ARB\0" + "GL_MATRIX26_ARB\0" + "GL_MATRIX27_ARB\0" + "GL_MATRIX28_ARB\0" + "GL_MATRIX29_ARB\0" + "GL_MATRIX2_ARB\0" + "GL_MATRIX2_NV\0" + "GL_MATRIX30_ARB\0" + "GL_MATRIX31_ARB\0" + "GL_MATRIX3_ARB\0" + "GL_MATRIX3_NV\0" + "GL_MATRIX4_ARB\0" + "GL_MATRIX4_NV\0" + "GL_MATRIX5_ARB\0" + "GL_MATRIX5_NV\0" + "GL_MATRIX6_ARB\0" + "GL_MATRIX6_NV\0" + "GL_MATRIX7_ARB\0" + "GL_MATRIX7_NV\0" + "GL_MATRIX8_ARB\0" + "GL_MATRIX9_ARB\0" + "GL_MATRIX_INDEX_ARRAY_ARB\0" + "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES\0" + "GL_MATRIX_INDEX_ARRAY_OES\0" + "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0" + "GL_MATRIX_INDEX_ARRAY_POINTER_OES\0" + "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_SIZE_OES\0" + "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_STRIDE_OES\0" + "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_TYPE_OES\0" + "GL_MATRIX_MODE\0" + "GL_MATRIX_PALETTE_ARB\0" + "GL_MATRIX_PALETTE_OES\0" + "GL_MAX\0" + "GL_MAX_3D_TEXTURE_SIZE\0" + "GL_MAX_3D_TEXTURE_SIZE_OES\0" + "GL_MAX_ARRAY_TEXTURE_LAYERS\0" + "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT\0" + "GL_MAX_ATTRIB_STACK_DEPTH\0" + "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0" + "GL_MAX_CLIPMAP_DEPTH_SGIX\0" + "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" + "GL_MAX_CLIP_DISTANCES\0" + "GL_MAX_CLIP_PLANES\0" + "GL_MAX_COLOR_ATTACHMENTS\0" + "GL_MAX_COLOR_ATTACHMENTS_EXT\0" + "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0" + "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0" + "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_CONVOLUTION_HEIGHT\0" + "GL_MAX_CONVOLUTION_HEIGHT_EXT\0" + "GL_MAX_CONVOLUTION_WIDTH\0" + "GL_MAX_CONVOLUTION_WIDTH_EXT\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES\0" + "GL_MAX_DRAW_BUFFERS\0" + "GL_MAX_DRAW_BUFFERS_ARB\0" + "GL_MAX_DRAW_BUFFERS_ATI\0" + "GL_MAX_ELEMENTS_INDICES\0" + "GL_MAX_ELEMENTS_VERTICES\0" + "GL_MAX_EVAL_ORDER\0" + "GL_MAX_EXT\0" + "GL_MAX_FRAGMENT_INPUT_COMPONENTS\0" + "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS\0" + "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_FRAGMENT_UNIFORM_VECTORS\0" + "GL_MAX_GEOMETRY_INPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_OUTPUT_VERTICES\0" + "GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB\0" + "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB\0" + "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS\0" + "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB\0" + "GL_MAX_LIGHTS\0" + "GL_MAX_LIST_NESTING\0" + "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0" + "GL_MAX_MODELVIEW_STACK_DEPTH\0" + "GL_MAX_NAME_STACK_DEPTH\0" + "GL_MAX_PALETTE_MATRICES_ARB\0" + "GL_MAX_PALETTE_MATRICES_OES\0" + "GL_MAX_PIXEL_MAP_TABLE\0" + "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0" + "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_ATTRIBS_ARB\0" + "GL_MAX_PROGRAM_CALL_DEPTH_NV\0" + "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0" + "GL_MAX_PROGRAM_IF_DEPTH_NV\0" + "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_LOOP_COUNT_NV\0" + "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0" + "GL_MAX_PROGRAM_MATRICES_ARB\0" + "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_TEMPORARIES_ARB\0" + "GL_MAX_PROGRAM_TEXEL_OFFSET\0" + "GL_MAX_PROGRAM_TEXEL_OFFSET_EXT\0" + "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0" + "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0" + "GL_MAX_PROJECTION_STACK_DEPTH\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0" + "GL_MAX_RENDERBUFFER_SIZE\0" + "GL_MAX_RENDERBUFFER_SIZE_EXT\0" + "GL_MAX_RENDERBUFFER_SIZE_OES\0" + "GL_MAX_SAMPLES\0" + "GL_MAX_SAMPLES_EXT\0" + "GL_MAX_SERVER_WAIT_TIMEOUT\0" + "GL_MAX_SHININESS_NV\0" + "GL_MAX_SPOT_EXPONENT_NV\0" + "GL_MAX_TEXTURE_BUFFER_SIZE\0" + "GL_MAX_TEXTURE_COORDS\0" + "GL_MAX_TEXTURE_COORDS_ARB\0" + "GL_MAX_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_TEXTURE_LOD_BIAS\0" + "GL_MAX_TEXTURE_LOD_BIAS_EXT\0" + "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0" + "GL_MAX_TEXTURE_SIZE\0" + "GL_MAX_TEXTURE_STACK_DEPTH\0" + "GL_MAX_TEXTURE_UNITS\0" + "GL_MAX_TEXTURE_UNITS_ARB\0" + "GL_MAX_TRACK_MATRICES_NV\0" + "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" + "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\0" + "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT\0" + "GL_MAX_VARYING_COMPONENTS\0" + "GL_MAX_VARYING_FLOATS\0" + "GL_MAX_VARYING_FLOATS_ARB\0" + "GL_MAX_VARYING_VECTORS\0" + "GL_MAX_VERTEX_ATTRIBS\0" + "GL_MAX_VERTEX_ATTRIBS_ARB\0" + "GL_MAX_VERTEX_OUTPUT_COMPONENTS\0" + "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" + "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_VERTEX_UNIFORM_VECTORS\0" + "GL_MAX_VERTEX_UNITS_ARB\0" + "GL_MAX_VERTEX_UNITS_OES\0" + "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB\0" + "GL_MAX_VIEWPORT_DIMS\0" + "GL_MEDIUM_FLOAT\0" + "GL_MEDIUM_INT\0" + "GL_MIN\0" + "GL_MINMAX\0" + "GL_MINMAX_EXT\0" + "GL_MINMAX_FORMAT\0" + "GL_MINMAX_FORMAT_EXT\0" + "GL_MINMAX_SINK\0" + "GL_MINMAX_SINK_EXT\0" + "GL_MINOR_VERSION\0" + "GL_MIN_EXT\0" + "GL_MIN_PROGRAM_TEXEL_OFFSET\0" + "GL_MIN_PROGRAM_TEXEL_OFFSET_EXT\0" + "GL_MIRRORED_REPEAT\0" + "GL_MIRRORED_REPEAT_ARB\0" + "GL_MIRRORED_REPEAT_IBM\0" + "GL_MIRROR_CLAMP_ATI\0" + "GL_MIRROR_CLAMP_EXT\0" + "GL_MIRROR_CLAMP_TO_BORDER_EXT\0" + "GL_MIRROR_CLAMP_TO_EDGE_ATI\0" + "GL_MIRROR_CLAMP_TO_EDGE_EXT\0" + "GL_MODELVIEW\0" + "GL_MODELVIEW0_ARB\0" + "GL_MODELVIEW10_ARB\0" + "GL_MODELVIEW11_ARB\0" + "GL_MODELVIEW12_ARB\0" + "GL_MODELVIEW13_ARB\0" + "GL_MODELVIEW14_ARB\0" + "GL_MODELVIEW15_ARB\0" + "GL_MODELVIEW16_ARB\0" + "GL_MODELVIEW17_ARB\0" + "GL_MODELVIEW18_ARB\0" + "GL_MODELVIEW19_ARB\0" + "GL_MODELVIEW1_ARB\0" + "GL_MODELVIEW20_ARB\0" + "GL_MODELVIEW21_ARB\0" + "GL_MODELVIEW22_ARB\0" + "GL_MODELVIEW23_ARB\0" + "GL_MODELVIEW24_ARB\0" + "GL_MODELVIEW25_ARB\0" + "GL_MODELVIEW26_ARB\0" + "GL_MODELVIEW27_ARB\0" + "GL_MODELVIEW28_ARB\0" + "GL_MODELVIEW29_ARB\0" + "GL_MODELVIEW2_ARB\0" + "GL_MODELVIEW30_ARB\0" + "GL_MODELVIEW31_ARB\0" + "GL_MODELVIEW3_ARB\0" + "GL_MODELVIEW4_ARB\0" + "GL_MODELVIEW5_ARB\0" + "GL_MODELVIEW6_ARB\0" + "GL_MODELVIEW7_ARB\0" + "GL_MODELVIEW8_ARB\0" + "GL_MODELVIEW9_ARB\0" + "GL_MODELVIEW_MATRIX\0" + "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_MODELVIEW_PROJECTION_NV\0" + "GL_MODELVIEW_STACK_DEPTH\0" + "GL_MODULATE\0" + "GL_MODULATE_ADD_ATI\0" + "GL_MODULATE_SIGNED_ADD_ATI\0" + "GL_MODULATE_SUBTRACT_ATI\0" + "GL_MULT\0" + "GL_MULTISAMPLE\0" + "GL_MULTISAMPLE_3DFX\0" + "GL_MULTISAMPLE_ARB\0" + "GL_MULTISAMPLE_BIT\0" + "GL_MULTISAMPLE_BIT_3DFX\0" + "GL_MULTISAMPLE_BIT_ARB\0" + "GL_MULTISAMPLE_FILTER_HINT_NV\0" + "GL_N3F_V3F\0" + "GL_NAME_STACK_DEPTH\0" + "GL_NAND\0" + "GL_NEAREST\0" + "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0" + "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0" + "GL_NEAREST_MIPMAP_LINEAR\0" + "GL_NEAREST_MIPMAP_NEAREST\0" + "GL_NEVER\0" + "GL_NICEST\0" + "GL_NONE\0" + "GL_NONE_OES\0" + "GL_NOOP\0" + "GL_NOR\0" + "GL_NORMALIZE\0" + "GL_NORMAL_ARRAY\0" + "GL_NORMAL_ARRAY_BUFFER_BINDING\0" + "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0" + "GL_NORMAL_ARRAY_POINTER\0" + "GL_NORMAL_ARRAY_STRIDE\0" + "GL_NORMAL_ARRAY_TYPE\0" + "GL_NORMAL_MAP\0" + "GL_NORMAL_MAP_ARB\0" + "GL_NORMAL_MAP_NV\0" + "GL_NORMAL_MAP_OES\0" + "GL_NOTEQUAL\0" + "GL_NO_ERROR\0" + "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" + "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" + "GL_NUM_EXTENSIONS\0" + "GL_NUM_PROGRAM_BINARY_FORMATS_OES\0" + "GL_NUM_SHADER_BINARY_FORMATS\0" + "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" + "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" + "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" + "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0" + "GL_OBJECT_ATTACHED_OBJECTS_ARB\0" + "GL_OBJECT_COMPILE_STATUS_ARB\0" + "GL_OBJECT_DELETE_STATUS_ARB\0" + "GL_OBJECT_INFO_LOG_LENGTH_ARB\0" + "GL_OBJECT_LINEAR\0" + "GL_OBJECT_LINK_STATUS_ARB\0" + "GL_OBJECT_PLANE\0" + "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0" + "GL_OBJECT_SUBTYPE_ARB\0" + "GL_OBJECT_TYPE\0" + "GL_OBJECT_TYPE_ARB\0" + "GL_OBJECT_VALIDATE_STATUS_ARB\0" + "GL_OCCLUSION_TEST_HP\0" + "GL_OCCLUSION_TEST_RESULT_HP\0" + "GL_ONE\0" + "GL_ONE_MINUS_CONSTANT_ALPHA\0" + "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0" + "GL_ONE_MINUS_CONSTANT_COLOR\0" + "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0" + "GL_ONE_MINUS_DST_ALPHA\0" + "GL_ONE_MINUS_DST_COLOR\0" + "GL_ONE_MINUS_SRC_ALPHA\0" + "GL_ONE_MINUS_SRC_COLOR\0" + "GL_OPERAND0_ALPHA\0" + "GL_OPERAND0_ALPHA_ARB\0" + "GL_OPERAND0_ALPHA_EXT\0" + "GL_OPERAND0_RGB\0" + "GL_OPERAND0_RGB_ARB\0" + "GL_OPERAND0_RGB_EXT\0" + "GL_OPERAND1_ALPHA\0" + "GL_OPERAND1_ALPHA_ARB\0" + "GL_OPERAND1_ALPHA_EXT\0" + "GL_OPERAND1_RGB\0" + "GL_OPERAND1_RGB_ARB\0" + "GL_OPERAND1_RGB_EXT\0" + "GL_OPERAND2_ALPHA\0" + "GL_OPERAND2_ALPHA_ARB\0" + "GL_OPERAND2_ALPHA_EXT\0" + "GL_OPERAND2_RGB\0" + "GL_OPERAND2_RGB_ARB\0" + "GL_OPERAND2_RGB_EXT\0" + "GL_OPERAND3_ALPHA_NV\0" + "GL_OPERAND3_RGB_NV\0" + "GL_OR\0" + "GL_ORDER\0" + "GL_OR_INVERTED\0" + "GL_OR_REVERSE\0" + "GL_OUT_OF_MEMORY\0" + "GL_PACK_ALIGNMENT\0" + "GL_PACK_IMAGE_HEIGHT\0" + "GL_PACK_INVERT_MESA\0" + "GL_PACK_LSB_FIRST\0" + "GL_PACK_ROW_LENGTH\0" + "GL_PACK_SKIP_IMAGES\0" + "GL_PACK_SKIP_PIXELS\0" + "GL_PACK_SKIP_ROWS\0" + "GL_PACK_SWAP_BYTES\0" + "GL_PALETTE4_R5_G6_B5_OES\0" + "GL_PALETTE4_RGB5_A1_OES\0" + "GL_PALETTE4_RGB8_OES\0" + "GL_PALETTE4_RGBA4_OES\0" + "GL_PALETTE4_RGBA8_OES\0" + "GL_PALETTE8_R5_G6_B5_OES\0" + "GL_PALETTE8_RGB5_A1_OES\0" + "GL_PALETTE8_RGB8_OES\0" + "GL_PALETTE8_RGBA4_OES\0" + "GL_PALETTE8_RGBA8_OES\0" + "GL_PASS_THROUGH_TOKEN\0" + "GL_PERSPECTIVE_CORRECTION_HINT\0" + "GL_PIXEL_MAP_A_TO_A\0" + "GL_PIXEL_MAP_A_TO_A_SIZE\0" + "GL_PIXEL_MAP_B_TO_B\0" + "GL_PIXEL_MAP_B_TO_B_SIZE\0" + "GL_PIXEL_MAP_G_TO_G\0" + "GL_PIXEL_MAP_G_TO_G_SIZE\0" + "GL_PIXEL_MAP_I_TO_A\0" + "GL_PIXEL_MAP_I_TO_A_SIZE\0" + "GL_PIXEL_MAP_I_TO_B\0" + "GL_PIXEL_MAP_I_TO_B_SIZE\0" + "GL_PIXEL_MAP_I_TO_G\0" + "GL_PIXEL_MAP_I_TO_G_SIZE\0" + "GL_PIXEL_MAP_I_TO_I\0" + "GL_PIXEL_MAP_I_TO_I_SIZE\0" + "GL_PIXEL_MAP_I_TO_R\0" + "GL_PIXEL_MAP_I_TO_R_SIZE\0" + "GL_PIXEL_MAP_R_TO_R\0" + "GL_PIXEL_MAP_R_TO_R_SIZE\0" + "GL_PIXEL_MAP_S_TO_S\0" + "GL_PIXEL_MAP_S_TO_S_SIZE\0" + "GL_PIXEL_MODE_BIT\0" + "GL_PIXEL_PACK_BUFFER\0" + "GL_PIXEL_PACK_BUFFER_BINDING\0" + "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0" + "GL_PIXEL_PACK_BUFFER_EXT\0" + "GL_PIXEL_UNPACK_BUFFER\0" + "GL_PIXEL_UNPACK_BUFFER_BINDING\0" + "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0" + "GL_PIXEL_UNPACK_BUFFER_EXT\0" + "GL_POINT\0" + "GL_POINTS\0" + "GL_POINT_BIT\0" + "GL_POINT_DISTANCE_ATTENUATION\0" + "GL_POINT_DISTANCE_ATTENUATION_ARB\0" + "GL_POINT_DISTANCE_ATTENUATION_EXT\0" + "GL_POINT_DISTANCE_ATTENUATION_SGIS\0" + "GL_POINT_FADE_THRESHOLD_SIZE\0" + "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0" + "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0" + "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0" + "GL_POINT_SIZE\0" + "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES\0" + "GL_POINT_SIZE_ARRAY_OES\0" + "GL_POINT_SIZE_ARRAY_POINTER_OES\0" + "GL_POINT_SIZE_ARRAY_STRIDE_OES\0" + "GL_POINT_SIZE_ARRAY_TYPE_OES\0" + "GL_POINT_SIZE_GRANULARITY\0" + "GL_POINT_SIZE_MAX\0" + "GL_POINT_SIZE_MAX_ARB\0" + "GL_POINT_SIZE_MAX_EXT\0" + "GL_POINT_SIZE_MAX_SGIS\0" + "GL_POINT_SIZE_MIN\0" + "GL_POINT_SIZE_MIN_ARB\0" + "GL_POINT_SIZE_MIN_EXT\0" + "GL_POINT_SIZE_MIN_SGIS\0" + "GL_POINT_SIZE_RANGE\0" + "GL_POINT_SMOOTH\0" + "GL_POINT_SMOOTH_HINT\0" + "GL_POINT_SPRITE\0" + "GL_POINT_SPRITE_ARB\0" + "GL_POINT_SPRITE_COORD_ORIGIN\0" + "GL_POINT_SPRITE_NV\0" + "GL_POINT_SPRITE_OES\0" + "GL_POINT_SPRITE_R_MODE_NV\0" + "GL_POINT_TOKEN\0" + "GL_POLYGON\0" + "GL_POLYGON_BIT\0" + "GL_POLYGON_MODE\0" + "GL_POLYGON_OFFSET_BIAS\0" + "GL_POLYGON_OFFSET_FACTOR\0" + "GL_POLYGON_OFFSET_FILL\0" + "GL_POLYGON_OFFSET_LINE\0" + "GL_POLYGON_OFFSET_POINT\0" + "GL_POLYGON_OFFSET_UNITS\0" + "GL_POLYGON_SMOOTH\0" + "GL_POLYGON_SMOOTH_HINT\0" + "GL_POLYGON_STIPPLE\0" + "GL_POLYGON_STIPPLE_BIT\0" + "GL_POLYGON_TOKEN\0" + "GL_POSITION\0" + "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0" + "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0" + "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_BLUE_BIAS\0" + "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_BLUE_SCALE\0" + "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_COLOR_TABLE\0" + "GL_POST_COLOR_MATRIX_GREEN_BIAS\0" + "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_GREEN_SCALE\0" + "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_RED_BIAS\0" + "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_RED_SCALE\0" + "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0" + "GL_POST_CONVOLUTION_ALPHA_BIAS\0" + "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0" + "GL_POST_CONVOLUTION_ALPHA_SCALE\0" + "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0" + "GL_POST_CONVOLUTION_BLUE_BIAS\0" + "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0" + "GL_POST_CONVOLUTION_BLUE_SCALE\0" + "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0" + "GL_POST_CONVOLUTION_COLOR_TABLE\0" + "GL_POST_CONVOLUTION_GREEN_BIAS\0" + "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0" + "GL_POST_CONVOLUTION_GREEN_SCALE\0" + "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0" + "GL_POST_CONVOLUTION_RED_BIAS\0" + "GL_POST_CONVOLUTION_RED_BIAS_EXT\0" + "GL_POST_CONVOLUTION_RED_SCALE\0" + "GL_POST_CONVOLUTION_RED_SCALE_EXT\0" + "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0" + "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0" + "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0" + "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0" + "GL_PREVIOUS\0" + "GL_PREVIOUS_ARB\0" + "GL_PREVIOUS_EXT\0" + "GL_PRIMARY_COLOR\0" + "GL_PRIMARY_COLOR_ARB\0" + "GL_PRIMARY_COLOR_EXT\0" + "GL_PRIMITIVES_GENERATED\0" + "GL_PRIMITIVES_GENERATED_EXT\0" + "GL_PRIMITIVE_RESTART\0" + "GL_PRIMITIVE_RESTART_INDEX\0" + "GL_PRIMITIVE_RESTART_INDEX_NV\0" + "GL_PRIMITIVE_RESTART_NV\0" + "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0" + "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_ATTRIBS_ARB\0" + "GL_PROGRAM_BINARY_FORMATS_OES\0" + "GL_PROGRAM_BINARY_LENGTH_OES\0" + "GL_PROGRAM_BINDING_ARB\0" + "GL_PROGRAM_ERROR_POSITION_ARB\0" + "GL_PROGRAM_ERROR_POSITION_NV\0" + "GL_PROGRAM_ERROR_STRING_ARB\0" + "GL_PROGRAM_FORMAT_ARB\0" + "GL_PROGRAM_FORMAT_ASCII_ARB\0" + "GL_PROGRAM_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_LENGTH_ARB\0" + "GL_PROGRAM_LENGTH_NV\0" + "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" + "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0" + "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0" + "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0" + "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" + "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_OBJECT_ARB\0" + "GL_PROGRAM_PARAMETERS_ARB\0" + "GL_PROGRAM_PARAMETER_NV\0" + "GL_PROGRAM_POINT_SIZE\0" + "GL_PROGRAM_POINT_SIZE_ARB\0" + "GL_PROGRAM_RESIDENT_NV\0" + "GL_PROGRAM_STRING_ARB\0" + "GL_PROGRAM_STRING_NV\0" + "GL_PROGRAM_TARGET_NV\0" + "GL_PROGRAM_TEMPORARIES_ARB\0" + "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0" + "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0" + "GL_PROJECTION\0" + "GL_PROJECTION_MATRIX\0" + "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_PROJECTION_STACK_DEPTH\0" + "GL_PROVOKING_VERTEX\0" + "GL_PROVOKING_VERTEX_EXT\0" + "GL_PROXY_COLOR_TABLE\0" + "GL_PROXY_HISTOGRAM\0" + "GL_PROXY_HISTOGRAM_EXT\0" + "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0" + "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0" + "GL_PROXY_TEXTURE_1D\0" + "GL_PROXY_TEXTURE_1D_ARRAY\0" + "GL_PROXY_TEXTURE_1D_ARRAY_EXT\0" + "GL_PROXY_TEXTURE_1D_EXT\0" + "GL_PROXY_TEXTURE_2D\0" + "GL_PROXY_TEXTURE_2D_ARRAY\0" + "GL_PROXY_TEXTURE_2D_ARRAY_EXT\0" + "GL_PROXY_TEXTURE_2D_EXT\0" + "GL_PROXY_TEXTURE_3D\0" + "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0" + "GL_PROXY_TEXTURE_CUBE_MAP\0" + "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0" + "GL_PROXY_TEXTURE_RECTANGLE\0" + "GL_PROXY_TEXTURE_RECTANGLE_ARB\0" + "GL_PROXY_TEXTURE_RECTANGLE_NV\0" + "GL_PURGEABLE_APPLE\0" + "GL_Q\0" + "GL_QUADRATIC_ATTENUATION\0" + "GL_QUADS\0" + "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\0" + "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0" + "GL_QUAD_MESH_SUN\0" + "GL_QUAD_STRIP\0" + "GL_QUERY_BY_REGION_NO_WAIT\0" + "GL_QUERY_BY_REGION_NO_WAIT_NV\0" + "GL_QUERY_BY_REGION_WAIT\0" + "GL_QUERY_BY_REGION_WAIT_NV\0" + "GL_QUERY_COUNTER_BITS\0" + "GL_QUERY_COUNTER_BITS_ARB\0" + "GL_QUERY_NO_WAIT\0" + "GL_QUERY_NO_WAIT_NV\0" + "GL_QUERY_RESULT\0" + "GL_QUERY_RESULT_ARB\0" + "GL_QUERY_RESULT_AVAILABLE\0" + "GL_QUERY_RESULT_AVAILABLE_ARB\0" + "GL_QUERY_WAIT\0" + "GL_QUERY_WAIT_NV\0" + "GL_R\0" + "GL_R11F_G11F_B10F\0" + "GL_R16_SNORM\0" + "GL_R3_G3_B2\0" + "GL_R8_SNORM\0" + "GL_RASTERIZER_DISCARD\0" + "GL_RASTERIZER_DISCARD_EXT\0" + "GL_RASTER_POSITION_UNCLIPPED_IBM\0" + "GL_READ_BUFFER\0" + "GL_READ_FRAMEBUFFER\0" + "GL_READ_FRAMEBUFFER_BINDING\0" + "GL_READ_FRAMEBUFFER_BINDING_EXT\0" + "GL_READ_FRAMEBUFFER_EXT\0" + "GL_READ_ONLY\0" + "GL_READ_ONLY_ARB\0" + "GL_READ_WRITE\0" + "GL_READ_WRITE_ARB\0" + "GL_RED\0" + "GL_REDUCE\0" + "GL_REDUCE_EXT\0" + "GL_RED_BIAS\0" + "GL_RED_BITS\0" + "GL_RED_INTEGER\0" + "GL_RED_INTEGER_EXT\0" + "GL_RED_SCALE\0" + "GL_RED_SNORM\0" + "GL_REFLECTION_MAP\0" + "GL_REFLECTION_MAP_ARB\0" + "GL_REFLECTION_MAP_NV\0" + "GL_REFLECTION_MAP_OES\0" + "GL_RELEASED_APPLE\0" + "GL_RENDER\0" + "GL_RENDERBUFFER\0" + "GL_RENDERBUFFER_ALPHA_SIZE\0" + "GL_RENDERBUFFER_ALPHA_SIZE_OES\0" + "GL_RENDERBUFFER_BINDING\0" + "GL_RENDERBUFFER_BINDING_EXT\0" + "GL_RENDERBUFFER_BINDING_OES\0" + "GL_RENDERBUFFER_BLUE_SIZE\0" + "GL_RENDERBUFFER_BLUE_SIZE_OES\0" + "GL_RENDERBUFFER_DEPTH_SIZE\0" + "GL_RENDERBUFFER_DEPTH_SIZE_OES\0" + "GL_RENDERBUFFER_EXT\0" + "GL_RENDERBUFFER_GREEN_SIZE\0" + "GL_RENDERBUFFER_GREEN_SIZE_OES\0" + "GL_RENDERBUFFER_HEIGHT\0" + "GL_RENDERBUFFER_HEIGHT_EXT\0" + "GL_RENDERBUFFER_HEIGHT_OES\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT_OES\0" + "GL_RENDERBUFFER_OES\0" + "GL_RENDERBUFFER_RED_SIZE\0" + "GL_RENDERBUFFER_RED_SIZE_OES\0" + "GL_RENDERBUFFER_SAMPLES\0" + "GL_RENDERBUFFER_SAMPLES_EXT\0" + "GL_RENDERBUFFER_STENCIL_SIZE\0" + "GL_RENDERBUFFER_STENCIL_SIZE_OES\0" + "GL_RENDERBUFFER_WIDTH\0" + "GL_RENDERBUFFER_WIDTH_EXT\0" + "GL_RENDERBUFFER_WIDTH_OES\0" + "GL_RENDERER\0" + "GL_RENDER_MODE\0" + "GL_REPEAT\0" + "GL_REPLACE\0" + "GL_REPLACE_EXT\0" + "GL_REPLICATE_BORDER_HP\0" + "GL_RESCALE_NORMAL\0" + "GL_RESCALE_NORMAL_EXT\0" + "GL_RETAINED_APPLE\0" + "GL_RETURN\0" + "GL_RG16_SNORM\0" + "GL_RG8_SNORM\0" + "GL_RGB\0" + "GL_RGB10\0" + "GL_RGB10_A2\0" + "GL_RGB10_A2_EXT\0" + "GL_RGB10_EXT\0" + "GL_RGB12\0" + "GL_RGB12_EXT\0" + "GL_RGB16\0" + "GL_RGB16F\0" + "GL_RGB16I\0" + "GL_RGB16I_EXT\0" + "GL_RGB16UI\0" + "GL_RGB16UI_EXT\0" + "GL_RGB16_EXT\0" + "GL_RGB16_SNORM\0" + "GL_RGB2_EXT\0" + "GL_RGB32F\0" + "GL_RGB32I\0" + "GL_RGB32I_EXT\0" + "GL_RGB32UI\0" + "GL_RGB32UI_EXT\0" + "GL_RGB4\0" + "GL_RGB4_EXT\0" + "GL_RGB4_S3TC\0" + "GL_RGB5\0" + "GL_RGB565\0" + "GL_RGB565_OES\0" + "GL_RGB5_A1\0" + "GL_RGB5_A1_EXT\0" + "GL_RGB5_A1_OES\0" + "GL_RGB5_EXT\0" + "GL_RGB8\0" + "GL_RGB8I\0" + "GL_RGB8I_EXT\0" + "GL_RGB8UI\0" + "GL_RGB8UI_EXT\0" + "GL_RGB8_EXT\0" + "GL_RGB8_OES\0" + "GL_RGB8_SNORM\0" + "GL_RGB9_E5\0" + "GL_RGBA\0" + "GL_RGBA12\0" + "GL_RGBA12_EXT\0" + "GL_RGBA16\0" + "GL_RGBA16F\0" + "GL_RGBA16I\0" + "GL_RGBA16I_EXT\0" + "GL_RGBA16UI\0" + "GL_RGBA16UI_EXT\0" + "GL_RGBA16_EXT\0" + "GL_RGBA16_SNORM\0" + "GL_RGBA2\0" + "GL_RGBA2_EXT\0" + "GL_RGBA32F\0" + "GL_RGBA32I\0" + "GL_RGBA32I_EXT\0" + "GL_RGBA32UI\0" + "GL_RGBA32UI_EXT\0" + "GL_RGBA4\0" + "GL_RGBA4_DXT5_S3TC\0" + "GL_RGBA4_EXT\0" + "GL_RGBA4_OES\0" + "GL_RGBA4_S3TC\0" + "GL_RGBA8\0" + "GL_RGBA8I\0" + "GL_RGBA8I_EXT\0" + "GL_RGBA8UI\0" + "GL_RGBA8UI_EXT\0" + "GL_RGBA8_EXT\0" + "GL_RGBA8_OES\0" + "GL_RGBA8_SNORM\0" + "GL_RGBA_DXT5_S3TC\0" + "GL_RGBA_INTEGER\0" + "GL_RGBA_INTEGER_EXT\0" + "GL_RGBA_INTEGER_MODE_EXT\0" + "GL_RGBA_MODE\0" + "GL_RGBA_S3TC\0" + "GL_RGBA_SNORM\0" + "GL_RGB_INTEGER\0" + "GL_RGB_INTEGER_EXT\0" + "GL_RGB_S3TC\0" + "GL_RGB_SCALE\0" + "GL_RGB_SCALE_ARB\0" + "GL_RGB_SCALE_EXT\0" + "GL_RGB_SNORM\0" + "GL_RG_SNORM\0" + "GL_RIGHT\0" + "GL_S\0" + "GL_SAMPLER_1D\0" + "GL_SAMPLER_1D_ARRAY\0" + "GL_SAMPLER_1D_ARRAY_EXT\0" + "GL_SAMPLER_1D_ARRAY_SHADOW\0" + "GL_SAMPLER_1D_ARRAY_SHADOW_EXT\0" + "GL_SAMPLER_1D_SHADOW\0" + "GL_SAMPLER_2D\0" + "GL_SAMPLER_2D_ARRAY\0" + "GL_SAMPLER_2D_ARRAY_EXT\0" + "GL_SAMPLER_2D_ARRAY_SHADOW\0" + "GL_SAMPLER_2D_ARRAY_SHADOW_EXT\0" + "GL_SAMPLER_2D_RECT\0" + "GL_SAMPLER_2D_RECT_SHADOW\0" + "GL_SAMPLER_2D_SHADOW\0" + "GL_SAMPLER_3D\0" + "GL_SAMPLER_3D_OES\0" + "GL_SAMPLER_BUFFER\0" + "GL_SAMPLER_BUFFER_EXT\0" + "GL_SAMPLER_CUBE\0" + "GL_SAMPLER_CUBE_SHADOW\0" + "GL_SAMPLER_CUBE_SHADOW_EXT\0" + "GL_SAMPLES\0" + "GL_SAMPLES_3DFX\0" + "GL_SAMPLES_ARB\0" + "GL_SAMPLES_PASSED\0" + "GL_SAMPLES_PASSED_ARB\0" + "GL_SAMPLE_ALPHA_TO_COVERAGE\0" + "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0" + "GL_SAMPLE_ALPHA_TO_ONE\0" + "GL_SAMPLE_ALPHA_TO_ONE_ARB\0" + "GL_SAMPLE_BUFFERS\0" + "GL_SAMPLE_BUFFERS_3DFX\0" + "GL_SAMPLE_BUFFERS_ARB\0" + "GL_SAMPLE_COVERAGE\0" + "GL_SAMPLE_COVERAGE_ARB\0" + "GL_SAMPLE_COVERAGE_INVERT\0" + "GL_SAMPLE_COVERAGE_INVERT_ARB\0" + "GL_SAMPLE_COVERAGE_VALUE\0" + "GL_SAMPLE_COVERAGE_VALUE_ARB\0" + "GL_SCISSOR_BIT\0" + "GL_SCISSOR_BOX\0" + "GL_SCISSOR_TEST\0" + "GL_SECONDARY_COLOR_ARRAY\0" + "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0" + "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0" + "GL_SECONDARY_COLOR_ARRAY_POINTER\0" + "GL_SECONDARY_COLOR_ARRAY_SIZE\0" + "GL_SECONDARY_COLOR_ARRAY_STRIDE\0" + "GL_SECONDARY_COLOR_ARRAY_TYPE\0" + "GL_SELECT\0" + "GL_SELECTION_BUFFER_POINTER\0" + "GL_SELECTION_BUFFER_SIZE\0" + "GL_SEPARABLE_2D\0" + "GL_SEPARATE_ATTRIBS\0" + "GL_SEPARATE_ATTRIBS_EXT\0" + "GL_SEPARATE_SPECULAR_COLOR\0" + "GL_SEPARATE_SPECULAR_COLOR_EXT\0" + "GL_SET\0" + "GL_SHADER_BINARY_FORMATS\0" + "GL_SHADER_COMPILER\0" + "GL_SHADER_OBJECT_ARB\0" + "GL_SHADER_SOURCE_LENGTH\0" + "GL_SHADER_TYPE\0" + "GL_SHADE_MODEL\0" + "GL_SHADING_LANGUAGE_VERSION\0" + "GL_SHADOW_AMBIENT_SGIX\0" + "GL_SHARED_TEXTURE_PALETTE_EXT\0" + "GL_SHININESS\0" + "GL_SHORT\0" + "GL_SIGNALED\0" + "GL_SIGNED_NORMALIZED\0" + "GL_SINGLE_COLOR\0" + "GL_SINGLE_COLOR_EXT\0" + "GL_SLICE_ACCUM_SUN\0" + "GL_SLUMINANCE\0" + "GL_SLUMINANCE8\0" + "GL_SLUMINANCE8_ALPHA8\0" + "GL_SLUMINANCE_ALPHA\0" + "GL_SMOOTH\0" + "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0" + "GL_SMOOTH_LINE_WIDTH_RANGE\0" + "GL_SMOOTH_POINT_SIZE_GRANULARITY\0" + "GL_SMOOTH_POINT_SIZE_RANGE\0" + "GL_SOURCE0_ALPHA\0" + "GL_SOURCE0_ALPHA_ARB\0" + "GL_SOURCE0_ALPHA_EXT\0" + "GL_SOURCE0_RGB\0" + "GL_SOURCE0_RGB_ARB\0" + "GL_SOURCE0_RGB_EXT\0" + "GL_SOURCE1_ALPHA\0" + "GL_SOURCE1_ALPHA_ARB\0" + "GL_SOURCE1_ALPHA_EXT\0" + "GL_SOURCE1_RGB\0" + "GL_SOURCE1_RGB_ARB\0" + "GL_SOURCE1_RGB_EXT\0" + "GL_SOURCE2_ALPHA\0" + "GL_SOURCE2_ALPHA_ARB\0" + "GL_SOURCE2_ALPHA_EXT\0" + "GL_SOURCE2_RGB\0" + "GL_SOURCE2_RGB_ARB\0" + "GL_SOURCE2_RGB_EXT\0" + "GL_SOURCE3_ALPHA_NV\0" + "GL_SOURCE3_RGB_NV\0" + "GL_SPECULAR\0" + "GL_SPHERE_MAP\0" + "GL_SPOT_CUTOFF\0" + "GL_SPOT_DIRECTION\0" + "GL_SPOT_EXPONENT\0" + "GL_SRC0_ALPHA\0" + "GL_SRC0_RGB\0" + "GL_SRC1_ALPHA\0" + "GL_SRC1_RGB\0" + "GL_SRC2_ALPHA\0" + "GL_SRC2_RGB\0" + "GL_SRC_ALPHA\0" + "GL_SRC_ALPHA_SATURATE\0" + "GL_SRC_COLOR\0" + "GL_SRGB\0" + "GL_SRGB8\0" + "GL_SRGB8_ALPHA8\0" + "GL_SRGB_ALPHA\0" + "GL_STACK_OVERFLOW\0" + "GL_STACK_UNDERFLOW\0" + "GL_STATIC_COPY\0" + "GL_STATIC_COPY_ARB\0" + "GL_STATIC_DRAW\0" + "GL_STATIC_DRAW_ARB\0" + "GL_STATIC_READ\0" + "GL_STATIC_READ_ARB\0" + "GL_STENCIL\0" + "GL_STENCIL_ATTACHMENT\0" + "GL_STENCIL_ATTACHMENT_EXT\0" + "GL_STENCIL_ATTACHMENT_OES\0" + "GL_STENCIL_BACK_FAIL\0" + "GL_STENCIL_BACK_FAIL_ATI\0" + "GL_STENCIL_BACK_FUNC\0" + "GL_STENCIL_BACK_FUNC_ATI\0" + "GL_STENCIL_BACK_PASS_DEPTH_FAIL\0" + "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI\0" + "GL_STENCIL_BACK_PASS_DEPTH_PASS\0" + "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI\0" + "GL_STENCIL_BACK_REF\0" + "GL_STENCIL_BACK_VALUE_MASK\0" + "GL_STENCIL_BACK_WRITEMASK\0" + "GL_STENCIL_BITS\0" + "GL_STENCIL_BUFFER\0" + "GL_STENCIL_BUFFER_BIT\0" + "GL_STENCIL_CLEAR_VALUE\0" + "GL_STENCIL_FAIL\0" + "GL_STENCIL_FUNC\0" + "GL_STENCIL_INDEX\0" + "GL_STENCIL_INDEX1\0" + "GL_STENCIL_INDEX16\0" + "GL_STENCIL_INDEX16_EXT\0" + "GL_STENCIL_INDEX1_EXT\0" + "GL_STENCIL_INDEX1_OES\0" + "GL_STENCIL_INDEX4\0" + "GL_STENCIL_INDEX4_EXT\0" + "GL_STENCIL_INDEX4_OES\0" + "GL_STENCIL_INDEX8\0" + "GL_STENCIL_INDEX8_EXT\0" + "GL_STENCIL_INDEX8_OES\0" + "GL_STENCIL_INDEX_EXT\0" + "GL_STENCIL_PASS_DEPTH_FAIL\0" + "GL_STENCIL_PASS_DEPTH_PASS\0" + "GL_STENCIL_REF\0" + "GL_STENCIL_TEST\0" + "GL_STENCIL_TEST_TWO_SIDE_EXT\0" + "GL_STENCIL_VALUE_MASK\0" + "GL_STENCIL_WRITEMASK\0" + "GL_STEREO\0" + "GL_STORAGE_CACHED_APPLE\0" + "GL_STORAGE_PRIVATE_APPLE\0" + "GL_STORAGE_SHARED_APPLE\0" + "GL_STREAM_COPY\0" + "GL_STREAM_COPY_ARB\0" + "GL_STREAM_DRAW\0" + "GL_STREAM_DRAW_ARB\0" + "GL_STREAM_READ\0" + "GL_STREAM_READ_ARB\0" + "GL_SUBPIXEL_BITS\0" + "GL_SUBTRACT\0" + "GL_SUBTRACT_ARB\0" + "GL_SYNC_CONDITION\0" + "GL_SYNC_FENCE\0" + "GL_SYNC_FLAGS\0" + "GL_SYNC_FLUSH_COMMANDS_BIT\0" + "GL_SYNC_GPU_COMMANDS_COMPLETE\0" + "GL_SYNC_STATUS\0" + "GL_T\0" + "GL_T2F_C3F_V3F\0" + "GL_T2F_C4F_N3F_V3F\0" + "GL_T2F_C4UB_V3F\0" + "GL_T2F_N3F_V3F\0" + "GL_T2F_V3F\0" + "GL_T4F_C4F_N3F_V4F\0" + "GL_T4F_V4F\0" + "GL_TABLE_TOO_LARGE_EXT\0" + "GL_TEXTURE\0" + "GL_TEXTURE0\0" + "GL_TEXTURE0_ARB\0" + "GL_TEXTURE1\0" + "GL_TEXTURE10\0" + "GL_TEXTURE10_ARB\0" + "GL_TEXTURE11\0" + "GL_TEXTURE11_ARB\0" + "GL_TEXTURE12\0" + "GL_TEXTURE12_ARB\0" + "GL_TEXTURE13\0" + "GL_TEXTURE13_ARB\0" + "GL_TEXTURE14\0" + "GL_TEXTURE14_ARB\0" + "GL_TEXTURE15\0" + "GL_TEXTURE15_ARB\0" + "GL_TEXTURE16\0" + "GL_TEXTURE16_ARB\0" + "GL_TEXTURE17\0" + "GL_TEXTURE17_ARB\0" + "GL_TEXTURE18\0" + "GL_TEXTURE18_ARB\0" + "GL_TEXTURE19\0" + "GL_TEXTURE19_ARB\0" + "GL_TEXTURE1_ARB\0" + "GL_TEXTURE2\0" + "GL_TEXTURE20\0" + "GL_TEXTURE20_ARB\0" + "GL_TEXTURE21\0" + "GL_TEXTURE21_ARB\0" + "GL_TEXTURE22\0" + "GL_TEXTURE22_ARB\0" + "GL_TEXTURE23\0" + "GL_TEXTURE23_ARB\0" + "GL_TEXTURE24\0" + "GL_TEXTURE24_ARB\0" + "GL_TEXTURE25\0" + "GL_TEXTURE25_ARB\0" + "GL_TEXTURE26\0" + "GL_TEXTURE26_ARB\0" + "GL_TEXTURE27\0" + "GL_TEXTURE27_ARB\0" + "GL_TEXTURE28\0" + "GL_TEXTURE28_ARB\0" + "GL_TEXTURE29\0" + "GL_TEXTURE29_ARB\0" + "GL_TEXTURE2_ARB\0" + "GL_TEXTURE3\0" + "GL_TEXTURE30\0" + "GL_TEXTURE30_ARB\0" + "GL_TEXTURE31\0" + "GL_TEXTURE31_ARB\0" + "GL_TEXTURE3_ARB\0" + "GL_TEXTURE4\0" + "GL_TEXTURE4_ARB\0" + "GL_TEXTURE5\0" + "GL_TEXTURE5_ARB\0" + "GL_TEXTURE6\0" + "GL_TEXTURE6_ARB\0" + "GL_TEXTURE7\0" + "GL_TEXTURE7_ARB\0" + "GL_TEXTURE8\0" + "GL_TEXTURE8_ARB\0" + "GL_TEXTURE9\0" + "GL_TEXTURE9_ARB\0" + "GL_TEXTURE_1D\0" + "GL_TEXTURE_1D_ARRAY\0" + "GL_TEXTURE_1D_ARRAY_EXT\0" + "GL_TEXTURE_2D\0" + "GL_TEXTURE_2D_ARRAY\0" + "GL_TEXTURE_2D_ARRAY_EXT\0" + "GL_TEXTURE_3D\0" + "GL_TEXTURE_3D_OES\0" + "GL_TEXTURE_ALPHA_SIZE\0" + "GL_TEXTURE_ALPHA_SIZE_EXT\0" + "GL_TEXTURE_BASE_LEVEL\0" + "GL_TEXTURE_BINDING_1D\0" + "GL_TEXTURE_BINDING_1D_ARRAY\0" + "GL_TEXTURE_BINDING_1D_ARRAY_EXT\0" + "GL_TEXTURE_BINDING_2D\0" + "GL_TEXTURE_BINDING_2D_ARRAY\0" + "GL_TEXTURE_BINDING_2D_ARRAY_EXT\0" + "GL_TEXTURE_BINDING_3D\0" + "GL_TEXTURE_BINDING_3D_OES\0" + "GL_TEXTURE_BINDING_BUFFER\0" + "GL_TEXTURE_BINDING_CUBE_MAP\0" + "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0" + "GL_TEXTURE_BINDING_CUBE_MAP_OES\0" + "GL_TEXTURE_BINDING_RECTANGLE\0" + "GL_TEXTURE_BINDING_RECTANGLE_ARB\0" + "GL_TEXTURE_BINDING_RECTANGLE_NV\0" + "GL_TEXTURE_BIT\0" + "GL_TEXTURE_BLUE_SIZE\0" + "GL_TEXTURE_BLUE_SIZE_EXT\0" + "GL_TEXTURE_BORDER\0" + "GL_TEXTURE_BORDER_COLOR\0" + "GL_TEXTURE_BUFFER\0" + "GL_TEXTURE_BUFFER_DATA_STORE_BINDING\0" + "GL_TEXTURE_BUFFER_FORMAT\0" + "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0" + "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0" + "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0" + "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0" + "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0" + "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" + "GL_TEXTURE_COLOR_TABLE_SGI\0" + "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0" + "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0" + "GL_TEXTURE_COMPARE_FUNC\0" + "GL_TEXTURE_COMPARE_FUNC_ARB\0" + "GL_TEXTURE_COMPARE_MODE\0" + "GL_TEXTURE_COMPARE_MODE_ARB\0" + "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0" + "GL_TEXTURE_COMPARE_SGIX\0" + "GL_TEXTURE_COMPONENTS\0" + "GL_TEXTURE_COMPRESSED\0" + "GL_TEXTURE_COMPRESSED_ARB\0" + "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0" + "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0" + "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0" + "GL_TEXTURE_COMPRESSION_HINT\0" + "GL_TEXTURE_COMPRESSION_HINT_ARB\0" + "GL_TEXTURE_COORD_ARRAY\0" + "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0" + "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0" + "GL_TEXTURE_COORD_ARRAY_POINTER\0" + "GL_TEXTURE_COORD_ARRAY_SIZE\0" + "GL_TEXTURE_COORD_ARRAY_STRIDE\0" + "GL_TEXTURE_COORD_ARRAY_TYPE\0" + "GL_TEXTURE_CROP_RECT_OES\0" + "GL_TEXTURE_CUBE_MAP\0" + "GL_TEXTURE_CUBE_MAP_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES\0" + "GL_TEXTURE_CUBE_MAP_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES\0" + "GL_TEXTURE_CUBE_MAP_SEAMLESS\0" + "GL_TEXTURE_DEPTH\0" + "GL_TEXTURE_DEPTH_SIZE\0" + "GL_TEXTURE_DEPTH_SIZE_ARB\0" + "GL_TEXTURE_ENV\0" + "GL_TEXTURE_ENV_COLOR\0" + "GL_TEXTURE_ENV_MODE\0" + "GL_TEXTURE_FILTER_CONTROL\0" + "GL_TEXTURE_FILTER_CONTROL_EXT\0" + "GL_TEXTURE_GEN_MODE\0" + "GL_TEXTURE_GEN_MODE_OES\0" + "GL_TEXTURE_GEN_Q\0" + "GL_TEXTURE_GEN_R\0" + "GL_TEXTURE_GEN_S\0" + "GL_TEXTURE_GEN_STR_OES\0" + "GL_TEXTURE_GEN_T\0" + "GL_TEXTURE_GEQUAL_R_SGIX\0" + "GL_TEXTURE_GREEN_SIZE\0" + "GL_TEXTURE_GREEN_SIZE_EXT\0" + "GL_TEXTURE_HEIGHT\0" + "GL_TEXTURE_INDEX_SIZE_EXT\0" + "GL_TEXTURE_INTENSITY_SIZE\0" + "GL_TEXTURE_INTENSITY_SIZE_EXT\0" + "GL_TEXTURE_INTERNAL_FORMAT\0" + "GL_TEXTURE_LEQUAL_R_SGIX\0" + "GL_TEXTURE_LOD_BIAS\0" + "GL_TEXTURE_LOD_BIAS_EXT\0" + "GL_TEXTURE_LOD_BIAS_R_SGIX\0" + "GL_TEXTURE_LOD_BIAS_S_SGIX\0" + "GL_TEXTURE_LOD_BIAS_T_SGIX\0" + "GL_TEXTURE_LUMINANCE_SIZE\0" + "GL_TEXTURE_LUMINANCE_SIZE_EXT\0" + "GL_TEXTURE_MAG_FILTER\0" + "GL_TEXTURE_MATRIX\0" + "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_TEXTURE_MAX_ANISOTROPY_EXT\0" + "GL_TEXTURE_MAX_CLAMP_R_SGIX\0" + "GL_TEXTURE_MAX_CLAMP_S_SGIX\0" + "GL_TEXTURE_MAX_CLAMP_T_SGIX\0" + "GL_TEXTURE_MAX_LEVEL\0" + "GL_TEXTURE_MAX_LOD\0" + "GL_TEXTURE_MIN_FILTER\0" + "GL_TEXTURE_MIN_LOD\0" + "GL_TEXTURE_PRIORITY\0" + "GL_TEXTURE_RANGE_LENGTH_APPLE\0" + "GL_TEXTURE_RANGE_POINTER_APPLE\0" + "GL_TEXTURE_RECTANGLE\0" + "GL_TEXTURE_RECTANGLE_ARB\0" + "GL_TEXTURE_RECTANGLE_NV\0" + "GL_TEXTURE_RED_SIZE\0" + "GL_TEXTURE_RED_SIZE_EXT\0" + "GL_TEXTURE_RESIDENT\0" + "GL_TEXTURE_SHARED_SIZE\0" + "GL_TEXTURE_STACK_DEPTH\0" + "GL_TEXTURE_STENCIL_SIZE\0" + "GL_TEXTURE_STENCIL_SIZE_EXT\0" + "GL_TEXTURE_STORAGE_HINT_APPLE\0" + "GL_TEXTURE_TOO_LARGE_EXT\0" + "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0" + "GL_TEXTURE_WIDTH\0" + "GL_TEXTURE_WRAP_R\0" + "GL_TEXTURE_WRAP_R_OES\0" + "GL_TEXTURE_WRAP_S\0" + "GL_TEXTURE_WRAP_T\0" + "GL_TIMEOUT_EXPIRED\0" + "GL_TIME_ELAPSED_EXT\0" + "GL_TRACK_MATRIX_NV\0" + "GL_TRACK_MATRIX_TRANSFORM_NV\0" + "GL_TRANSFORM_BIT\0" + "GL_TRANSFORM_FEEDBACK\0" + "GL_TRANSFORM_FEEDBACK_BINDING\0" + "GL_TRANSFORM_FEEDBACK_BUFFER\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_MODE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_START\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT\0" + "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN\0" + "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT\0" + "GL_TRANSFORM_FEEDBACK_VARYINGS\0" + "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT\0" + "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH\0" + "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT\0" + "GL_TRANSPOSE_COLOR_MATRIX\0" + "GL_TRANSPOSE_COLOR_MATRIX_ARB\0" + "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0" + "GL_TRANSPOSE_MODELVIEW_MATRIX\0" + "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0" + "GL_TRANSPOSE_NV\0" + "GL_TRANSPOSE_PROJECTION_MATRIX\0" + "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0" + "GL_TRANSPOSE_TEXTURE_MATRIX\0" + "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0" + "GL_TRIANGLES\0" + "GL_TRIANGLES_ADJACENCY\0" + "GL_TRIANGLES_ADJACENCY_ARB\0" + "GL_TRIANGLE_FAN\0" + "GL_TRIANGLE_MESH_SUN\0" + "GL_TRIANGLE_STRIP\0" + "GL_TRIANGLE_STRIP_ADJACENCY\0" + "GL_TRIANGLE_STRIP_ADJACENCY_ARB\0" + "GL_TRUE\0" + "GL_UNDEFINED_APPLE\0" + "GL_UNPACK_ALIGNMENT\0" + "GL_UNPACK_IMAGE_HEIGHT\0" + "GL_UNPACK_LSB_FIRST\0" + "GL_UNPACK_ROW_LENGTH\0" + "GL_UNPACK_SKIP_IMAGES\0" + "GL_UNPACK_SKIP_PIXELS\0" + "GL_UNPACK_SKIP_ROWS\0" + "GL_UNPACK_SWAP_BYTES\0" + "GL_UNSIGNALED\0" + "GL_UNSIGNED_BYTE\0" + "GL_UNSIGNED_BYTE_2_3_3_REV\0" + "GL_UNSIGNED_BYTE_3_3_2\0" + "GL_UNSIGNED_INT\0" + "GL_UNSIGNED_INT_10F_11F_11F_REV\0" + "GL_UNSIGNED_INT_10_10_10_2\0" + "GL_UNSIGNED_INT_10_10_10_2_OES\0" + "GL_UNSIGNED_INT_24_8\0" + "GL_UNSIGNED_INT_24_8_EXT\0" + "GL_UNSIGNED_INT_24_8_NV\0" + "GL_UNSIGNED_INT_24_8_OES\0" + "GL_UNSIGNED_INT_2_10_10_10_REV\0" + "GL_UNSIGNED_INT_2_10_10_10_REV_EXT\0" + "GL_UNSIGNED_INT_5_9_9_9_REV\0" + "GL_UNSIGNED_INT_8_8_8_8\0" + "GL_UNSIGNED_INT_8_8_8_8_REV\0" + "GL_UNSIGNED_INT_SAMPLER_1D\0" + "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY\0" + "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_1D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D\0" + "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY\0" + "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_RECT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_3D\0" + "GL_UNSIGNED_INT_SAMPLER_3D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_BUFFER\0" + "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_CUBE\0" + "GL_UNSIGNED_INT_SAMPLER_CUBE_EXT\0" + "GL_UNSIGNED_INT_VEC2\0" + "GL_UNSIGNED_INT_VEC2_EXT\0" + "GL_UNSIGNED_INT_VEC3\0" + "GL_UNSIGNED_INT_VEC3_EXT\0" + "GL_UNSIGNED_INT_VEC4\0" + "GL_UNSIGNED_INT_VEC4_EXT\0" + "GL_UNSIGNED_NORMALIZED\0" + "GL_UNSIGNED_SHORT\0" + "GL_UNSIGNED_SHORT_1_5_5_5_REV\0" + "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT\0" + "GL_UNSIGNED_SHORT_4_4_4_4\0" + "GL_UNSIGNED_SHORT_4_4_4_4_REV\0" + "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT\0" + "GL_UNSIGNED_SHORT_5_5_5_1\0" + "GL_UNSIGNED_SHORT_5_6_5\0" + "GL_UNSIGNED_SHORT_5_6_5_REV\0" + "GL_UNSIGNED_SHORT_8_8_APPLE\0" + "GL_UNSIGNED_SHORT_8_8_MESA\0" + "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0" + "GL_UNSIGNED_SHORT_8_8_REV_MESA\0" + "GL_UPPER_LEFT\0" + "GL_V2F\0" + "GL_V3F\0" + "GL_VALIDATE_STATUS\0" + "GL_VENDOR\0" + "GL_VERSION\0" + "GL_VERTEX_ARRAY\0" + "GL_VERTEX_ARRAY_BINDING\0" + "GL_VERTEX_ARRAY_BINDING_APPLE\0" + "GL_VERTEX_ARRAY_BUFFER_BINDING\0" + "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0" + "GL_VERTEX_ARRAY_POINTER\0" + "GL_VERTEX_ARRAY_SIZE\0" + "GL_VERTEX_ARRAY_STRIDE\0" + "GL_VERTEX_ARRAY_TYPE\0" + "GL_VERTEX_ATTRIB_ARRAY0_NV\0" + "GL_VERTEX_ATTRIB_ARRAY10_NV\0" + "GL_VERTEX_ATTRIB_ARRAY11_NV\0" + "GL_VERTEX_ATTRIB_ARRAY12_NV\0" + "GL_VERTEX_ATTRIB_ARRAY13_NV\0" + "GL_VERTEX_ATTRIB_ARRAY14_NV\0" + "GL_VERTEX_ATTRIB_ARRAY15_NV\0" + "GL_VERTEX_ATTRIB_ARRAY1_NV\0" + "GL_VERTEX_ATTRIB_ARRAY2_NV\0" + "GL_VERTEX_ATTRIB_ARRAY3_NV\0" + "GL_VERTEX_ATTRIB_ARRAY4_NV\0" + "GL_VERTEX_ATTRIB_ARRAY5_NV\0" + "GL_VERTEX_ATTRIB_ARRAY6_NV\0" + "GL_VERTEX_ATTRIB_ARRAY7_NV\0" + "GL_VERTEX_ATTRIB_ARRAY8_NV\0" + "GL_VERTEX_ATTRIB_ARRAY9_NV\0" + "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0" + "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_ENABLED\0" + "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_INTEGER\0" + "GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT\0" + "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED\0" + "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_POINTER\0" + "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_SIZE\0" + "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_STRIDE\0" + "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_TYPE\0" + "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0" + "GL_VERTEX_BLEND_ARB\0" + "GL_VERTEX_PROGRAM_ARB\0" + "GL_VERTEX_PROGRAM_BINDING_NV\0" + "GL_VERTEX_PROGRAM_NV\0" + "GL_VERTEX_PROGRAM_POINT_SIZE\0" + "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0" + "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0" + "GL_VERTEX_PROGRAM_TWO_SIDE\0" + "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0" + "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0" + "GL_VERTEX_SHADER\0" + "GL_VERTEX_SHADER_ARB\0" + "GL_VERTEX_STATE_PROGRAM_NV\0" + "GL_VIEWPORT\0" + "GL_VIEWPORT_BIT\0" + "GL_VOLATILE_APPLE\0" + "GL_WAIT_FAILED\0" + "GL_WEIGHT_ARRAY_ARB\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING_OES\0" + "GL_WEIGHT_ARRAY_OES\0" + "GL_WEIGHT_ARRAY_POINTER_ARB\0" + "GL_WEIGHT_ARRAY_POINTER_OES\0" + "GL_WEIGHT_ARRAY_SIZE_ARB\0" + "GL_WEIGHT_ARRAY_SIZE_OES\0" + "GL_WEIGHT_ARRAY_STRIDE_ARB\0" + "GL_WEIGHT_ARRAY_STRIDE_OES\0" + "GL_WEIGHT_ARRAY_TYPE_ARB\0" + "GL_WEIGHT_ARRAY_TYPE_OES\0" + "GL_WEIGHT_SUM_UNITY_ARB\0" + "GL_WRAP_BORDER_SUN\0" + "GL_WRITE_ONLY\0" + "GL_WRITE_ONLY_ARB\0" + "GL_WRITE_ONLY_OES\0" + "GL_XOR\0" + "GL_YCBCR_422_APPLE\0" + "GL_YCBCR_MESA\0" + "GL_ZERO\0" + "GL_ZOOM_X\0" + "GL_ZOOM_Y\0" + ; + +static const enum_elt all_enums[2294] = +{ + { 0, 0x00000600 }, /* GL_2D */ + { 6, 0x00001407 }, /* GL_2_BYTES */ + { 17, 0x00000601 }, /* GL_3D */ + { 23, 0x00000602 }, /* GL_3D_COLOR */ + { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */ + { 55, 0x00001408 }, /* GL_3_BYTES */ + { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */ + { 86, 0x00001409 }, /* GL_4_BYTES */ + { 97, 0x00000100 }, /* GL_ACCUM */ + { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */ + { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */ + { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */ + { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */ + { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */ + { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */ + { 224, 0x00008B89 }, /* GL_ACTIVE_ATTRIBUTES */ + { 245, 0x00008B8A }, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ + { 276, 0x00008B8D }, /* GL_ACTIVE_PROGRAM_EXT */ + { 298, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */ + { 325, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */ + { 343, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */ + { 365, 0x00008B86 }, /* GL_ACTIVE_UNIFORMS */ + { 384, 0x00008B87 }, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ + { 413, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */ + { 440, 0x00000104 }, /* GL_ADD */ + { 447, 0x00008574 }, /* GL_ADD_SIGNED */ + { 461, 0x00008574 }, /* GL_ADD_SIGNED_ARB */ + { 479, 0x00008574 }, /* GL_ADD_SIGNED_EXT */ + { 497, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */ + { 525, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */ + { 553, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */ + { 572, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */ + { 598, 0x00001906 }, /* GL_ALPHA */ + { 607, 0x0000803D }, /* GL_ALPHA12 */ + { 618, 0x0000803D }, /* GL_ALPHA12_EXT */ + { 633, 0x0000803E }, /* GL_ALPHA16 */ + { 644, 0x00008D8A }, /* GL_ALPHA16I_EXT */ + { 660, 0x00008D78 }, /* GL_ALPHA16UI_EXT */ + { 677, 0x0000803E }, /* GL_ALPHA16_EXT */ + { 692, 0x00008D84 }, /* GL_ALPHA32I_EXT */ + { 708, 0x00008D72 }, /* GL_ALPHA32UI_EXT */ + { 725, 0x0000803B }, /* GL_ALPHA4 */ + { 735, 0x0000803B }, /* GL_ALPHA4_EXT */ + { 749, 0x0000803C }, /* GL_ALPHA8 */ + { 759, 0x00008D90 }, /* GL_ALPHA8I_EXT */ + { 774, 0x00008D7E }, /* GL_ALPHA8UI_EXT */ + { 790, 0x0000803C }, /* GL_ALPHA8_EXT */ + { 804, 0x00000D1D }, /* GL_ALPHA_BIAS */ + { 818, 0x00000D55 }, /* GL_ALPHA_BITS */ + { 832, 0x00008D97 }, /* GL_ALPHA_INTEGER_EXT */ + { 853, 0x00000D1C }, /* GL_ALPHA_SCALE */ + { 868, 0x00000BC0 }, /* GL_ALPHA_TEST */ + { 882, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */ + { 901, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */ + { 919, 0x0000911A }, /* GL_ALREADY_SIGNALED */ + { 939, 0x00000207 }, /* GL_ALWAYS */ + { 949, 0x00001200 }, /* GL_AMBIENT */ + { 960, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */ + { 983, 0x00001501 }, /* GL_AND */ + { 990, 0x00001504 }, /* GL_AND_INVERTED */ + { 1006, 0x00001502 }, /* GL_AND_REVERSE */ + { 1021, 0x00008892 }, /* GL_ARRAY_BUFFER */ + { 1037, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */ + { 1061, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */ + { 1089, 0x00008B85 }, /* GL_ATTACHED_SHADERS */ + { 1109, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */ + { 1136, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */ + { 1160, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */ + { 1186, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */ + { 1210, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */ + { 1232, 0x00000D80 }, /* GL_AUTO_NORMAL */ + { 1247, 0x00000409 }, /* GL_AUX0 */ + { 1255, 0x0000040A }, /* GL_AUX1 */ + { 1263, 0x0000040B }, /* GL_AUX2 */ + { 1271, 0x0000040C }, /* GL_AUX3 */ + { 1279, 0x00000C00 }, /* GL_AUX_BUFFERS */ + { 1294, 0x00000405 }, /* GL_BACK */ + { 1302, 0x00000402 }, /* GL_BACK_LEFT */ + { 1315, 0x00000403 }, /* GL_BACK_RIGHT */ + { 1329, 0x000080E0 }, /* GL_BGR */ + { 1336, 0x000080E1 }, /* GL_BGRA */ + { 1344, 0x000080E1 }, /* GL_BGRA_EXT */ + { 1356, 0x00008D9B }, /* GL_BGRA_INTEGER */ + { 1372, 0x00008D9B }, /* GL_BGRA_INTEGER_EXT */ + { 1392, 0x00008D9A }, /* GL_BGR_INTEGER */ + { 1407, 0x00008D9A }, /* GL_BGR_INTEGER_EXT */ + { 1426, 0x00001A00 }, /* GL_BITMAP */ + { 1436, 0x00000704 }, /* GL_BITMAP_TOKEN */ + { 1452, 0x00000BE2 }, /* GL_BLEND */ + { 1461, 0x00008005 }, /* GL_BLEND_COLOR */ + { 1476, 0x00008005 }, /* GL_BLEND_COLOR_EXT */ + { 1495, 0x00000BE0 }, /* GL_BLEND_DST */ + { 1508, 0x000080CA }, /* GL_BLEND_DST_ALPHA */ + { 1527, 0x000080CA }, /* GL_BLEND_DST_ALPHA_OES */ + { 1550, 0x000080C8 }, /* GL_BLEND_DST_RGB */ + { 1567, 0x000080C8 }, /* GL_BLEND_DST_RGB_OES */ + { 1588, 0x00008009 }, /* GL_BLEND_EQUATION */ + { 1606, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */ + { 1630, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */ + { 1658, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_OES */ + { 1686, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */ + { 1708, 0x00008009 }, /* GL_BLEND_EQUATION_OES */ + { 1730, 0x00008009 }, /* GL_BLEND_EQUATION_RGB */ + { 1752, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */ + { 1778, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_OES */ + { 1804, 0x00000BE1 }, /* GL_BLEND_SRC */ + { 1817, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */ + { 1836, 0x000080CB }, /* GL_BLEND_SRC_ALPHA_OES */ + { 1859, 0x000080C9 }, /* GL_BLEND_SRC_RGB */ + { 1876, 0x000080C9 }, /* GL_BLEND_SRC_RGB_OES */ + { 1897, 0x00001905 }, /* GL_BLUE */ + { 1905, 0x00000D1B }, /* GL_BLUE_BIAS */ + { 1918, 0x00000D54 }, /* GL_BLUE_BITS */ + { 1931, 0x00008D96 }, /* GL_BLUE_INTEGER */ + { 1947, 0x00008D96 }, /* GL_BLUE_INTEGER_EXT */ + { 1967, 0x00000D1A }, /* GL_BLUE_SCALE */ + { 1981, 0x00008B56 }, /* GL_BOOL */ + { 1989, 0x00008B56 }, /* GL_BOOL_ARB */ + { 2001, 0x00008B57 }, /* GL_BOOL_VEC2 */ + { 2014, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */ + { 2031, 0x00008B58 }, /* GL_BOOL_VEC3 */ + { 2044, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */ + { 2061, 0x00008B59 }, /* GL_BOOL_VEC4 */ + { 2074, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */ + { 2091, 0x000088BB }, /* GL_BUFFER_ACCESS */ + { 2108, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */ + { 2129, 0x0000911F }, /* GL_BUFFER_ACCESS_FLAGS */ + { 2152, 0x000088BB }, /* GL_BUFFER_ACCESS_OES */ + { 2173, 0x00008A13 }, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ + { 2204, 0x000088BC }, /* GL_BUFFER_MAPPED */ + { 2221, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */ + { 2242, 0x000088BC }, /* GL_BUFFER_MAPPED_OES */ + { 2263, 0x00009120 }, /* GL_BUFFER_MAP_LENGTH */ + { 2284, 0x00009121 }, /* GL_BUFFER_MAP_OFFSET */ + { 2305, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */ + { 2327, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */ + { 2353, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_OES */ + { 2379, 0x000085B3 }, /* GL_BUFFER_OBJECT_APPLE */ + { 2402, 0x00008A12 }, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ + { 2436, 0x00008764 }, /* GL_BUFFER_SIZE */ + { 2451, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */ + { 2470, 0x00008765 }, /* GL_BUFFER_USAGE */ + { 2486, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */ + { 2506, 0x0000877B }, /* GL_BUMP_ENVMAP_ATI */ + { 2525, 0x00008777 }, /* GL_BUMP_NUM_TEX_UNITS_ATI */ + { 2551, 0x00008775 }, /* GL_BUMP_ROT_MATRIX_ATI */ + { 2574, 0x00008776 }, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ + { 2602, 0x0000877C }, /* GL_BUMP_TARGET_ATI */ + { 2621, 0x00008778 }, /* GL_BUMP_TEX_UNITS_ATI */ + { 2643, 0x00001400 }, /* GL_BYTE */ + { 2651, 0x00002A24 }, /* GL_C3F_V3F */ + { 2662, 0x00002A26 }, /* GL_C4F_N3F_V3F */ + { 2677, 0x00002A22 }, /* GL_C4UB_V2F */ + { 2689, 0x00002A23 }, /* GL_C4UB_V3F */ + { 2701, 0x00000901 }, /* GL_CCW */ + { 2708, 0x00002900 }, /* GL_CLAMP */ + { 2717, 0x0000891C }, /* GL_CLAMP_READ_COLOR */ + { 2737, 0x0000812D }, /* GL_CLAMP_TO_BORDER */ + { 2756, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */ + { 2779, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */ + { 2803, 0x0000812F }, /* GL_CLAMP_TO_EDGE */ + { 2820, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */ + { 2842, 0x00001500 }, /* GL_CLEAR */ + { 2851, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */ + { 2876, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */ + { 2905, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */ + { 2931, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ + { 2960, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */ + { 2986, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */ + { 3013, 0x00003000 }, /* GL_CLIP_DISTANCE0 */ + { 3031, 0x00003001 }, /* GL_CLIP_DISTANCE1 */ + { 3049, 0x00003002 }, /* GL_CLIP_DISTANCE2 */ + { 3067, 0x00003003 }, /* GL_CLIP_DISTANCE3 */ + { 3085, 0x00003004 }, /* GL_CLIP_DISTANCE4 */ + { 3103, 0x00003005 }, /* GL_CLIP_DISTANCE5 */ + { 3121, 0x00003006 }, /* GL_CLIP_DISTANCE6 */ + { 3139, 0x00003007 }, /* GL_CLIP_DISTANCE7 */ + { 3157, 0x00003000 }, /* GL_CLIP_PLANE0 */ + { 3172, 0x00003001 }, /* GL_CLIP_PLANE1 */ + { 3187, 0x00003002 }, /* GL_CLIP_PLANE2 */ + { 3202, 0x00003003 }, /* GL_CLIP_PLANE3 */ + { 3217, 0x00003004 }, /* GL_CLIP_PLANE4 */ + { 3232, 0x00003005 }, /* GL_CLIP_PLANE5 */ + { 3247, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ + { 3280, 0x00000A00 }, /* GL_COEFF */ + { 3289, 0x00001800 }, /* GL_COLOR */ + { 3298, 0x00008076 }, /* GL_COLOR_ARRAY */ + { 3313, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */ + { 3343, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */ + { 3377, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */ + { 3400, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */ + { 3420, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */ + { 3442, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */ + { 3462, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0 */ + { 3483, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */ + { 3508, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_OES */ + { 3533, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1 */ + { 3554, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10 */ + { 3576, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */ + { 3602, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11 */ + { 3624, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */ + { 3650, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12 */ + { 3672, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */ + { 3698, 0x00008CED }, /* GL_COLOR_ATTACHMENT13 */ + { 3720, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */ + { 3746, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14 */ + { 3768, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */ + { 3794, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15 */ + { 3816, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */ + { 3842, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */ + { 3867, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2 */ + { 3888, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */ + { 3913, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3 */ + { 3934, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */ + { 3959, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4 */ + { 3980, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */ + { 4005, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5 */ + { 4026, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */ + { 4051, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6 */ + { 4072, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */ + { 4097, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7 */ + { 4118, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */ + { 4143, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8 */ + { 4164, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */ + { 4189, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9 */ + { 4210, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */ + { 4235, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */ + { 4255, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */ + { 4276, 0x00001900 }, /* GL_COLOR_INDEX */ + { 4291, 0x00001603 }, /* GL_COLOR_INDEXES */ + { 4308, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */ + { 4326, 0x00000B57 }, /* GL_COLOR_MATERIAL */ + { 4344, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */ + { 4367, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */ + { 4395, 0x000080B1 }, /* GL_COLOR_MATRIX */ + { 4411, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */ + { 4431, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */ + { 4459, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */ + { 4491, 0x00008458 }, /* GL_COLOR_SUM */ + { 4504, 0x00008458 }, /* GL_COLOR_SUM_ARB */ + { 4521, 0x000080D0 }, /* GL_COLOR_TABLE */ + { 4536, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */ + { 4562, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */ + { 4592, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */ + { 4622, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */ + { 4642, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */ + { 4666, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */ + { 4691, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */ + { 4720, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */ + { 4749, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */ + { 4771, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */ + { 4797, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */ + { 4823, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */ + { 4849, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */ + { 4879, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */ + { 4909, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */ + { 4939, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */ + { 4973, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */ + { 5007, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ + { 5037, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */ + { 5071, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */ + { 5105, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */ + { 5129, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */ + { 5157, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */ + { 5185, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */ + { 5206, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */ + { 5231, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */ + { 5252, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */ + { 5277, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */ + { 5302, 0x00000C23 }, /* GL_COLOR_WRITEMASK */ + { 5321, 0x00008570 }, /* GL_COMBINE */ + { 5332, 0x00008503 }, /* GL_COMBINE4 */ + { 5344, 0x00008572 }, /* GL_COMBINE_ALPHA */ + { 5361, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */ + { 5382, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */ + { 5403, 0x00008570 }, /* GL_COMBINE_ARB */ + { 5418, 0x00008570 }, /* GL_COMBINE_EXT */ + { 5433, 0x00008571 }, /* GL_COMBINE_RGB */ + { 5448, 0x00008571 }, /* GL_COMBINE_RGB_ARB */ + { 5467, 0x00008571 }, /* GL_COMBINE_RGB_EXT */ + { 5486, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */ + { 5522, 0x0000884E }, /* GL_COMPARE_REF_TO_TEXTURE */ + { 5548, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */ + { 5572, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */ + { 5600, 0x00001300 }, /* GL_COMPILE */ + { 5611, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */ + { 5634, 0x00008B81 }, /* GL_COMPILE_STATUS */ + { 5652, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */ + { 5672, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */ + { 5696, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */ + { 5720, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */ + { 5748, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */ + { 5772, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */ + { 5802, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */ + { 5836, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */ + { 5864, 0x00008225 }, /* GL_COMPRESSED_RED */ + { 5882, 0x00008226 }, /* GL_COMPRESSED_RG */ + { 5899, 0x000084ED }, /* GL_COMPRESSED_RGB */ + { 5917, 0x000084EE }, /* GL_COMPRESSED_RGBA */ + { 5936, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */ + { 5959, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ + { 5988, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ + { 6021, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ + { 6054, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ + { 6087, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */ + { 6109, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */ + { 6137, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ + { 6169, 0x00008C4A }, /* GL_COMPRESSED_SLUMINANCE */ + { 6194, 0x00008C4B }, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ + { 6225, 0x00008C48 }, /* GL_COMPRESSED_SRGB */ + { 6244, 0x00008C49 }, /* GL_COMPRESSED_SRGB_ALPHA */ + { 6269, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */ + { 6299, 0x0000911C }, /* GL_CONDITION_SATISFIED */ + { 6322, 0x00008576 }, /* GL_CONSTANT */ + { 6334, 0x00008003 }, /* GL_CONSTANT_ALPHA */ + { 6352, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */ + { 6374, 0x00008576 }, /* GL_CONSTANT_ARB */ + { 6390, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */ + { 6414, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */ + { 6436, 0x00008001 }, /* GL_CONSTANT_COLOR */ + { 6454, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */ + { 6476, 0x00008576 }, /* GL_CONSTANT_EXT */ + { 6492, 0x00000002 }, /* GL_CONTEXT_COMPATIBILITY_PROFILE_BIT */ + { 6529, 0x00000001 }, /* GL_CONTEXT_CORE_PROFILE_BIT */ + { 6557, 0x0000821E }, /* GL_CONTEXT_FLAGS */ + { 6574, 0x00000001 }, /* GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ + { 6613, 0x00009126 }, /* GL_CONTEXT_PROFILE_MASK */ + { 6637, 0x00008010 }, /* GL_CONVOLUTION_1D */ + { 6655, 0x00008011 }, /* GL_CONVOLUTION_2D */ + { 6673, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */ + { 6701, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */ + { 6732, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */ + { 6759, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */ + { 6790, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */ + { 6817, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */ + { 6848, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */ + { 6876, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */ + { 6908, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */ + { 6930, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */ + { 6956, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */ + { 6978, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */ + { 7004, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */ + { 7025, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */ + { 7050, 0x00008862 }, /* GL_COORD_REPLACE */ + { 7067, 0x00008862 }, /* GL_COORD_REPLACE_ARB */ + { 7088, 0x00008862 }, /* GL_COORD_REPLACE_NV */ + { 7108, 0x00008862 }, /* GL_COORD_REPLACE_OES */ + { 7129, 0x00001503 }, /* GL_COPY */ + { 7137, 0x0000150C }, /* GL_COPY_INVERTED */ + { 7154, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */ + { 7174, 0x00008F36 }, /* GL_COPY_READ_BUFFER */ + { 7194, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */ + { 7215, 0x00000B44 }, /* GL_CULL_FACE */ + { 7228, 0x00000B45 }, /* GL_CULL_FACE_MODE */ + { 7246, 0x000081AA }, /* GL_CULL_VERTEX_EXT */ + { 7265, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ + { 7297, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ + { 7332, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */ + { 7353, 0x00000001 }, /* GL_CURRENT_BIT */ + { 7368, 0x00000B00 }, /* GL_CURRENT_COLOR */ + { 7385, 0x00008453 }, /* GL_CURRENT_FOG_COORD */ + { 7406, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */ + { 7432, 0x00000B01 }, /* GL_CURRENT_INDEX */ + { 7449, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */ + { 7471, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */ + { 7499, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */ + { 7520, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ + { 7554, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */ + { 7587, 0x00000B02 }, /* GL_CURRENT_NORMAL */ + { 7605, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */ + { 7635, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_OES */ + { 7665, 0x00008B8D }, /* GL_CURRENT_PROGRAM */ + { 7684, 0x00008865 }, /* GL_CURRENT_QUERY */ + { 7701, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */ + { 7722, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */ + { 7746, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */ + { 7773, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */ + { 7797, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */ + { 7824, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */ + { 7857, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ + { 7891, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ + { 7924, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */ + { 7951, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */ + { 7977, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */ + { 8002, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */ + { 8031, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */ + { 8053, 0x00000900 }, /* GL_CW */ + { 8059, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */ + { 8080, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */ + { 8101, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */ + { 8121, 0x00002101 }, /* GL_DECAL */ + { 8130, 0x00001E03 }, /* GL_DECR */ + { 8138, 0x00008508 }, /* GL_DECR_WRAP */ + { 8151, 0x00008508 }, /* GL_DECR_WRAP_EXT */ + { 8168, 0x00008B80 }, /* GL_DELETE_STATUS */ + { 8185, 0x00001801 }, /* GL_DEPTH */ + { 8194, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */ + { 8214, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */ + { 8238, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_OES */ + { 8262, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */ + { 8282, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */ + { 8306, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_OES */ + { 8330, 0x00000D1F }, /* GL_DEPTH_BIAS */ + { 8344, 0x00000D56 }, /* GL_DEPTH_BITS */ + { 8358, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */ + { 8378, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */ + { 8403, 0x00008223 }, /* GL_DEPTH_BUFFER */ + { 8419, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */ + { 8439, 0x0000864F }, /* GL_DEPTH_CLAMP */ + { 8454, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */ + { 8472, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */ + { 8493, 0x00001902 }, /* GL_DEPTH_COMPONENT */ + { 8512, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */ + { 8533, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */ + { 8558, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_OES */ + { 8583, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */ + { 8609, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */ + { 8630, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */ + { 8655, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_OES */ + { 8680, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */ + { 8706, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */ + { 8727, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */ + { 8752, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_OES */ + { 8777, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */ + { 8803, 0x00000B74 }, /* GL_DEPTH_FUNC */ + { 8817, 0x00000B70 }, /* GL_DEPTH_RANGE */ + { 8832, 0x00000D1E }, /* GL_DEPTH_SCALE */ + { 8847, 0x000084F9 }, /* GL_DEPTH_STENCIL */ + { 8864, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */ + { 8892, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */ + { 8913, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */ + { 8933, 0x000084F9 }, /* GL_DEPTH_STENCIL_OES */ + { 8954, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ + { 8982, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ + { 9010, 0x00000B71 }, /* GL_DEPTH_TEST */ + { 9024, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */ + { 9046, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */ + { 9072, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */ + { 9091, 0x00001201 }, /* GL_DIFFUSE */ + { 9102, 0x00000BD0 }, /* GL_DITHER */ + { 9112, 0x00000A02 }, /* GL_DOMAIN */ + { 9122, 0x00001100 }, /* GL_DONT_CARE */ + { 9135, 0x000086AE }, /* GL_DOT3_RGB */ + { 9147, 0x000086AF }, /* GL_DOT3_RGBA */ + { 9160, 0x000086AF }, /* GL_DOT3_RGBA_ARB */ + { 9177, 0x00008741 }, /* GL_DOT3_RGBA_EXT */ + { 9194, 0x000086AE }, /* GL_DOT3_RGB_ARB */ + { 9210, 0x00008740 }, /* GL_DOT3_RGB_EXT */ + { 9226, 0x0000140A }, /* GL_DOUBLE */ + { 9236, 0x00000C32 }, /* GL_DOUBLEBUFFER */ + { 9252, 0x00000C01 }, /* GL_DRAW_BUFFER */ + { 9267, 0x00008825 }, /* GL_DRAW_BUFFER0 */ + { 9283, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */ + { 9303, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */ + { 9323, 0x00008826 }, /* GL_DRAW_BUFFER1 */ + { 9339, 0x0000882F }, /* GL_DRAW_BUFFER10 */ + { 9356, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */ + { 9377, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */ + { 9398, 0x00008830 }, /* GL_DRAW_BUFFER11 */ + { 9415, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */ + { 9436, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */ + { 9457, 0x00008831 }, /* GL_DRAW_BUFFER12 */ + { 9474, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */ + { 9495, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */ + { 9516, 0x00008832 }, /* GL_DRAW_BUFFER13 */ + { 9533, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */ + { 9554, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */ + { 9575, 0x00008833 }, /* GL_DRAW_BUFFER14 */ + { 9592, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */ + { 9613, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */ + { 9634, 0x00008834 }, /* GL_DRAW_BUFFER15 */ + { 9651, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */ + { 9672, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */ + { 9693, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */ + { 9713, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */ + { 9733, 0x00008827 }, /* GL_DRAW_BUFFER2 */ + { 9749, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */ + { 9769, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */ + { 9789, 0x00008828 }, /* GL_DRAW_BUFFER3 */ + { 9805, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */ + { 9825, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */ + { 9845, 0x00008829 }, /* GL_DRAW_BUFFER4 */ + { 9861, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */ + { 9881, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */ + { 9901, 0x0000882A }, /* GL_DRAW_BUFFER5 */ + { 9917, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */ + { 9937, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */ + { 9957, 0x0000882B }, /* GL_DRAW_BUFFER6 */ + { 9973, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */ + { 9993, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */ + { 10013, 0x0000882C }, /* GL_DRAW_BUFFER7 */ + { 10029, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */ + { 10049, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */ + { 10069, 0x0000882D }, /* GL_DRAW_BUFFER8 */ + { 10085, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */ + { 10105, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */ + { 10125, 0x0000882E }, /* GL_DRAW_BUFFER9 */ + { 10141, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */ + { 10161, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */ + { 10181, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */ + { 10201, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */ + { 10229, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */ + { 10261, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */ + { 10285, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */ + { 10305, 0x00000304 }, /* GL_DST_ALPHA */ + { 10318, 0x00000306 }, /* GL_DST_COLOR */ + { 10331, 0x0000877A }, /* GL_DU8DV8_ATI */ + { 10345, 0x00008779 }, /* GL_DUDV_ATI */ + { 10357, 0x000088EA }, /* GL_DYNAMIC_COPY */ + { 10373, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */ + { 10393, 0x000088E8 }, /* GL_DYNAMIC_DRAW */ + { 10409, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */ + { 10429, 0x000088E9 }, /* GL_DYNAMIC_READ */ + { 10445, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */ + { 10465, 0x00000B43 }, /* GL_EDGE_FLAG */ + { 10478, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */ + { 10497, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ + { 10531, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */ + { 10569, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */ + { 10596, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */ + { 10622, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */ + { 10646, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ + { 10678, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */ + { 10714, 0x00001600 }, /* GL_EMISSION */ + { 10726, 0x00002000 }, /* GL_ENABLE_BIT */ + { 10740, 0x00000202 }, /* GL_EQUAL */ + { 10749, 0x00001509 }, /* GL_EQUIV */ + { 10758, 0x00010000 }, /* GL_EVAL_BIT */ + { 10770, 0x00000800 }, /* GL_EXP */ + { 10777, 0x00000801 }, /* GL_EXP2 */ + { 10785, 0x00001F03 }, /* GL_EXTENSIONS */ + { 10799, 0x00002400 }, /* GL_EYE_LINEAR */ + { 10813, 0x00002502 }, /* GL_EYE_PLANE */ + { 10826, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */ + { 10851, 0x0000855B }, /* GL_EYE_RADIAL_NV */ + { 10868, 0x00000000 }, /* GL_FALSE */ + { 10877, 0x00001101 }, /* GL_FASTEST */ + { 10888, 0x00001C01 }, /* GL_FEEDBACK */ + { 10900, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */ + { 10927, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */ + { 10951, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */ + { 10975, 0x00001B02 }, /* GL_FILL */ + { 10983, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */ + { 11010, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */ + { 11041, 0x0000140C }, /* GL_FIXED */ + { 11050, 0x0000140C }, /* GL_FIXED_OES */ + { 11063, 0x0000891D }, /* GL_FIXED_ONLY */ + { 11077, 0x00001D00 }, /* GL_FLAT */ + { 11085, 0x00001406 }, /* GL_FLOAT */ + { 11094, 0x00008B5A }, /* GL_FLOAT_MAT2 */ + { 11108, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */ + { 11126, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */ + { 11142, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */ + { 11158, 0x00008B5B }, /* GL_FLOAT_MAT3 */ + { 11172, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */ + { 11190, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */ + { 11206, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */ + { 11222, 0x00008B5C }, /* GL_FLOAT_MAT4 */ + { 11236, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */ + { 11254, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */ + { 11270, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */ + { 11286, 0x00008B50 }, /* GL_FLOAT_VEC2 */ + { 11300, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */ + { 11318, 0x00008B51 }, /* GL_FLOAT_VEC3 */ + { 11332, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */ + { 11350, 0x00008B52 }, /* GL_FLOAT_VEC4 */ + { 11364, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */ + { 11382, 0x00000B60 }, /* GL_FOG */ + { 11389, 0x00000080 }, /* GL_FOG_BIT */ + { 11400, 0x00000B66 }, /* GL_FOG_COLOR */ + { 11413, 0x00008451 }, /* GL_FOG_COORD */ + { 11426, 0x00008451 }, /* GL_FOG_COORDINATE */ + { 11444, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */ + { 11468, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ + { 11507, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */ + { 11550, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */ + { 11582, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ + { 11613, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */ + { 11642, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */ + { 11667, 0x00008457 }, /* GL_FOG_COORD_ARRAY */ + { 11686, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */ + { 11720, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */ + { 11747, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */ + { 11773, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */ + { 11797, 0x00008450 }, /* GL_FOG_COORD_SRC */ + { 11814, 0x00000B62 }, /* GL_FOG_DENSITY */ + { 11829, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */ + { 11853, 0x00000B64 }, /* GL_FOG_END */ + { 11864, 0x00000C54 }, /* GL_FOG_HINT */ + { 11876, 0x00000B61 }, /* GL_FOG_INDEX */ + { 11889, 0x00000B65 }, /* GL_FOG_MODE */ + { 11901, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */ + { 11920, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */ + { 11945, 0x00000B63 }, /* GL_FOG_START */ + { 11958, 0x00008452 }, /* GL_FRAGMENT_DEPTH */ + { 11976, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */ + { 12000, 0x00008B30 }, /* GL_FRAGMENT_SHADER */ + { 12019, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */ + { 12042, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ + { 12077, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES */ + { 12116, 0x00008D40 }, /* GL_FRAMEBUFFER */ + { 12131, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ + { 12168, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ + { 12204, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ + { 12245, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ + { 12286, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ + { 12323, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ + { 12360, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ + { 12394, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ + { 12432, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ + { 12470, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */ + { 12512, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES */ + { 12554, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ + { 12592, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */ + { 12634, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES */ + { 12676, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ + { 12711, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ + { 12750, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */ + { 12799, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES */ + { 12848, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ + { 12896, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */ + { 12948, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES */ + { 13000, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ + { 13040, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ + { 13084, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ + { 13124, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */ + { 13168, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES */ + { 13212, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */ + { 13235, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */ + { 13262, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_OES */ + { 13289, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */ + { 13313, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */ + { 13341, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_OES */ + { 13369, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */ + { 13392, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */ + { 13411, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ + { 13448, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */ + { 13489, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES */ + { 13530, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS */ + { 13567, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ + { 13608, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES */ + { 13649, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ + { 13687, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */ + { 13729, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES */ + { 13771, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ + { 13822, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ + { 13860, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES */ + { 13898, 0x00008DA9 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ + { 13940, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ + { 13980, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ + { 14024, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ + { 14069, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */ + { 14118, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES */ + { 14167, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ + { 14205, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */ + { 14247, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ + { 14285, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */ + { 14327, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES */ + { 14369, 0x00008D40 }, /* GL_FRAMEBUFFER_OES */ + { 14388, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ + { 14420, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */ + { 14445, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */ + { 14472, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */ + { 14503, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_OES */ + { 14534, 0x00000404 }, /* GL_FRONT */ + { 14543, 0x00000408 }, /* GL_FRONT_AND_BACK */ + { 14561, 0x00000B46 }, /* GL_FRONT_FACE */ + { 14575, 0x00000400 }, /* GL_FRONT_LEFT */ + { 14589, 0x00000401 }, /* GL_FRONT_RIGHT */ + { 14604, 0x00008006 }, /* GL_FUNC_ADD */ + { 14616, 0x00008006 }, /* GL_FUNC_ADD_EXT */ + { 14632, 0x00008006 }, /* GL_FUNC_ADD_OES */ + { 14648, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */ + { 14673, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */ + { 14702, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_OES */ + { 14731, 0x0000800A }, /* GL_FUNC_SUBTRACT */ + { 14748, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */ + { 14769, 0x0000800A }, /* GL_FUNC_SUBTRACT_OES */ + { 14790, 0x00008191 }, /* GL_GENERATE_MIPMAP */ + { 14809, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */ + { 14833, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */ + { 14862, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */ + { 14886, 0x00008917 }, /* GL_GEOMETRY_INPUT_TYPE */ + { 14909, 0x00008DDB }, /* GL_GEOMETRY_INPUT_TYPE_ARB */ + { 14936, 0x00008918 }, /* GL_GEOMETRY_OUTPUT_TYPE */ + { 14960, 0x00008DDC }, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ + { 14988, 0x00008DD9 }, /* GL_GEOMETRY_SHADER */ + { 15007, 0x00008DD9 }, /* GL_GEOMETRY_SHADER_ARB */ + { 15030, 0x00008916 }, /* GL_GEOMETRY_VERTICES_OUT */ + { 15055, 0x00008DDA }, /* GL_GEOMETRY_VERTICES_OUT_ARB */ + { 15084, 0x00000206 }, /* GL_GEQUAL */ + { 15094, 0x00000204 }, /* GL_GREATER */ + { 15105, 0x00001904 }, /* GL_GREEN */ + { 15114, 0x00000D19 }, /* GL_GREEN_BIAS */ + { 15128, 0x00000D53 }, /* GL_GREEN_BITS */ + { 15142, 0x00008D95 }, /* GL_GREEN_INTEGER */ + { 15159, 0x00008D95 }, /* GL_GREEN_INTEGER_EXT */ + { 15180, 0x00000D18 }, /* GL_GREEN_SCALE */ + { 15195, 0x0000140B }, /* GL_HALF_FLOAT */ + { 15209, 0x00008D61 }, /* GL_HALF_FLOAT_OES */ + { 15227, 0x00008DF2 }, /* GL_HIGH_FLOAT */ + { 15241, 0x00008DF5 }, /* GL_HIGH_INT */ + { 15253, 0x00008000 }, /* GL_HINT_BIT */ + { 15265, 0x00008024 }, /* GL_HISTOGRAM */ + { 15278, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ + { 15302, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ + { 15330, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ + { 15353, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ + { 15380, 0x00008024 }, /* GL_HISTOGRAM_EXT */ + { 15397, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ + { 15417, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ + { 15441, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ + { 15465, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ + { 15493, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + { 15521, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ + { 15553, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ + { 15575, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ + { 15601, 0x0000802D }, /* GL_HISTOGRAM_SINK */ + { 15619, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ + { 15641, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ + { 15660, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ + { 15683, 0x0000862A }, /* GL_IDENTITY_NV */ + { 15698, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ + { 15718, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ + { 15754, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ + { 15794, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ + { 15828, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ + { 15866, 0x00001E02 }, /* GL_INCR */ + { 15874, 0x00008507 }, /* GL_INCR_WRAP */ + { 15887, 0x00008507 }, /* GL_INCR_WRAP_EXT */ + { 15904, 0x00008222 }, /* GL_INDEX */ + { 15913, 0x00008077 }, /* GL_INDEX_ARRAY */ + { 15928, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + { 15958, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ + { 15992, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ + { 16015, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ + { 16037, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ + { 16057, 0x00000D51 }, /* GL_INDEX_BITS */ + { 16071, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ + { 16092, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ + { 16110, 0x00000C30 }, /* GL_INDEX_MODE */ + { 16124, 0x00000D13 }, /* GL_INDEX_OFFSET */ + { 16140, 0x00000D12 }, /* GL_INDEX_SHIFT */ + { 16155, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ + { 16174, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ + { 16193, 0x00001404 }, /* GL_INT */ + { 16200, 0x00008049 }, /* GL_INTENSITY */ + { 16213, 0x0000804C }, /* GL_INTENSITY12 */ + { 16228, 0x0000804C }, /* GL_INTENSITY12_EXT */ + { 16247, 0x0000804D }, /* GL_INTENSITY16 */ + { 16262, 0x00008D8B }, /* GL_INTENSITY16I_EXT */ + { 16282, 0x00008D79 }, /* GL_INTENSITY16UI_EXT */ + { 16303, 0x0000804D }, /* GL_INTENSITY16_EXT */ + { 16322, 0x00008D85 }, /* GL_INTENSITY32I_EXT */ + { 16342, 0x00008D73 }, /* GL_INTENSITY32UI_EXT */ + { 16363, 0x0000804A }, /* GL_INTENSITY4 */ + { 16377, 0x0000804A }, /* GL_INTENSITY4_EXT */ + { 16395, 0x0000804B }, /* GL_INTENSITY8 */ + { 16409, 0x00008D91 }, /* GL_INTENSITY8I_EXT */ + { 16428, 0x00008D7F }, /* GL_INTENSITY8UI_EXT */ + { 16448, 0x0000804B }, /* GL_INTENSITY8_EXT */ + { 16466, 0x00008049 }, /* GL_INTENSITY_EXT */ + { 16483, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS */ + { 16506, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS_EXT */ + { 16533, 0x00008575 }, /* GL_INTERPOLATE */ + { 16548, 0x00008575 }, /* GL_INTERPOLATE_ARB */ + { 16567, 0x00008575 }, /* GL_INTERPOLATE_EXT */ + { 16586, 0x00008DF7 }, /* GL_INT_10_10_10_2_OES */ + { 16608, 0x00008DC9 }, /* GL_INT_SAMPLER_1D */ + { 16626, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY */ + { 16650, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY_EXT */ + { 16678, 0x00008DC9 }, /* GL_INT_SAMPLER_1D_EXT */ + { 16700, 0x00008DCA }, /* GL_INT_SAMPLER_2D */ + { 16718, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY */ + { 16742, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY_EXT */ + { 16770, 0x00008DCA }, /* GL_INT_SAMPLER_2D_EXT */ + { 16792, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT */ + { 16815, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT_EXT */ + { 16842, 0x00008DCB }, /* GL_INT_SAMPLER_3D */ + { 16860, 0x00008DCB }, /* GL_INT_SAMPLER_3D_EXT */ + { 16882, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER */ + { 16904, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER_EXT */ + { 16930, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE */ + { 16950, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE_EXT */ + { 16974, 0x00008B53 }, /* GL_INT_VEC2 */ + { 16986, 0x00008B53 }, /* GL_INT_VEC2_ARB */ + { 17002, 0x00008B54 }, /* GL_INT_VEC3 */ + { 17014, 0x00008B54 }, /* GL_INT_VEC3_ARB */ + { 17030, 0x00008B55 }, /* GL_INT_VEC4 */ + { 17042, 0x00008B55 }, /* GL_INT_VEC4_ARB */ + { 17058, 0x00000500 }, /* GL_INVALID_ENUM */ + { 17074, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + { 17107, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ + { 17144, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_OES */ + { 17181, 0x00000502 }, /* GL_INVALID_OPERATION */ + { 17202, 0x00000501 }, /* GL_INVALID_VALUE */ + { 17219, 0x0000862B }, /* GL_INVERSE_NV */ + { 17233, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ + { 17257, 0x0000150A }, /* GL_INVERT */ + { 17267, 0x00001E00 }, /* GL_KEEP */ + { 17275, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ + { 17301, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ + { 17331, 0x00000406 }, /* GL_LEFT */ + { 17339, 0x00000203 }, /* GL_LEQUAL */ + { 17349, 0x00000201 }, /* GL_LESS */ + { 17357, 0x00004000 }, /* GL_LIGHT0 */ + { 17367, 0x00004001 }, /* GL_LIGHT1 */ + { 17377, 0x00004002 }, /* GL_LIGHT2 */ + { 17387, 0x00004003 }, /* GL_LIGHT3 */ + { 17397, 0x00004004 }, /* GL_LIGHT4 */ + { 17407, 0x00004005 }, /* GL_LIGHT5 */ + { 17417, 0x00004006 }, /* GL_LIGHT6 */ + { 17427, 0x00004007 }, /* GL_LIGHT7 */ + { 17437, 0x00000B50 }, /* GL_LIGHTING */ + { 17449, 0x00000040 }, /* GL_LIGHTING_BIT */ + { 17465, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ + { 17488, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + { 17517, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ + { 17550, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + { 17578, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ + { 17602, 0x00001B01 }, /* GL_LINE */ + { 17610, 0x00002601 }, /* GL_LINEAR */ + { 17620, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ + { 17642, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + { 17672, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + { 17703, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ + { 17727, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ + { 17752, 0x00000001 }, /* GL_LINES */ + { 17761, 0x0000000A }, /* GL_LINES_ADJACENCY */ + { 17780, 0x0000000A }, /* GL_LINES_ADJACENCY_ARB */ + { 17803, 0x00000004 }, /* GL_LINE_BIT */ + { 17815, 0x00000002 }, /* GL_LINE_LOOP */ + { 17828, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ + { 17848, 0x00000B20 }, /* GL_LINE_SMOOTH */ + { 17863, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ + { 17883, 0x00000B24 }, /* GL_LINE_STIPPLE */ + { 17899, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ + { 17923, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ + { 17946, 0x00000003 }, /* GL_LINE_STRIP */ + { 17960, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY */ + { 17984, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY_ARB */ + { 18012, 0x00000702 }, /* GL_LINE_TOKEN */ + { 18026, 0x00000B21 }, /* GL_LINE_WIDTH */ + { 18040, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ + { 18066, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ + { 18086, 0x00008B82 }, /* GL_LINK_STATUS */ + { 18101, 0x00000B32 }, /* GL_LIST_BASE */ + { 18114, 0x00020000 }, /* GL_LIST_BIT */ + { 18126, 0x00000B33 }, /* GL_LIST_INDEX */ + { 18140, 0x00000B30 }, /* GL_LIST_MODE */ + { 18153, 0x00000101 }, /* GL_LOAD */ + { 18161, 0x00000BF1 }, /* GL_LOGIC_OP */ + { 18173, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ + { 18190, 0x00008CA1 }, /* GL_LOWER_LEFT */ + { 18204, 0x00008DF0 }, /* GL_LOW_FLOAT */ + { 18217, 0x00008DF3 }, /* GL_LOW_INT */ + { 18228, 0x00001909 }, /* GL_LUMINANCE */ + { 18241, 0x00008041 }, /* GL_LUMINANCE12 */ + { 18256, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ + { 18279, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ + { 18306, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ + { 18328, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ + { 18354, 0x00008041 }, /* GL_LUMINANCE12_EXT */ + { 18373, 0x00008042 }, /* GL_LUMINANCE16 */ + { 18388, 0x00008D8C }, /* GL_LUMINANCE16I_EXT */ + { 18408, 0x00008D7A }, /* GL_LUMINANCE16UI_EXT */ + { 18429, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ + { 18452, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ + { 18479, 0x00008042 }, /* GL_LUMINANCE16_EXT */ + { 18498, 0x00008D86 }, /* GL_LUMINANCE32I_EXT */ + { 18518, 0x00008D74 }, /* GL_LUMINANCE32UI_EXT */ + { 18539, 0x0000803F }, /* GL_LUMINANCE4 */ + { 18553, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ + { 18574, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ + { 18599, 0x0000803F }, /* GL_LUMINANCE4_EXT */ + { 18617, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ + { 18638, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ + { 18663, 0x00008040 }, /* GL_LUMINANCE8 */ + { 18677, 0x00008D92 }, /* GL_LUMINANCE8I_EXT */ + { 18696, 0x00008D80 }, /* GL_LUMINANCE8UI_EXT */ + { 18716, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ + { 18737, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ + { 18762, 0x00008040 }, /* GL_LUMINANCE8_EXT */ + { 18780, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ + { 18799, 0x00008D8D }, /* GL_LUMINANCE_ALPHA16I_EXT */ + { 18825, 0x00008D7B }, /* GL_LUMINANCE_ALPHA16UI_EXT */ + { 18852, 0x00008D87 }, /* GL_LUMINANCE_ALPHA32I_EXT */ + { 18878, 0x00008D75 }, /* GL_LUMINANCE_ALPHA32UI_EXT */ + { 18905, 0x00008D93 }, /* GL_LUMINANCE_ALPHA8I_EXT */ + { 18930, 0x00008D81 }, /* GL_LUMINANCE_ALPHA8UI_EXT */ + { 18956, 0x00008D9D }, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ + { 18987, 0x00008D9C }, /* GL_LUMINANCE_INTEGER_EXT */ + { 19012, 0x0000821B }, /* GL_MAJOR_VERSION */ + { 19029, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ + { 19045, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ + { 19065, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ + { 19087, 0x00000D91 }, /* GL_MAP1_INDEX */ + { 19101, 0x00000D92 }, /* GL_MAP1_NORMAL */ + { 19116, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ + { 19140, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ + { 19164, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ + { 19188, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ + { 19212, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ + { 19229, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ + { 19246, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + { 19274, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + { 19303, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + { 19332, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + { 19361, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + { 19390, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + { 19419, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + { 19448, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + { 19476, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + { 19504, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + { 19532, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + { 19560, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + { 19588, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + { 19616, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + { 19644, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + { 19672, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + { 19700, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ + { 19716, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ + { 19736, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ + { 19758, 0x00000DB1 }, /* GL_MAP2_INDEX */ + { 19772, 0x00000DB2 }, /* GL_MAP2_NORMAL */ + { 19787, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ + { 19811, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ + { 19835, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ + { 19859, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ + { 19883, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ + { 19900, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ + { 19917, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + { 19945, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + { 19974, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + { 20003, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + { 20032, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + { 20061, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + { 20090, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + { 20119, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + { 20147, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + { 20175, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + { 20203, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + { 20231, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + { 20259, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + { 20287, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ + { 20315, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + { 20343, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + { 20371, 0x00000D10 }, /* GL_MAP_COLOR */ + { 20384, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ + { 20410, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ + { 20439, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ + { 20467, 0x00000001 }, /* GL_MAP_READ_BIT */ + { 20483, 0x00000D11 }, /* GL_MAP_STENCIL */ + { 20498, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ + { 20524, 0x00000002 }, /* GL_MAP_WRITE_BIT */ + { 20541, 0x000088C0 }, /* GL_MATRIX0_ARB */ + { 20556, 0x00008630 }, /* GL_MATRIX0_NV */ + { 20570, 0x000088CA }, /* GL_MATRIX10_ARB */ + { 20586, 0x000088CB }, /* GL_MATRIX11_ARB */ + { 20602, 0x000088CC }, /* GL_MATRIX12_ARB */ + { 20618, 0x000088CD }, /* GL_MATRIX13_ARB */ + { 20634, 0x000088CE }, /* GL_MATRIX14_ARB */ + { 20650, 0x000088CF }, /* GL_MATRIX15_ARB */ + { 20666, 0x000088D0 }, /* GL_MATRIX16_ARB */ + { 20682, 0x000088D1 }, /* GL_MATRIX17_ARB */ + { 20698, 0x000088D2 }, /* GL_MATRIX18_ARB */ + { 20714, 0x000088D3 }, /* GL_MATRIX19_ARB */ + { 20730, 0x000088C1 }, /* GL_MATRIX1_ARB */ + { 20745, 0x00008631 }, /* GL_MATRIX1_NV */ + { 20759, 0x000088D4 }, /* GL_MATRIX20_ARB */ + { 20775, 0x000088D5 }, /* GL_MATRIX21_ARB */ + { 20791, 0x000088D6 }, /* GL_MATRIX22_ARB */ + { 20807, 0x000088D7 }, /* GL_MATRIX23_ARB */ + { 20823, 0x000088D8 }, /* GL_MATRIX24_ARB */ + { 20839, 0x000088D9 }, /* GL_MATRIX25_ARB */ + { 20855, 0x000088DA }, /* GL_MATRIX26_ARB */ + { 20871, 0x000088DB }, /* GL_MATRIX27_ARB */ + { 20887, 0x000088DC }, /* GL_MATRIX28_ARB */ + { 20903, 0x000088DD }, /* GL_MATRIX29_ARB */ + { 20919, 0x000088C2 }, /* GL_MATRIX2_ARB */ + { 20934, 0x00008632 }, /* GL_MATRIX2_NV */ + { 20948, 0x000088DE }, /* GL_MATRIX30_ARB */ + { 20964, 0x000088DF }, /* GL_MATRIX31_ARB */ + { 20980, 0x000088C3 }, /* GL_MATRIX3_ARB */ + { 20995, 0x00008633 }, /* GL_MATRIX3_NV */ + { 21009, 0x000088C4 }, /* GL_MATRIX4_ARB */ + { 21024, 0x00008634 }, /* GL_MATRIX4_NV */ + { 21038, 0x000088C5 }, /* GL_MATRIX5_ARB */ + { 21053, 0x00008635 }, /* GL_MATRIX5_NV */ + { 21067, 0x000088C6 }, /* GL_MATRIX6_ARB */ + { 21082, 0x00008636 }, /* GL_MATRIX6_NV */ + { 21096, 0x000088C7 }, /* GL_MATRIX7_ARB */ + { 21111, 0x00008637 }, /* GL_MATRIX7_NV */ + { 21125, 0x000088C8 }, /* GL_MATRIX8_ARB */ + { 21140, 0x000088C9 }, /* GL_MATRIX9_ARB */ + { 21155, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ + { 21181, 0x00008B9E }, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ + { 21222, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_OES */ + { 21248, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + { 21282, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_OES */ + { 21316, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + { 21347, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_OES */ + { 21378, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + { 21411, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_OES */ + { 21444, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + { 21475, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_OES */ + { 21506, 0x00000BA0 }, /* GL_MATRIX_MODE */ + { 21521, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ + { 21543, 0x00008840 }, /* GL_MATRIX_PALETTE_OES */ + { 21565, 0x00008008 }, /* GL_MAX */ + { 21572, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ + { 21595, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE_OES */ + { 21622, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ + { 21650, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ + { 21682, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ + { 21708, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + { 21741, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + { 21767, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 21801, 0x00000D32 }, /* GL_MAX_CLIP_DISTANCES */ + { 21823, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ + { 21842, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ + { 21867, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ + { 21896, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + { 21928, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ + { 21964, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + { 22000, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ + { 22040, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ + { 22066, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ + { 22096, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ + { 22121, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ + { 22150, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + { 22179, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ + { 22212, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES */ + { 22245, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ + { 22265, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ + { 22289, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ + { 22313, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ + { 22337, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ + { 22362, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ + { 22380, 0x00008008 }, /* GL_MAX_EXT */ + { 22391, 0x00009125 }, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ + { 22424, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + { 22459, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ + { 22498, 0x00008DFD }, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ + { 22530, 0x00009123 }, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ + { 22563, 0x00009124 }, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ + { 22597, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ + { 22629, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ + { 22665, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ + { 22701, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ + { 22741, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ + { 22781, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ + { 22825, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ + { 22860, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ + { 22899, 0x00008DDD }, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ + { 22938, 0x00000D31 }, /* GL_MAX_LIGHTS */ + { 22952, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ + { 22972, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + { 23010, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + { 23039, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ + { 23063, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ + { 23091, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_OES */ + { 23119, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ + { 23142, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 23179, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 23215, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + { 23242, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + { 23271, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + { 23305, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ + { 23341, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + { 23368, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + { 23400, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + { 23436, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + { 23465, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + { 23494, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ + { 23522, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + { 23560, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 23604, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 23647, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 23681, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 23720, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 23757, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 23795, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 23838, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 23881, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + { 23911, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + { 23942, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ + { 23970, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET_EXT */ + { 24002, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 24038, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 24074, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ + { 24104, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ + { 24134, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ + { 24168, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ + { 24201, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ + { 24226, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ + { 24255, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_OES */ + { 24284, 0x00008D57 }, /* GL_MAX_SAMPLES */ + { 24299, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ + { 24318, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + { 24345, 0x00008504 }, /* GL_MAX_SHININESS_NV */ + { 24365, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ + { 24389, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE */ + { 24416, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ + { 24438, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ + { 24464, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + { 24491, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ + { 24522, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ + { 24546, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS_EXT */ + { 24574, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + { 24608, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ + { 24628, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ + { 24655, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ + { 24676, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ + { 24701, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ + { 24726, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ + { 24761, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ + { 24810, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ + { 24863, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ + { 24906, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ + { 24953, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ + { 24999, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ + { 25049, 0x00008B4B }, /* GL_MAX_VARYING_COMPONENTS */ + { 25075, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ + { 25097, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ + { 25123, 0x00008DFC }, /* GL_MAX_VARYING_VECTORS */ + { 25146, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ + { 25168, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ + { 25194, 0x00009122 }, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ + { 25226, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + { 25260, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ + { 25298, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + { 25331, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ + { 25368, 0x00008DFB }, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ + { 25398, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ + { 25422, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_OES */ + { 25446, 0x00008DDE }, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ + { 25483, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ + { 25504, 0x00008DF1 }, /* GL_MEDIUM_FLOAT */ + { 25520, 0x00008DF4 }, /* GL_MEDIUM_INT */ + { 25534, 0x00008007 }, /* GL_MIN */ + { 25541, 0x0000802E }, /* GL_MINMAX */ + { 25551, 0x0000802E }, /* GL_MINMAX_EXT */ + { 25565, 0x0000802F }, /* GL_MINMAX_FORMAT */ + { 25582, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ + { 25603, 0x00008030 }, /* GL_MINMAX_SINK */ + { 25618, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ + { 25637, 0x0000821C }, /* GL_MINOR_VERSION */ + { 25654, 0x00008007 }, /* GL_MIN_EXT */ + { 25665, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ + { 25693, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET_EXT */ + { 25725, 0x00008370 }, /* GL_MIRRORED_REPEAT */ + { 25744, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ + { 25767, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ + { 25790, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ + { 25810, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ + { 25830, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + { 25860, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ + { 25888, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + { 25916, 0x00001700 }, /* GL_MODELVIEW */ + { 25929, 0x00001700 }, /* GL_MODELVIEW0_ARB */ + { 25947, 0x0000872A }, /* GL_MODELVIEW10_ARB */ + { 25966, 0x0000872B }, /* GL_MODELVIEW11_ARB */ + { 25985, 0x0000872C }, /* GL_MODELVIEW12_ARB */ + { 26004, 0x0000872D }, /* GL_MODELVIEW13_ARB */ + { 26023, 0x0000872E }, /* GL_MODELVIEW14_ARB */ + { 26042, 0x0000872F }, /* GL_MODELVIEW15_ARB */ + { 26061, 0x00008730 }, /* GL_MODELVIEW16_ARB */ + { 26080, 0x00008731 }, /* GL_MODELVIEW17_ARB */ + { 26099, 0x00008732 }, /* GL_MODELVIEW18_ARB */ + { 26118, 0x00008733 }, /* GL_MODELVIEW19_ARB */ + { 26137, 0x0000850A }, /* GL_MODELVIEW1_ARB */ + { 26155, 0x00008734 }, /* GL_MODELVIEW20_ARB */ + { 26174, 0x00008735 }, /* GL_MODELVIEW21_ARB */ + { 26193, 0x00008736 }, /* GL_MODELVIEW22_ARB */ + { 26212, 0x00008737 }, /* GL_MODELVIEW23_ARB */ + { 26231, 0x00008738 }, /* GL_MODELVIEW24_ARB */ + { 26250, 0x00008739 }, /* GL_MODELVIEW25_ARB */ + { 26269, 0x0000873A }, /* GL_MODELVIEW26_ARB */ + { 26288, 0x0000873B }, /* GL_MODELVIEW27_ARB */ + { 26307, 0x0000873C }, /* GL_MODELVIEW28_ARB */ + { 26326, 0x0000873D }, /* GL_MODELVIEW29_ARB */ + { 26345, 0x00008722 }, /* GL_MODELVIEW2_ARB */ + { 26363, 0x0000873E }, /* GL_MODELVIEW30_ARB */ + { 26382, 0x0000873F }, /* GL_MODELVIEW31_ARB */ + { 26401, 0x00008723 }, /* GL_MODELVIEW3_ARB */ + { 26419, 0x00008724 }, /* GL_MODELVIEW4_ARB */ + { 26437, 0x00008725 }, /* GL_MODELVIEW5_ARB */ + { 26455, 0x00008726 }, /* GL_MODELVIEW6_ARB */ + { 26473, 0x00008727 }, /* GL_MODELVIEW7_ARB */ + { 26491, 0x00008728 }, /* GL_MODELVIEW8_ARB */ + { 26509, 0x00008729 }, /* GL_MODELVIEW9_ARB */ + { 26527, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ + { 26547, 0x0000898D }, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 26589, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ + { 26616, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ + { 26641, 0x00002100 }, /* GL_MODULATE */ + { 26653, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ + { 26673, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ + { 26700, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ + { 26725, 0x00000103 }, /* GL_MULT */ + { 26733, 0x0000809D }, /* GL_MULTISAMPLE */ + { 26748, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ + { 26768, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ + { 26787, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ + { 26806, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ + { 26830, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ + { 26853, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + { 26883, 0x00002A25 }, /* GL_N3F_V3F */ + { 26894, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ + { 26914, 0x0000150E }, /* GL_NAND */ + { 26922, 0x00002600 }, /* GL_NEAREST */ + { 26933, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + { 26964, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + { 26996, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ + { 27021, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ + { 27047, 0x00000200 }, /* GL_NEVER */ + { 27056, 0x00001102 }, /* GL_NICEST */ + { 27066, 0x00000000 }, /* GL_NONE */ + { 27074, 0x00000000 }, /* GL_NONE_OES */ + { 27086, 0x00001505 }, /* GL_NOOP */ + { 27094, 0x00001508 }, /* GL_NOR */ + { 27101, 0x00000BA1 }, /* GL_NORMALIZE */ + { 27114, 0x00008075 }, /* GL_NORMAL_ARRAY */ + { 27130, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + { 27161, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ + { 27196, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ + { 27220, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ + { 27243, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ + { 27264, 0x00008511 }, /* GL_NORMAL_MAP */ + { 27278, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ + { 27296, 0x00008511 }, /* GL_NORMAL_MAP_NV */ + { 27313, 0x00008511 }, /* GL_NORMAL_MAP_OES */ + { 27331, 0x00000205 }, /* GL_NOTEQUAL */ + { 27343, 0x00000000 }, /* GL_NO_ERROR */ + { 27355, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + { 27389, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ + { 27427, 0x0000821D }, /* GL_NUM_EXTENSIONS */ + { 27445, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ + { 27479, 0x00008DF9 }, /* GL_NUM_SHADER_BINARY_FORMATS */ + { 27508, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ + { 27540, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ + { 27582, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ + { 27612, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ + { 27652, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ + { 27683, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ + { 27712, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ + { 27740, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ + { 27770, 0x00002401 }, /* GL_OBJECT_LINEAR */ + { 27787, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ + { 27813, 0x00002501 }, /* GL_OBJECT_PLANE */ + { 27829, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ + { 27864, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ + { 27886, 0x00009112 }, /* GL_OBJECT_TYPE */ + { 27901, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ + { 27920, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ + { 27950, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ + { 27971, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ + { 27999, 0x00000001 }, /* GL_ONE */ + { 28006, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + { 28034, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ + { 28066, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ + { 28094, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ + { 28126, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ + { 28149, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ + { 28172, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ + { 28195, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ + { 28218, 0x00008598 }, /* GL_OPERAND0_ALPHA */ + { 28236, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ + { 28258, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ + { 28280, 0x00008590 }, /* GL_OPERAND0_RGB */ + { 28296, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ + { 28316, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ + { 28336, 0x00008599 }, /* GL_OPERAND1_ALPHA */ + { 28354, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ + { 28376, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ + { 28398, 0x00008591 }, /* GL_OPERAND1_RGB */ + { 28414, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ + { 28434, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ + { 28454, 0x0000859A }, /* GL_OPERAND2_ALPHA */ + { 28472, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ + { 28494, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ + { 28516, 0x00008592 }, /* GL_OPERAND2_RGB */ + { 28532, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ + { 28552, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ + { 28572, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ + { 28593, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ + { 28612, 0x00001507 }, /* GL_OR */ + { 28618, 0x00000A01 }, /* GL_ORDER */ + { 28627, 0x0000150D }, /* GL_OR_INVERTED */ + { 28642, 0x0000150B }, /* GL_OR_REVERSE */ + { 28656, 0x00000505 }, /* GL_OUT_OF_MEMORY */ + { 28673, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ + { 28691, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ + { 28712, 0x00008758 }, /* GL_PACK_INVERT_MESA */ + { 28732, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ + { 28750, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ + { 28769, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ + { 28789, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ + { 28809, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ + { 28827, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ + { 28846, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ + { 28871, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ + { 28895, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ + { 28916, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ + { 28938, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ + { 28960, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ + { 28985, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ + { 29009, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ + { 29030, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ + { 29052, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ + { 29074, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ + { 29096, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ + { 29127, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ + { 29147, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + { 29172, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ + { 29192, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + { 29217, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ + { 29237, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + { 29262, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ + { 29282, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + { 29307, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ + { 29327, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + { 29352, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ + { 29372, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + { 29397, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ + { 29417, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + { 29442, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ + { 29462, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + { 29487, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ + { 29507, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + { 29532, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ + { 29552, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + { 29577, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ + { 29595, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ + { 29616, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ + { 29645, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ + { 29678, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ + { 29703, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ + { 29726, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + { 29757, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ + { 29792, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ + { 29819, 0x00001B00 }, /* GL_POINT */ + { 29828, 0x00000000 }, /* GL_POINTS */ + { 29838, 0x00000002 }, /* GL_POINT_BIT */ + { 29851, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ + { 29881, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ + { 29915, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ + { 29949, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ + { 29984, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ + { 30013, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ + { 30046, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ + { 30079, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ + { 30113, 0x00000B11 }, /* GL_POINT_SIZE */ + { 30127, 0x00008B9F }, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ + { 30166, 0x00008B9C }, /* GL_POINT_SIZE_ARRAY_OES */ + { 30190, 0x0000898C }, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ + { 30222, 0x0000898B }, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ + { 30253, 0x0000898A }, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ + { 30282, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ + { 30308, 0x00008127 }, /* GL_POINT_SIZE_MAX */ + { 30326, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ + { 30348, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ + { 30370, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ + { 30393, 0x00008126 }, /* GL_POINT_SIZE_MIN */ + { 30411, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ + { 30433, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ + { 30455, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ + { 30478, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ + { 30498, 0x00000B10 }, /* GL_POINT_SMOOTH */ + { 30514, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ + { 30535, 0x00008861 }, /* GL_POINT_SPRITE */ + { 30551, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ + { 30571, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ + { 30600, 0x00008861 }, /* GL_POINT_SPRITE_NV */ + { 30619, 0x00008861 }, /* GL_POINT_SPRITE_OES */ + { 30639, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ + { 30665, 0x00000701 }, /* GL_POINT_TOKEN */ + { 30680, 0x00000009 }, /* GL_POLYGON */ + { 30691, 0x00000008 }, /* GL_POLYGON_BIT */ + { 30706, 0x00000B40 }, /* GL_POLYGON_MODE */ + { 30722, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ + { 30745, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ + { 30770, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ + { 30793, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ + { 30816, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ + { 30840, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ + { 30864, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ + { 30882, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ + { 30905, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ + { 30924, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ + { 30947, 0x00000703 }, /* GL_POLYGON_TOKEN */ + { 30964, 0x00001203 }, /* GL_POSITION */ + { 30976, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + { 31008, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ + { 31044, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + { 31077, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ + { 31114, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + { 31145, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ + { 31180, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + { 31212, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ + { 31248, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + { 31281, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + { 31313, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ + { 31349, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + { 31382, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ + { 31419, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + { 31449, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ + { 31483, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + { 31514, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ + { 31549, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + { 31580, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ + { 31615, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + { 31647, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ + { 31683, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + { 31713, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ + { 31747, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + { 31778, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ + { 31813, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + { 31845, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + { 31876, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ + { 31911, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + { 31943, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ + { 31979, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ + { 32008, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ + { 32041, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ + { 32071, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ + { 32105, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + { 32144, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + { 32177, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + { 32217, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + { 32251, 0x00008578 }, /* GL_PREVIOUS */ + { 32263, 0x00008578 }, /* GL_PREVIOUS_ARB */ + { 32279, 0x00008578 }, /* GL_PREVIOUS_EXT */ + { 32295, 0x00008577 }, /* GL_PRIMARY_COLOR */ + { 32312, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ + { 32333, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ + { 32354, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED */ + { 32378, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED_EXT */ + { 32406, 0x00008F9D }, /* GL_PRIMITIVE_RESTART */ + { 32427, 0x00008F9E }, /* GL_PRIMITIVE_RESTART_INDEX */ + { 32454, 0x00008559 }, /* GL_PRIMITIVE_RESTART_INDEX_NV */ + { 32484, 0x00008558 }, /* GL_PRIMITIVE_RESTART_NV */ + { 32508, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 32541, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 32573, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ + { 32596, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS_OES */ + { 32626, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH_OES */ + { 32655, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ + { 32678, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ + { 32708, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ + { 32737, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ + { 32765, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ + { 32787, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + { 32815, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + { 32843, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ + { 32865, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ + { 32886, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 32926, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 32965, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 32995, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 33030, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 33063, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 33097, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 33136, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 33175, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ + { 33197, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ + { 33223, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ + { 33247, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE */ + { 33269, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE_ARB */ + { 33295, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ + { 33318, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ + { 33340, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ + { 33361, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ + { 33382, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ + { 33409, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 33441, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 33473, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + { 33508, 0x00001701 }, /* GL_PROJECTION */ + { 33522, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ + { 33543, 0x0000898E }, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 33586, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ + { 33612, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ + { 33632, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ + { 33656, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ + { 33677, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ + { 33696, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ + { 33719, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + { 33758, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + { 33796, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ + { 33816, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY */ + { 33842, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ + { 33872, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ + { 33896, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ + { 33916, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY */ + { 33942, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ + { 33972, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ + { 33996, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ + { 34016, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + { 34049, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ + { 34075, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ + { 34105, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE */ + { 34132, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ + { 34163, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ + { 34193, 0x00008A1D }, /* GL_PURGEABLE_APPLE */ + { 34212, 0x00002003 }, /* GL_Q */ + { 34217, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ + { 34242, 0x00000007 }, /* GL_QUADS */ + { 34251, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + { 34295, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ + { 34343, 0x00008614 }, /* GL_QUAD_MESH_SUN */ + { 34360, 0x00000008 }, /* GL_QUAD_STRIP */ + { 34374, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT */ + { 34401, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ + { 34431, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT */ + { 34455, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ + { 34482, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ + { 34504, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ + { 34530, 0x00008E14 }, /* GL_QUERY_NO_WAIT */ + { 34547, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ + { 34567, 0x00008866 }, /* GL_QUERY_RESULT */ + { 34583, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ + { 34603, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ + { 34629, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ + { 34659, 0x00008E13 }, /* GL_QUERY_WAIT */ + { 34673, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ + { 34690, 0x00002002 }, /* GL_R */ + { 34695, 0x00008C3A }, /* GL_R11F_G11F_B10F */ + { 34713, 0x00008F98 }, /* GL_R16_SNORM */ + { 34726, 0x00002A10 }, /* GL_R3_G3_B2 */ + { 34738, 0x00008F94 }, /* GL_R8_SNORM */ + { 34750, 0x00008C89 }, /* GL_RASTERIZER_DISCARD */ + { 34772, 0x00008C89 }, /* GL_RASTERIZER_DISCARD_EXT */ + { 34798, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + { 34831, 0x00000C02 }, /* GL_READ_BUFFER */ + { 34846, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ + { 34866, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ + { 34894, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ + { 34926, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ + { 34950, 0x000088B8 }, /* GL_READ_ONLY */ + { 34963, 0x000088B8 }, /* GL_READ_ONLY_ARB */ + { 34980, 0x000088BA }, /* GL_READ_WRITE */ + { 34994, 0x000088BA }, /* GL_READ_WRITE_ARB */ + { 35012, 0x00001903 }, /* GL_RED */ + { 35019, 0x00008016 }, /* GL_REDUCE */ + { 35029, 0x00008016 }, /* GL_REDUCE_EXT */ + { 35043, 0x00000D15 }, /* GL_RED_BIAS */ + { 35055, 0x00000D52 }, /* GL_RED_BITS */ + { 35067, 0x00008D94 }, /* GL_RED_INTEGER */ + { 35082, 0x00008D94 }, /* GL_RED_INTEGER_EXT */ + { 35101, 0x00000D14 }, /* GL_RED_SCALE */ + { 35114, 0x00008F90 }, /* GL_RED_SNORM */ + { 35127, 0x00008512 }, /* GL_REFLECTION_MAP */ + { 35145, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ + { 35167, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ + { 35188, 0x00008512 }, /* GL_REFLECTION_MAP_OES */ + { 35210, 0x00008A19 }, /* GL_RELEASED_APPLE */ + { 35228, 0x00001C00 }, /* GL_RENDER */ + { 35238, 0x00008D41 }, /* GL_RENDERBUFFER */ + { 35254, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ + { 35281, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE_OES */ + { 35312, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ + { 35336, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ + { 35364, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_OES */ + { 35392, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ + { 35418, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE_OES */ + { 35448, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ + { 35475, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE_OES */ + { 35506, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ + { 35526, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ + { 35553, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE_OES */ + { 35584, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ + { 35607, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ + { 35634, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_OES */ + { 35661, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + { 35693, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ + { 35729, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ + { 35765, 0x00008D41 }, /* GL_RENDERBUFFER_OES */ + { 35785, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ + { 35810, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE_OES */ + { 35839, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ + { 35863, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ + { 35891, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ + { 35920, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE_OES */ + { 35953, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ + { 35975, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ + { 36001, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_OES */ + { 36027, 0x00001F01 }, /* GL_RENDERER */ + { 36039, 0x00000C40 }, /* GL_RENDER_MODE */ + { 36054, 0x00002901 }, /* GL_REPEAT */ + { 36064, 0x00001E01 }, /* GL_REPLACE */ + { 36075, 0x00008062 }, /* GL_REPLACE_EXT */ + { 36090, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ + { 36113, 0x0000803A }, /* GL_RESCALE_NORMAL */ + { 36131, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ + { 36153, 0x00008A1B }, /* GL_RETAINED_APPLE */ + { 36171, 0x00000102 }, /* GL_RETURN */ + { 36181, 0x00008F99 }, /* GL_RG16_SNORM */ + { 36195, 0x00008F95 }, /* GL_RG8_SNORM */ + { 36208, 0x00001907 }, /* GL_RGB */ + { 36215, 0x00008052 }, /* GL_RGB10 */ + { 36224, 0x00008059 }, /* GL_RGB10_A2 */ + { 36236, 0x00008059 }, /* GL_RGB10_A2_EXT */ + { 36252, 0x00008052 }, /* GL_RGB10_EXT */ + { 36265, 0x00008053 }, /* GL_RGB12 */ + { 36274, 0x00008053 }, /* GL_RGB12_EXT */ + { 36287, 0x00008054 }, /* GL_RGB16 */ + { 36296, 0x0000881B }, /* GL_RGB16F */ + { 36306, 0x00008D89 }, /* GL_RGB16I */ + { 36316, 0x00008D89 }, /* GL_RGB16I_EXT */ + { 36330, 0x00008D77 }, /* GL_RGB16UI */ + { 36341, 0x00008D77 }, /* GL_RGB16UI_EXT */ + { 36356, 0x00008054 }, /* GL_RGB16_EXT */ + { 36369, 0x00008F9A }, /* GL_RGB16_SNORM */ + { 36384, 0x0000804E }, /* GL_RGB2_EXT */ + { 36396, 0x00008815 }, /* GL_RGB32F */ + { 36406, 0x00008D83 }, /* GL_RGB32I */ + { 36416, 0x00008D83 }, /* GL_RGB32I_EXT */ + { 36430, 0x00008D71 }, /* GL_RGB32UI */ + { 36441, 0x00008D71 }, /* GL_RGB32UI_EXT */ + { 36456, 0x0000804F }, /* GL_RGB4 */ + { 36464, 0x0000804F }, /* GL_RGB4_EXT */ + { 36476, 0x000083A1 }, /* GL_RGB4_S3TC */ + { 36489, 0x00008050 }, /* GL_RGB5 */ + { 36497, 0x00008D62 }, /* GL_RGB565 */ + { 36507, 0x00008D62 }, /* GL_RGB565_OES */ + { 36521, 0x00008057 }, /* GL_RGB5_A1 */ + { 36532, 0x00008057 }, /* GL_RGB5_A1_EXT */ + { 36547, 0x00008057 }, /* GL_RGB5_A1_OES */ + { 36562, 0x00008050 }, /* GL_RGB5_EXT */ + { 36574, 0x00008051 }, /* GL_RGB8 */ + { 36582, 0x00008D8F }, /* GL_RGB8I */ + { 36591, 0x00008D8F }, /* GL_RGB8I_EXT */ + { 36604, 0x00008D7D }, /* GL_RGB8UI */ + { 36614, 0x00008D7D }, /* GL_RGB8UI_EXT */ + { 36628, 0x00008051 }, /* GL_RGB8_EXT */ + { 36640, 0x00008051 }, /* GL_RGB8_OES */ + { 36652, 0x00008F96 }, /* GL_RGB8_SNORM */ + { 36666, 0x00008C3D }, /* GL_RGB9_E5 */ + { 36677, 0x00001908 }, /* GL_RGBA */ + { 36685, 0x0000805A }, /* GL_RGBA12 */ + { 36695, 0x0000805A }, /* GL_RGBA12_EXT */ + { 36709, 0x0000805B }, /* GL_RGBA16 */ + { 36719, 0x0000881A }, /* GL_RGBA16F */ + { 36730, 0x00008D88 }, /* GL_RGBA16I */ + { 36741, 0x00008D88 }, /* GL_RGBA16I_EXT */ + { 36756, 0x00008D76 }, /* GL_RGBA16UI */ + { 36768, 0x00008D76 }, /* GL_RGBA16UI_EXT */ + { 36784, 0x0000805B }, /* GL_RGBA16_EXT */ + { 36798, 0x00008F9B }, /* GL_RGBA16_SNORM */ + { 36814, 0x00008055 }, /* GL_RGBA2 */ + { 36823, 0x00008055 }, /* GL_RGBA2_EXT */ + { 36836, 0x00008814 }, /* GL_RGBA32F */ + { 36847, 0x00008D82 }, /* GL_RGBA32I */ + { 36858, 0x00008D82 }, /* GL_RGBA32I_EXT */ + { 36873, 0x00008D70 }, /* GL_RGBA32UI */ + { 36885, 0x00008D70 }, /* GL_RGBA32UI_EXT */ + { 36901, 0x00008056 }, /* GL_RGBA4 */ + { 36910, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ + { 36929, 0x00008056 }, /* GL_RGBA4_EXT */ + { 36942, 0x00008056 }, /* GL_RGBA4_OES */ + { 36955, 0x000083A3 }, /* GL_RGBA4_S3TC */ + { 36969, 0x00008058 }, /* GL_RGBA8 */ + { 36978, 0x00008D8E }, /* GL_RGBA8I */ + { 36988, 0x00008D8E }, /* GL_RGBA8I_EXT */ + { 37002, 0x00008D7C }, /* GL_RGBA8UI */ + { 37013, 0x00008D7C }, /* GL_RGBA8UI_EXT */ + { 37028, 0x00008058 }, /* GL_RGBA8_EXT */ + { 37041, 0x00008058 }, /* GL_RGBA8_OES */ + { 37054, 0x00008F97 }, /* GL_RGBA8_SNORM */ + { 37069, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ + { 37087, 0x00008D99 }, /* GL_RGBA_INTEGER */ + { 37103, 0x00008D99 }, /* GL_RGBA_INTEGER_EXT */ + { 37123, 0x00008D9E }, /* GL_RGBA_INTEGER_MODE_EXT */ + { 37148, 0x00000C31 }, /* GL_RGBA_MODE */ + { 37161, 0x000083A2 }, /* GL_RGBA_S3TC */ + { 37174, 0x00008F93 }, /* GL_RGBA_SNORM */ + { 37188, 0x00008D98 }, /* GL_RGB_INTEGER */ + { 37203, 0x00008D98 }, /* GL_RGB_INTEGER_EXT */ + { 37222, 0x000083A0 }, /* GL_RGB_S3TC */ + { 37234, 0x00008573 }, /* GL_RGB_SCALE */ + { 37247, 0x00008573 }, /* GL_RGB_SCALE_ARB */ + { 37264, 0x00008573 }, /* GL_RGB_SCALE_EXT */ + { 37281, 0x00008F92 }, /* GL_RGB_SNORM */ + { 37294, 0x00008F91 }, /* GL_RG_SNORM */ + { 37306, 0x00000407 }, /* GL_RIGHT */ + { 37315, 0x00002000 }, /* GL_S */ + { 37320, 0x00008B5D }, /* GL_SAMPLER_1D */ + { 37334, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY */ + { 37354, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY_EXT */ + { 37378, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW */ + { 37405, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW_EXT */ + { 37436, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ + { 37457, 0x00008B5E }, /* GL_SAMPLER_2D */ + { 37471, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY */ + { 37491, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY_EXT */ + { 37515, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW */ + { 37542, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW_EXT */ + { 37573, 0x00008B63 }, /* GL_SAMPLER_2D_RECT */ + { 37592, 0x00008B64 }, /* GL_SAMPLER_2D_RECT_SHADOW */ + { 37618, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ + { 37639, 0x00008B5F }, /* GL_SAMPLER_3D */ + { 37653, 0x00008B5F }, /* GL_SAMPLER_3D_OES */ + { 37671, 0x00008DC2 }, /* GL_SAMPLER_BUFFER */ + { 37689, 0x00008DC2 }, /* GL_SAMPLER_BUFFER_EXT */ + { 37711, 0x00008B60 }, /* GL_SAMPLER_CUBE */ + { 37727, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW */ + { 37750, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW_EXT */ + { 37777, 0x000080A9 }, /* GL_SAMPLES */ + { 37788, 0x000086B4 }, /* GL_SAMPLES_3DFX */ + { 37804, 0x000080A9 }, /* GL_SAMPLES_ARB */ + { 37819, 0x00008914 }, /* GL_SAMPLES_PASSED */ + { 37837, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ + { 37859, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + { 37887, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ + { 37919, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ + { 37942, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ + { 37969, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ + { 37987, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ + { 38010, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ + { 38032, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ + { 38051, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ + { 38074, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ + { 38100, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ + { 38130, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ + { 38155, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ + { 38184, 0x00080000 }, /* GL_SCISSOR_BIT */ + { 38199, 0x00000C10 }, /* GL_SCISSOR_BOX */ + { 38214, 0x00000C11 }, /* GL_SCISSOR_TEST */ + { 38230, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ + { 38255, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + { 38295, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ + { 38339, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + { 38372, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + { 38402, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + { 38434, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + { 38464, 0x00001C02 }, /* GL_SELECT */ + { 38474, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ + { 38502, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ + { 38527, 0x00008012 }, /* GL_SEPARABLE_2D */ + { 38543, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS */ + { 38563, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS_EXT */ + { 38587, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ + { 38614, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ + { 38645, 0x0000150F }, /* GL_SET */ + { 38652, 0x00008DF8 }, /* GL_SHADER_BINARY_FORMATS */ + { 38677, 0x00008DFA }, /* GL_SHADER_COMPILER */ + { 38696, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ + { 38717, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ + { 38741, 0x00008B4F }, /* GL_SHADER_TYPE */ + { 38756, 0x00000B54 }, /* GL_SHADE_MODEL */ + { 38771, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ + { 38799, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ + { 38822, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + { 38852, 0x00001601 }, /* GL_SHININESS */ + { 38865, 0x00001402 }, /* GL_SHORT */ + { 38874, 0x00009119 }, /* GL_SIGNALED */ + { 38886, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ + { 38907, 0x000081F9 }, /* GL_SINGLE_COLOR */ + { 38923, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ + { 38943, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ + { 38962, 0x00008C46 }, /* GL_SLUMINANCE */ + { 38976, 0x00008C47 }, /* GL_SLUMINANCE8 */ + { 38991, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ + { 39013, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ + { 39033, 0x00001D01 }, /* GL_SMOOTH */ + { 39043, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ + { 39076, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ + { 39103, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ + { 39136, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ + { 39163, 0x00008588 }, /* GL_SOURCE0_ALPHA */ + { 39180, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ + { 39201, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ + { 39222, 0x00008580 }, /* GL_SOURCE0_RGB */ + { 39237, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ + { 39256, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ + { 39275, 0x00008589 }, /* GL_SOURCE1_ALPHA */ + { 39292, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ + { 39313, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ + { 39334, 0x00008581 }, /* GL_SOURCE1_RGB */ + { 39349, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ + { 39368, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ + { 39387, 0x0000858A }, /* GL_SOURCE2_ALPHA */ + { 39404, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ + { 39425, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ + { 39446, 0x00008582 }, /* GL_SOURCE2_RGB */ + { 39461, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ + { 39480, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ + { 39499, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ + { 39519, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ + { 39537, 0x00001202 }, /* GL_SPECULAR */ + { 39549, 0x00002402 }, /* GL_SPHERE_MAP */ + { 39563, 0x00001206 }, /* GL_SPOT_CUTOFF */ + { 39578, 0x00001204 }, /* GL_SPOT_DIRECTION */ + { 39596, 0x00001205 }, /* GL_SPOT_EXPONENT */ + { 39613, 0x00008588 }, /* GL_SRC0_ALPHA */ + { 39627, 0x00008580 }, /* GL_SRC0_RGB */ + { 39639, 0x00008589 }, /* GL_SRC1_ALPHA */ + { 39653, 0x00008581 }, /* GL_SRC1_RGB */ + { 39665, 0x0000858A }, /* GL_SRC2_ALPHA */ + { 39679, 0x00008582 }, /* GL_SRC2_RGB */ + { 39691, 0x00000302 }, /* GL_SRC_ALPHA */ + { 39704, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ + { 39726, 0x00000300 }, /* GL_SRC_COLOR */ + { 39739, 0x00008C40 }, /* GL_SRGB */ + { 39747, 0x00008C41 }, /* GL_SRGB8 */ + { 39756, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ + { 39772, 0x00008C42 }, /* GL_SRGB_ALPHA */ + { 39786, 0x00000503 }, /* GL_STACK_OVERFLOW */ + { 39804, 0x00000504 }, /* GL_STACK_UNDERFLOW */ + { 39823, 0x000088E6 }, /* GL_STATIC_COPY */ + { 39838, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ + { 39857, 0x000088E4 }, /* GL_STATIC_DRAW */ + { 39872, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ + { 39891, 0x000088E5 }, /* GL_STATIC_READ */ + { 39906, 0x000088E5 }, /* GL_STATIC_READ_ARB */ + { 39925, 0x00001802 }, /* GL_STENCIL */ + { 39936, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ + { 39958, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ + { 39984, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_OES */ + { 40010, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ + { 40031, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ + { 40056, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ + { 40077, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ + { 40102, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + { 40134, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ + { 40170, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + { 40202, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ + { 40238, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ + { 40258, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ + { 40285, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ + { 40311, 0x00000D57 }, /* GL_STENCIL_BITS */ + { 40327, 0x00008224 }, /* GL_STENCIL_BUFFER */ + { 40345, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ + { 40367, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ + { 40390, 0x00000B94 }, /* GL_STENCIL_FAIL */ + { 40406, 0x00000B92 }, /* GL_STENCIL_FUNC */ + { 40422, 0x00001901 }, /* GL_STENCIL_INDEX */ + { 40439, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ + { 40457, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ + { 40476, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ + { 40499, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ + { 40521, 0x00008D46 }, /* GL_STENCIL_INDEX1_OES */ + { 40543, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ + { 40561, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ + { 40583, 0x00008D47 }, /* GL_STENCIL_INDEX4_OES */ + { 40605, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ + { 40623, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ + { 40645, 0x00008D48 }, /* GL_STENCIL_INDEX8_OES */ + { 40667, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ + { 40688, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ + { 40715, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ + { 40742, 0x00000B97 }, /* GL_STENCIL_REF */ + { 40757, 0x00000B90 }, /* GL_STENCIL_TEST */ + { 40773, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + { 40802, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ + { 40824, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ + { 40845, 0x00000C33 }, /* GL_STEREO */ + { 40855, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ + { 40879, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ + { 40904, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ + { 40928, 0x000088E2 }, /* GL_STREAM_COPY */ + { 40943, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ + { 40962, 0x000088E0 }, /* GL_STREAM_DRAW */ + { 40977, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ + { 40996, 0x000088E1 }, /* GL_STREAM_READ */ + { 41011, 0x000088E1 }, /* GL_STREAM_READ_ARB */ + { 41030, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ + { 41047, 0x000084E7 }, /* GL_SUBTRACT */ + { 41059, 0x000084E7 }, /* GL_SUBTRACT_ARB */ + { 41075, 0x00009113 }, /* GL_SYNC_CONDITION */ + { 41093, 0x00009116 }, /* GL_SYNC_FENCE */ + { 41107, 0x00009115 }, /* GL_SYNC_FLAGS */ + { 41121, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ + { 41148, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + { 41178, 0x00009114 }, /* GL_SYNC_STATUS */ + { 41193, 0x00002001 }, /* GL_T */ + { 41198, 0x00002A2A }, /* GL_T2F_C3F_V3F */ + { 41213, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ + { 41232, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ + { 41248, 0x00002A2B }, /* GL_T2F_N3F_V3F */ + { 41263, 0x00002A27 }, /* GL_T2F_V3F */ + { 41274, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ + { 41293, 0x00002A28 }, /* GL_T4F_V4F */ + { 41304, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ + { 41327, 0x00001702 }, /* GL_TEXTURE */ + { 41338, 0x000084C0 }, /* GL_TEXTURE0 */ + { 41350, 0x000084C0 }, /* GL_TEXTURE0_ARB */ + { 41366, 0x000084C1 }, /* GL_TEXTURE1 */ + { 41378, 0x000084CA }, /* GL_TEXTURE10 */ + { 41391, 0x000084CA }, /* GL_TEXTURE10_ARB */ + { 41408, 0x000084CB }, /* GL_TEXTURE11 */ + { 41421, 0x000084CB }, /* GL_TEXTURE11_ARB */ + { 41438, 0x000084CC }, /* GL_TEXTURE12 */ + { 41451, 0x000084CC }, /* GL_TEXTURE12_ARB */ + { 41468, 0x000084CD }, /* GL_TEXTURE13 */ + { 41481, 0x000084CD }, /* GL_TEXTURE13_ARB */ + { 41498, 0x000084CE }, /* GL_TEXTURE14 */ + { 41511, 0x000084CE }, /* GL_TEXTURE14_ARB */ + { 41528, 0x000084CF }, /* GL_TEXTURE15 */ + { 41541, 0x000084CF }, /* GL_TEXTURE15_ARB */ + { 41558, 0x000084D0 }, /* GL_TEXTURE16 */ + { 41571, 0x000084D0 }, /* GL_TEXTURE16_ARB */ + { 41588, 0x000084D1 }, /* GL_TEXTURE17 */ + { 41601, 0x000084D1 }, /* GL_TEXTURE17_ARB */ + { 41618, 0x000084D2 }, /* GL_TEXTURE18 */ + { 41631, 0x000084D2 }, /* GL_TEXTURE18_ARB */ + { 41648, 0x000084D3 }, /* GL_TEXTURE19 */ + { 41661, 0x000084D3 }, /* GL_TEXTURE19_ARB */ + { 41678, 0x000084C1 }, /* GL_TEXTURE1_ARB */ + { 41694, 0x000084C2 }, /* GL_TEXTURE2 */ + { 41706, 0x000084D4 }, /* GL_TEXTURE20 */ + { 41719, 0x000084D4 }, /* GL_TEXTURE20_ARB */ + { 41736, 0x000084D5 }, /* GL_TEXTURE21 */ + { 41749, 0x000084D5 }, /* GL_TEXTURE21_ARB */ + { 41766, 0x000084D6 }, /* GL_TEXTURE22 */ + { 41779, 0x000084D6 }, /* GL_TEXTURE22_ARB */ + { 41796, 0x000084D7 }, /* GL_TEXTURE23 */ + { 41809, 0x000084D7 }, /* GL_TEXTURE23_ARB */ + { 41826, 0x000084D8 }, /* GL_TEXTURE24 */ + { 41839, 0x000084D8 }, /* GL_TEXTURE24_ARB */ + { 41856, 0x000084D9 }, /* GL_TEXTURE25 */ + { 41869, 0x000084D9 }, /* GL_TEXTURE25_ARB */ + { 41886, 0x000084DA }, /* GL_TEXTURE26 */ + { 41899, 0x000084DA }, /* GL_TEXTURE26_ARB */ + { 41916, 0x000084DB }, /* GL_TEXTURE27 */ + { 41929, 0x000084DB }, /* GL_TEXTURE27_ARB */ + { 41946, 0x000084DC }, /* GL_TEXTURE28 */ + { 41959, 0x000084DC }, /* GL_TEXTURE28_ARB */ + { 41976, 0x000084DD }, /* GL_TEXTURE29 */ + { 41989, 0x000084DD }, /* GL_TEXTURE29_ARB */ + { 42006, 0x000084C2 }, /* GL_TEXTURE2_ARB */ + { 42022, 0x000084C3 }, /* GL_TEXTURE3 */ + { 42034, 0x000084DE }, /* GL_TEXTURE30 */ + { 42047, 0x000084DE }, /* GL_TEXTURE30_ARB */ + { 42064, 0x000084DF }, /* GL_TEXTURE31 */ + { 42077, 0x000084DF }, /* GL_TEXTURE31_ARB */ + { 42094, 0x000084C3 }, /* GL_TEXTURE3_ARB */ + { 42110, 0x000084C4 }, /* GL_TEXTURE4 */ + { 42122, 0x000084C4 }, /* GL_TEXTURE4_ARB */ + { 42138, 0x000084C5 }, /* GL_TEXTURE5 */ + { 42150, 0x000084C5 }, /* GL_TEXTURE5_ARB */ + { 42166, 0x000084C6 }, /* GL_TEXTURE6 */ + { 42178, 0x000084C6 }, /* GL_TEXTURE6_ARB */ + { 42194, 0x000084C7 }, /* GL_TEXTURE7 */ + { 42206, 0x000084C7 }, /* GL_TEXTURE7_ARB */ + { 42222, 0x000084C8 }, /* GL_TEXTURE8 */ + { 42234, 0x000084C8 }, /* GL_TEXTURE8_ARB */ + { 42250, 0x000084C9 }, /* GL_TEXTURE9 */ + { 42262, 0x000084C9 }, /* GL_TEXTURE9_ARB */ + { 42278, 0x00000DE0 }, /* GL_TEXTURE_1D */ + { 42292, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY */ + { 42312, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ + { 42336, 0x00000DE1 }, /* GL_TEXTURE_2D */ + { 42350, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY */ + { 42370, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ + { 42394, 0x0000806F }, /* GL_TEXTURE_3D */ + { 42408, 0x0000806F }, /* GL_TEXTURE_3D_OES */ + { 42426, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ + { 42448, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ + { 42474, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ + { 42496, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ + { 42518, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY */ + { 42546, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ + { 42578, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ + { 42600, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY */ + { 42628, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ + { 42660, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ + { 42682, 0x0000806A }, /* GL_TEXTURE_BINDING_3D_OES */ + { 42708, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER */ + { 42734, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ + { 42762, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ + { 42794, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_OES */ + { 42826, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE */ + { 42855, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ + { 42888, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ + { 42920, 0x00040000 }, /* GL_TEXTURE_BIT */ + { 42935, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ + { 42956, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ + { 42981, 0x00001005 }, /* GL_TEXTURE_BORDER */ + { 42999, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ + { 43023, 0x00008C2A }, /* GL_TEXTURE_BUFFER */ + { 43041, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ + { 43078, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT */ + { 43103, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + { 43134, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + { 43164, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + { 43194, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + { 43229, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + { 43260, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 43298, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ + { 43325, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + { 43357, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + { 43391, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ + { 43415, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ + { 43443, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ + { 43467, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ + { 43495, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + { 43528, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ + { 43552, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ + { 43574, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ + { 43596, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ + { 43622, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ + { 43656, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + { 43689, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ + { 43726, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ + { 43754, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ + { 43786, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ + { 43809, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + { 43847, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ + { 43889, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + { 43920, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + { 43948, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + { 43978, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + { 44006, 0x00008B9D }, /* GL_TEXTURE_CROP_RECT_OES */ + { 44031, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ + { 44051, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ + { 44075, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + { 44106, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ + { 44141, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES */ + { 44176, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + { 44207, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ + { 44242, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES */ + { 44277, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + { 44308, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ + { 44343, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES */ + { 44378, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_OES */ + { 44402, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + { 44433, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ + { 44468, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES */ + { 44503, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + { 44534, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ + { 44569, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES */ + { 44604, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + { 44635, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ + { 44670, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ + { 44705, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + { 44734, 0x00008071 }, /* GL_TEXTURE_DEPTH */ + { 44751, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ + { 44773, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ + { 44799, 0x00002300 }, /* GL_TEXTURE_ENV */ + { 44814, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ + { 44835, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ + { 44855, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ + { 44881, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL_EXT */ + { 44911, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ + { 44931, 0x00002500 }, /* GL_TEXTURE_GEN_MODE_OES */ + { 44955, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ + { 44972, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ + { 44989, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ + { 45006, 0x00008D60 }, /* GL_TEXTURE_GEN_STR_OES */ + { 45029, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ + { 45046, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ + { 45071, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ + { 45093, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ + { 45119, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ + { 45137, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ + { 45163, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ + { 45189, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ + { 45219, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ + { 45246, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ + { 45271, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ + { 45291, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ + { 45315, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + { 45342, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + { 45369, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + { 45396, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ + { 45422, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ + { 45452, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ + { 45474, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ + { 45492, 0x0000898F }, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 45532, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + { 45562, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + { 45590, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + { 45618, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + { 45646, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ + { 45667, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ + { 45686, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ + { 45708, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ + { 45727, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ + { 45747, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + { 45777, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + { 45808, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE */ + { 45829, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ + { 45854, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ + { 45878, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ + { 45898, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ + { 45922, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ + { 45942, 0x00008C3F }, /* GL_TEXTURE_SHARED_SIZE */ + { 45965, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ + { 45988, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ + { 46012, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ + { 46040, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + { 46070, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ + { 46095, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + { 46129, 0x00001000 }, /* GL_TEXTURE_WIDTH */ + { 46146, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ + { 46164, 0x00008072 }, /* GL_TEXTURE_WRAP_R_OES */ + { 46186, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ + { 46204, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ + { 46222, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ + { 46241, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ + { 46261, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ + { 46280, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + { 46309, 0x00001000 }, /* GL_TRANSFORM_BIT */ + { 46326, 0x00008E22 }, /* GL_TRANSFORM_FEEDBACK */ + { 46348, 0x00008E25 }, /* GL_TRANSFORM_FEEDBACK_BINDING */ + { 46378, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER */ + { 46407, 0x00008E24 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ + { 46443, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ + { 46480, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ + { 46521, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ + { 46554, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ + { 46588, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ + { 46626, 0x00008E23 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ + { 46662, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ + { 46696, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ + { 46734, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ + { 46769, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ + { 46808, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ + { 46849, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ + { 46894, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ + { 46925, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ + { 46960, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ + { 47001, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ + { 47046, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ + { 47072, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ + { 47102, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + { 47134, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + { 47164, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ + { 47198, 0x0000862C }, /* GL_TRANSPOSE_NV */ + { 47214, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + { 47245, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ + { 47280, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + { 47308, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ + { 47340, 0x00000004 }, /* GL_TRIANGLES */ + { 47353, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY */ + { 47376, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY_ARB */ + { 47403, 0x00000006 }, /* GL_TRIANGLE_FAN */ + { 47419, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ + { 47440, 0x00000005 }, /* GL_TRIANGLE_STRIP */ + { 47458, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY */ + { 47486, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ + { 47518, 0x00000001 }, /* GL_TRUE */ + { 47526, 0x00008A1C }, /* GL_UNDEFINED_APPLE */ + { 47545, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ + { 47565, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ + { 47588, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ + { 47608, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ + { 47629, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ + { 47651, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ + { 47673, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ + { 47693, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ + { 47714, 0x00009118 }, /* GL_UNSIGNALED */ + { 47728, 0x00001401 }, /* GL_UNSIGNED_BYTE */ + { 47745, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + { 47772, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ + { 47795, 0x00001405 }, /* GL_UNSIGNED_INT */ + { 47811, 0x00008C3B }, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ + { 47843, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ + { 47870, 0x00008DF6 }, /* GL_UNSIGNED_INT_10_10_10_2_OES */ + { 47901, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ + { 47922, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ + { 47947, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ + { 47971, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_OES */ + { 47996, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + { 48027, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV_EXT */ + { 48062, 0x00008C3E }, /* GL_UNSIGNED_INT_5_9_9_9_REV */ + { 48090, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ + { 48114, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + { 48142, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D */ + { 48169, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ + { 48202, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT */ + { 48239, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D_EXT */ + { 48270, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D */ + { 48297, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ + { 48330, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT */ + { 48367, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D_EXT */ + { 48398, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ + { 48430, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT */ + { 48466, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D */ + { 48493, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D_EXT */ + { 48524, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ + { 48555, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT */ + { 48590, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ + { 48619, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE_EXT */ + { 48652, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2 */ + { 48673, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2_EXT */ + { 48698, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3 */ + { 48719, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3_EXT */ + { 48744, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4 */ + { 48765, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4_EXT */ + { 48790, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ + { 48813, 0x00001403 }, /* GL_UNSIGNED_SHORT */ + { 48831, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + { 48861, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT */ + { 48895, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + { 48921, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + { 48951, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT */ + { 48985, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + { 49011, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ + { 49035, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + { 49063, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + { 49091, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ + { 49118, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + { 49150, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ + { 49181, 0x00008CA2 }, /* GL_UPPER_LEFT */ + { 49195, 0x00002A20 }, /* GL_V2F */ + { 49202, 0x00002A21 }, /* GL_V3F */ + { 49209, 0x00008B83 }, /* GL_VALIDATE_STATUS */ + { 49228, 0x00001F00 }, /* GL_VENDOR */ + { 49238, 0x00001F02 }, /* GL_VERSION */ + { 49249, 0x00008074 }, /* GL_VERTEX_ARRAY */ + { 49265, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ + { 49289, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ + { 49319, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + { 49350, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ + { 49385, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ + { 49409, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ + { 49430, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ + { 49453, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ + { 49474, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + { 49501, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + { 49529, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + { 49557, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + { 49585, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + { 49613, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + { 49641, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + { 49669, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + { 49696, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + { 49723, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + { 49750, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + { 49777, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + { 49804, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + { 49831, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + { 49858, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + { 49885, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + { 49912, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + { 49950, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ + { 49992, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + { 50023, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ + { 50058, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ + { 50089, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT */ + { 50124, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + { 50158, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ + { 50196, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + { 50227, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ + { 50262, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + { 50290, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ + { 50322, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + { 50352, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ + { 50386, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + { 50414, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ + { 50446, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ + { 50466, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ + { 50488, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ + { 50517, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ + { 50538, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ + { 50567, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ + { 50600, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ + { 50632, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + { 50659, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ + { 50690, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + { 50720, 0x00008B31 }, /* GL_VERTEX_SHADER */ + { 50737, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ + { 50758, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ + { 50785, 0x00000BA2 }, /* GL_VIEWPORT */ + { 50797, 0x00000800 }, /* GL_VIEWPORT_BIT */ + { 50813, 0x00008A1A }, /* GL_VOLATILE_APPLE */ + { 50831, 0x0000911D }, /* GL_WAIT_FAILED */ + { 50846, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ + { 50866, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + { 50897, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ + { 50932, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_OES */ + { 50967, 0x000086AD }, /* GL_WEIGHT_ARRAY_OES */ + { 50987, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + { 51015, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_OES */ + { 51043, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + { 51068, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_OES */ + { 51093, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + { 51120, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_OES */ + { 51147, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + { 51172, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_OES */ + { 51197, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ + { 51221, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ + { 51240, 0x000088B9 }, /* GL_WRITE_ONLY */ + { 51254, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ + { 51272, 0x000088B9 }, /* GL_WRITE_ONLY_OES */ + { 51290, 0x00001506 }, /* GL_XOR */ + { 51297, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ + { 51316, 0x00008757 }, /* GL_YCBCR_MESA */ + { 51330, 0x00000000 }, /* GL_ZERO */ + { 51338, 0x00000D16 }, /* GL_ZOOM_X */ + { 51348, 0x00000D17 }, /* GL_ZOOM_Y */ +}; + +static const unsigned reduced_enums[1551] = +{ + 535, /* GL_FALSE */ + 827, /* GL_LINES */ + 831, /* GL_LINE_LOOP */ + 838, /* GL_LINE_STRIP */ + 2135, /* GL_TRIANGLES */ + 2140, /* GL_TRIANGLE_STRIP */ + 2138, /* GL_TRIANGLE_FAN */ + 1507, /* GL_QUADS */ + 1511, /* GL_QUAD_STRIP */ + 1378, /* GL_POLYGON */ + 828, /* GL_LINES_ADJACENCY */ + 839, /* GL_LINE_STRIP_ADJACENCY */ + 2136, /* GL_TRIANGLES_ADJACENCY */ + 2141, /* GL_TRIANGLE_STRIP_ADJACENCY */ + 1390, /* GL_POLYGON_STIPPLE_BIT */ + 1333, /* GL_PIXEL_MODE_BIT */ + 814, /* GL_LIGHTING_BIT */ + 568, /* GL_FOG_BIT */ + 8, /* GL_ACCUM */ + 850, /* GL_LOAD */ + 1596, /* GL_RETURN */ + 1200, /* GL_MULT */ + 24, /* GL_ADD */ + 1216, /* GL_NEVER */ + 804, /* GL_LESS */ + 525, /* GL_EQUAL */ + 803, /* GL_LEQUAL */ + 691, /* GL_GREATER */ + 1233, /* GL_NOTEQUAL */ + 690, /* GL_GEQUAL */ + 55, /* GL_ALWAYS */ + 1803, /* GL_SRC_COLOR */ + 1266, /* GL_ONE_MINUS_SRC_COLOR */ + 1801, /* GL_SRC_ALPHA */ + 1265, /* GL_ONE_MINUS_SRC_ALPHA */ + 504, /* GL_DST_ALPHA */ + 1263, /* GL_ONE_MINUS_DST_ALPHA */ + 505, /* GL_DST_COLOR */ + 1264, /* GL_ONE_MINUS_DST_COLOR */ + 1802, /* GL_SRC_ALPHA_SATURATE */ + 667, /* GL_FRONT_LEFT */ + 668, /* GL_FRONT_RIGHT */ + 77, /* GL_BACK_LEFT */ + 78, /* GL_BACK_RIGHT */ + 664, /* GL_FRONT */ + 76, /* GL_BACK */ + 802, /* GL_LEFT */ + 1685, /* GL_RIGHT */ + 665, /* GL_FRONT_AND_BACK */ + 71, /* GL_AUX0 */ + 72, /* GL_AUX1 */ + 73, /* GL_AUX2 */ + 74, /* GL_AUX3 */ + 790, /* GL_INVALID_ENUM */ + 795, /* GL_INVALID_VALUE */ + 794, /* GL_INVALID_OPERATION */ + 1808, /* GL_STACK_OVERFLOW */ + 1809, /* GL_STACK_UNDERFLOW */ + 1291, /* GL_OUT_OF_MEMORY */ + 791, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + 0, /* GL_2D */ + 2, /* GL_3D */ + 3, /* GL_3D_COLOR */ + 4, /* GL_3D_COLOR_TEXTURE */ + 6, /* GL_4D_COLOR_TEXTURE */ + 1311, /* GL_PASS_THROUGH_TOKEN */ + 1377, /* GL_POINT_TOKEN */ + 841, /* GL_LINE_TOKEN */ + 1391, /* GL_POLYGON_TOKEN */ + 87, /* GL_BITMAP_TOKEN */ + 503, /* GL_DRAW_PIXEL_TOKEN */ + 349, /* GL_COPY_PIXEL_TOKEN */ + 832, /* GL_LINE_RESET_TOKEN */ + 528, /* GL_EXP */ + 529, /* GL_EXP2 */ + 386, /* GL_CW */ + 154, /* GL_CCW */ + 184, /* GL_COEFF */ + 1288, /* GL_ORDER */ + 440, /* GL_DOMAIN */ + 359, /* GL_CURRENT_COLOR */ + 362, /* GL_CURRENT_INDEX */ + 368, /* GL_CURRENT_NORMAL */ + 382, /* GL_CURRENT_TEXTURE_COORDS */ + 374, /* GL_CURRENT_RASTER_COLOR */ + 376, /* GL_CURRENT_RASTER_INDEX */ + 380, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ + 377, /* GL_CURRENT_RASTER_POSITION */ + 378, /* GL_CURRENT_RASTER_POSITION_VALID */ + 375, /* GL_CURRENT_RASTER_DISTANCE */ + 1369, /* GL_POINT_SMOOTH */ + 1353, /* GL_POINT_SIZE */ + 1368, /* GL_POINT_SIZE_RANGE */ + 1359, /* GL_POINT_SIZE_GRANULARITY */ + 833, /* GL_LINE_SMOOTH */ + 842, /* GL_LINE_WIDTH */ + 844, /* GL_LINE_WIDTH_RANGE */ + 843, /* GL_LINE_WIDTH_GRANULARITY */ + 835, /* GL_LINE_STIPPLE */ + 836, /* GL_LINE_STIPPLE_PATTERN */ + 837, /* GL_LINE_STIPPLE_REPEAT */ + 849, /* GL_LIST_MODE */ + 1056, /* GL_MAX_LIST_NESTING */ + 846, /* GL_LIST_BASE */ + 848, /* GL_LIST_INDEX */ + 1380, /* GL_POLYGON_MODE */ + 1387, /* GL_POLYGON_SMOOTH */ + 1389, /* GL_POLYGON_STIPPLE */ + 514, /* GL_EDGE_FLAG */ + 352, /* GL_CULL_FACE */ + 353, /* GL_CULL_FACE_MODE */ + 666, /* GL_FRONT_FACE */ + 813, /* GL_LIGHTING */ + 818, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + 819, /* GL_LIGHT_MODEL_TWO_SIDE */ + 815, /* GL_LIGHT_MODEL_AMBIENT */ + 1750, /* GL_SHADE_MODEL */ + 232, /* GL_COLOR_MATERIAL_FACE */ + 233, /* GL_COLOR_MATERIAL_PARAMETER */ + 231, /* GL_COLOR_MATERIAL */ + 567, /* GL_FOG */ + 589, /* GL_FOG_INDEX */ + 585, /* GL_FOG_DENSITY */ + 593, /* GL_FOG_START */ + 587, /* GL_FOG_END */ + 590, /* GL_FOG_MODE */ + 569, /* GL_FOG_COLOR */ + 425, /* GL_DEPTH_RANGE */ + 434, /* GL_DEPTH_TEST */ + 437, /* GL_DEPTH_WRITEMASK */ + 410, /* GL_DEPTH_CLEAR_VALUE */ + 424, /* GL_DEPTH_FUNC */ + 12, /* GL_ACCUM_CLEAR_VALUE */ + 1853, /* GL_STENCIL_TEST */ + 1834, /* GL_STENCIL_CLEAR_VALUE */ + 1836, /* GL_STENCIL_FUNC */ + 1855, /* GL_STENCIL_VALUE_MASK */ + 1835, /* GL_STENCIL_FAIL */ + 1850, /* GL_STENCIL_PASS_DEPTH_FAIL */ + 1851, /* GL_STENCIL_PASS_DEPTH_PASS */ + 1852, /* GL_STENCIL_REF */ + 1856, /* GL_STENCIL_WRITEMASK */ + 1006, /* GL_MATRIX_MODE */ + 1222, /* GL_NORMALIZE */ + 2266, /* GL_VIEWPORT */ + 1195, /* GL_MODELVIEW_STACK_DEPTH */ + 1481, /* GL_PROJECTION_STACK_DEPTH */ + 2089, /* GL_TEXTURE_STACK_DEPTH */ + 1192, /* GL_MODELVIEW_MATRIX */ + 1479, /* GL_PROJECTION_MATRIX */ + 2069, /* GL_TEXTURE_MATRIX */ + 69, /* GL_ATTRIB_STACK_DEPTH */ + 166, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ + 51, /* GL_ALPHA_TEST */ + 52, /* GL_ALPHA_TEST_FUNC */ + 53, /* GL_ALPHA_TEST_REF */ + 439, /* GL_DITHER */ + 91, /* GL_BLEND_DST */ + 105, /* GL_BLEND_SRC */ + 88, /* GL_BLEND */ + 852, /* GL_LOGIC_OP_MODE */ + 739, /* GL_INDEX_LOGIC_OP */ + 230, /* GL_COLOR_LOGIC_OP */ + 75, /* GL_AUX_BUFFERS */ + 450, /* GL_DRAW_BUFFER */ + 1534, /* GL_READ_BUFFER */ + 1727, /* GL_SCISSOR_BOX */ + 1728, /* GL_SCISSOR_TEST */ + 738, /* GL_INDEX_CLEAR_VALUE */ + 743, /* GL_INDEX_WRITEMASK */ + 227, /* GL_COLOR_CLEAR_VALUE */ + 269, /* GL_COLOR_WRITEMASK */ + 740, /* GL_INDEX_MODE */ + 1674, /* GL_RGBA_MODE */ + 449, /* GL_DOUBLEBUFFER */ + 1857, /* GL_STEREO */ + 1588, /* GL_RENDER_MODE */ + 1312, /* GL_PERSPECTIVE_CORRECTION_HINT */ + 1370, /* GL_POINT_SMOOTH_HINT */ + 834, /* GL_LINE_SMOOTH_HINT */ + 1388, /* GL_POLYGON_SMOOTH_HINT */ + 588, /* GL_FOG_HINT */ + 2049, /* GL_TEXTURE_GEN_S */ + 2051, /* GL_TEXTURE_GEN_T */ + 2048, /* GL_TEXTURE_GEN_R */ + 2047, /* GL_TEXTURE_GEN_Q */ + 1325, /* GL_PIXEL_MAP_I_TO_I */ + 1331, /* GL_PIXEL_MAP_S_TO_S */ + 1327, /* GL_PIXEL_MAP_I_TO_R */ + 1323, /* GL_PIXEL_MAP_I_TO_G */ + 1321, /* GL_PIXEL_MAP_I_TO_B */ + 1319, /* GL_PIXEL_MAP_I_TO_A */ + 1329, /* GL_PIXEL_MAP_R_TO_R */ + 1317, /* GL_PIXEL_MAP_G_TO_G */ + 1315, /* GL_PIXEL_MAP_B_TO_B */ + 1313, /* GL_PIXEL_MAP_A_TO_A */ + 1326, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + 1332, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + 1328, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + 1324, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + 1322, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + 1320, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + 1330, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + 1318, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + 1316, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + 1314, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + 2152, /* GL_UNPACK_SWAP_BYTES */ + 2147, /* GL_UNPACK_LSB_FIRST */ + 2148, /* GL_UNPACK_ROW_LENGTH */ + 2151, /* GL_UNPACK_SKIP_ROWS */ + 2150, /* GL_UNPACK_SKIP_PIXELS */ + 2145, /* GL_UNPACK_ALIGNMENT */ + 1300, /* GL_PACK_SWAP_BYTES */ + 1295, /* GL_PACK_LSB_FIRST */ + 1296, /* GL_PACK_ROW_LENGTH */ + 1299, /* GL_PACK_SKIP_ROWS */ + 1298, /* GL_PACK_SKIP_PIXELS */ + 1292, /* GL_PACK_ALIGNMENT */ + 947, /* GL_MAP_COLOR */ + 952, /* GL_MAP_STENCIL */ + 742, /* GL_INDEX_SHIFT */ + 741, /* GL_INDEX_OFFSET */ + 1550, /* GL_RED_SCALE */ + 1546, /* GL_RED_BIAS */ + 2292, /* GL_ZOOM_X */ + 2293, /* GL_ZOOM_Y */ + 697, /* GL_GREEN_SCALE */ + 693, /* GL_GREEN_BIAS */ + 115, /* GL_BLUE_SCALE */ + 111, /* GL_BLUE_BIAS */ + 50, /* GL_ALPHA_SCALE */ + 47, /* GL_ALPHA_BIAS */ + 426, /* GL_DEPTH_SCALE */ + 402, /* GL_DEPTH_BIAS */ + 1038, /* GL_MAX_EVAL_ORDER */ + 1055, /* GL_MAX_LIGHTS */ + 1018, /* GL_MAX_CLIP_DISTANCES */ + 1110, /* GL_MAX_TEXTURE_SIZE */ + 1062, /* GL_MAX_PIXEL_MAP_TABLE */ + 1014, /* GL_MAX_ATTRIB_STACK_DEPTH */ + 1058, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + 1059, /* GL_MAX_NAME_STACK_DEPTH */ + 1090, /* GL_MAX_PROJECTION_STACK_DEPTH */ + 1111, /* GL_MAX_TEXTURE_STACK_DEPTH */ + 1137, /* GL_MAX_VIEWPORT_DIMS */ + 1015, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + 1867, /* GL_SUBPIXEL_BITS */ + 737, /* GL_INDEX_BITS */ + 1547, /* GL_RED_BITS */ + 694, /* GL_GREEN_BITS */ + 112, /* GL_BLUE_BITS */ + 48, /* GL_ALPHA_BITS */ + 403, /* GL_DEPTH_BITS */ + 1831, /* GL_STENCIL_BITS */ + 14, /* GL_ACCUM_RED_BITS */ + 13, /* GL_ACCUM_GREEN_BITS */ + 10, /* GL_ACCUM_BLUE_BITS */ + 9, /* GL_ACCUM_ALPHA_BITS */ + 1209, /* GL_NAME_STACK_DEPTH */ + 70, /* GL_AUTO_NORMAL */ + 893, /* GL_MAP1_COLOR_4 */ + 896, /* GL_MAP1_INDEX */ + 897, /* GL_MAP1_NORMAL */ + 898, /* GL_MAP1_TEXTURE_COORD_1 */ + 899, /* GL_MAP1_TEXTURE_COORD_2 */ + 900, /* GL_MAP1_TEXTURE_COORD_3 */ + 901, /* GL_MAP1_TEXTURE_COORD_4 */ + 902, /* GL_MAP1_VERTEX_3 */ + 903, /* GL_MAP1_VERTEX_4 */ + 920, /* GL_MAP2_COLOR_4 */ + 923, /* GL_MAP2_INDEX */ + 924, /* GL_MAP2_NORMAL */ + 925, /* GL_MAP2_TEXTURE_COORD_1 */ + 926, /* GL_MAP2_TEXTURE_COORD_2 */ + 927, /* GL_MAP2_TEXTURE_COORD_3 */ + 928, /* GL_MAP2_TEXTURE_COORD_4 */ + 929, /* GL_MAP2_VERTEX_3 */ + 930, /* GL_MAP2_VERTEX_4 */ + 894, /* GL_MAP1_GRID_DOMAIN */ + 895, /* GL_MAP1_GRID_SEGMENTS */ + 921, /* GL_MAP2_GRID_DOMAIN */ + 922, /* GL_MAP2_GRID_SEGMENTS */ + 1950, /* GL_TEXTURE_1D */ + 1953, /* GL_TEXTURE_2D */ + 538, /* GL_FEEDBACK_BUFFER_POINTER */ + 539, /* GL_FEEDBACK_BUFFER_SIZE */ + 540, /* GL_FEEDBACK_BUFFER_TYPE */ + 1737, /* GL_SELECTION_BUFFER_POINTER */ + 1738, /* GL_SELECTION_BUFFER_SIZE */ + 2095, /* GL_TEXTURE_WIDTH */ + 2055, /* GL_TEXTURE_HEIGHT */ + 1999, /* GL_TEXTURE_COMPONENTS */ + 1980, /* GL_TEXTURE_BORDER_COLOR */ + 1979, /* GL_TEXTURE_BORDER */ + 441, /* GL_DONT_CARE */ + 536, /* GL_FASTEST */ + 1217, /* GL_NICEST */ + 56, /* GL_AMBIENT */ + 438, /* GL_DIFFUSE */ + 1790, /* GL_SPECULAR */ + 1392, /* GL_POSITION */ + 1793, /* GL_SPOT_DIRECTION */ + 1794, /* GL_SPOT_EXPONENT */ + 1792, /* GL_SPOT_CUTOFF */ + 317, /* GL_CONSTANT_ATTENUATION */ + 822, /* GL_LINEAR_ATTENUATION */ + 1506, /* GL_QUADRATIC_ATTENUATION */ + 284, /* GL_COMPILE */ + 285, /* GL_COMPILE_AND_EXECUTE */ + 149, /* GL_BYTE */ + 2154, /* GL_UNSIGNED_BYTE */ + 1755, /* GL_SHORT */ + 2193, /* GL_UNSIGNED_SHORT */ + 745, /* GL_INT */ + 2157, /* GL_UNSIGNED_INT */ + 548, /* GL_FLOAT */ + 1, /* GL_2_BYTES */ + 5, /* GL_3_BYTES */ + 7, /* GL_4_BYTES */ + 448, /* GL_DOUBLE */ + 698, /* GL_HALF_FLOAT */ + 544, /* GL_FIXED */ + 162, /* GL_CLEAR */ + 58, /* GL_AND */ + 60, /* GL_AND_REVERSE */ + 347, /* GL_COPY */ + 59, /* GL_AND_INVERTED */ + 1220, /* GL_NOOP */ + 2288, /* GL_XOR */ + 1287, /* GL_OR */ + 1221, /* GL_NOR */ + 526, /* GL_EQUIV */ + 798, /* GL_INVERT */ + 1290, /* GL_OR_REVERSE */ + 348, /* GL_COPY_INVERTED */ + 1289, /* GL_OR_INVERTED */ + 1210, /* GL_NAND */ + 1744, /* GL_SET */ + 523, /* GL_EMISSION */ + 1754, /* GL_SHININESS */ + 57, /* GL_AMBIENT_AND_DIFFUSE */ + 229, /* GL_COLOR_INDEXES */ + 1159, /* GL_MODELVIEW */ + 1478, /* GL_PROJECTION */ + 1885, /* GL_TEXTURE */ + 185, /* GL_COLOR */ + 395, /* GL_DEPTH */ + 1816, /* GL_STENCIL */ + 228, /* GL_COLOR_INDEX */ + 1837, /* GL_STENCIL_INDEX */ + 411, /* GL_DEPTH_COMPONENT */ + 1543, /* GL_RED */ + 692, /* GL_GREEN */ + 110, /* GL_BLUE */ + 32, /* GL_ALPHA */ + 1599, /* GL_RGB */ + 1639, /* GL_RGBA */ + 856, /* GL_LUMINANCE */ + 883, /* GL_LUMINANCE_ALPHA */ + 86, /* GL_BITMAP */ + 1342, /* GL_POINT */ + 820, /* GL_LINE */ + 541, /* GL_FILL */ + 1557, /* GL_RENDER */ + 537, /* GL_FEEDBACK */ + 1736, /* GL_SELECT */ + 547, /* GL_FLAT */ + 1765, /* GL_SMOOTH */ + 799, /* GL_KEEP */ + 1590, /* GL_REPLACE */ + 727, /* GL_INCR */ + 391, /* GL_DECR */ + 2210, /* GL_VENDOR */ + 1587, /* GL_RENDERER */ + 2211, /* GL_VERSION */ + 530, /* GL_EXTENSIONS */ + 1686, /* GL_S */ + 1876, /* GL_T */ + 1526, /* GL_R */ + 1505, /* GL_Q */ + 1196, /* GL_MODULATE */ + 390, /* GL_DECAL */ + 2042, /* GL_TEXTURE_ENV_MODE */ + 2041, /* GL_TEXTURE_ENV_COLOR */ + 2040, /* GL_TEXTURE_ENV */ + 531, /* GL_EYE_LINEAR */ + 1248, /* GL_OBJECT_LINEAR */ + 1791, /* GL_SPHERE_MAP */ + 2045, /* GL_TEXTURE_GEN_MODE */ + 1250, /* GL_OBJECT_PLANE */ + 532, /* GL_EYE_PLANE */ + 1211, /* GL_NEAREST */ + 821, /* GL_LINEAR */ + 1215, /* GL_NEAREST_MIPMAP_NEAREST */ + 826, /* GL_LINEAR_MIPMAP_NEAREST */ + 1214, /* GL_NEAREST_MIPMAP_LINEAR */ + 825, /* GL_LINEAR_MIPMAP_LINEAR */ + 2068, /* GL_TEXTURE_MAG_FILTER */ + 2077, /* GL_TEXTURE_MIN_FILTER */ + 2098, /* GL_TEXTURE_WRAP_S */ + 2099, /* GL_TEXTURE_WRAP_T */ + 155, /* GL_CLAMP */ + 1589, /* GL_REPEAT */ + 1386, /* GL_POLYGON_OFFSET_UNITS */ + 1385, /* GL_POLYGON_OFFSET_POINT */ + 1384, /* GL_POLYGON_OFFSET_LINE */ + 1529, /* GL_R3_G3_B2 */ + 2207, /* GL_V2F */ + 2208, /* GL_V3F */ + 152, /* GL_C4UB_V2F */ + 153, /* GL_C4UB_V3F */ + 150, /* GL_C3F_V3F */ + 1208, /* GL_N3F_V3F */ + 151, /* GL_C4F_N3F_V3F */ + 1881, /* GL_T2F_V3F */ + 1883, /* GL_T4F_V4F */ + 1879, /* GL_T2F_C4UB_V3F */ + 1877, /* GL_T2F_C3F_V3F */ + 1880, /* GL_T2F_N3F_V3F */ + 1878, /* GL_T2F_C4F_N3F_V3F */ + 1882, /* GL_T4F_C4F_N3F_V4F */ + 169, /* GL_CLIP_DISTANCE0 */ + 170, /* GL_CLIP_DISTANCE1 */ + 171, /* GL_CLIP_DISTANCE2 */ + 172, /* GL_CLIP_DISTANCE3 */ + 173, /* GL_CLIP_DISTANCE4 */ + 174, /* GL_CLIP_DISTANCE5 */ + 175, /* GL_CLIP_DISTANCE6 */ + 176, /* GL_CLIP_DISTANCE7 */ + 805, /* GL_LIGHT0 */ + 806, /* GL_LIGHT1 */ + 807, /* GL_LIGHT2 */ + 808, /* GL_LIGHT3 */ + 809, /* GL_LIGHT4 */ + 810, /* GL_LIGHT5 */ + 811, /* GL_LIGHT6 */ + 812, /* GL_LIGHT7 */ + 702, /* GL_HINT_BIT */ + 319, /* GL_CONSTANT_COLOR */ + 1261, /* GL_ONE_MINUS_CONSTANT_COLOR */ + 314, /* GL_CONSTANT_ALPHA */ + 1259, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + 89, /* GL_BLEND_COLOR */ + 669, /* GL_FUNC_ADD */ + 1140, /* GL_MIN */ + 1009, /* GL_MAX */ + 96, /* GL_BLEND_EQUATION */ + 675, /* GL_FUNC_SUBTRACT */ + 672, /* GL_FUNC_REVERSE_SUBTRACT */ + 327, /* GL_CONVOLUTION_1D */ + 328, /* GL_CONVOLUTION_2D */ + 1739, /* GL_SEPARABLE_2D */ + 331, /* GL_CONVOLUTION_BORDER_MODE */ + 335, /* GL_CONVOLUTION_FILTER_SCALE */ + 333, /* GL_CONVOLUTION_FILTER_BIAS */ + 1544, /* GL_REDUCE */ + 337, /* GL_CONVOLUTION_FORMAT */ + 341, /* GL_CONVOLUTION_WIDTH */ + 339, /* GL_CONVOLUTION_HEIGHT */ + 1028, /* GL_MAX_CONVOLUTION_WIDTH */ + 1026, /* GL_MAX_CONVOLUTION_HEIGHT */ + 1425, /* GL_POST_CONVOLUTION_RED_SCALE */ + 1421, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + 1416, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + 1412, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + 1423, /* GL_POST_CONVOLUTION_RED_BIAS */ + 1419, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + 1414, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + 1410, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + 703, /* GL_HISTOGRAM */ + 1485, /* GL_PROXY_HISTOGRAM */ + 719, /* GL_HISTOGRAM_WIDTH */ + 709, /* GL_HISTOGRAM_FORMAT */ + 715, /* GL_HISTOGRAM_RED_SIZE */ + 711, /* GL_HISTOGRAM_GREEN_SIZE */ + 706, /* GL_HISTOGRAM_BLUE_SIZE */ + 704, /* GL_HISTOGRAM_ALPHA_SIZE */ + 713, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + 717, /* GL_HISTOGRAM_SINK */ + 1141, /* GL_MINMAX */ + 1143, /* GL_MINMAX_FORMAT */ + 1145, /* GL_MINMAX_SINK */ + 1884, /* GL_TABLE_TOO_LARGE_EXT */ + 2156, /* GL_UNSIGNED_BYTE_3_3_2 */ + 2196, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + 2199, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + 2168, /* GL_UNSIGNED_INT_8_8_8_8 */ + 2159, /* GL_UNSIGNED_INT_10_10_10_2 */ + 1383, /* GL_POLYGON_OFFSET_FILL */ + 1382, /* GL_POLYGON_OFFSET_FACTOR */ + 1381, /* GL_POLYGON_OFFSET_BIAS */ + 1593, /* GL_RESCALE_NORMAL */ + 41, /* GL_ALPHA4 */ + 43, /* GL_ALPHA8 */ + 33, /* GL_ALPHA12 */ + 35, /* GL_ALPHA16 */ + 871, /* GL_LUMINANCE4 */ + 877, /* GL_LUMINANCE8 */ + 857, /* GL_LUMINANCE12 */ + 863, /* GL_LUMINANCE16 */ + 872, /* GL_LUMINANCE4_ALPHA4 */ + 875, /* GL_LUMINANCE6_ALPHA2 */ + 880, /* GL_LUMINANCE8_ALPHA8 */ + 860, /* GL_LUMINANCE12_ALPHA4 */ + 858, /* GL_LUMINANCE12_ALPHA12 */ + 866, /* GL_LUMINANCE16_ALPHA16 */ + 746, /* GL_INTENSITY */ + 755, /* GL_INTENSITY4 */ + 757, /* GL_INTENSITY8 */ + 747, /* GL_INTENSITY12 */ + 749, /* GL_INTENSITY16 */ + 1614, /* GL_RGB2_EXT */ + 1620, /* GL_RGB4 */ + 1623, /* GL_RGB5 */ + 1630, /* GL_RGB8 */ + 1600, /* GL_RGB10 */ + 1604, /* GL_RGB12 */ + 1606, /* GL_RGB16 */ + 1650, /* GL_RGBA2 */ + 1657, /* GL_RGBA4 */ + 1626, /* GL_RGB5_A1 */ + 1662, /* GL_RGBA8 */ + 1601, /* GL_RGB10_A2 */ + 1640, /* GL_RGBA12 */ + 1642, /* GL_RGBA16 */ + 2085, /* GL_TEXTURE_RED_SIZE */ + 2053, /* GL_TEXTURE_GREEN_SIZE */ + 1977, /* GL_TEXTURE_BLUE_SIZE */ + 1958, /* GL_TEXTURE_ALPHA_SIZE */ + 2066, /* GL_TEXTURE_LUMINANCE_SIZE */ + 2057, /* GL_TEXTURE_INTENSITY_SIZE */ + 1591, /* GL_REPLACE_EXT */ + 1489, /* GL_PROXY_TEXTURE_1D */ + 1493, /* GL_PROXY_TEXTURE_2D */ + 2093, /* GL_TEXTURE_TOO_LARGE_EXT */ + 2079, /* GL_TEXTURE_PRIORITY */ + 2087, /* GL_TEXTURE_RESIDENT */ + 1961, /* GL_TEXTURE_BINDING_1D */ + 1964, /* GL_TEXTURE_BINDING_2D */ + 1967, /* GL_TEXTURE_BINDING_3D */ + 1297, /* GL_PACK_SKIP_IMAGES */ + 1293, /* GL_PACK_IMAGE_HEIGHT */ + 2149, /* GL_UNPACK_SKIP_IMAGES */ + 2146, /* GL_UNPACK_IMAGE_HEIGHT */ + 1956, /* GL_TEXTURE_3D */ + 1497, /* GL_PROXY_TEXTURE_3D */ + 2037, /* GL_TEXTURE_DEPTH */ + 2096, /* GL_TEXTURE_WRAP_R */ + 1010, /* GL_MAX_3D_TEXTURE_SIZE */ + 2212, /* GL_VERTEX_ARRAY */ + 1223, /* GL_NORMAL_ARRAY */ + 186, /* GL_COLOR_ARRAY */ + 731, /* GL_INDEX_ARRAY */ + 2007, /* GL_TEXTURE_COORD_ARRAY */ + 515, /* GL_EDGE_FLAG_ARRAY */ + 2218, /* GL_VERTEX_ARRAY_SIZE */ + 2220, /* GL_VERTEX_ARRAY_TYPE */ + 2219, /* GL_VERTEX_ARRAY_STRIDE */ + 1228, /* GL_NORMAL_ARRAY_TYPE */ + 1227, /* GL_NORMAL_ARRAY_STRIDE */ + 190, /* GL_COLOR_ARRAY_SIZE */ + 192, /* GL_COLOR_ARRAY_TYPE */ + 191, /* GL_COLOR_ARRAY_STRIDE */ + 736, /* GL_INDEX_ARRAY_TYPE */ + 735, /* GL_INDEX_ARRAY_STRIDE */ + 2011, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + 2013, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + 2012, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + 519, /* GL_EDGE_FLAG_ARRAY_STRIDE */ + 2217, /* GL_VERTEX_ARRAY_POINTER */ + 1226, /* GL_NORMAL_ARRAY_POINTER */ + 189, /* GL_COLOR_ARRAY_POINTER */ + 734, /* GL_INDEX_ARRAY_POINTER */ + 2010, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + 518, /* GL_EDGE_FLAG_ARRAY_POINTER */ + 1201, /* GL_MULTISAMPLE */ + 1713, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + 1715, /* GL_SAMPLE_ALPHA_TO_ONE */ + 1720, /* GL_SAMPLE_COVERAGE */ + 1717, /* GL_SAMPLE_BUFFERS */ + 1708, /* GL_SAMPLES */ + 1724, /* GL_SAMPLE_COVERAGE_VALUE */ + 1722, /* GL_SAMPLE_COVERAGE_INVERT */ + 234, /* GL_COLOR_MATRIX */ + 236, /* GL_COLOR_MATRIX_STACK_DEPTH */ + 1022, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + 1408, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + 1404, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + 1399, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + 1395, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + 1406, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + 1402, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + 1397, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + 1393, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + 1990, /* GL_TEXTURE_COLOR_TABLE_SGI */ + 1498, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + 1992, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + 94, /* GL_BLEND_DST_RGB */ + 108, /* GL_BLEND_SRC_RGB */ + 92, /* GL_BLEND_DST_ALPHA */ + 106, /* GL_BLEND_SRC_ALPHA */ + 240, /* GL_COLOR_TABLE */ + 1418, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + 1401, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + 1484, /* GL_PROXY_COLOR_TABLE */ + 1488, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + 1487, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + 264, /* GL_COLOR_TABLE_SCALE */ + 244, /* GL_COLOR_TABLE_BIAS */ + 249, /* GL_COLOR_TABLE_FORMAT */ + 266, /* GL_COLOR_TABLE_WIDTH */ + 261, /* GL_COLOR_TABLE_RED_SIZE */ + 252, /* GL_COLOR_TABLE_GREEN_SIZE */ + 246, /* GL_COLOR_TABLE_BLUE_SIZE */ + 241, /* GL_COLOR_TABLE_ALPHA_SIZE */ + 258, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ + 255, /* GL_COLOR_TABLE_INTENSITY_SIZE */ + 79, /* GL_BGR */ + 80, /* GL_BGRA */ + 1037, /* GL_MAX_ELEMENTS_VERTICES */ + 1036, /* GL_MAX_ELEMENTS_INDICES */ + 2056, /* GL_TEXTURE_INDEX_SIZE_EXT */ + 183, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ + 1364, /* GL_POINT_SIZE_MIN */ + 1360, /* GL_POINT_SIZE_MAX */ + 1349, /* GL_POINT_FADE_THRESHOLD_SIZE */ + 1345, /* GL_POINT_DISTANCE_ATTENUATION */ + 157, /* GL_CLAMP_TO_BORDER */ + 160, /* GL_CLAMP_TO_EDGE */ + 2078, /* GL_TEXTURE_MIN_LOD */ + 2076, /* GL_TEXTURE_MAX_LOD */ + 1960, /* GL_TEXTURE_BASE_LEVEL */ + 2075, /* GL_TEXTURE_MAX_LEVEL */ + 722, /* GL_IGNORE_BORDER_HP */ + 318, /* GL_CONSTANT_BORDER_HP */ + 1592, /* GL_REPLICATE_BORDER_HP */ + 329, /* GL_CONVOLUTION_BORDER_COLOR */ + 1256, /* GL_OCCLUSION_TEST_HP */ + 1257, /* GL_OCCLUSION_TEST_RESULT_HP */ + 823, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + 1984, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + 1986, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + 1988, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + 1989, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 1987, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + 1985, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + 1016, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + 1017, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 1428, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + 1430, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + 1427, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + 1429, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + 2064, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + 2065, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + 2063, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + 678, /* GL_GENERATE_MIPMAP */ + 679, /* GL_GENERATE_MIPMAP_HINT */ + 591, /* GL_FOG_OFFSET_SGIX */ + 592, /* GL_FOG_OFFSET_VALUE_SGIX */ + 1998, /* GL_TEXTURE_COMPARE_SGIX */ + 1997, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + 2060, /* GL_TEXTURE_LEQUAL_R_SGIX */ + 2052, /* GL_TEXTURE_GEQUAL_R_SGIX */ + 412, /* GL_DEPTH_COMPONENT16 */ + 416, /* GL_DEPTH_COMPONENT24 */ + 420, /* GL_DEPTH_COMPONENT32 */ + 354, /* GL_CULL_VERTEX_EXT */ + 356, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ + 355, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ + 2284, /* GL_WRAP_BORDER_SUN */ + 1991, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + 816, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + 1758, /* GL_SINGLE_COLOR */ + 1742, /* GL_SEPARATE_SPECULAR_COLOR */ + 1753, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + 603, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ + 604, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ + 615, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ + 606, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ + 602, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ + 601, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ + 605, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ + 616, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ + 633, /* GL_FRAMEBUFFER_DEFAULT */ + 660, /* GL_FRAMEBUFFER_UNDEFINED */ + 428, /* GL_DEPTH_STENCIL_ATTACHMENT */ + 892, /* GL_MAJOR_VERSION */ + 1147, /* GL_MINOR_VERSION */ + 1237, /* GL_NUM_EXTENSIONS */ + 324, /* GL_CONTEXT_FLAGS */ + 730, /* GL_INDEX */ + 406, /* GL_DEPTH_BUFFER */ + 1832, /* GL_STENCIL_BUFFER */ + 295, /* GL_COMPRESSED_RED */ + 296, /* GL_COMPRESSED_RG */ + 2155, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + 2200, /* GL_UNSIGNED_SHORT_5_6_5 */ + 2201, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + 2197, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + 2194, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + 2169, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + 2165, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + 2073, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + 2074, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + 2072, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + 1151, /* GL_MIRRORED_REPEAT */ + 1679, /* GL_RGB_S3TC */ + 1622, /* GL_RGB4_S3TC */ + 1675, /* GL_RGBA_S3TC */ + 1661, /* GL_RGBA4_S3TC */ + 1670, /* GL_RGBA_DXT5_S3TC */ + 1658, /* GL_RGBA4_DXT5_S3TC */ + 306, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ + 301, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ + 302, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ + 303, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ + 1213, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + 1212, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + 824, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + 578, /* GL_FOG_COORDINATE_SOURCE */ + 570, /* GL_FOG_COORD */ + 594, /* GL_FRAGMENT_DEPTH */ + 360, /* GL_CURRENT_FOG_COORD */ + 577, /* GL_FOG_COORDINATE_ARRAY_TYPE */ + 576, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ + 575, /* GL_FOG_COORDINATE_ARRAY_POINTER */ + 572, /* GL_FOG_COORDINATE_ARRAY */ + 238, /* GL_COLOR_SUM */ + 381, /* GL_CURRENT_SECONDARY_COLOR */ + 1733, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + 1735, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + 1734, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + 1732, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + 1729, /* GL_SECONDARY_COLOR_ARRAY */ + 379, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ + 29, /* GL_ALIASED_POINT_SIZE_RANGE */ + 28, /* GL_ALIASED_LINE_WIDTH_RANGE */ + 1886, /* GL_TEXTURE0 */ + 1888, /* GL_TEXTURE1 */ + 1910, /* GL_TEXTURE2 */ + 1932, /* GL_TEXTURE3 */ + 1938, /* GL_TEXTURE4 */ + 1940, /* GL_TEXTURE5 */ + 1942, /* GL_TEXTURE6 */ + 1944, /* GL_TEXTURE7 */ + 1946, /* GL_TEXTURE8 */ + 1948, /* GL_TEXTURE9 */ + 1889, /* GL_TEXTURE10 */ + 1891, /* GL_TEXTURE11 */ + 1893, /* GL_TEXTURE12 */ + 1895, /* GL_TEXTURE13 */ + 1897, /* GL_TEXTURE14 */ + 1899, /* GL_TEXTURE15 */ + 1901, /* GL_TEXTURE16 */ + 1903, /* GL_TEXTURE17 */ + 1905, /* GL_TEXTURE18 */ + 1907, /* GL_TEXTURE19 */ + 1911, /* GL_TEXTURE20 */ + 1913, /* GL_TEXTURE21 */ + 1915, /* GL_TEXTURE22 */ + 1917, /* GL_TEXTURE23 */ + 1919, /* GL_TEXTURE24 */ + 1921, /* GL_TEXTURE25 */ + 1923, /* GL_TEXTURE26 */ + 1925, /* GL_TEXTURE27 */ + 1927, /* GL_TEXTURE28 */ + 1929, /* GL_TEXTURE29 */ + 1933, /* GL_TEXTURE30 */ + 1935, /* GL_TEXTURE31 */ + 19, /* GL_ACTIVE_TEXTURE */ + 163, /* GL_CLIENT_ACTIVE_TEXTURE */ + 1112, /* GL_MAX_TEXTURE_UNITS */ + 2128, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + 2131, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + 2133, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + 2125, /* GL_TRANSPOSE_COLOR_MATRIX */ + 1868, /* GL_SUBTRACT */ + 1094, /* GL_MAX_RENDERBUFFER_SIZE */ + 287, /* GL_COMPRESSED_ALPHA */ + 291, /* GL_COMPRESSED_LUMINANCE */ + 292, /* GL_COMPRESSED_LUMINANCE_ALPHA */ + 289, /* GL_COMPRESSED_INTENSITY */ + 297, /* GL_COMPRESSED_RGB */ + 298, /* GL_COMPRESSED_RGBA */ + 2005, /* GL_TEXTURE_COMPRESSION_HINT */ + 2082, /* GL_TEXTURE_RECTANGLE */ + 1973, /* GL_TEXTURE_BINDING_RECTANGLE */ + 1501, /* GL_PROXY_TEXTURE_RECTANGLE */ + 1091, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ + 427, /* GL_DEPTH_STENCIL */ + 2161, /* GL_UNSIGNED_INT_24_8 */ + 1107, /* GL_MAX_TEXTURE_LOD_BIAS */ + 2071, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + 1109, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + 2043, /* GL_TEXTURE_FILTER_CONTROL */ + 2061, /* GL_TEXTURE_LOD_BIAS */ + 271, /* GL_COMBINE4 */ + 1100, /* GL_MAX_SHININESS_NV */ + 1101, /* GL_MAX_SPOT_EXPONENT_NV */ + 728, /* GL_INCR_WRAP */ + 392, /* GL_DECR_WRAP */ + 1171, /* GL_MODELVIEW1_ARB */ + 1229, /* GL_NORMAL_MAP */ + 1552, /* GL_REFLECTION_MAP */ + 2015, /* GL_TEXTURE_CUBE_MAP */ + 1970, /* GL_TEXTURE_BINDING_CUBE_MAP */ + 2027, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + 2017, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + 2030, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + 2020, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + 2033, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + 2023, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + 1499, /* GL_PROXY_TEXTURE_CUBE_MAP */ + 1030, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + 1207, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + 1442, /* GL_PRIMITIVE_RESTART_NV */ + 1441, /* GL_PRIMITIVE_RESTART_INDEX_NV */ + 586, /* GL_FOG_DISTANCE_MODE_NV */ + 534, /* GL_EYE_RADIAL_NV */ + 533, /* GL_EYE_PLANE_ABSOLUTE_NV */ + 270, /* GL_COMBINE */ + 277, /* GL_COMBINE_RGB */ + 272, /* GL_COMBINE_ALPHA */ + 1680, /* GL_RGB_SCALE */ + 25, /* GL_ADD_SIGNED */ + 764, /* GL_INTERPOLATE */ + 313, /* GL_CONSTANT */ + 1434, /* GL_PRIMARY_COLOR */ + 1431, /* GL_PREVIOUS */ + 1773, /* GL_SOURCE0_RGB */ + 1779, /* GL_SOURCE1_RGB */ + 1785, /* GL_SOURCE2_RGB */ + 1789, /* GL_SOURCE3_RGB_NV */ + 1770, /* GL_SOURCE0_ALPHA */ + 1776, /* GL_SOURCE1_ALPHA */ + 1782, /* GL_SOURCE2_ALPHA */ + 1788, /* GL_SOURCE3_ALPHA_NV */ + 1270, /* GL_OPERAND0_RGB */ + 1276, /* GL_OPERAND1_RGB */ + 1282, /* GL_OPERAND2_RGB */ + 1286, /* GL_OPERAND3_RGB_NV */ + 1267, /* GL_OPERAND0_ALPHA */ + 1273, /* GL_OPERAND1_ALPHA */ + 1279, /* GL_OPERAND2_ALPHA */ + 1285, /* GL_OPERAND3_ALPHA_NV */ + 137, /* GL_BUFFER_OBJECT_APPLE */ + 2213, /* GL_VERTEX_ARRAY_BINDING */ + 2080, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + 2081, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + 2289, /* GL_YCBCR_422_APPLE */ + 2202, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + 2204, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + 2092, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + 1859, /* GL_STORAGE_PRIVATE_APPLE */ + 1858, /* GL_STORAGE_CACHED_APPLE */ + 1860, /* GL_STORAGE_SHARED_APPLE */ + 1760, /* GL_SLICE_ACCUM_SUN */ + 1510, /* GL_QUAD_MESH_SUN */ + 2139, /* GL_TRIANGLE_MESH_SUN */ + 2254, /* GL_VERTEX_PROGRAM_ARB */ + 2265, /* GL_VERTEX_STATE_PROGRAM_NV */ + 2239, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + 2247, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + 2249, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + 2251, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + 383, /* GL_CURRENT_VERTEX_ATTRIB */ + 1455, /* GL_PROGRAM_LENGTH_ARB */ + 1471, /* GL_PROGRAM_STRING_ARB */ + 1194, /* GL_MODELVIEW_PROJECTION_NV */ + 721, /* GL_IDENTITY_NV */ + 796, /* GL_INVERSE_NV */ + 2130, /* GL_TRANSPOSE_NV */ + 797, /* GL_INVERSE_TRANSPOSE_NV */ + 1075, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + 1074, /* GL_MAX_PROGRAM_MATRICES_ARB */ + 956, /* GL_MATRIX0_NV */ + 968, /* GL_MATRIX1_NV */ + 980, /* GL_MATRIX2_NV */ + 984, /* GL_MATRIX3_NV */ + 986, /* GL_MATRIX4_NV */ + 988, /* GL_MATRIX5_NV */ + 990, /* GL_MATRIX6_NV */ + 992, /* GL_MATRIX7_NV */ + 366, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ + 363, /* GL_CURRENT_MATRIX_ARB */ + 1468, /* GL_PROGRAM_POINT_SIZE */ + 2260, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + 1467, /* GL_PROGRAM_PARAMETER_NV */ + 2245, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + 1473, /* GL_PROGRAM_TARGET_NV */ + 1470, /* GL_PROGRAM_RESIDENT_NV */ + 2102, /* GL_TRACK_MATRIX_NV */ + 2103, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + 2255, /* GL_VERTEX_PROGRAM_BINDING_NV */ + 1449, /* GL_PROGRAM_ERROR_POSITION_ARB */ + 408, /* GL_DEPTH_CLAMP */ + 2221, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + 2228, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + 2229, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + 2230, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + 2231, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + 2232, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + 2233, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + 2234, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + 2235, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + 2236, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + 2222, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + 2223, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + 2224, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + 2225, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + 2226, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + 2227, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + 904, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + 911, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + 912, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + 913, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + 914, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + 915, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + 916, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + 917, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + 918, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + 919, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + 905, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + 906, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + 907, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + 908, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + 909, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + 910, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + 931, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + 938, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + 939, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + 940, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + 941, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + 942, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + 943, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + 1448, /* GL_PROGRAM_BINDING_ARB */ + 945, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + 946, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + 932, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + 933, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + 934, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + 935, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + 936, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + 937, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + 2003, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + 2000, /* GL_TEXTURE_COMPRESSED */ + 1235, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + 311, /* GL_COMPRESSED_TEXTURE_FORMATS */ + 1134, /* GL_MAX_VERTEX_UNITS_ARB */ + 23, /* GL_ACTIVE_VERTEX_UNITS_ARB */ + 2283, /* GL_WEIGHT_SUM_UNITY_ARB */ + 2253, /* GL_VERTEX_BLEND_ARB */ + 385, /* GL_CURRENT_WEIGHT_ARB */ + 2281, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + 2279, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + 2277, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + 2275, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + 2270, /* GL_WEIGHT_ARRAY_ARB */ + 442, /* GL_DOT3_RGB */ + 443, /* GL_DOT3_RGBA */ + 305, /* GL_COMPRESSED_RGB_FXT1_3DFX */ + 300, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ + 1202, /* GL_MULTISAMPLE_3DFX */ + 1718, /* GL_SAMPLE_BUFFERS_3DFX */ + 1709, /* GL_SAMPLES_3DFX */ + 1182, /* GL_MODELVIEW2_ARB */ + 1185, /* GL_MODELVIEW3_ARB */ + 1186, /* GL_MODELVIEW4_ARB */ + 1187, /* GL_MODELVIEW5_ARB */ + 1188, /* GL_MODELVIEW6_ARB */ + 1189, /* GL_MODELVIEW7_ARB */ + 1190, /* GL_MODELVIEW8_ARB */ + 1191, /* GL_MODELVIEW9_ARB */ + 1161, /* GL_MODELVIEW10_ARB */ + 1162, /* GL_MODELVIEW11_ARB */ + 1163, /* GL_MODELVIEW12_ARB */ + 1164, /* GL_MODELVIEW13_ARB */ + 1165, /* GL_MODELVIEW14_ARB */ + 1166, /* GL_MODELVIEW15_ARB */ + 1167, /* GL_MODELVIEW16_ARB */ + 1168, /* GL_MODELVIEW17_ARB */ + 1169, /* GL_MODELVIEW18_ARB */ + 1170, /* GL_MODELVIEW19_ARB */ + 1172, /* GL_MODELVIEW20_ARB */ + 1173, /* GL_MODELVIEW21_ARB */ + 1174, /* GL_MODELVIEW22_ARB */ + 1175, /* GL_MODELVIEW23_ARB */ + 1176, /* GL_MODELVIEW24_ARB */ + 1177, /* GL_MODELVIEW25_ARB */ + 1178, /* GL_MODELVIEW26_ARB */ + 1179, /* GL_MODELVIEW27_ARB */ + 1180, /* GL_MODELVIEW28_ARB */ + 1181, /* GL_MODELVIEW29_ARB */ + 1183, /* GL_MODELVIEW30_ARB */ + 1184, /* GL_MODELVIEW31_ARB */ + 447, /* GL_DOT3_RGB_EXT */ + 445, /* GL_DOT3_RGBA_EXT */ + 1155, /* GL_MIRROR_CLAMP_EXT */ + 1158, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + 1197, /* GL_MODULATE_ADD_ATI */ + 1198, /* GL_MODULATE_SIGNED_ADD_ATI */ + 1199, /* GL_MODULATE_SUBTRACT_ATI */ + 2290, /* GL_YCBCR_MESA */ + 1294, /* GL_PACK_INVERT_MESA */ + 388, /* GL_DEBUG_OBJECT_MESA */ + 389, /* GL_DEBUG_PRINT_MESA */ + 387, /* GL_DEBUG_ASSERT_MESA */ + 139, /* GL_BUFFER_SIZE */ + 141, /* GL_BUFFER_USAGE */ + 145, /* GL_BUMP_ROT_MATRIX_ATI */ + 146, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ + 144, /* GL_BUMP_NUM_TEX_UNITS_ATI */ + 148, /* GL_BUMP_TEX_UNITS_ATI */ + 507, /* GL_DUDV_ATI */ + 506, /* GL_DU8DV8_ATI */ + 143, /* GL_BUMP_ENVMAP_ATI */ + 147, /* GL_BUMP_TARGET_ATI */ + 1238, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ + 1446, /* GL_PROGRAM_BINARY_FORMATS_OES */ + 1822, /* GL_STENCIL_BACK_FUNC */ + 1820, /* GL_STENCIL_BACK_FAIL */ + 1824, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + 1826, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + 595, /* GL_FRAGMENT_PROGRAM_ARB */ + 1444, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 1476, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 1475, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + 1458, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 1464, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 1463, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 1064, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 1089, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 1088, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + 1077, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 1083, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 1082, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 1652, /* GL_RGBA32F */ + 1615, /* GL_RGB32F */ + 1643, /* GL_RGBA16F */ + 1607, /* GL_RGB16F */ + 1033, /* GL_MAX_DRAW_BUFFERS */ + 451, /* GL_DRAW_BUFFER0 */ + 454, /* GL_DRAW_BUFFER1 */ + 475, /* GL_DRAW_BUFFER2 */ + 478, /* GL_DRAW_BUFFER3 */ + 481, /* GL_DRAW_BUFFER4 */ + 484, /* GL_DRAW_BUFFER5 */ + 487, /* GL_DRAW_BUFFER6 */ + 490, /* GL_DRAW_BUFFER7 */ + 493, /* GL_DRAW_BUFFER8 */ + 496, /* GL_DRAW_BUFFER9 */ + 455, /* GL_DRAW_BUFFER10 */ + 458, /* GL_DRAW_BUFFER11 */ + 461, /* GL_DRAW_BUFFER12 */ + 464, /* GL_DRAW_BUFFER13 */ + 467, /* GL_DRAW_BUFFER14 */ + 470, /* GL_DRAW_BUFFER15 */ + 97, /* GL_BLEND_EQUATION_ALPHA */ + 1007, /* GL_MATRIX_PALETTE_ARB */ + 1057, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + 1060, /* GL_MAX_PALETTE_MATRICES_ARB */ + 369, /* GL_CURRENT_PALETTE_MATRIX_ARB */ + 995, /* GL_MATRIX_INDEX_ARRAY_ARB */ + 364, /* GL_CURRENT_MATRIX_INDEX_ARB */ + 1000, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + 1004, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + 1002, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + 998, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + 2038, /* GL_TEXTURE_DEPTH_SIZE */ + 435, /* GL_DEPTH_TEXTURE_MODE */ + 1995, /* GL_TEXTURE_COMPARE_MODE */ + 1993, /* GL_TEXTURE_COMPARE_FUNC */ + 281, /* GL_COMPARE_REF_TO_TEXTURE */ + 1371, /* GL_POINT_SPRITE */ + 343, /* GL_COORD_REPLACE */ + 1376, /* GL_POINT_SPRITE_R_MODE_NV */ + 1516, /* GL_QUERY_COUNTER_BITS */ + 372, /* GL_CURRENT_QUERY */ + 1520, /* GL_QUERY_RESULT */ + 1522, /* GL_QUERY_RESULT_AVAILABLE */ + 1126, /* GL_MAX_VERTEX_ATTRIBS */ + 2243, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + 433, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ + 432, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ + 1103, /* GL_MAX_TEXTURE_COORDS */ + 1105, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + 1451, /* GL_PROGRAM_ERROR_STRING_ARB */ + 1453, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + 1452, /* GL_PROGRAM_FORMAT_ARB */ + 2094, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + 405, /* GL_DEPTH_BOUNDS_TEST_EXT */ + 404, /* GL_DEPTH_BOUNDS_EXT */ + 61, /* GL_ARRAY_BUFFER */ + 520, /* GL_ELEMENT_ARRAY_BUFFER */ + 62, /* GL_ARRAY_BUFFER_BINDING */ + 521, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ + 2215, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + 1224, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + 187, /* GL_COLOR_ARRAY_BUFFER_BINDING */ + 732, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + 2008, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + 516, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ + 1730, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + 573, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ + 2271, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + 2237, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + 1454, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + 1070, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + 1460, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 1079, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 1474, /* GL_PROGRAM_TEMPORARIES_ARB */ + 1085, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + 1462, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 1081, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 1466, /* GL_PROGRAM_PARAMETERS_ARB */ + 1084, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + 1461, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + 1080, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + 1445, /* GL_PROGRAM_ATTRIBS_ARB */ + 1065, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + 1459, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + 1078, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + 1443, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + 1063, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + 1457, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 1076, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 1071, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + 1067, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + 1477, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + 2127, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + 1539, /* GL_READ_ONLY */ + 2285, /* GL_WRITE_ONLY */ + 1541, /* GL_READ_WRITE */ + 124, /* GL_BUFFER_ACCESS */ + 129, /* GL_BUFFER_MAPPED */ + 134, /* GL_BUFFER_MAP_POINTER */ + 2101, /* GL_TIME_ELAPSED_EXT */ + 955, /* GL_MATRIX0_ARB */ + 967, /* GL_MATRIX1_ARB */ + 979, /* GL_MATRIX2_ARB */ + 983, /* GL_MATRIX3_ARB */ + 985, /* GL_MATRIX4_ARB */ + 987, /* GL_MATRIX5_ARB */ + 989, /* GL_MATRIX6_ARB */ + 991, /* GL_MATRIX7_ARB */ + 993, /* GL_MATRIX8_ARB */ + 994, /* GL_MATRIX9_ARB */ + 957, /* GL_MATRIX10_ARB */ + 958, /* GL_MATRIX11_ARB */ + 959, /* GL_MATRIX12_ARB */ + 960, /* GL_MATRIX13_ARB */ + 961, /* GL_MATRIX14_ARB */ + 962, /* GL_MATRIX15_ARB */ + 963, /* GL_MATRIX16_ARB */ + 964, /* GL_MATRIX17_ARB */ + 965, /* GL_MATRIX18_ARB */ + 966, /* GL_MATRIX19_ARB */ + 969, /* GL_MATRIX20_ARB */ + 970, /* GL_MATRIX21_ARB */ + 971, /* GL_MATRIX22_ARB */ + 972, /* GL_MATRIX23_ARB */ + 973, /* GL_MATRIX24_ARB */ + 974, /* GL_MATRIX25_ARB */ + 975, /* GL_MATRIX26_ARB */ + 976, /* GL_MATRIX27_ARB */ + 977, /* GL_MATRIX28_ARB */ + 978, /* GL_MATRIX29_ARB */ + 981, /* GL_MATRIX30_ARB */ + 982, /* GL_MATRIX31_ARB */ + 1863, /* GL_STREAM_DRAW */ + 1865, /* GL_STREAM_READ */ + 1861, /* GL_STREAM_COPY */ + 1812, /* GL_STATIC_DRAW */ + 1814, /* GL_STATIC_READ */ + 1810, /* GL_STATIC_COPY */ + 510, /* GL_DYNAMIC_DRAW */ + 512, /* GL_DYNAMIC_READ */ + 508, /* GL_DYNAMIC_COPY */ + 1334, /* GL_PIXEL_PACK_BUFFER */ + 1338, /* GL_PIXEL_UNPACK_BUFFER */ + 1335, /* GL_PIXEL_PACK_BUFFER_BINDING */ + 1339, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + 396, /* GL_DEPTH24_STENCIL8 */ + 2090, /* GL_TEXTURE_STENCIL_SIZE */ + 2036, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + 1066, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + 1069, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + 1073, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + 1072, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + 2241, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ + 1012, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ + 1149, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ + 1086, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ + 1854, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + 18, /* GL_ACTIVE_STENCIL_FACE_EXT */ + 1156, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + 1711, /* GL_SAMPLES_PASSED */ + 688, /* GL_GEOMETRY_VERTICES_OUT */ + 682, /* GL_GEOMETRY_INPUT_TYPE */ + 684, /* GL_GEOMETRY_OUTPUT_TYPE */ + 156, /* GL_CLAMP_READ_COLOR */ + 546, /* GL_FIXED_ONLY */ + 1358, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ + 1357, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ + 1356, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ + 1193, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ + 1480, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ + 2070, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ + 138, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ + 128, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ + 1556, /* GL_RELEASED_APPLE */ + 2268, /* GL_VOLATILE_APPLE */ + 1595, /* GL_RETAINED_APPLE */ + 2144, /* GL_UNDEFINED_APPLE */ + 1504, /* GL_PURGEABLE_APPLE */ + 596, /* GL_FRAGMENT_SHADER */ + 2263, /* GL_VERTEX_SHADER */ + 1465, /* GL_PROGRAM_OBJECT_ARB */ + 1747, /* GL_SHADER_OBJECT_ARB */ + 1041, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + 1131, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + 1122, /* GL_MAX_VARYING_COMPONENTS */ + 1129, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + 1024, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + 1254, /* GL_OBJECT_TYPE_ARB */ + 1749, /* GL_SHADER_TYPE */ + 561, /* GL_FLOAT_VEC2 */ + 563, /* GL_FLOAT_VEC3 */ + 565, /* GL_FLOAT_VEC4 */ + 784, /* GL_INT_VEC2 */ + 786, /* GL_INT_VEC3 */ + 788, /* GL_INT_VEC4 */ + 116, /* GL_BOOL */ + 118, /* GL_BOOL_VEC2 */ + 120, /* GL_BOOL_VEC3 */ + 122, /* GL_BOOL_VEC4 */ + 549, /* GL_FLOAT_MAT2 */ + 553, /* GL_FLOAT_MAT3 */ + 557, /* GL_FLOAT_MAT4 */ + 1687, /* GL_SAMPLER_1D */ + 1693, /* GL_SAMPLER_2D */ + 1701, /* GL_SAMPLER_3D */ + 1705, /* GL_SAMPLER_CUBE */ + 1692, /* GL_SAMPLER_1D_SHADOW */ + 1700, /* GL_SAMPLER_2D_SHADOW */ + 1698, /* GL_SAMPLER_2D_RECT */ + 1699, /* GL_SAMPLER_2D_RECT_SHADOW */ + 551, /* GL_FLOAT_MAT2x3 */ + 552, /* GL_FLOAT_MAT2x4 */ + 555, /* GL_FLOAT_MAT3x2 */ + 556, /* GL_FLOAT_MAT3x4 */ + 559, /* GL_FLOAT_MAT4x2 */ + 560, /* GL_FLOAT_MAT4x3 */ + 394, /* GL_DELETE_STATUS */ + 286, /* GL_COMPILE_STATUS */ + 845, /* GL_LINK_STATUS */ + 2209, /* GL_VALIDATE_STATUS */ + 744, /* GL_INFO_LOG_LENGTH */ + 64, /* GL_ATTACHED_SHADERS */ + 21, /* GL_ACTIVE_UNIFORMS */ + 22, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ + 1748, /* GL_SHADER_SOURCE_LENGTH */ + 15, /* GL_ACTIVE_ATTRIBUTES */ + 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ + 598, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ + 1751, /* GL_SHADING_LANGUAGE_VERSION */ + 371, /* GL_CURRENT_PROGRAM */ + 1303, /* GL_PALETTE4_RGB8_OES */ + 1305, /* GL_PALETTE4_RGBA8_OES */ + 1301, /* GL_PALETTE4_R5_G6_B5_OES */ + 1304, /* GL_PALETTE4_RGBA4_OES */ + 1302, /* GL_PALETTE4_RGB5_A1_OES */ + 1308, /* GL_PALETTE8_RGB8_OES */ + 1310, /* GL_PALETTE8_RGBA8_OES */ + 1306, /* GL_PALETTE8_R5_G6_B5_OES */ + 1309, /* GL_PALETTE8_RGBA4_OES */ + 1307, /* GL_PALETTE8_RGB5_A1_OES */ + 726, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ + 724, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ + 1355, /* GL_POINT_SIZE_ARRAY_OES */ + 2014, /* GL_TEXTURE_CROP_RECT_OES */ + 996, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ + 1354, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ + 2192, /* GL_UNSIGNED_NORMALIZED */ + 1951, /* GL_TEXTURE_1D_ARRAY */ + 1490, /* GL_PROXY_TEXTURE_1D_ARRAY */ + 1954, /* GL_TEXTURE_2D_ARRAY */ + 1494, /* GL_PROXY_TEXTURE_2D_ARRAY */ + 1962, /* GL_TEXTURE_BINDING_1D_ARRAY */ + 1965, /* GL_TEXTURE_BINDING_2D_ARRAY */ + 1048, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ + 1981, /* GL_TEXTURE_BUFFER */ + 1102, /* GL_MAX_TEXTURE_BUFFER_SIZE */ + 1969, /* GL_TEXTURE_BINDING_BUFFER */ + 1982, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ + 1983, /* GL_TEXTURE_BUFFER_FORMAT */ + 1527, /* GL_R11F_G11F_B10F */ + 2158, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ + 1638, /* GL_RGB9_E5 */ + 2167, /* GL_UNSIGNED_INT_5_9_9_9_REV */ + 2088, /* GL_TEXTURE_SHARED_SIZE */ + 1804, /* GL_SRGB */ + 1805, /* GL_SRGB8 */ + 1807, /* GL_SRGB_ALPHA */ + 1806, /* GL_SRGB8_ALPHA8 */ + 1764, /* GL_SLUMINANCE_ALPHA */ + 1763, /* GL_SLUMINANCE8_ALPHA8 */ + 1761, /* GL_SLUMINANCE */ + 1762, /* GL_SLUMINANCE8 */ + 309, /* GL_COMPRESSED_SRGB */ + 310, /* GL_COMPRESSED_SRGB_ALPHA */ + 307, /* GL_COMPRESSED_SLUMINANCE */ + 308, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ + 2123, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ + 2112, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ + 1120, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ + 2121, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ + 2117, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ + 2115, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ + 1437, /* GL_PRIMITIVES_GENERATED */ + 2119, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ + 1531, /* GL_RASTERIZER_DISCARD */ + 1116, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ + 1118, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ + 762, /* GL_INTERLEAVED_ATTRIBS */ + 1740, /* GL_SEPARATE_ATTRIBS */ + 2107, /* GL_TRANSFORM_FEEDBACK_BUFFER */ + 2109, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ + 1373, /* GL_POINT_SPRITE_COORD_ORIGIN */ + 853, /* GL_LOWER_LEFT */ + 2206, /* GL_UPPER_LEFT */ + 1828, /* GL_STENCIL_BACK_REF */ + 1829, /* GL_STENCIL_BACK_VALUE_MASK */ + 1830, /* GL_STENCIL_BACK_WRITEMASK */ + 500, /* GL_DRAW_FRAMEBUFFER_BINDING */ + 1561, /* GL_RENDERBUFFER_BINDING */ + 1535, /* GL_READ_FRAMEBUFFER */ + 499, /* GL_DRAW_FRAMEBUFFER */ + 1536, /* GL_READ_FRAMEBUFFER_BINDING */ + 1580, /* GL_RENDERBUFFER_SAMPLES */ + 612, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ + 609, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ + 624, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ + 619, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ + 622, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ + 630, /* GL_FRAMEBUFFER_COMPLETE */ + 635, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ + 650, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ + 644, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ + 639, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ + 645, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ + 641, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ + 655, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ + 661, /* GL_FRAMEBUFFER_UNSUPPORTED */ + 659, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ + 1020, /* GL_MAX_COLOR_ATTACHMENTS */ + 193, /* GL_COLOR_ATTACHMENT0 */ + 196, /* GL_COLOR_ATTACHMENT1 */ + 210, /* GL_COLOR_ATTACHMENT2 */ + 212, /* GL_COLOR_ATTACHMENT3 */ + 214, /* GL_COLOR_ATTACHMENT4 */ + 216, /* GL_COLOR_ATTACHMENT5 */ + 218, /* GL_COLOR_ATTACHMENT6 */ + 220, /* GL_COLOR_ATTACHMENT7 */ + 222, /* GL_COLOR_ATTACHMENT8 */ + 224, /* GL_COLOR_ATTACHMENT9 */ + 197, /* GL_COLOR_ATTACHMENT10 */ + 199, /* GL_COLOR_ATTACHMENT11 */ + 201, /* GL_COLOR_ATTACHMENT12 */ + 203, /* GL_COLOR_ATTACHMENT13 */ + 205, /* GL_COLOR_ATTACHMENT14 */ + 207, /* GL_COLOR_ATTACHMENT15 */ + 399, /* GL_DEPTH_ATTACHMENT */ + 1817, /* GL_STENCIL_ATTACHMENT */ + 600, /* GL_FRAMEBUFFER */ + 1558, /* GL_RENDERBUFFER */ + 1584, /* GL_RENDERBUFFER_WIDTH */ + 1571, /* GL_RENDERBUFFER_HEIGHT */ + 1574, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + 1849, /* GL_STENCIL_INDEX_EXT */ + 1838, /* GL_STENCIL_INDEX1 */ + 1843, /* GL_STENCIL_INDEX4 */ + 1846, /* GL_STENCIL_INDEX8 */ + 1839, /* GL_STENCIL_INDEX16 */ + 1578, /* GL_RENDERBUFFER_RED_SIZE */ + 1569, /* GL_RENDERBUFFER_GREEN_SIZE */ + 1564, /* GL_RENDERBUFFER_BLUE_SIZE */ + 1559, /* GL_RENDERBUFFER_ALPHA_SIZE */ + 1566, /* GL_RENDERBUFFER_DEPTH_SIZE */ + 1582, /* GL_RENDERBUFFER_STENCIL_SIZE */ + 653, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ + 1097, /* GL_MAX_SAMPLES */ + 2050, /* GL_TEXTURE_GEN_STR_OES */ + 699, /* GL_HALF_FLOAT_OES */ + 1625, /* GL_RGB565_OES */ + 1655, /* GL_RGBA32UI */ + 1618, /* GL_RGB32UI */ + 40, /* GL_ALPHA32UI_EXT */ + 754, /* GL_INTENSITY32UI_EXT */ + 870, /* GL_LUMINANCE32UI_EXT */ + 887, /* GL_LUMINANCE_ALPHA32UI_EXT */ + 1646, /* GL_RGBA16UI */ + 1610, /* GL_RGB16UI */ + 37, /* GL_ALPHA16UI_EXT */ + 751, /* GL_INTENSITY16UI_EXT */ + 865, /* GL_LUMINANCE16UI_EXT */ + 885, /* GL_LUMINANCE_ALPHA16UI_EXT */ + 1665, /* GL_RGBA8UI */ + 1633, /* GL_RGB8UI */ + 45, /* GL_ALPHA8UI_EXT */ + 759, /* GL_INTENSITY8UI_EXT */ + 879, /* GL_LUMINANCE8UI_EXT */ + 889, /* GL_LUMINANCE_ALPHA8UI_EXT */ + 1653, /* GL_RGBA32I */ + 1616, /* GL_RGB32I */ + 39, /* GL_ALPHA32I_EXT */ + 753, /* GL_INTENSITY32I_EXT */ + 869, /* GL_LUMINANCE32I_EXT */ + 886, /* GL_LUMINANCE_ALPHA32I_EXT */ + 1644, /* GL_RGBA16I */ + 1608, /* GL_RGB16I */ + 36, /* GL_ALPHA16I_EXT */ + 750, /* GL_INTENSITY16I_EXT */ + 864, /* GL_LUMINANCE16I_EXT */ + 884, /* GL_LUMINANCE_ALPHA16I_EXT */ + 1663, /* GL_RGBA8I */ + 1631, /* GL_RGB8I */ + 44, /* GL_ALPHA8I_EXT */ + 758, /* GL_INTENSITY8I_EXT */ + 878, /* GL_LUMINANCE8I_EXT */ + 888, /* GL_LUMINANCE_ALPHA8I_EXT */ + 1548, /* GL_RED_INTEGER */ + 695, /* GL_GREEN_INTEGER */ + 113, /* GL_BLUE_INTEGER */ + 49, /* GL_ALPHA_INTEGER_EXT */ + 1677, /* GL_RGB_INTEGER */ + 1671, /* GL_RGBA_INTEGER */ + 84, /* GL_BGR_INTEGER */ + 82, /* GL_BGRA_INTEGER */ + 891, /* GL_LUMINANCE_INTEGER_EXT */ + 890, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ + 1673, /* GL_RGBA_INTEGER_MODE_EXT */ + 607, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ + 648, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ + 647, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ + 1688, /* GL_SAMPLER_1D_ARRAY */ + 1694, /* GL_SAMPLER_2D_ARRAY */ + 1703, /* GL_SAMPLER_BUFFER */ + 1690, /* GL_SAMPLER_1D_ARRAY_SHADOW */ + 1696, /* GL_SAMPLER_2D_ARRAY_SHADOW */ + 1706, /* GL_SAMPLER_CUBE_SHADOW */ + 2186, /* GL_UNSIGNED_INT_VEC2 */ + 2188, /* GL_UNSIGNED_INT_VEC3 */ + 2190, /* GL_UNSIGNED_INT_VEC4 */ + 768, /* GL_INT_SAMPLER_1D */ + 772, /* GL_INT_SAMPLER_2D */ + 778, /* GL_INT_SAMPLER_3D */ + 782, /* GL_INT_SAMPLER_CUBE */ + 776, /* GL_INT_SAMPLER_2D_RECT */ + 769, /* GL_INT_SAMPLER_1D_ARRAY */ + 773, /* GL_INT_SAMPLER_2D_ARRAY */ + 780, /* GL_INT_SAMPLER_BUFFER */ + 2170, /* GL_UNSIGNED_INT_SAMPLER_1D */ + 2174, /* GL_UNSIGNED_INT_SAMPLER_2D */ + 2180, /* GL_UNSIGNED_INT_SAMPLER_3D */ + 2184, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ + 2178, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ + 2171, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ + 2175, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ + 2182, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ + 686, /* GL_GEOMETRY_SHADER */ + 689, /* GL_GEOMETRY_VERTICES_OUT_ARB */ + 683, /* GL_GEOMETRY_INPUT_TYPE_ARB */ + 685, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ + 1054, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ + 1136, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ + 1052, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ + 1046, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ + 1050, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ + 854, /* GL_LOW_FLOAT */ + 1138, /* GL_MEDIUM_FLOAT */ + 700, /* GL_HIGH_FLOAT */ + 855, /* GL_LOW_INT */ + 1139, /* GL_MEDIUM_INT */ + 701, /* GL_HIGH_INT */ + 2160, /* GL_UNSIGNED_INT_10_10_10_2_OES */ + 767, /* GL_INT_10_10_10_2_OES */ + 1745, /* GL_SHADER_BINARY_FORMATS */ + 1239, /* GL_NUM_SHADER_BINARY_FORMATS */ + 1746, /* GL_SHADER_COMPILER */ + 1133, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ + 1125, /* GL_MAX_VARYING_VECTORS */ + 1043, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ + 1524, /* GL_QUERY_WAIT */ + 1518, /* GL_QUERY_NO_WAIT */ + 1514, /* GL_QUERY_BY_REGION_WAIT */ + 1512, /* GL_QUERY_BY_REGION_NO_WAIT */ + 2105, /* GL_TRANSFORM_FEEDBACK */ + 2114, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ + 2108, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ + 2106, /* GL_TRANSFORM_FEEDBACK_BINDING */ + 1508, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + 542, /* GL_FIRST_VERTEX_CONVENTION */ + 800, /* GL_LAST_VERTEX_CONVENTION */ + 1482, /* GL_PROVOKING_VERTEX */ + 350, /* GL_COPY_READ_BUFFER */ + 351, /* GL_COPY_WRITE_BUFFER */ + 1551, /* GL_RED_SNORM */ + 1684, /* GL_RG_SNORM */ + 1683, /* GL_RGB_SNORM */ + 1676, /* GL_RGBA_SNORM */ + 1530, /* GL_R8_SNORM */ + 1598, /* GL_RG8_SNORM */ + 1637, /* GL_RGB8_SNORM */ + 1669, /* GL_RGBA8_SNORM */ + 1528, /* GL_R16_SNORM */ + 1597, /* GL_RG16_SNORM */ + 1613, /* GL_RGB16_SNORM */ + 1649, /* GL_RGBA16_SNORM */ + 1757, /* GL_SIGNED_NORMALIZED */ + 1439, /* GL_PRIMITIVE_RESTART */ + 1440, /* GL_PRIMITIVE_RESTART_INDEX */ + 1099, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + 1253, /* GL_OBJECT_TYPE */ + 1870, /* GL_SYNC_CONDITION */ + 1875, /* GL_SYNC_STATUS */ + 1872, /* GL_SYNC_FLAGS */ + 1871, /* GL_SYNC_FENCE */ + 1874, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + 2153, /* GL_UNSIGNALED */ + 1756, /* GL_SIGNALED */ + 54, /* GL_ALREADY_SIGNALED */ + 2100, /* GL_TIMEOUT_EXPIRED */ + 312, /* GL_CONDITION_SATISFIED */ + 2269, /* GL_WAIT_FAILED */ + 126, /* GL_BUFFER_ACCESS_FLAGS */ + 132, /* GL_BUFFER_MAP_LENGTH */ + 133, /* GL_BUFFER_MAP_OFFSET */ + 1128, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ + 1044, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ + 1045, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ + 1040, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ + 326, /* GL_CONTEXT_PROFILE_MASK */ + 527, /* GL_EVAL_BIT */ + 1533, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + 847, /* GL_LIST_BIT */ + 1976, /* GL_TEXTURE_BIT */ + 1726, /* GL_SCISSOR_BIT */ + 30, /* GL_ALL_ATTRIB_BITS */ + 1204, /* GL_MULTISAMPLE_BIT */ + 31, /* GL_ALL_CLIENT_ATTRIB_BITS */ +}; + +typedef int (*cfunc)(const void *, const void *); + +/** + * Compare a key name to an element in the \c all_enums array. + * + * \c bsearch always passes the key as the first parameter and the pointer + * to the array element as the second parameter. We can elimiate some + * extra work by taking advantage of that fact. + * + * \param a Pointer to the desired enum name. + * \param b Pointer to an element of the \c all_enums array. + */ +static int compar_name( const char *a, const enum_elt *b ) +{ + return strcmp( a, & enum_string_table[ b->offset ] ); +} + +/** + * Compare a key enum value to an element in the \c all_enums array. + * + * \c bsearch always passes the key as the first parameter and the pointer + * to the array element as the second parameter. We can elimiate some + * extra work by taking advantage of that fact. + * + * \param a Pointer to the desired enum name. + * \param b Pointer to an index into the \c all_enums array. + */ +static int compar_nr( const int *a, const unsigned *b ) +{ + return a[0] - all_enums[*b].n; +} + + +static char token_tmp[20]; + +const char *_mesa_lookup_enum_by_nr( int nr ) +{ + unsigned * i; + + i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, + Elements(reduced_enums), + sizeof(reduced_enums[0]), + (cfunc) compar_nr); + + if ( i != NULL ) { + return & enum_string_table[ all_enums[ *i ].offset ]; + } + else { + /* this is not re-entrant safe, no big deal here */ + _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); + token_tmp[sizeof(token_tmp) - 1] = '\0'; + return token_tmp; + } +} + +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ) +{ + switch (nr) { + case GL_POINTS: return "GL_POINTS"; + case GL_LINES: return "GL_LINES"; + case GL_LINE_STRIP: return "GL_LINE_STRIP"; + case GL_LINE_LOOP: return "GL_LINE_LOOP"; + case GL_TRIANGLES: return "GL_TRIANGLES"; + case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; + case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; + case GL_QUADS: return "GL_QUADS"; + case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; + case GL_POLYGON: return "GL_POLYGON"; + case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; + default: return ""; + } +} + + + +int _mesa_lookup_enum_by_name( const char *symbol ) +{ + enum_elt * f = NULL; + + if ( symbol != NULL ) { + f = (enum_elt *) _mesa_bsearch(symbol, all_enums, + Elements(all_enums), + sizeof( enum_elt ), + (cfunc) compar_name); + } + + return (f != NULL) ? f->n : -1; +} + + diff --git a/mesalib/src/mesa/main/enums.h b/mesalib/src/mesa/main/enums.h index b5f69001b..b3ad3f92c 100644 --- a/mesalib/src/mesa/main/enums.h +++ b/mesalib/src/mesa/main/enums.h @@ -1,61 +1,62 @@ -/** - * \file enums.h - * Enumeration name/number lookup functions. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _ENUMS_H_ -#define _ENUMS_H_ - - -#if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL - -extern const char *_mesa_lookup_enum_by_nr( int nr ); - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char *_mesa_lookup_prim_by_nr( int nr ); - -extern int _mesa_lookup_enum_by_name( const char *symbol ); - -#else - -/** No-op */ -#define _mesa_lookup_enum_by_name( s ) 0 - -/** No-op */ -#define _mesa_lookup_enum_by_nr( n ) "unknown" - -#endif - -#endif +/** + * \file enums.h + * Enumeration name/number lookup functions. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _ENUMS_H_ +#define _ENUMS_H_ + +#include "mfeatures.h" + +#if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL + +extern const char *_mesa_lookup_enum_by_nr( int nr ); + +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ); + +extern int _mesa_lookup_enum_by_name( const char *symbol ); + +#else + +/** No-op */ +#define _mesa_lookup_enum_by_name( s ) 0 + +/** No-op */ +#define _mesa_lookup_enum_by_nr( n ) "unknown" + +#endif + +#endif diff --git a/mesalib/src/mesa/main/es_generator.py b/mesalib/src/mesa/main/es_generator.py index ecb34bb5c..36bd14d6c 100644 --- a/mesalib/src/mesa/main/es_generator.py +++ b/mesalib/src/mesa/main/es_generator.py @@ -1,743 +1,760 @@ -#************************************************************************* -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# TUNGSTEN GRAPHICS 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. -#************************************************************************* - - -import sys, os -import APIspecutil as apiutil - -# These dictionary entries are used for automatic conversion. -# The string will be used as a format string with the conversion -# variable. -Converters = { - 'GLfloat': { - 'GLdouble': "(GLdouble) (%s)", - 'GLfixed' : "(GLint) (%s * 65536)", - }, - 'GLfixed': { - 'GLfloat': "(GLfloat) (%s / 65536.0f)", - 'GLdouble': "(GLdouble) (%s / 65536.0)", - }, - 'GLdouble': { - 'GLfloat': "(GLfloat) (%s)", - 'GLfixed': "(GLfixed) (%s * 65536)", - }, - 'GLclampf': { - 'GLclampd': "(GLclampd) (%s)", - 'GLclampx': "(GLclampx) (%s * 65536)", - }, - 'GLclampx': { - 'GLclampf': "(GLclampf) (%s / 65536.0f)", - 'GLclampd': "(GLclampd) (%s / 65536.0)", - }, - 'GLubyte': { - 'GLfloat': "(GLfloat) (%s / 255.0f)", - }, -} - -def GetBaseType(type): - typeTokens = type.split(' ') - baseType = None - typeModifiers = [] - for t in typeTokens: - if t in ['const', '*']: - typeModifiers.append(t) - else: - baseType = t - return (baseType, typeModifiers) - -def ConvertValue(value, fromType, toType): - """Returns a string that represents the given parameter string, - type-converted if necessary.""" - - if not Converters.has_key(fromType): - print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType - return value - - if not Converters[fromType].has_key(toType): - print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType) - return value - - # This part is simple. Return the proper conversion. - conversionString = Converters[fromType][toType] - return conversionString % value - -FormatStrings = { - 'GLenum' : '0x%x', - 'GLfloat' : '%f', - 'GLint' : '%d', - 'GLbitfield' : '0x%x', -} -def GetFormatString(type): - if FormatStrings.has_key(type): - return FormatStrings[type] - else: - return None - - -###################################################################### -# Version-specific values to be used in the main script -# header: which header file to include -# api: what text specifies an API-level function -VersionSpecificValues = { - 'GLES1.1' : { - 'description' : 'GLES1.1 functions', - 'header' : 'GLES/gl.h', - 'extheader' : 'GLES/glext.h', - 'shortname' : 'es1' - }, - 'GLES2.0': { - 'description' : 'GLES2.0 functions', - 'header' : 'GLES2/gl2.h', - 'extheader' : 'GLES2/gl2ext.h', - 'shortname' : 'es2' - } -} - - -###################################################################### -# Main code for the script begins here. - -# Get the name of the program (without the directory part) for use in -# error messages. -program = os.path.basename(sys.argv[0]) - -# Set default values -verbose = 0 -functionList = "APIspec.xml" -version = "GLES1.1" - -# Allow for command-line switches -import getopt, time -options = "hvV:S:" -try: - optlist, args = getopt.getopt(sys.argv[1:], options) -except getopt.GetoptError, message: - sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message)) - sys.exit(1) - -for option, optarg in optlist: - if option == "-h": - sys.stderr.write("Usage: %s [-%s]\n" % (program, options)) - sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n") - sys.stderr.write("-h gives help\n") - sys.stderr.write("-v is verbose\n") - sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version) - for key in VersionSpecificValues.keys(): - sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description'])) - sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList) - sys.exit(1) - elif option == "-v": - verbose += 1 - elif option == "-V": - version = optarg - elif option == "-S": - functionList = optarg - -# Beyond switches, we support no further command-line arguments -if len(args) > 0: - sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program) - sys.exit(1) - -# If we don't have a valid version, abort. -if not VersionSpecificValues.has_key(version): - sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version)) - sys.exit(1) - -# Grab the version-specific items we need to use -versionHeader = VersionSpecificValues[version]['header'] -versionExtHeader = VersionSpecificValues[version]['extheader'] -shortname = VersionSpecificValues[version]['shortname'] - -# If we get to here, we're good to go. The "version" parameter -# directs GetDispatchedFunctions to only allow functions from -# that "category" (version in our parlance). This allows -# functions with different declarations in different categories -# to exist (glTexImage2D, for example, is different between -# GLES1 and GLES2). -keys = apiutil.GetAllFunctions(functionList, version) - -allSpecials = apiutil.AllSpecials() - -print """/* DO NOT EDIT ************************************************* - * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT - * API specification file: %s - * GLES version: %s - * date: %s - */ -""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) - -# The headers we choose are version-specific. -print """ -#include "%s" -#include "%s" -#include "main/mfeatures.h" - -#if FEATURE_%s -""" % (versionHeader, versionExtHeader, shortname.upper()) - -# Everyone needs these types. -print """ -/* These types are needed for the Mesa veneer, but are not defined in - * the standard GLES headers. - */ -typedef double GLdouble; -typedef double GLclampd; - -/* Mesa error handling requires these */ -extern void *_mesa_get_current_context(void); -extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); - -#include "main/compiler.h" -#include "main/api_exec.h" -#include "main/remap.h" - -/* cannot include main/dispatch.h here */ -#ifdef IN_DRI_DRIVER -#define _GLAPI_USE_REMAP_TABLE -#endif -/* glapi uses GLAPIENTRY while GLES headers define GL_APIENTRY */ -#ifndef GLAPIENTRY -#define GLAPIENTRY GL_APIENTRY -#endif -#include "%sapi/glapi/glapitable.h" -#include "%sapi/glapi/glapioffsets.h" -#include "%sapi/glapi/glapidispatch.h" - -#if FEATURE_remap_table - -#if !FEATURE_GL -int driDispatchRemapTable[driDispatchRemapTable_size]; -#endif - -#define need_MESA_remap_table - -#include "%sapi/main/remap_helper.h" - -void -_mesa_init_remap_table_%s(void) -{ - _mesa_do_init_remap_table(_mesa_function_pool, - driDispatchRemapTable_size, - MESA_remap_table_functions); -} - -void -_mesa_map_static_functions_%s(void) -{ -} - -#endif - -typedef void (*_glapi_proc)(void); /* generic function pointer */ -""" % (shortname, shortname, shortname, shortname, shortname, shortname); - -# Finally we get to the all-important functions -print """/************************************************************* - * Generated functions begin here - */ -""" -for funcName in keys: - if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) - - # start figuring out what this function will look like. - returnType = apiutil.ReturnType(funcName) - props = apiutil.Properties(funcName) - params = apiutil.Parameters(funcName) - declarationString = apiutil.MakeDeclarationString(params) - - # In case of error, a function may have to return. Make - # sure we have valid return values in this case. - if returnType == "void": - errorReturn = "return" - elif returnType == "GLboolean": - errorReturn = "return GL_FALSE" - else: - errorReturn = "return (%s) 0" % returnType - - # These are the output of this large calculation block. - # passthroughDeclarationString: a typed set of parameters that - # will be used to create the "extern" reference for the - # underlying Mesa or support function. Note that as generated - # these have an extra ", " at the beginning, which will be - # removed before use. - # - # passthroughDeclarationString: an untyped list of parameters - # that will be used to call the underlying Mesa or support - # function (including references to converted parameters). - # This will also be generated with an extra ", " at the - # beginning, which will be removed before use. - # - # variables: C code to create any local variables determined to - # be necessary. - # conversionCodeOutgoing: C code to convert application parameters - # to a necessary type before calling the underlying support code. - # May be empty if no conversion is required. - # conversionCodeIncoming: C code to do the converse: convert - # values returned by underlying Mesa code to the types needed - # by the application. - # Note that *either* the conversionCodeIncoming will be used (for - # generated query functions), *or* the conversionCodeOutgoing will - # be used (for generated non-query functions), never both. - passthroughFuncName = "" - passthroughDeclarationString = "" - passthroughCallString = "" - prefixOverride = None - variables = [] - conversionCodeOutgoing = [] - conversionCodeIncoming = [] - switchCode = [] - - # Calculate the name of the underlying support function to call. - # By default, the passthrough function is named _mesa_. - # We're allowed to override the prefix and/or the function name - # for each function record, though. The "ConversionFunction" - # utility is poorly named, BTW... - if funcName in allSpecials: - # perform checks and pass through - funcPrefix = "_check_" - aliasprefix = "_es_" - else: - funcPrefix = "_es_" - aliasprefix = apiutil.AliasPrefix(funcName) - alias = apiutil.ConversionFunction(funcName) - prefixOverride = apiutil.FunctionPrefix(funcName) - if prefixOverride != "_mesa_": - aliasprefix = apiutil.FunctionPrefix(funcName) - if not alias: - # There may still be a Mesa alias for the function - if apiutil.Alias(funcName): - passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName)) - else: - passthroughFuncName = "%s%s" % (aliasprefix, funcName) - else: # a specific alias is provided - passthroughFuncName = "%s%s" % (aliasprefix, alias) - - # Look at every parameter: each one may have only specific - # allowed values, or dependent parameters to check, or - # variant-sized vector arrays to calculate - for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params: - # We'll need this below if we're doing conversions - (paramBaseType, paramTypeModifiers) = GetBaseType(paramType) - - # Conversion management. - # We'll handle three cases, easiest to hardest: a parameter - # that doesn't require conversion, a scalar parameter that - # requires conversion, and a vector parameter that requires - # conversion. - if paramConvertToType == None: - # Unconverted parameters are easy, whether they're vector - # or scalar - just add them to the call list. No conversions - # or anything to worry about. - passthroughDeclarationString += ", %s %s" % (paramType, paramName) - passthroughCallString += ", %s" % paramName - - elif paramMaxVecSize == 0: # a scalar parameter that needs conversion - # A scalar to hold a converted parameter - variables.append(" %s converted_%s;" % (paramConvertToType, paramName)) - - # Outgoing conversion depends on whether we have to conditionally - # perform value conversion. - if paramValueConversion == "none": - conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - - # Write code based on that conditional. - conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) - conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) - conversionCodeOutgoing.append(" } else {") - conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - else: # paramValueConversion == "all" - conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) - - # Note that there can be no incoming conversion for a - # scalar parameter; changing the scalar will only change - # the local value, and won't ultimately change anything - # that passes back to the application. - - # Call strings. The unusual " ".join() call will join the - # array of parameter modifiers with spaces as separators. - passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) - passthroughCallString += ", converted_%s" % paramName - - else: # a vector parameter that needs conversion - # We'll need an index variable for conversions - if " register unsigned int i;" not in variables: - variables.append(" register unsigned int i;") - - # This variable will hold the (possibly variant) size of - # this array needing conversion. By default, we'll set - # it to the maximal size (which is correct for functions - # with a constant-sized vector parameter); for true - # variant arrays, we'll modify it with other code. - variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize)) - - # This array will hold the actual converted values. - variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize)) - - # Again, we choose the conversion code based on whether we - # have to always convert values, never convert values, or - # conditionally convert values. - if paramValueConversion == "none": - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - # Write code based on that conditional. - conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) - conversionCodeOutgoing.append(" }") - conversionCodeOutgoing.append(" } else {") - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - conversionCodeOutgoing.append(" }") - else: # paramValueConversion == "all" - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) - - conversionCodeOutgoing.append(" }") - - # If instead we need an incoming conversion (i.e. results - # from Mesa have to be converted before handing back - # to the application), this is it. Fortunately, we don't - # have to worry about conditional value conversion - the - # functions that do (e.g. glGetFixedv()) are handled - # specially, outside this code generation. - # - # Whether we use incoming conversion or outgoing conversion - # is determined later - we only ever use one or the other. - - if paramValueConversion == "none": - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeIncoming.append(" }") - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - - # Write code based on that conditional. - conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName) - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) - conversionCodeIncoming.append(" }") - conversionCodeIncoming.append(" } else {") - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName)) - conversionCodeIncoming.append(" }") - conversionCodeIncoming.append(" }") - else: # paramValueConversion == "all" - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) - conversionCodeIncoming.append(" }") - - # Call strings. The unusual " ".join() call will join the - # array of parameter modifiers with spaces as separators. - passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) - passthroughCallString += ", converted_%s" % paramName - - # endif conversion management - - # Parameter checking. If the parameter has a specific list of - # valid values, we have to make sure that the passed-in values - # match these, or we make an error. - if len(paramValidValues) > 0: - # We're about to make a big switch statement with an - # error at the end. By default, the error is GL_INVALID_ENUM, - # unless we find a "case" statement in the middle with a - # non-GLenum value. - errorDefaultCase = "GL_INVALID_ENUM" - - # This parameter has specific valid values. Make a big - # switch statement to handle it. Note that the original - # parameters are always what is checked, not the - # converted parameters. - switchCode.append(" switch(%s) {" % paramName) - - for valueIndex in range(len(paramValidValues)): - (paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex] - - # We're going to need information on the dependent param - # as well. - if dependentParamName: - depParamIndex = apiutil.FindParamIndex(params, dependentParamName) - if depParamIndex == None: - sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName)) - - (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex] - else: - (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None) - - # This is a sneaky trick. It's valid syntax for a parameter - # that is *not* going to be converted to be declared - # with a dependent vector size; but in this case, the - # dependent vector size is unused and unnecessary. - # So check for this and ignore the dependent vector size - # if the parameter is not going to be converted. - if depParamConvertToType: - usedDependentVecSize = dependentVecSize - else: - usedDependentVecSize = None - - # We'll peek ahead at the next parameter, to see whether - # we can combine cases - if valueIndex + 1 < len(paramValidValues) : - (nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1] - if depParamConvertToType: - usedNextDependentVecSize = nextDependentVecSize - else: - usedNextDependentVecSize = None - - # Create a case for this value. As a mnemonic, - # if we have a dependent vector size that we're ignoring, - # add it as a comment. - if usedDependentVecSize == None and dependentVecSize != None: - switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize)) - else: - switchCode.append(" case %s:" % paramValue) - - # If this is not a GLenum case, then switch our error - # if no value is matched to be GL_INVALID_VALUE instead - # of GL_INVALID_ENUM. (Yes, this does get confused - # if there are both values and GLenums in the same - # switch statement, which shouldn't happen.) - if paramValue[0:3] != "GL_": - errorDefaultCase = "GL_INVALID_VALUE" - - # If all the remaining parameters are identical to the - # next set, then we're done - we'll just create the - # official code on the next pass through, and the two - # cases will share the code. - if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert: - continue - - # Otherwise, we'll have to generate code for this case. - # Start off with a check: if there is a dependent parameter, - # and a list of valid values for that parameter, we need - # to generate an error if something other than one - # of those values is passed. - if len(dependentValidValues) > 0: - conditional="" - - # If the parameter being checked is actually an array, - # check only its first element. - if depParamMaxVecSize == 0: - valueToCheck = dependentParamName - else: - valueToCheck = "%s[0]" % dependentParamName - - for v in dependentValidValues: - conditional += " && %s != %s" % (valueToCheck, v) - switchCode.append(" if (%s) {" % conditional[4:]) - if errorCode == None: - errorCode = "GL_INVALID_ENUM" - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName)) - switchCode.append(" %s;" % errorReturn) - switchCode.append(" }") - # endif there are dependent valid values - - # The dependent parameter may require conditional - # value conversion. If it does, and we don't want - # to convert values, we'll have to generate code for that - if depParamValueConversion == "some" and valueConvert == "noconvert": - switchCode.append(" convert_%s_value = 0;" % dependentParamName) - - # If there's a dependent vector size for this parameter - # that we're actually going to use (i.e. we need conversion), - # mark it. - if usedDependentVecSize: - switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize)) - - # In all cases, break out of the switch if any valid - # value is found. - switchCode.append(" break;") - - - # Need a default case to catch all the other, invalid - # parameter values. These will all generate errors. - switchCode.append(" default:") - if errorCode == None: - errorCode = "GL_INVALID_ENUM" - formatString = GetFormatString(paramType) - if formatString == None: - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName)) - else: - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName)) - switchCode.append(" %s;" % errorReturn) - - # End of our switch code. - switchCode.append(" }") - - # endfor every recognized parameter value - - # endfor every param - - # Here, the passthroughDeclarationString and passthroughCallString - # are complete; remove the extra ", " at the front of each. - passthroughDeclarationString = passthroughDeclarationString[2:] - passthroughCallString = passthroughCallString[2:] - if not passthroughDeclarationString: - passthroughDeclarationString = "void" - - # The Mesa functions are scattered across all the Mesa - # header files. The easiest way to manage declarations - # is to create them ourselves. - if funcName in allSpecials: - print "/* this function is special and is defined elsewhere */" - print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) - - # A function may be a core function (i.e. it exists in - # the core specification), a core addition (extension - # functions added officially to the core), a required - # extension (usually an extension for an earlier version - # that has been officially adopted), or an optional extension. - # - # Core functions have a simple category (e.g. "GLES1.1"); - # we generate only a simple callback for them. - # - # Core additions have two category listings, one simple - # and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]). - # We generate the core function, and also an extension function. - # - # Required extensions and implemented optional extensions - # have a single compound category "GLES1.1:OES_point_size_array". - # For these we generate just the extension function. - for categorySpec in apiutil.Categories(funcName): - compoundCategory = categorySpec.split(":") - - # This category isn't for us, if the base category doesn't match - # our version - if compoundCategory[0] != version: - continue - - # Otherwise, determine if we're writing code for a core - # function (no suffix) or an extension function. - if len(compoundCategory) == 1: - # This is a core function - extensionName = None - extensionSuffix = "" - else: - # This is an extension function. We'll need to append - # the extension suffix. - extensionName = compoundCategory[1] - extensionSuffix = extensionName.split("_")[0] - fullFuncName = funcPrefix + funcName + extensionSuffix - - # Now the generated function. The text used to mark an API-level - # function, oddly, is version-specific. - if extensionName: - print "/* Extension %s */" % extensionName - - if (not variables and - not switchCode and - not conversionCodeOutgoing and - not conversionCodeIncoming): - # pass through directly - print "#define %s %s" % (fullFuncName, passthroughFuncName) - print - continue - - print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString) - print "{" - - # Start printing our code pieces. Start with any local - # variables we need. This unusual syntax joins the - # lines in the variables[] array with the "\n" separator. - if len(variables) > 0: - print "\n".join(variables) + "\n" - - # If there's any sort of parameter checking or variable - # array sizing, the switch code will contain it. - if len(switchCode) > 0: - print "\n".join(switchCode) + "\n" - - # In the case of an outgoing conversion (i.e. parameters must - # be converted before calling the underlying Mesa function), - # use the appropriate code. - if "get" not in props and len(conversionCodeOutgoing) > 0: - print "\n".join(conversionCodeOutgoing) + "\n" - - # Call the Mesa function. Note that there are very few functions - # that return a value (i.e. returnType is not "void"), and that - # none of them require incoming translation; so we're safe - # to generate code that directly returns in those cases, - # even though it's not completely independent. - - if returnType == "void": - print " %s(%s);" % (passthroughFuncName, passthroughCallString) - else: - print " return %s(%s);" % (passthroughFuncName, passthroughCallString) - - # If the function is one that returns values (i.e. "get" in props), - # it might return values of a different type than we need, that - # require conversion before passing back to the application. - if "get" in props and len(conversionCodeIncoming) > 0: - print "\n".join(conversionCodeIncoming) - - # All done. - print "}" - print - # end for each category provided for a function - -# end for each function - -print """ -struct _glapi_table * -_mesa_create_exec_table_%s(void) -{ - struct _glapi_table *exec; - exec = _mesa_alloc_dispatch_table(sizeof *exec); - if (exec == NULL) - return NULL; - -""" % shortname - -for func in keys: - prefix = "_es_" if func not in allSpecials else "_check_" - for spec in apiutil.Categories(func): - ext = spec.split(":") - # version does not match - if ext.pop(0) != version: - continue - entry = func - if ext: - suffix = ext[0].split("_")[0] - entry += suffix - print " SET_%s(exec, %s%s);" % (entry, prefix, entry) -print "" -print " return exec;" -print "}" - -print """ -#endif /* FEATURE_%s */""" % (shortname.upper()) +#************************************************************************* +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# TUNGSTEN GRAPHICS 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. +#************************************************************************* + + +import sys, os +import APIspecutil as apiutil + +# These dictionary entries are used for automatic conversion. +# The string will be used as a format string with the conversion +# variable. +Converters = { + 'GLfloat': { + 'GLdouble': "(GLdouble) (%s)", + 'GLfixed' : "(GLint) (%s * 65536)", + }, + 'GLfixed': { + 'GLfloat': "(GLfloat) (%s / 65536.0f)", + 'GLdouble': "(GLdouble) (%s / 65536.0)", + }, + 'GLdouble': { + 'GLfloat': "(GLfloat) (%s)", + 'GLfixed': "(GLfixed) (%s * 65536)", + }, + 'GLclampf': { + 'GLclampd': "(GLclampd) (%s)", + 'GLclampx': "(GLclampx) (%s * 65536)", + }, + 'GLclampx': { + 'GLclampf': "(GLclampf) (%s / 65536.0f)", + 'GLclampd': "(GLclampd) (%s / 65536.0)", + }, + 'GLubyte': { + 'GLfloat': "(GLfloat) (%s / 255.0f)", + }, +} + +def GetBaseType(type): + typeTokens = type.split(' ') + baseType = None + typeModifiers = [] + for t in typeTokens: + if t in ['const', '*']: + typeModifiers.append(t) + else: + baseType = t + return (baseType, typeModifiers) + +def ConvertValue(value, fromType, toType): + """Returns a string that represents the given parameter string, + type-converted if necessary.""" + + if not Converters.has_key(fromType): + print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType + return value + + if not Converters[fromType].has_key(toType): + print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType) + return value + + # This part is simple. Return the proper conversion. + conversionString = Converters[fromType][toType] + return conversionString % value + +FormatStrings = { + 'GLenum' : '0x%x', + 'GLfloat' : '%f', + 'GLint' : '%d', + 'GLbitfield' : '0x%x', +} +def GetFormatString(type): + if FormatStrings.has_key(type): + return FormatStrings[type] + else: + return None + + +###################################################################### +# Version-specific values to be used in the main script +# header: which header file to include +# api: what text specifies an API-level function +VersionSpecificValues = { + 'GLES1.1' : { + 'description' : 'GLES1.1 functions', + 'header' : 'GLES/gl.h', + 'extheader' : 'GLES/glext.h', + 'shortname' : 'es1' + }, + 'GLES2.0': { + 'description' : 'GLES2.0 functions', + 'header' : 'GLES2/gl2.h', + 'extheader' : 'GLES2/gl2ext.h', + 'shortname' : 'es2' + } +} + + +###################################################################### +# Main code for the script begins here. + +# Get the name of the program (without the directory part) for use in +# error messages. +program = os.path.basename(sys.argv[0]) + +# Set default values +verbose = 0 +functionList = "APIspec.xml" +version = "GLES1.1" + +# Allow for command-line switches +import getopt, time +options = "hvV:S:" +try: + optlist, args = getopt.getopt(sys.argv[1:], options) +except getopt.GetoptError, message: + sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message)) + sys.exit(1) + +for option, optarg in optlist: + if option == "-h": + sys.stderr.write("Usage: %s [-%s]\n" % (program, options)) + sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n") + sys.stderr.write("-h gives help\n") + sys.stderr.write("-v is verbose\n") + sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version) + for key in VersionSpecificValues.keys(): + sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description'])) + sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList) + sys.exit(1) + elif option == "-v": + verbose += 1 + elif option == "-V": + version = optarg + elif option == "-S": + functionList = optarg + +# Beyond switches, we support no further command-line arguments +if len(args) > 0: + sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program) + sys.exit(1) + +# If we don't have a valid version, abort. +if not VersionSpecificValues.has_key(version): + sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version)) + sys.exit(1) + +# Grab the version-specific items we need to use +versionHeader = VersionSpecificValues[version]['header'] +versionExtHeader = VersionSpecificValues[version]['extheader'] +shortname = VersionSpecificValues[version]['shortname'] + +# If we get to here, we're good to go. The "version" parameter +# directs GetDispatchedFunctions to only allow functions from +# that "category" (version in our parlance). This allows +# functions with different declarations in different categories +# to exist (glTexImage2D, for example, is different between +# GLES1 and GLES2). +keys = apiutil.GetAllFunctions(functionList, version) + +allSpecials = apiutil.AllSpecials() + +print """/* DO NOT EDIT ************************************************* + * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT + * API specification file: %s + * GLES version: %s + * date: %s + */ +""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) + +# The headers we choose are version-specific. +print """ +#include "%s" +#include "%s" +#include "main/mfeatures.h" +#include "main/compiler.h" +#include "main/api_exec.h" + +#if FEATURE_%s +""" % (versionHeader, versionExtHeader, shortname.upper()) + +# Everyone needs these types. +print """ +/* These types are needed for the Mesa veneer, but are not defined in + * the standard GLES headers. + */ +typedef double GLdouble; +typedef double GLclampd; + +/* Mesa error handling requires these */ +extern void *_mesa_get_current_context(void); +extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); +""" + +# Finally we get to the all-important functions +print """/************************************************************* + * Generated functions begin here + */ +""" +for funcName in keys: + if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) + + # start figuring out what this function will look like. + returnType = apiutil.ReturnType(funcName) + props = apiutil.Properties(funcName) + params = apiutil.Parameters(funcName) + declarationString = apiutil.MakeDeclarationString(params) + + # In case of error, a function may have to return. Make + # sure we have valid return values in this case. + if returnType == "void": + errorReturn = "return" + elif returnType == "GLboolean": + errorReturn = "return GL_FALSE" + else: + errorReturn = "return (%s) 0" % returnType + + # These are the output of this large calculation block. + # passthroughDeclarationString: a typed set of parameters that + # will be used to create the "extern" reference for the + # underlying Mesa or support function. Note that as generated + # these have an extra ", " at the beginning, which will be + # removed before use. + # + # passthroughDeclarationString: an untyped list of parameters + # that will be used to call the underlying Mesa or support + # function (including references to converted parameters). + # This will also be generated with an extra ", " at the + # beginning, which will be removed before use. + # + # variables: C code to create any local variables determined to + # be necessary. + # conversionCodeOutgoing: C code to convert application parameters + # to a necessary type before calling the underlying support code. + # May be empty if no conversion is required. + # conversionCodeIncoming: C code to do the converse: convert + # values returned by underlying Mesa code to the types needed + # by the application. + # Note that *either* the conversionCodeIncoming will be used (for + # generated query functions), *or* the conversionCodeOutgoing will + # be used (for generated non-query functions), never both. + passthroughFuncName = "" + passthroughDeclarationString = "" + passthroughCallString = "" + prefixOverride = None + variables = [] + conversionCodeOutgoing = [] + conversionCodeIncoming = [] + switchCode = [] + + # Calculate the name of the underlying support function to call. + # By default, the passthrough function is named _mesa_. + # We're allowed to override the prefix and/or the function name + # for each function record, though. The "ConversionFunction" + # utility is poorly named, BTW... + if funcName in allSpecials: + # perform checks and pass through + funcPrefix = "_check_" + aliasprefix = "_es_" + else: + funcPrefix = "_es_" + aliasprefix = apiutil.AliasPrefix(funcName) + alias = apiutil.ConversionFunction(funcName) + prefixOverride = apiutil.FunctionPrefix(funcName) + if prefixOverride != "_mesa_": + aliasprefix = apiutil.FunctionPrefix(funcName) + if not alias: + # There may still be a Mesa alias for the function + if apiutil.Alias(funcName): + passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName)) + else: + passthroughFuncName = "%s%s" % (aliasprefix, funcName) + else: # a specific alias is provided + passthroughFuncName = "%s%s" % (aliasprefix, alias) + + # Look at every parameter: each one may have only specific + # allowed values, or dependent parameters to check, or + # variant-sized vector arrays to calculate + for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params: + # We'll need this below if we're doing conversions + (paramBaseType, paramTypeModifiers) = GetBaseType(paramType) + + # Conversion management. + # We'll handle three cases, easiest to hardest: a parameter + # that doesn't require conversion, a scalar parameter that + # requires conversion, and a vector parameter that requires + # conversion. + if paramConvertToType == None: + # Unconverted parameters are easy, whether they're vector + # or scalar - just add them to the call list. No conversions + # or anything to worry about. + passthroughDeclarationString += ", %s %s" % (paramType, paramName) + passthroughCallString += ", %s" % paramName + + elif paramMaxVecSize == 0: # a scalar parameter that needs conversion + # A scalar to hold a converted parameter + variables.append(" %s converted_%s;" % (paramConvertToType, paramName)) + + # Outgoing conversion depends on whether we have to conditionally + # perform value conversion. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + + # Note that there can be no incoming conversion for a + # scalar parameter; changing the scalar will only change + # the local value, and won't ultimately change anything + # that passes back to the application. + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + else: # a vector parameter that needs conversion + # We'll need an index variable for conversions + if " register unsigned int i;" not in variables: + variables.append(" register unsigned int i;") + + # This variable will hold the (possibly variant) size of + # this array needing conversion. By default, we'll set + # it to the maximal size (which is correct for functions + # with a constant-sized vector parameter); for true + # variant arrays, we'll modify it with other code. + variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize)) + + # This array will hold the actual converted values. + variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize)) + + # Again, we choose the conversion code based on whether we + # have to always convert values, never convert values, or + # conditionally convert values. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + + conversionCodeOutgoing.append(" }") + + # If instead we need an incoming conversion (i.e. results + # from Mesa have to be converted before handing back + # to the application), this is it. Fortunately, we don't + # have to worry about conditional value conversion - the + # functions that do (e.g. glGetFixedv()) are handled + # specially, outside this code generation. + # + # Whether we use incoming conversion or outgoing conversion + # is determined later - we only ever use one or the other. + + if paramValueConversion == "none": + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeIncoming.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName) + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" } else {") + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName)) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" }") + else: # paramValueConversion == "all" + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + # endif conversion management + + # Parameter checking. If the parameter has a specific list of + # valid values, we have to make sure that the passed-in values + # match these, or we make an error. + if len(paramValidValues) > 0: + # We're about to make a big switch statement with an + # error at the end. By default, the error is GL_INVALID_ENUM, + # unless we find a "case" statement in the middle with a + # non-GLenum value. + errorDefaultCase = "GL_INVALID_ENUM" + + # This parameter has specific valid values. Make a big + # switch statement to handle it. Note that the original + # parameters are always what is checked, not the + # converted parameters. + switchCode.append(" switch(%s) {" % paramName) + + for valueIndex in range(len(paramValidValues)): + (paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex] + + # We're going to need information on the dependent param + # as well. + if dependentParamName: + depParamIndex = apiutil.FindParamIndex(params, dependentParamName) + if depParamIndex == None: + sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName)) + + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex] + else: + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None) + + # This is a sneaky trick. It's valid syntax for a parameter + # that is *not* going to be converted to be declared + # with a dependent vector size; but in this case, the + # dependent vector size is unused and unnecessary. + # So check for this and ignore the dependent vector size + # if the parameter is not going to be converted. + if depParamConvertToType: + usedDependentVecSize = dependentVecSize + else: + usedDependentVecSize = None + + # We'll peek ahead at the next parameter, to see whether + # we can combine cases + if valueIndex + 1 < len(paramValidValues) : + (nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1] + if depParamConvertToType: + usedNextDependentVecSize = nextDependentVecSize + else: + usedNextDependentVecSize = None + + # Create a case for this value. As a mnemonic, + # if we have a dependent vector size that we're ignoring, + # add it as a comment. + if usedDependentVecSize == None and dependentVecSize != None: + switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize)) + else: + switchCode.append(" case %s:" % paramValue) + + # If this is not a GLenum case, then switch our error + # if no value is matched to be GL_INVALID_VALUE instead + # of GL_INVALID_ENUM. (Yes, this does get confused + # if there are both values and GLenums in the same + # switch statement, which shouldn't happen.) + if paramValue[0:3] != "GL_": + errorDefaultCase = "GL_INVALID_VALUE" + + # If all the remaining parameters are identical to the + # next set, then we're done - we'll just create the + # official code on the next pass through, and the two + # cases will share the code. + if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert: + continue + + # Otherwise, we'll have to generate code for this case. + # Start off with a check: if there is a dependent parameter, + # and a list of valid values for that parameter, we need + # to generate an error if something other than one + # of those values is passed. + if len(dependentValidValues) > 0: + conditional="" + + # If the parameter being checked is actually an array, + # check only its first element. + if depParamMaxVecSize == 0: + valueToCheck = dependentParamName + else: + valueToCheck = "%s[0]" % dependentParamName + + for v in dependentValidValues: + conditional += " && %s != %s" % (valueToCheck, v) + switchCode.append(" if (%s) {" % conditional[4:]) + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName)) + switchCode.append(" %s;" % errorReturn) + switchCode.append(" }") + # endif there are dependent valid values + + # The dependent parameter may require conditional + # value conversion. If it does, and we don't want + # to convert values, we'll have to generate code for that + if depParamValueConversion == "some" and valueConvert == "noconvert": + switchCode.append(" convert_%s_value = 0;" % dependentParamName) + + # If there's a dependent vector size for this parameter + # that we're actually going to use (i.e. we need conversion), + # mark it. + if usedDependentVecSize: + switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize)) + + # In all cases, break out of the switch if any valid + # value is found. + switchCode.append(" break;") + + + # Need a default case to catch all the other, invalid + # parameter values. These will all generate errors. + switchCode.append(" default:") + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + formatString = GetFormatString(paramType) + if formatString == None: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName)) + else: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName)) + switchCode.append(" %s;" % errorReturn) + + # End of our switch code. + switchCode.append(" }") + + # endfor every recognized parameter value + + # endfor every param + + # Here, the passthroughDeclarationString and passthroughCallString + # are complete; remove the extra ", " at the front of each. + passthroughDeclarationString = passthroughDeclarationString[2:] + passthroughCallString = passthroughCallString[2:] + if not passthroughDeclarationString: + passthroughDeclarationString = "void" + + # The Mesa functions are scattered across all the Mesa + # header files. The easiest way to manage declarations + # is to create them ourselves. + if funcName in allSpecials: + print "/* this function is special and is defined elsewhere */" + print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) + + # A function may be a core function (i.e. it exists in + # the core specification), a core addition (extension + # functions added officially to the core), a required + # extension (usually an extension for an earlier version + # that has been officially adopted), or an optional extension. + # + # Core functions have a simple category (e.g. "GLES1.1"); + # we generate only a simple callback for them. + # + # Core additions have two category listings, one simple + # and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]). + # We generate the core function, and also an extension function. + # + # Required extensions and implemented optional extensions + # have a single compound category "GLES1.1:OES_point_size_array". + # For these we generate just the extension function. + for categorySpec in apiutil.Categories(funcName): + compoundCategory = categorySpec.split(":") + + # This category isn't for us, if the base category doesn't match + # our version + if compoundCategory[0] != version: + continue + + # Otherwise, determine if we're writing code for a core + # function (no suffix) or an extension function. + if len(compoundCategory) == 1: + # This is a core function + extensionName = None + extensionSuffix = "" + else: + # This is an extension function. We'll need to append + # the extension suffix. + extensionName = compoundCategory[1] + extensionSuffix = extensionName.split("_")[0] + fullFuncName = funcPrefix + funcName + extensionSuffix + + # Now the generated function. The text used to mark an API-level + # function, oddly, is version-specific. + if extensionName: + print "/* Extension %s */" % extensionName + + if (not variables and + not switchCode and + not conversionCodeOutgoing and + not conversionCodeIncoming): + # pass through directly + print "#define %s %s" % (fullFuncName, passthroughFuncName) + print + continue + + print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString) + print "{" + + # Start printing our code pieces. Start with any local + # variables we need. This unusual syntax joins the + # lines in the variables[] array with the "\n" separator. + if len(variables) > 0: + print "\n".join(variables) + "\n" + + # If there's any sort of parameter checking or variable + # array sizing, the switch code will contain it. + if len(switchCode) > 0: + print "\n".join(switchCode) + "\n" + + # In the case of an outgoing conversion (i.e. parameters must + # be converted before calling the underlying Mesa function), + # use the appropriate code. + if "get" not in props and len(conversionCodeOutgoing) > 0: + print "\n".join(conversionCodeOutgoing) + "\n" + + # Call the Mesa function. Note that there are very few functions + # that return a value (i.e. returnType is not "void"), and that + # none of them require incoming translation; so we're safe + # to generate code that directly returns in those cases, + # even though it's not completely independent. + + if returnType == "void": + print " %s(%s);" % (passthroughFuncName, passthroughCallString) + else: + print " return %s(%s);" % (passthroughFuncName, passthroughCallString) + + # If the function is one that returns values (i.e. "get" in props), + # it might return values of a different type than we need, that + # require conversion before passing back to the application. + if "get" in props and len(conversionCodeIncoming) > 0: + print "\n".join(conversionCodeIncoming) + + # All done. + print "}" + print + # end for each category provided for a function + +# end for each function + +print """ +#include "glapi/glapi.h" + +#if FEATURE_remap_table + +/* cannot include main/dispatch.h here */ +#define _GLAPI_USE_REMAP_TABLE +#include "%sapi/main/glapidispatch.h" + +#define need_MESA_remap_table +#include "%sapi/main/remap_helper.h" + +/* force SET_* macros to use the local remap table */ +#define driDispatchRemapTable remap_table +static int remap_table[driDispatchRemapTable_size]; + +static void +init_remap_table(void) +{ + _glthread_DECLARE_STATIC_MUTEX(mutex); + static GLboolean initialized = GL_FALSE; + const struct gl_function_pool_remap *remap = MESA_remap_table_functions; + int i; + + _glthread_LOCK_MUTEX(mutex); + if (initialized) { + _glthread_UNLOCK_MUTEX(mutex); + return; + } + + for (i = 0; i < driDispatchRemapTable_size; i++) { + GLint offset; + const char *spec; + + /* sanity check */ + ASSERT(i == remap[i].remap_index); + spec = _mesa_function_pool + remap[i].pool_index; + + offset = _mesa_map_function_spec(spec); + remap_table[i] = offset; + } + initialized = GL_TRUE; + _glthread_UNLOCK_MUTEX(mutex); +} + +#else /* FEATURE_remap_table */ + +/* cannot include main/dispatch.h here */ +#include "%sapi/main/glapidispatch.h" + +static INLINE void +init_remap_table(void) +{ +} + +#endif /* FEATURE_remap_table */ + +struct _glapi_table * +_mesa_create_exec_table_%s(void) +{ + struct _glapi_table *exec; + + exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (exec == NULL) + return NULL; + + init_remap_table(); +""" % (shortname, shortname, shortname, shortname) + +for func in keys: + prefix = "_es_" if func not in allSpecials else "_check_" + for spec in apiutil.Categories(func): + ext = spec.split(":") + # version does not match + if ext.pop(0) != version: + continue + entry = func + if ext: + suffix = ext[0].split("_")[0] + entry += suffix + print " SET_%s(exec, %s%s);" % (entry, prefix, entry) +print "" +print " return exec;" +print "}" + +print """ +#endif /* FEATURE_%s */""" % (shortname.upper()) diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c index bd2e1177f..d7666a630 100644 --- a/mesalib/src/mesa/main/eval.c +++ b/mesalib/src/mesa/main/eval.c @@ -1,1001 +1,1001 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * eval.c was written by - * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and - * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). - * - * My original implementation of evaluators was simplistic and didn't - * compute surface normal vectors properly. Bernd and Volker applied - * used more sophisticated methods to get better results. - * - * Thanks guys! - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "context.h" -#include "eval.h" -#include "macros.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_evaluators - - -/* - * Return the number of components per control point for any type of - * evaluator. Return 0 if bad target. - * See table 5.1 in the OpenGL 1.2 spec. - */ -GLuint _mesa_evaluator_components( GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: return 3; - case GL_MAP1_VERTEX_4: return 4; - case GL_MAP1_INDEX: return 1; - case GL_MAP1_COLOR_4: return 4; - case GL_MAP1_NORMAL: return 3; - case GL_MAP1_TEXTURE_COORD_1: return 1; - case GL_MAP1_TEXTURE_COORD_2: return 2; - case GL_MAP1_TEXTURE_COORD_3: return 3; - case GL_MAP1_TEXTURE_COORD_4: return 4; - case GL_MAP2_VERTEX_3: return 3; - case GL_MAP2_VERTEX_4: return 4; - case GL_MAP2_INDEX: return 1; - case GL_MAP2_COLOR_4: return 4; - case GL_MAP2_NORMAL: return 3; - case GL_MAP2_TEXTURE_COORD_1: return 1; - case GL_MAP2_TEXTURE_COORD_2: return 2; - case GL_MAP2_TEXTURE_COORD_3: return 3; - case GL_MAP2_TEXTURE_COORD_4: return 4; - default: break; - } - - /* XXX need to check for the vertex program extension - if (!ctx->Extensions.NV_vertex_program) - return 0; - */ - - if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) - return 4; - - if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) - return 4; - - return 0; -} - - -/* - * Return pointer to the gl_1d_map struct for the named target. - */ -static struct gl_1d_map * -get_1d_map( GLcontext *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: - return &ctx->EvalMap.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return &ctx->EvalMap.Map1Vertex4; - case GL_MAP1_INDEX: - return &ctx->EvalMap.Map1Index; - case GL_MAP1_COLOR_4: - return &ctx->EvalMap.Map1Color4; - case GL_MAP1_NORMAL: - return &ctx->EvalMap.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return &ctx->EvalMap.Map1Texture1; - case GL_MAP1_TEXTURE_COORD_2: - return &ctx->EvalMap.Map1Texture2; - case GL_MAP1_TEXTURE_COORD_3: - return &ctx->EvalMap.Map1Texture3; - case GL_MAP1_TEXTURE_COORD_4: - return &ctx->EvalMap.Map1Texture4; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; - default: - return NULL; - } -} - - -/* - * Return pointer to the gl_2d_map struct for the named target. - */ -static struct gl_2d_map * -get_2d_map( GLcontext *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP2_VERTEX_3: - return &ctx->EvalMap.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return &ctx->EvalMap.Map2Vertex4; - case GL_MAP2_INDEX: - return &ctx->EvalMap.Map2Index; - case GL_MAP2_COLOR_4: - return &ctx->EvalMap.Map2Color4; - case GL_MAP2_NORMAL: - return &ctx->EvalMap.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return &ctx->EvalMap.Map2Texture1; - case GL_MAP2_TEXTURE_COORD_2: - return &ctx->EvalMap.Map2Texture2; - case GL_MAP2_TEXTURE_COORD_3: - return &ctx->EvalMap.Map2Texture3; - case GL_MAP2_TEXTURE_COORD_4: - return &ctx->EvalMap.Map2Texture4; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; - default: - return NULL; - } -} - - -/**********************************************************************/ -/*** Copy and deallocate control points ***/ -/**********************************************************************/ - - -/* - * Copy 1-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * \param see glMap1f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = points[k]; - - return buffer; -} - - - -/* - * Same as above but convert doubles to floats. - */ -GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, - const GLdouble *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = (GLfloat) points[k]; - - return buffer; -} - - - -/* - * Copy 2-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * Additional memory is allocated to be used by the horner and - * de Casteljau evaluation schemes. - * - * \param see glMap2f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, j, k, size, dsize, hsize; - GLint uinc; - - size = _mesa_evaluator_components(target); - - if (!points || size==0) { - return NULL; - } - - /* max(uorder, vorder) additional points are used in */ - /* horner evaluation and uorder*vorder additional */ - /* values are needed for de Casteljau */ - dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; - hsize = (uorder > vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); - return; - } - if (!points) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k == 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); - return; - } - - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - - map = get_1d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Order = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - - -static void GLAPIENTRY -_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points ) -{ - map1(target, u1, u2, stride, order, points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble *points ) -{ - map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); -} - - -static void -map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLvoid *points, GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint k; - GLfloat *pnts; - struct gl_2d_map *map = NULL; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - ASSERT(type == GL_FLOAT || type == GL_DOUBLE); - - if (u1==u2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); - return; - } - - if (v1==v2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); - return; - } - - if (uorder<1 || uorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); - return; - } - - if (vorder<1 || vorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k==0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); - return; - } - if (vstride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); - return; - } - - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - - map = get_2d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Uorder = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - map->Vorder = vorder; - map->v1 = v1; - map->v2 = v2; - map->dv = 1.0F / (v2 - v1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - -static void GLAPIENTRY -_mesa_Map2f( GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points) -{ - map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, - points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map2d( GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble *points ) -{ - map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, - (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); -} - - - -static void GLAPIENTRY -_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = (GLdouble) map2d->Uorder; - v[1] = (GLdouble) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = (GLdouble) map1d->u1; - v[1] = (GLdouble) map1d->u2; - } - else { - v[0] = (GLdouble) map2d->u1; - v[1] = (GLdouble) map2d->u2; - v[2] = (GLdouble) map2d->v1; - v[3] = (GLdouble) map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); - } -} - - -static void GLAPIENTRY -_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = (GLfloat) map2d->Uorder; - v[1] = (GLfloat) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = map1d->u1; - v[1] = map1d->u2; - } - else { - v[0] = map2d->u1; - v[1] = map2d->u2; - v[2] = map2d->v1; - v[3] = map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); - } -} - - -static void GLAPIENTRY -_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLuint i, n; - GLfloat *data; - GLuint comps; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - for (i=0;iOrder; - } - else { - v[0] = map2d->Uorder; - v[1] = map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - v[0] = IROUND(map1d->u1); - v[1] = IROUND(map1d->u2); - } - else { - v[0] = IROUND(map2d->u1); - v[1] = IROUND(map2d->u2); - v[2] = IROUND(map2d->v1); - v[3] = IROUND(map2d->v2); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); - } -} - - - -static void GLAPIENTRY -_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); - return; - } - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid1un = un; - ctx->Eval.MapGrid1u1 = u1; - ctx->Eval.MapGrid1u2 = u2; - ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; -} - - -static void GLAPIENTRY -_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) -{ - _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); -} - - -static void GLAPIENTRY -_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); - return; - } - if (vn<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid2un = un; - ctx->Eval.MapGrid2u1 = u1; - ctx->Eval.MapGrid2u2 = u2; - ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; - ctx->Eval.MapGrid2vn = vn; - ctx->Eval.MapGrid2v1 = v1; - ctx->Eval.MapGrid2v2 = v2; - ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; -} - - -static void GLAPIENTRY -_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2 ) -{ - _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2 ); -} - - -void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_EvalCoord1f(disp, vfmt->EvalCoord1f); - SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); - SET_EvalCoord2f(disp, vfmt->EvalCoord2f); - SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); - SET_EvalPoint1(disp, vfmt->EvalPoint1); - SET_EvalPoint2(disp, vfmt->EvalPoint2); - - SET_EvalMesh1(disp, vfmt->EvalMesh1); - SET_EvalMesh2(disp, vfmt->EvalMesh2); -} - - -void -_mesa_init_eval_dispatch(struct _glapi_table *disp) -{ - SET_GetMapdv(disp, _mesa_GetMapdv); - SET_GetMapfv(disp, _mesa_GetMapfv); - SET_GetMapiv(disp, _mesa_GetMapiv); - SET_Map1d(disp, _mesa_Map1d); - SET_Map1f(disp, _mesa_Map1f); - SET_Map2d(disp, _mesa_Map2d); - SET_Map2f(disp, _mesa_Map2f); - SET_MapGrid1d(disp, _mesa_MapGrid1d); - SET_MapGrid1f(disp, _mesa_MapGrid1f); - SET_MapGrid2d(disp, _mesa_MapGrid2d); - SET_MapGrid2f(disp, _mesa_MapGrid2f); -} - - -#endif /* FEATURE_evaluators */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Initialize a 1-D evaluator map. - */ -static void -init_1d_map( struct gl_1d_map *map, int n, const float *initial ) -{ - map->Order = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -/** - * Initialize a 2-D evaluator map - */ -static void -init_2d_map( struct gl_2d_map *map, int n, const float *initial ) -{ - map->Uorder = 1; - map->Vorder = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->v1 = 0.0; - map->v2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -void _mesa_init_eval( GLcontext *ctx ) -{ - int i; - - /* Evaluators group */ - ctx->Eval.Map1Color4 = GL_FALSE; - ctx->Eval.Map1Index = GL_FALSE; - ctx->Eval.Map1Normal = GL_FALSE; - ctx->Eval.Map1TextureCoord1 = GL_FALSE; - ctx->Eval.Map1TextureCoord2 = GL_FALSE; - ctx->Eval.Map1TextureCoord3 = GL_FALSE; - ctx->Eval.Map1TextureCoord4 = GL_FALSE; - ctx->Eval.Map1Vertex3 = GL_FALSE; - ctx->Eval.Map1Vertex4 = GL_FALSE; - memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); - ctx->Eval.Map2Color4 = GL_FALSE; - ctx->Eval.Map2Index = GL_FALSE; - ctx->Eval.Map2Normal = GL_FALSE; - ctx->Eval.Map2TextureCoord1 = GL_FALSE; - ctx->Eval.Map2TextureCoord2 = GL_FALSE; - ctx->Eval.Map2TextureCoord3 = GL_FALSE; - ctx->Eval.Map2TextureCoord4 = GL_FALSE; - ctx->Eval.Map2Vertex3 = GL_FALSE; - ctx->Eval.Map2Vertex4 = GL_FALSE; - memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); - ctx->Eval.AutoNormal = GL_FALSE; - ctx->Eval.MapGrid1un = 1; - ctx->Eval.MapGrid1u1 = 0.0; - ctx->Eval.MapGrid1u2 = 1.0; - ctx->Eval.MapGrid2un = 1; - ctx->Eval.MapGrid2vn = 1; - ctx->Eval.MapGrid2u1 = 0.0; - ctx->Eval.MapGrid2u2 = 1.0; - ctx->Eval.MapGrid2v1 = 0.0; - ctx->Eval.MapGrid2v2 = 1.0; - - /* Evaluator data */ - { - static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; - static GLfloat index[1] = { 1.0 }; - static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; - static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; - - init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); - init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); - init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); - init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); - init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); - init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); - - init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); - init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); - init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); - init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); - init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); - init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); - } -} - - -void _mesa_free_eval_data( GLcontext *ctx ) -{ - int i; - - /* Free evaluator data */ - if (ctx->EvalMap.Map1Vertex3.Points) - FREE( ctx->EvalMap.Map1Vertex3.Points ); - if (ctx->EvalMap.Map1Vertex4.Points) - FREE( ctx->EvalMap.Map1Vertex4.Points ); - if (ctx->EvalMap.Map1Index.Points) - FREE( ctx->EvalMap.Map1Index.Points ); - if (ctx->EvalMap.Map1Color4.Points) - FREE( ctx->EvalMap.Map1Color4.Points ); - if (ctx->EvalMap.Map1Normal.Points) - FREE( ctx->EvalMap.Map1Normal.Points ); - if (ctx->EvalMap.Map1Texture1.Points) - FREE( ctx->EvalMap.Map1Texture1.Points ); - if (ctx->EvalMap.Map1Texture2.Points) - FREE( ctx->EvalMap.Map1Texture2.Points ); - if (ctx->EvalMap.Map1Texture3.Points) - FREE( ctx->EvalMap.Map1Texture3.Points ); - if (ctx->EvalMap.Map1Texture4.Points) - FREE( ctx->EvalMap.Map1Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map1Attrib[i].Points)); - - if (ctx->EvalMap.Map2Vertex3.Points) - FREE( ctx->EvalMap.Map2Vertex3.Points ); - if (ctx->EvalMap.Map2Vertex4.Points) - FREE( ctx->EvalMap.Map2Vertex4.Points ); - if (ctx->EvalMap.Map2Index.Points) - FREE( ctx->EvalMap.Map2Index.Points ); - if (ctx->EvalMap.Map2Color4.Points) - FREE( ctx->EvalMap.Map2Color4.Points ); - if (ctx->EvalMap.Map2Normal.Points) - FREE( ctx->EvalMap.Map2Normal.Points ); - if (ctx->EvalMap.Map2Texture1.Points) - FREE( ctx->EvalMap.Map2Texture1.Points ); - if (ctx->EvalMap.Map2Texture2.Points) - FREE( ctx->EvalMap.Map2Texture2.Points ); - if (ctx->EvalMap.Map2Texture3.Points) - FREE( ctx->EvalMap.Map2Texture3.Points ); - if (ctx->EvalMap.Map2Texture4.Points) - FREE( ctx->EvalMap.Map2Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map2Attrib[i].Points)); -} + +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* + * eval.c was written by + * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and + * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). + * + * My original implementation of evaluators was simplistic and didn't + * compute surface normal vectors properly. Bernd and Volker applied + * used more sophisticated methods to get better results. + * + * Thanks guys! + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "context.h" +#include "eval.h" +#include "macros.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_evaluators + + +/* + * Return the number of components per control point for any type of + * evaluator. Return 0 if bad target. + * See table 5.1 in the OpenGL 1.2 spec. + */ +GLuint _mesa_evaluator_components( GLenum target ) +{ + switch (target) { + case GL_MAP1_VERTEX_3: return 3; + case GL_MAP1_VERTEX_4: return 4; + case GL_MAP1_INDEX: return 1; + case GL_MAP1_COLOR_4: return 4; + case GL_MAP1_NORMAL: return 3; + case GL_MAP1_TEXTURE_COORD_1: return 1; + case GL_MAP1_TEXTURE_COORD_2: return 2; + case GL_MAP1_TEXTURE_COORD_3: return 3; + case GL_MAP1_TEXTURE_COORD_4: return 4; + case GL_MAP2_VERTEX_3: return 3; + case GL_MAP2_VERTEX_4: return 4; + case GL_MAP2_INDEX: return 1; + case GL_MAP2_COLOR_4: return 4; + case GL_MAP2_NORMAL: return 3; + case GL_MAP2_TEXTURE_COORD_1: return 1; + case GL_MAP2_TEXTURE_COORD_2: return 2; + case GL_MAP2_TEXTURE_COORD_3: return 3; + case GL_MAP2_TEXTURE_COORD_4: return 4; + default: break; + } + + /* XXX need to check for the vertex program extension + if (!ctx->Extensions.NV_vertex_program) + return 0; + */ + + if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) + return 4; + + if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) + return 4; + + return 0; +} + + +/* + * Return pointer to the gl_1d_map struct for the named target. + */ +static struct gl_1d_map * +get_1d_map( struct gl_context *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP1_VERTEX_3: + return &ctx->EvalMap.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return &ctx->EvalMap.Map1Vertex4; + case GL_MAP1_INDEX: + return &ctx->EvalMap.Map1Index; + case GL_MAP1_COLOR_4: + return &ctx->EvalMap.Map1Color4; + case GL_MAP1_NORMAL: + return &ctx->EvalMap.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return &ctx->EvalMap.Map1Texture1; + case GL_MAP1_TEXTURE_COORD_2: + return &ctx->EvalMap.Map1Texture2; + case GL_MAP1_TEXTURE_COORD_3: + return &ctx->EvalMap.Map1Texture3; + case GL_MAP1_TEXTURE_COORD_4: + return &ctx->EvalMap.Map1Texture4; + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; + } +} + + +/* + * Return pointer to the gl_2d_map struct for the named target. + */ +static struct gl_2d_map * +get_2d_map( struct gl_context *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP2_VERTEX_3: + return &ctx->EvalMap.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return &ctx->EvalMap.Map2Vertex4; + case GL_MAP2_INDEX: + return &ctx->EvalMap.Map2Index; + case GL_MAP2_COLOR_4: + return &ctx->EvalMap.Map2Color4; + case GL_MAP2_NORMAL: + return &ctx->EvalMap.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return &ctx->EvalMap.Map2Texture1; + case GL_MAP2_TEXTURE_COORD_2: + return &ctx->EvalMap.Map2Texture2; + case GL_MAP2_TEXTURE_COORD_3: + return &ctx->EvalMap.Map2Texture3; + case GL_MAP2_TEXTURE_COORD_4: + return &ctx->EvalMap.Map2Texture4; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; + } +} + + +/**********************************************************************/ +/*** Copy and deallocate control points ***/ +/**********************************************************************/ + + +/* + * Copy 1-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * \param see glMap1f for details + * \return pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, + const GLfloat *points ) +{ + GLfloat *buffer, *p; + GLint i, k, size = _mesa_evaluator_components(target); + + if (!points || !size) + return NULL; + + buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = points[k]; + + return buffer; +} + + + +/* + * Same as above but convert doubles to floats. + */ +GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, + const GLdouble *points ) +{ + GLfloat *buffer, *p; + GLint i, k, size = _mesa_evaluator_components(target); + + if (!points || !size) + return NULL; + + buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = (GLfloat) points[k]; + + return buffer; +} + + + +/* + * Copy 2-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * Additional memory is allocated to be used by the horner and + * de Casteljau evaluation schemes. + * + * \param see glMap2f for details + * \return pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +GLfloat *_mesa_copy_map_points2f( GLenum target, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, + const GLfloat *points ) +{ + GLfloat *buffer, *p; + GLint i, j, k, size, dsize, hsize; + GLint uinc; + + size = _mesa_evaluator_components(target); + + if (!points || size==0) { + return NULL; + } + + /* max(uorder, vorder) additional points are used in */ + /* horner evaluation and uorder*vorder additional */ + /* values are needed for de Casteljau */ + dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; + hsize = (uorder > vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; i vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; i MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); + return; + } + if (!points) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); + return; + } + + k = _mesa_evaluator_components( target ); + if (k == 0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + } + + if (ustride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); + return; + } + + if (ctx->Texture.CurrentUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); + return; + } + + map = get_1d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); + else + pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); + + + FLUSH_VERTICES(ctx, _NEW_EVAL); + map->Order = uorder; + map->u1 = u1; + map->u2 = u2; + map->du = 1.0F / (u2 - u1); + if (map->Points) + FREE( map->Points ); + map->Points = pnts; +} + + + +static void GLAPIENTRY +_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points ) +{ + map1(target, u1, u2, stride, order, points, GL_FLOAT); +} + + +static void GLAPIENTRY +_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points ) +{ + map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); +} + + +static void +map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLvoid *points, GLenum type ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint k; + GLfloat *pnts; + struct gl_2d_map *map = NULL; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + ASSERT(type == GL_FLOAT || type == GL_DOUBLE); + + if (u1==u2) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); + return; + } + + if (v1==v2) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); + return; + } + + if (uorder<1 || uorder>MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); + return; + } + + if (vorder<1 || vorder>MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); + return; + } + + k = _mesa_evaluator_components( target ); + if (k==0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + } + + if (ustride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); + return; + } + if (vstride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); + return; + } + + if (ctx->Texture.CurrentUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); + return; + } + + map = get_2d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _mesa_copy_map_points2f(target, ustride, uorder, + vstride, vorder, (GLfloat*) points); + else + pnts = _mesa_copy_map_points2d(target, ustride, uorder, + vstride, vorder, (GLdouble*) points); + + + FLUSH_VERTICES(ctx, _NEW_EVAL); + map->Uorder = uorder; + map->u1 = u1; + map->u2 = u2; + map->du = 1.0F / (u2 - u1); + map->Vorder = vorder; + map->v1 = v1; + map->v2 = v2; + map->dv = 1.0F / (v2 - v1); + if (map->Points) + FREE( map->Points ); + map->Points = pnts; +} + + +static void GLAPIENTRY +_mesa_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points) +{ + map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, + points, GL_FLOAT); +} + + +static void GLAPIENTRY +_mesa_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) +{ + map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, + (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); +} + + + +static void GLAPIENTRY +_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLint i, n; + GLfloat *data; + GLuint comps; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + for (i=0;iOrder; + } + else { + v[0] = (GLdouble) map2d->Uorder; + v[1] = (GLdouble) map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + v[0] = (GLdouble) map1d->u1; + v[1] = (GLdouble) map1d->u2; + } + else { + v[0] = (GLdouble) map2d->u1; + v[1] = (GLdouble) map2d->u2; + v[2] = (GLdouble) map2d->v1; + v[3] = (GLdouble) map2d->v2; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); + } +} + + +static void GLAPIENTRY +_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLint i, n; + GLfloat *data; + GLuint comps; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + for (i=0;iOrder; + } + else { + v[0] = (GLfloat) map2d->Uorder; + v[1] = (GLfloat) map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + v[0] = map1d->u1; + v[1] = map1d->u2; + } + else { + v[0] = map2d->u1; + v[1] = map2d->u2; + v[2] = map2d->v1; + v[3] = map2d->v2; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); + } +} + + +static void GLAPIENTRY +_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLuint i, n; + GLfloat *data; + GLuint comps; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + for (i=0;iOrder; + } + else { + v[0] = map2d->Uorder; + v[1] = map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + v[0] = IROUND(map1d->u1); + v[1] = IROUND(map1d->u2); + } + else { + v[0] = IROUND(map2d->u1); + v[1] = IROUND(map2d->u2); + v[2] = IROUND(map2d->v1); + v[3] = IROUND(map2d->v2); + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); + } +} + + + +static void GLAPIENTRY +_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (un<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); + return; + } + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.MapGrid1un = un; + ctx->Eval.MapGrid1u1 = u1; + ctx->Eval.MapGrid1u2 = u2; + ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; +} + + +static void GLAPIENTRY +_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) +{ + _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); +} + + +static void GLAPIENTRY +_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (un<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); + return; + } + if (vn<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); + return; + } + + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.MapGrid2un = un; + ctx->Eval.MapGrid2u1 = u1; + ctx->Eval.MapGrid2u2 = u2; + ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; + ctx->Eval.MapGrid2vn = vn; + ctx->Eval.MapGrid2v1 = v1; + ctx->Eval.MapGrid2v2 = v2; + ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; +} + + +static void GLAPIENTRY +_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ) +{ + _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2 ); +} + + +void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_EvalCoord1f(disp, vfmt->EvalCoord1f); + SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); + SET_EvalCoord2f(disp, vfmt->EvalCoord2f); + SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); + SET_EvalPoint1(disp, vfmt->EvalPoint1); + SET_EvalPoint2(disp, vfmt->EvalPoint2); + + SET_EvalMesh1(disp, vfmt->EvalMesh1); + SET_EvalMesh2(disp, vfmt->EvalMesh2); +} + + +void +_mesa_init_eval_dispatch(struct _glapi_table *disp) +{ + SET_GetMapdv(disp, _mesa_GetMapdv); + SET_GetMapfv(disp, _mesa_GetMapfv); + SET_GetMapiv(disp, _mesa_GetMapiv); + SET_Map1d(disp, _mesa_Map1d); + SET_Map1f(disp, _mesa_Map1f); + SET_Map2d(disp, _mesa_Map2d); + SET_Map2f(disp, _mesa_Map2f); + SET_MapGrid1d(disp, _mesa_MapGrid1d); + SET_MapGrid1f(disp, _mesa_MapGrid1f); + SET_MapGrid2d(disp, _mesa_MapGrid2d); + SET_MapGrid2f(disp, _mesa_MapGrid2f); +} + + +#endif /* FEATURE_evaluators */ + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +/** + * Initialize a 1-D evaluator map. + */ +static void +init_1d_map( struct gl_1d_map *map, int n, const float *initial ) +{ + map->Order = 1; + map->u1 = 0.0; + map->u2 = 1.0; + map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); + if (map->Points) { + GLint i; + for (i=0;iPoints[i] = initial[i]; + } +} + + +/** + * Initialize a 2-D evaluator map + */ +static void +init_2d_map( struct gl_2d_map *map, int n, const float *initial ) +{ + map->Uorder = 1; + map->Vorder = 1; + map->u1 = 0.0; + map->u2 = 1.0; + map->v1 = 0.0; + map->v2 = 1.0; + map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); + if (map->Points) { + GLint i; + for (i=0;iPoints[i] = initial[i]; + } +} + + +void _mesa_init_eval( struct gl_context *ctx ) +{ + int i; + + /* Evaluators group */ + ctx->Eval.Map1Color4 = GL_FALSE; + ctx->Eval.Map1Index = GL_FALSE; + ctx->Eval.Map1Normal = GL_FALSE; + ctx->Eval.Map1TextureCoord1 = GL_FALSE; + ctx->Eval.Map1TextureCoord2 = GL_FALSE; + ctx->Eval.Map1TextureCoord3 = GL_FALSE; + ctx->Eval.Map1TextureCoord4 = GL_FALSE; + ctx->Eval.Map1Vertex3 = GL_FALSE; + ctx->Eval.Map1Vertex4 = GL_FALSE; + memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); + ctx->Eval.Map2Color4 = GL_FALSE; + ctx->Eval.Map2Index = GL_FALSE; + ctx->Eval.Map2Normal = GL_FALSE; + ctx->Eval.Map2TextureCoord1 = GL_FALSE; + ctx->Eval.Map2TextureCoord2 = GL_FALSE; + ctx->Eval.Map2TextureCoord3 = GL_FALSE; + ctx->Eval.Map2TextureCoord4 = GL_FALSE; + ctx->Eval.Map2Vertex3 = GL_FALSE; + ctx->Eval.Map2Vertex4 = GL_FALSE; + memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); + ctx->Eval.AutoNormal = GL_FALSE; + ctx->Eval.MapGrid1un = 1; + ctx->Eval.MapGrid1u1 = 0.0; + ctx->Eval.MapGrid1u2 = 1.0; + ctx->Eval.MapGrid2un = 1; + ctx->Eval.MapGrid2vn = 1; + ctx->Eval.MapGrid2u1 = 0.0; + ctx->Eval.MapGrid2u2 = 1.0; + ctx->Eval.MapGrid2v1 = 0.0; + ctx->Eval.MapGrid2v2 = 1.0; + + /* Evaluator data */ + { + static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; + static GLfloat index[1] = { 1.0 }; + static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; + static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; + + init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); + init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); + init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); + init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); + init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); + init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); + + init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); + init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); + init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); + init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); + init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); + init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); + } +} + + +void _mesa_free_eval_data( struct gl_context *ctx ) +{ + int i; + + /* Free evaluator data */ + if (ctx->EvalMap.Map1Vertex3.Points) + FREE( ctx->EvalMap.Map1Vertex3.Points ); + if (ctx->EvalMap.Map1Vertex4.Points) + FREE( ctx->EvalMap.Map1Vertex4.Points ); + if (ctx->EvalMap.Map1Index.Points) + FREE( ctx->EvalMap.Map1Index.Points ); + if (ctx->EvalMap.Map1Color4.Points) + FREE( ctx->EvalMap.Map1Color4.Points ); + if (ctx->EvalMap.Map1Normal.Points) + FREE( ctx->EvalMap.Map1Normal.Points ); + if (ctx->EvalMap.Map1Texture1.Points) + FREE( ctx->EvalMap.Map1Texture1.Points ); + if (ctx->EvalMap.Map1Texture2.Points) + FREE( ctx->EvalMap.Map1Texture2.Points ); + if (ctx->EvalMap.Map1Texture3.Points) + FREE( ctx->EvalMap.Map1Texture3.Points ); + if (ctx->EvalMap.Map1Texture4.Points) + FREE( ctx->EvalMap.Map1Texture4.Points ); + for (i = 0; i < 16; i++) + FREE((ctx->EvalMap.Map1Attrib[i].Points)); + + if (ctx->EvalMap.Map2Vertex3.Points) + FREE( ctx->EvalMap.Map2Vertex3.Points ); + if (ctx->EvalMap.Map2Vertex4.Points) + FREE( ctx->EvalMap.Map2Vertex4.Points ); + if (ctx->EvalMap.Map2Index.Points) + FREE( ctx->EvalMap.Map2Index.Points ); + if (ctx->EvalMap.Map2Color4.Points) + FREE( ctx->EvalMap.Map2Color4.Points ); + if (ctx->EvalMap.Map2Normal.Points) + FREE( ctx->EvalMap.Map2Normal.Points ); + if (ctx->EvalMap.Map2Texture1.Points) + FREE( ctx->EvalMap.Map2Texture1.Points ); + if (ctx->EvalMap.Map2Texture2.Points) + FREE( ctx->EvalMap.Map2Texture2.Points ); + if (ctx->EvalMap.Map2Texture3.Points) + FREE( ctx->EvalMap.Map2Texture3.Points ); + if (ctx->EvalMap.Map2Texture4.Points) + FREE( ctx->EvalMap.Map2Texture4.Points ); + for (i = 0; i < 16; i++) + FREE((ctx->EvalMap.Map2Attrib[i].Points)); +} diff --git a/mesalib/src/mesa/main/eval.h b/mesalib/src/mesa/main/eval.h index ffd1bab76..b92e41e9f 100644 --- a/mesalib/src/mesa/main/eval.h +++ b/mesalib/src/mesa/main/eval.h @@ -1,110 +1,110 @@ -/** - * \file eval.h - * Eval operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef EVAL_H -#define EVAL_H - - -#include "main/mtypes.h" - - -#if FEATURE_evaluators - -#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) \ - do { \ - (vfmt)->EvalCoord1f = impl ## EvalCoord1f; \ - (vfmt)->EvalCoord1fv = impl ## EvalCoord1fv; \ - (vfmt)->EvalCoord2f = impl ## EvalCoord2f; \ - (vfmt)->EvalCoord2fv = impl ## EvalCoord2fv; \ - (vfmt)->EvalPoint1 = impl ## EvalPoint1; \ - (vfmt)->EvalPoint2 = impl ## EvalPoint2; \ - (vfmt)->EvalMesh1 = impl ## EvalMesh1; \ - (vfmt)->EvalMesh2 = impl ## EvalMesh2; \ - } while (0) - -extern GLuint _mesa_evaluator_components( GLenum target ); - - -extern void gl_free_control_points( GLcontext *ctx, - GLenum target, GLfloat *data ); - - -extern GLfloat *_mesa_copy_map_points1f( GLenum target, - GLint ustride, GLint uorder, - const GLfloat *points ); - -extern GLfloat *_mesa_copy_map_points1d( GLenum target, - GLint ustride, GLint uorder, - const GLdouble *points ); - -extern GLfloat *_mesa_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ); - -extern GLfloat *_mesa_copy_map_points2d(GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLdouble *points ); - -extern void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt); - -extern void -_mesa_init_eval_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_evaluators */ - -#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) do { } while (0) - -static INLINE void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ -} - -static INLINE void -_mesa_init_eval_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_evaluators */ - -extern void _mesa_init_eval( GLcontext *ctx ); -extern void _mesa_free_eval_data( GLcontext *ctx ); - - -#endif /* EVAL_H */ +/** + * \file eval.h + * Eval operations. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef EVAL_H +#define EVAL_H + + +#include "main/mtypes.h" + + +#if FEATURE_evaluators + +#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->EvalCoord1f = impl ## EvalCoord1f; \ + (vfmt)->EvalCoord1fv = impl ## EvalCoord1fv; \ + (vfmt)->EvalCoord2f = impl ## EvalCoord2f; \ + (vfmt)->EvalCoord2fv = impl ## EvalCoord2fv; \ + (vfmt)->EvalPoint1 = impl ## EvalPoint1; \ + (vfmt)->EvalPoint2 = impl ## EvalPoint2; \ + (vfmt)->EvalMesh1 = impl ## EvalMesh1; \ + (vfmt)->EvalMesh2 = impl ## EvalMesh2; \ + } while (0) + +extern GLuint _mesa_evaluator_components( GLenum target ); + + +extern void gl_free_control_points( struct gl_context *ctx, + GLenum target, GLfloat *data ); + + +extern GLfloat *_mesa_copy_map_points1f( GLenum target, + GLint ustride, GLint uorder, + const GLfloat *points ); + +extern GLfloat *_mesa_copy_map_points1d( GLenum target, + GLint ustride, GLint uorder, + const GLdouble *points ); + +extern GLfloat *_mesa_copy_map_points2f( GLenum target, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, + const GLfloat *points ); + +extern GLfloat *_mesa_copy_map_points2d(GLenum target, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, + const GLdouble *points ); + +extern void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); + +extern void +_mesa_init_eval_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_evaluators */ + +#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) do { } while (0) + +static INLINE void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} + +static INLINE void +_mesa_init_eval_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_evaluators */ + +extern void _mesa_init_eval( struct gl_context *ctx ); +extern void _mesa_free_eval_data( struct gl_context *ctx ); + + +#endif /* EVAL_H */ diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 080fa98df..81978b3c1 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -1,989 +1,987 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "extensions.h" -#include "mtypes.h" - - -#define F(x) offsetof(struct gl_extensions, x) -#define ON GL_TRUE -#define OFF GL_FALSE - - -/* - * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. - */ -static const struct { - GLboolean enabled; - const char *name; - int flag_offset; -} default_extensions[] = { - { OFF, "GL_ARB_blend_func_extended", F(ARB_blend_func_extended) }, - { OFF, "GL_ARB_copy_buffer", F(ARB_copy_buffer) }, - { OFF, "GL_ARB_depth_buffer_float", F(ARB_depth_buffer_float) }, - { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, - { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, - { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, - { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, - { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) }, - { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, - { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, - { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, - { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, - { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, - { OFF, "GL_ARB_explicit_attrib_location", F(ARB_explicit_attrib_location) }, - /* TODO: reenable this when the new GLSL compiler actually supports them */ - /* { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, */ - { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, - { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) }, - { OFF, "GL_ARB_imaging", F(ARB_imaging) }, - { OFF, "GL_ARB_instanced_arrays", F(ARB_instanced_arrays) }, - { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, - { ON, "GL_ARB_multisample", F(ARB_multisample) }, - { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, - { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) }, - { OFF, "GL_ARB_occlusion_query2", F(ARB_occlusion_query2) }, - { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) }, - { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) }, - { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) }, - { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) }, - { OFF, "GL_ARB_sampler_objects", F(ARB_sampler_objects) }, - { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) }, - { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) }, - { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, - { OFF, "GL_ARB_shadow", F(ARB_shadow) }, - { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, - { OFF, "GL_ARB_sync", F(ARB_sync) }, - { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, - { OFF, "GL_ARB_texture_buffer_object", F(ARB_texture_buffer_object) }, - { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) }, - { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, - { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, - { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) }, - { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) }, - { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) }, - { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) }, - { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, - { OFF, "GL_ARB_texture_multisample", F(ARB_texture_multisample) }, - { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, - { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, - { OFF, "GL_ARB_texture_rg", F(ARB_texture_rg) }, - { OFF, "GL_ARB_texture_rgb10_a2ui", F(ARB_texture_rgb10_a2ui) }, - { OFF, "GL_ARB_texture_swizzle", F(EXT_texture_swizzle) }, - { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, - { OFF, "GL_ARB_transform_feedback2", F(ARB_transform_feedback2) }, - { OFF, "GL_ARB_uniform_buffer_object", F(ARB_uniform_buffer_object) }, - { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, - { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, - { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, - { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, - { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) }, - { OFF, "GL_ARB_vertex_type_2_10_10_10_rev", F(ARB_vertex_type_2_10_10_10_rev) }, - { ON, "GL_ARB_window_pos", F(ARB_window_pos) }, - { ON, "GL_EXT_abgr", F(EXT_abgr) }, - { ON, "GL_EXT_bgra", F(EXT_bgra) }, - { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, - { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) }, - { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, - { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, - { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, - { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, - { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, - { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) }, - { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, - { OFF, "GL_EXT_convolution", F(EXT_convolution) }, - { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, - { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, - { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, - { OFF, "GL_EXT_draw_instanced", F(ARB_draw_instanced) }, - { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, - { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, - { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, - { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) }, - { OFF, "GL_EXT_framebuffer_sRGB", F(EXT_framebuffer_sRGB) }, - { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, - { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) }, - { OFF, "GL_EXT_histogram", F(EXT_histogram) }, - { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) }, - { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) }, - { OFF, "GL_EXT_packed_float", F(EXT_packed_float) }, - { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, - { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, - { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) }, - { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, - { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, - { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) }, - { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, - { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, - { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) }, - { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) }, - { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, - { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) }, - { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, - { ON, "GL_EXT_subtexture", F(EXT_subtexture) }, - { ON, "GL_EXT_texture", F(EXT_texture) }, - { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, - { OFF, "GL_EXT_texture_array", F(EXT_texture_array) }, - { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) }, - { OFF, "GL_EXT_texture_compression_rgtc", F(EXT_texture_compression_rgtc) }, - { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) }, - { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, - { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, - { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, - { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, - { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, - { OFF, "GL_EXT_texture_integer", F(EXT_texture_integer) }, - { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, - { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, - { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, - { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, - { OFF, "GL_EXT_texture_shared_exponent", F(EXT_texture_shared_exponent) }, - { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, - { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) }, - { OFF, "GL_EXT_timer_query", F(EXT_timer_query) }, - { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) }, - { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) }, - { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) }, - { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, - { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) }, - { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }, - { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) }, - { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) }, - { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) }, - { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) }, - { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) }, - { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, - { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, - { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)}, - { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)}, - { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) }, - { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) }, - { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, - { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) }, - { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) }, - { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) }, - { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, - { OFF, "GL_MESA_texture_array", F(MESA_texture_array) }, - { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) }, - { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) }, - { ON, "GL_MESA_window_pos", F(ARB_window_pos) }, - { OFF, "GL_NV_blend_square", F(NV_blend_square) }, - { OFF, "GL_NV_conditional_render", F(NV_conditional_render) }, - { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) }, - { OFF, "GL_NV_fragment_program", F(NV_fragment_program) }, - { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) }, - { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) }, - { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) }, - { OFF, "GL_NV_point_sprite", F(NV_point_sprite) }, - { OFF, "GL_NV_primitive_restart", F(NV_primitive_restart) }, - { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, - { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) }, - { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) }, - { OFF, "GL_NV_vertex_program", F(NV_vertex_program) }, - { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) }, - { ON, "GL_OES_read_format", F(OES_read_format) }, - { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) }, - { OFF, "GL_SGI_color_table", F(SGI_color_table) }, - { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) }, - { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) }, - { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, - { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, - { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, - { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, - { OFF, "GL_S3_s3tc", F(S3_s3tc) }, -#if FEATURE_OES_EGL_image - { OFF, "GL_OES_EGL_image", F(OES_EGL_image) }, -#endif -#if FEATURE_OES_draw_texture - { OFF, "GL_OES_draw_texture", F(OES_draw_texture) }, -#endif /* FEATURE_OES_draw_texture */ -}; - - - -/** - * Enable all extensions suitable for a software-only renderer. - * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. - */ -void -_mesa_enable_sw_extensions(GLcontext *ctx) -{ - ctx->Extensions.ARB_copy_buffer = GL_TRUE; - ctx->Extensions.ARB_depth_clamp = GL_TRUE; - ctx->Extensions.ARB_depth_texture = GL_TRUE; - /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ - ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; - ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; -#if FEATURE_ARB_fragment_program - ctx->Extensions.ARB_fragment_program = GL_TRUE; - ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; -#endif -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif -#if FEATURE_ARB_framebuffer_object - ctx->Extensions.ARB_framebuffer_object = GL_TRUE; -#endif -#if FEATURE_ARB_geometry_shader4 - ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; -#endif - ctx->Extensions.ARB_half_float_pixel = GL_TRUE; - ctx->Extensions.ARB_half_float_vertex = GL_TRUE; - ctx->Extensions.ARB_imaging = GL_TRUE; - ctx->Extensions.ARB_map_buffer_range = GL_TRUE; - ctx->Extensions.ARB_multitexture = GL_TRUE; -#if FEATURE_queryobj - ctx->Extensions.ARB_occlusion_query = GL_TRUE; -#endif - ctx->Extensions.ARB_point_sprite = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif - ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.ARB_shadow_ambient = GL_TRUE; - ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ - ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; - ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; - ctx->Extensions.ARB_vertex_array_object = GL_TRUE; -#if FEATURE_ARB_vertex_program - ctx->Extensions.ARB_vertex_program = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_buffer_object - /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ -#endif -#if FEATURE_ARB_sync - ctx->Extensions.ARB_sync = GL_TRUE; -#endif - ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; -#if FEATURE_APPLE_object_purgeable - ctx->Extensions.APPLE_object_purgeable = GL_TRUE; -#endif - ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; -#if FEATURE_ATI_fragment_shader - ctx->Extensions.ATI_fragment_shader = GL_TRUE; -#endif - ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; - ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; - ctx->Extensions.ATI_separate_stencil = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_logic_op = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_convolution = GL_TRUE; - ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; - ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; -#if FEATURE_EXT_framebuffer_object - ctx->Extensions.EXT_framebuffer_object = GL_TRUE; -#endif -#if FEATURE_EXT_framebuffer_blit - ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; -#endif -#if FEATURE_ARB_framebuffer_object - ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; -#endif - ctx->Extensions.EXT_histogram = GL_TRUE; - /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ - ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; - ctx->Extensions.EXT_paletted_texture = GL_TRUE; -#if FEATURE_EXT_pixel_buffer_object - ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; -#endif - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_provoking_vertex = GL_TRUE; - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; - ctx->Extensions.EXT_stencil_wrap = GL_TRUE; - ctx->Extensions.EXT_stencil_two_side = GL_TRUE; - ctx->Extensions.EXT_texture_array = GL_TRUE; - ctx->Extensions.EXT_texture_env_add = GL_TRUE; - ctx->Extensions.EXT_texture_env_combine = GL_TRUE; - ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; - ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; -#if FEATURE_EXT_texture_sRGB - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; -#endif - ctx->Extensions.EXT_texture_swizzle = GL_TRUE; -#if FEATURE_EXT_transform_feedback - /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ -#endif - ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; - /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ - ctx->Extensions.MESA_pack_invert = GL_TRUE; - ctx->Extensions.MESA_resize_buffers = GL_TRUE; - ctx->Extensions.MESA_texture_array = GL_TRUE; - ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; - ctx->Extensions.NV_blend_square = GL_TRUE; - ctx->Extensions.NV_conditional_render = GL_TRUE; - /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ - ctx->Extensions.NV_point_sprite = GL_TRUE; - ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; - ctx->Extensions.NV_texture_rectangle = GL_TRUE; - /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ -#if FEATURE_NV_vertex_program - ctx->Extensions.NV_vertex_program = GL_TRUE; - ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program - ctx->Extensions.NV_fragment_program = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program - ctx->Extensions.NV_fragment_program_option = GL_TRUE; -#endif - ctx->Extensions.SGI_color_matrix = GL_TRUE; - ctx->Extensions.SGI_color_table = GL_TRUE; - ctx->Extensions.SGI_texture_color_table = GL_TRUE; - ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; - ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; -#endif -#if FEATURE_texture_fxt1 - _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); -#endif -#if FEATURE_texture_s3tc - if (ctx->Mesa_DXTn) { - _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); - _mesa_enable_extension(ctx, "GL_S3_s3tc"); - } -#endif -} - - -/** - * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it. - */ -void -_mesa_enable_imaging_extensions(GLcontext *ctx) -{ - ctx->Extensions.ARB_imaging = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_logic_op = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_convolution = GL_TRUE; - ctx->Extensions.EXT_histogram = GL_TRUE; - ctx->Extensions.SGI_color_matrix = GL_TRUE; - ctx->Extensions.SGI_color_table = GL_TRUE; -} - - - -/** - * Enable all OpenGL 1.3 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_3_extensions(GLcontext *ctx) -{ - /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ - ctx->Extensions.ARB_multitexture = GL_TRUE; - ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; - /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_env_add = GL_TRUE; - /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ -} - - - -/** - * Enable all OpenGL 1.4 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_4_extensions(GLcontext *ctx) -{ - ctx->Extensions.ARB_depth_texture = GL_TRUE; - ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; - ctx->Extensions.ARB_window_pos = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; - /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_stencil_wrap = GL_TRUE; - ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; - ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; -} - - -/** - * Enable all OpenGL 1.5 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_5_extensions(GLcontext *ctx) -{ - ctx->Extensions.ARB_occlusion_query = GL_TRUE; - /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; -} - - -/** - * Enable all OpenGL 2.0 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_0_extensions(GLcontext *ctx) -{ - /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif - ctx->Extensions.ARB_point_sprite = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif - ctx->Extensions.EXT_stencil_two_side = GL_TRUE; -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif -} - - -/** - * Enable all OpenGL 2.1 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_1_extensions(GLcontext *ctx) -{ -#if FEATURE_EXT_pixel_buffer_object - ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; -#endif -#if FEATURE_EXT_texture_sRGB - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; -#endif -} - - -/** - * Either enable or disable the named extension. - * \return GL_TRUE for success, GL_FALSE if invalid extension name - */ -static GLboolean -set_extension( GLcontext *ctx, const char *name, GLboolean state ) -{ - GLboolean *base = (GLboolean *) &ctx->Extensions; - GLuint i; - - if (ctx->Extensions.String) { - /* The string was already queried - can't change it now! */ - _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); - return GL_FALSE; - } - - for (i = 0 ; i < Elements(default_extensions) ; i++) { - if (strcmp(default_extensions[i].name, name) == 0) { - if (default_extensions[i].flag_offset) { - GLboolean *enabled = base + default_extensions[i].flag_offset; - *enabled = state; - } - return GL_TRUE; - } - } - return GL_FALSE; -} - - -/** - * Enable the named extension. - * Typically called by drivers. - */ -void -_mesa_enable_extension( GLcontext *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_TRUE)) - _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); -} - - -/** - * Disable the named extension. - * XXX is this really needed??? - */ -void -_mesa_disable_extension( GLcontext *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_FALSE)) - _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); -} - - -/** - * Check if the i-th extension is enabled. - */ -static GLboolean -extension_enabled(GLcontext *ctx, GLuint index) -{ - const GLboolean *base = (const GLboolean *) &ctx->Extensions; - if (!default_extensions[index].flag_offset || - *(base + default_extensions[index].flag_offset)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - -/** - * Test if the named extension is enabled in this context. - */ -GLboolean -_mesa_extension_is_enabled( GLcontext *ctx, const char *name ) -{ - GLuint i; - - for (i = 0 ; i < Elements(default_extensions) ; i++) { - if (strcmp(default_extensions[i].name, name) == 0) { - return extension_enabled(ctx, i); - } - } - return GL_FALSE; -} - - -/** - * Append string 'b' onto string 'a'. Free 'a' and return new string. - */ -static char * -append(const char *a, const char *b) -{ - const GLuint aLen = a ? strlen(a) : 0; - const GLuint bLen = b ? strlen(b) : 0; - char *s = calloc(1, aLen + bLen + 1); - if (s) { - if (a) - memcpy(s, a, aLen); - if (b) - memcpy(s + aLen, b, bLen); - s[aLen + bLen] = '\0'; - } - if (a) - free((void *) a); - return s; -} - - -/** - * Check the MESA_EXTENSION_OVERRIDE env var. - * For extension names that are recognized, turn them on. For extension - * names that are recognized and prefixed with '-', turn them off. - * Return a string of the unknown/leftover names. - */ -static const char * -get_extension_override( GLcontext *ctx ) -{ - const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); - char *extraExt = NULL; - char ext[1000]; - GLuint extLen = 0; - GLuint i; - GLboolean disableExt = GL_FALSE; - - if (!envExt) - return NULL; - - for (i = 0; ; i++) { - if (envExt[i] == '\0' || envExt[i] == ' ') { - /* terminate/process 'ext' if extLen > 0 */ - if (extLen > 0) { - assert(extLen < sizeof(ext)); - /* enable extension named by 'ext' */ - ext[extLen] = 0; - if (!set_extension(ctx, ext, !disableExt)) { - /* unknown extension name, append it to extraExt */ - if (extraExt) { - extraExt = append(extraExt, " "); - } - extraExt = append(extraExt, ext); - } - extLen = 0; - disableExt = GL_FALSE; - } - if (envExt[i] == '\0') - break; - } - else if (envExt[i] == '-') { - disableExt = GL_TRUE; - } - else { - /* accumulate this non-space character */ - ext[extLen++] = envExt[i]; - } - } - - return extraExt; -} - - -/** - * Run through the default_extensions array above and set the - * ctx->Extensions.ARB/EXT_* flags accordingly. - * To be called during context initialization. - */ -void -_mesa_init_extensions( GLcontext *ctx ) -{ - GLboolean *base = (GLboolean *) &ctx->Extensions; - GLuint i; - - for (i = 0 ; i < Elements(default_extensions) ; i++) { - if (default_extensions[i].enabled && - default_extensions[i].flag_offset) { - *(base + default_extensions[i].flag_offset) = GL_TRUE; - } - } -} - - -/** - * Construct the GL_EXTENSIONS string. Called the first time that - * glGetString(GL_EXTENSIONS) is called. - */ -static GLubyte * -compute_extensions( GLcontext *ctx ) -{ - const char *extraExt = get_extension_override(ctx); - GLuint extStrLen = 0; - char *s; - GLuint i; - - /* first, compute length of the extension string */ - for (i = 0 ; i < Elements(default_extensions) ; i++) { - if (extension_enabled(ctx, i)) { - extStrLen += (GLuint) strlen(default_extensions[i].name) + 1; - } - } - - if (extraExt) - extStrLen += strlen(extraExt) + 1; /* +1 for space */ - - /* allocate the extension string */ - s = (char *) malloc(extStrLen); - if (!s) - return NULL; - - /* second, build the extension string */ - extStrLen = 0; - for (i = 0 ; i < Elements(default_extensions) ; i++) { - if (extension_enabled(ctx, i)) { - GLuint len = (GLuint) strlen(default_extensions[i].name); - memcpy(s + extStrLen, default_extensions[i].name, len); - extStrLen += len; - s[extStrLen] = ' '; - extStrLen++; - } - } - ASSERT(extStrLen > 0); - - s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */ - - if (extraExt) { - s = append(s, " "); - s = append(s, extraExt); - } - - return (GLubyte *) s; -} - -static size_t -append_extension(GLubyte **str, const char *ext) -{ - GLubyte *s = *str; - size_t len = strlen(ext); - - if (s) { - memcpy(s, ext, len); - s[len++] = ' '; - s[len] = '\0'; - - *str += len; - } - else { - len++; - } - - return len; -} - - -static size_t -make_extension_string_es1(const GLcontext *ctx, GLubyte *str) -{ - size_t len = 0; - - /* Core additions */ - len += append_extension(&str, "GL_OES_byte_coordinates"); - len += append_extension(&str, "GL_OES_fixed_point"); - len += append_extension(&str, "GL_OES_single_precision"); - len += append_extension(&str, "GL_OES_matrix_get"); - - /* 1.1 required extensions */ - len += append_extension(&str, "GL_OES_read_format"); - len += append_extension(&str, "GL_OES_compressed_paletted_texture"); - len += append_extension(&str, "GL_OES_point_size_array"); - len += append_extension(&str, "GL_OES_point_sprite"); - - /* 1.1 deprecated extensions */ - len += append_extension(&str, "GL_OES_query_matrix"); - -#if FEATURE_OES_draw_texture - if (ctx->Extensions.OES_draw_texture) - len += append_extension(&str, "GL_OES_draw_texture"); -#endif - - if (ctx->Extensions.EXT_blend_equation_separate) - len += append_extension(&str, "GL_OES_blend_equation_separate"); - if (ctx->Extensions.EXT_blend_func_separate) - len += append_extension(&str, "GL_OES_blend_func_separate"); - if (ctx->Extensions.EXT_blend_subtract) - len += append_extension(&str, "GL_OES_blend_subtract"); - - if (ctx->Extensions.EXT_stencil_wrap) - len += append_extension(&str, "GL_OES_stencil_wrap"); - - if (ctx->Extensions.ARB_texture_cube_map) - len += append_extension(&str, "GL_OES_texture_cube_map"); - if (ctx->Extensions.ARB_texture_env_crossbar) - len += append_extension(&str, "GL_OES_texture_env_crossbar"); - if (ctx->Extensions.ARB_texture_mirrored_repeat) - len += append_extension(&str, "GL_OES_texture_mirrored_repeat"); - - if (ctx->Extensions.ARB_framebuffer_object) { - len += append_extension(&str, "GL_OES_framebuffer_object"); - len += append_extension(&str, "GL_OES_depth24"); - len += append_extension(&str, "GL_OES_depth32"); - len += append_extension(&str, "GL_OES_fbo_render_mipmap"); - len += append_extension(&str, "GL_OES_rgb8_rgba8"); - len += append_extension(&str, "GL_OES_stencil1"); - len += append_extension(&str, "GL_OES_stencil4"); - len += append_extension(&str, "GL_OES_stencil8"); - } - - if (ctx->Extensions.EXT_vertex_array) - len += append_extension(&str, "GL_OES_element_index_uint"); - if (ctx->Extensions.ARB_vertex_buffer_object) - len += append_extension(&str, "GL_OES_mapbuffer"); - if (ctx->Extensions.EXT_texture_filter_anisotropic) - len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); - - /* some applications check this for NPOT support */ - if (ctx->Extensions.ARB_texture_non_power_of_two) - len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); - - if (ctx->Extensions.EXT_texture_compression_s3tc) - len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); - if (ctx->Extensions.EXT_texture_lod_bias) - len += append_extension(&str, "GL_EXT_texture_lod_bias"); - if (ctx->Extensions.EXT_blend_minmax) - len += append_extension(&str, "GL_EXT_blend_minmax"); - if (ctx->Extensions.EXT_multi_draw_arrays) - len += append_extension(&str, "GL_EXT_multi_draw_arrays"); - -#if FEATURE_OES_EGL_image - if (ctx->Extensions.OES_EGL_image) - len += append_extension(&str, "GL_OES_EGL_image"); -#endif - - return len; -} - - -static GLubyte * -compute_extensions_es1(const GLcontext *ctx) -{ - GLubyte *s; - unsigned int len; - - len = make_extension_string_es1(ctx, NULL); - s = malloc(len + 1); - if (!s) - return NULL; - make_extension_string_es1(ctx, s); - - return s; -} - -static size_t -make_extension_string_es2(const GLcontext *ctx, GLubyte *str) -{ - size_t len = 0; - - len += append_extension(&str, "GL_OES_compressed_paletted_texture"); - - if (ctx->Extensions.ARB_framebuffer_object) { - len += append_extension(&str, "GL_OES_depth24"); - len += append_extension(&str, "GL_OES_depth32"); - len += append_extension(&str, "GL_OES_fbo_render_mipmap"); - len += append_extension(&str, "GL_OES_rgb8_rgba8"); - len += append_extension(&str, "GL_OES_stencil1"); - len += append_extension(&str, "GL_OES_stencil4"); - } - - if (ctx->Extensions.EXT_vertex_array) - len += append_extension(&str, "GL_OES_element_index_uint"); - if (ctx->Extensions.ARB_vertex_buffer_object) - len += append_extension(&str, "GL_OES_mapbuffer"); - - if (ctx->Extensions.EXT_texture3D) - len += append_extension(&str, "GL_OES_texture_3D"); - if (ctx->Extensions.ARB_texture_non_power_of_two) - len += append_extension(&str, "GL_OES_texture_npot"); - if (ctx->Extensions.EXT_texture_filter_anisotropic) - len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); - - len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV"); - if (ctx->Extensions.ARB_depth_texture) - len += append_extension(&str, "GL_OES_depth_texture"); - if (ctx->Extensions.EXT_packed_depth_stencil) - len += append_extension(&str, "GL_OES_packed_depth_stencil"); - if (ctx->Extensions.ARB_fragment_shader) - len += append_extension(&str, "GL_OES_standard_derivatives"); - - if (ctx->Extensions.EXT_texture_compression_s3tc) - len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); - if (ctx->Extensions.EXT_blend_minmax) - len += append_extension(&str, "GL_EXT_blend_minmax"); - if (ctx->Extensions.EXT_multi_draw_arrays) - len += append_extension(&str, "GL_EXT_multi_draw_arrays"); - -#if FEATURE_OES_EGL_image - if (ctx->Extensions.OES_EGL_image) - len += append_extension(&str, "GL_OES_EGL_image"); -#endif - - return len; -} - -static GLubyte * -compute_extensions_es2(GLcontext *ctx) -{ - GLubyte *s; - unsigned int len; - - len = make_extension_string_es2(ctx, NULL); - s = malloc(len + 1); - if (!s) - return NULL; - make_extension_string_es2(ctx, s); - - return s; -} - - -GLubyte * -_mesa_make_extension_string(GLcontext *ctx) -{ - switch (ctx->API) { - case API_OPENGL: - return compute_extensions(ctx); - case API_OPENGLES2: - return compute_extensions_es2(ctx); - case API_OPENGLES: - return compute_extensions_es1(ctx); - default: - assert(0); - return NULL; - } -} - -/** - * Return number of enabled extensions. - */ -GLuint -_mesa_get_extension_count(GLcontext *ctx) -{ - GLuint i; - - /* only count once */ - if (!ctx->Extensions.Count) { - for (i = 0; i < Elements(default_extensions); i++) { - if (extension_enabled(ctx, i)) { - ctx->Extensions.Count++; - } - } - } - - if (0) - _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count, - (int) Elements(default_extensions)); - - return ctx->Extensions.Count; -} - - -/** - * Return name of i-th enabled extension - */ -const GLubyte * -_mesa_get_enabled_extension(GLcontext *ctx, GLuint index) -{ - GLuint i; - - for (i = 0; i < Elements(default_extensions); i++) { - if (extension_enabled(ctx, i)) { - if (index == 0) - return (const GLubyte *) default_extensions[i].name; - index--; - } - } - - return NULL; -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "extensions.h" +#include "mtypes.h" + + +#define F(x) offsetof(struct gl_extensions, x) +#define ON GL_TRUE +#define OFF GL_FALSE + + +/* + * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. + */ +static const struct { + GLboolean enabled; + const char *name; + int flag_offset; +} default_extensions[] = { + { OFF, "GL_ARB_blend_func_extended", F(ARB_blend_func_extended) }, + { ON, "GL_ARB_copy_buffer", F(ARB_copy_buffer) }, + { OFF, "GL_ARB_depth_buffer_float", F(ARB_depth_buffer_float) }, + { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, + { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, + { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, + { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, + { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) }, + { OFF, "GL_ARB_explicit_attrib_location", F(ARB_explicit_attrib_location) }, + { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, + { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, + { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, + { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, + { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, + /* TODO: reenable this when the new GLSL compiler actually supports them */ + /* { OFF, "GL_ARB_geometry_shader4", F(ARB_geometry_shader4) }, */ + { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, + { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) }, + { OFF, "GL_ARB_instanced_arrays", F(ARB_instanced_arrays) }, + { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, + { ON, "GL_ARB_multisample", F(ARB_multisample) }, + { OFF, "GL_ARB_multitexture", F(ARB_multitexture) }, + { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) }, + { OFF, "GL_ARB_occlusion_query2", F(ARB_occlusion_query2) }, + { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) }, + { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) }, + { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) }, + { OFF, "GL_ARB_provoking_vertex", F(EXT_provoking_vertex) }, + { OFF, "GL_ARB_sampler_objects", F(ARB_sampler_objects) }, + { OFF, "GL_ARB_seamless_cube_map", F(ARB_seamless_cube_map) }, + { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) }, + { OFF, "GL_ARB_shader_stencil_export", F(ARB_shader_stencil_export) }, + { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, + { OFF, "GL_ARB_shadow", F(ARB_shadow) }, + { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, + { OFF, "GL_ARB_sync", F(ARB_sync) }, + { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, + { OFF, "GL_ARB_texture_buffer_object", F(ARB_texture_buffer_object) }, + { ON, "GL_ARB_texture_compression", F(ARB_texture_compression) }, + { OFF, "GL_ARB_texture_compression_rgtc", F(ARB_texture_compression_rgtc) }, + { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, + { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) }, + { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) }, + { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) }, + { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) }, + { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) }, + { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, + { OFF, "GL_ARB_texture_multisample", F(ARB_texture_multisample) }, + { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, + { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, + { OFF, "GL_ARB_texture_rg", F(ARB_texture_rg) }, + { OFF, "GL_ARB_texture_rgb10_a2ui", F(ARB_texture_rgb10_a2ui) }, + { OFF, "GL_ARB_texture_swizzle", F(EXT_texture_swizzle) }, + { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, + { OFF, "GL_ARB_transform_feedback2", F(ARB_transform_feedback2) }, + { OFF, "GL_ARB_uniform_buffer_object", F(ARB_uniform_buffer_object) }, + { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, + { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, + { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, + { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) }, + { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) }, + { OFF, "GL_ARB_vertex_type_2_10_10_10_rev", F(ARB_vertex_type_2_10_10_10_rev) }, + { ON, "GL_ARB_window_pos", F(ARB_window_pos) }, + { ON, "GL_EXT_abgr", F(EXT_abgr) }, + { ON, "GL_EXT_bgra", F(EXT_bgra) }, + { OFF, "GL_EXT_blend_color", F(EXT_blend_color) }, + { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) }, + { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) }, + { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) }, + { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) }, + { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) }, + { OFF, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) }, + { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) }, + { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) }, + { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) }, + { OFF, "GL_EXT_draw_buffers2", F(EXT_draw_buffers2) }, + { OFF, "GL_EXT_draw_instanced", F(ARB_draw_instanced) }, + { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) }, + { OFF, "GL_EXT_framebuffer_blit", F(EXT_framebuffer_blit) }, + { OFF, "GL_EXT_framebuffer_multisample", F(EXT_framebuffer_multisample) }, + { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) }, + { OFF, "GL_EXT_framebuffer_sRGB", F(EXT_framebuffer_sRGB) }, + { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) }, + { OFF, "GL_EXT_gpu_program_parameters", F(EXT_gpu_program_parameters) }, + { OFF, "GL_EXT_gpu_shader4", F(EXT_gpu_shader4) }, + { ON, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) }, + { OFF, "GL_EXT_packed_depth_stencil", F(EXT_packed_depth_stencil) }, + { OFF, "GL_EXT_packed_float", F(EXT_packed_float) }, + { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) }, + { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) }, + { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) }, + { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) }, + { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) }, + { OFF, "GL_EXT_provoking_vertex", F(EXT_provoking_vertex) }, + { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) }, + { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) }, + { OFF, "GL_EXT_separate_shader_objects", F(EXT_separate_shader_objects) }, + { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) }, + { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) }, + { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, + { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) }, + { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, + { ON, "GL_EXT_subtexture", F(EXT_subtexture) }, + { ON, "GL_EXT_texture", F(EXT_texture) }, + { ON, "GL_EXT_texture3D", F(EXT_texture3D) }, + { OFF, "GL_EXT_texture_array", F(EXT_texture_array) }, + { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) }, + { OFF, "GL_EXT_texture_compression_rgtc", F(ARB_texture_compression_rgtc) }, + { OFF, "GL_EXT_texture_cube_map", F(ARB_texture_cube_map) }, + { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, + { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) }, + { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) }, + { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) }, + { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) }, + { OFF, "GL_EXT_texture_integer", F(EXT_texture_integer) }, + { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) }, + { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, + { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, + { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, + { OFF, "GL_EXT_texture_shared_exponent", F(EXT_texture_shared_exponent) }, + { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, + { OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) }, + { OFF, "GL_EXT_timer_query", F(EXT_timer_query) }, + { OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) }, + { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) }, + { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) }, + { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, + { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) }, + { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }, + { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) }, + { OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) }, + { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) }, + { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) }, + { OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) }, + { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)}, + { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)}, + { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)}, + { OFF, "GL_ATI_separate_stencil", F(ATI_separate_stencil)}, + { ON, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) }, + { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) }, + { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)}, + { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) }, + { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) }, + { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, + { OFF, "GL_MESA_texture_array", F(MESA_texture_array) }, + { OFF, "GL_MESA_texture_signed_rgba", F(MESA_texture_signed_rgba) }, + { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) }, + { ON, "GL_MESA_window_pos", F(ARB_window_pos) }, + { OFF, "GL_NV_blend_square", F(NV_blend_square) }, + { OFF, "GL_NV_conditional_render", F(NV_conditional_render) }, + { OFF, "GL_NV_depth_clamp", F(ARB_depth_clamp) }, + { OFF, "GL_NV_fragment_program", F(NV_fragment_program) }, + { OFF, "GL_NV_fragment_program_option", F(NV_fragment_program_option) }, + { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) }, + { OFF, "GL_NV_packed_depth_stencil", F(EXT_packed_depth_stencil) }, + { OFF, "GL_NV_point_sprite", F(NV_point_sprite) }, + { OFF, "GL_NV_primitive_restart", F(NV_primitive_restart) }, + { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) }, + { OFF, "GL_NV_texture_env_combine4", F(NV_texture_env_combine4) }, + { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) }, + { OFF, "GL_NV_vertex_program", F(NV_vertex_program) }, + { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) }, + { ON, "GL_OES_read_format", F(OES_read_format) }, + { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) }, + { ON, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) }, + { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) }, + { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, + { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, + { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, + { OFF, "GL_S3_s3tc", F(S3_s3tc) }, + { OFF, "GL_EXT_texture_format_BGRA8888", F(EXT_texture_format_BGRA8888) }, +#if FEATURE_OES_EGL_image + { OFF, "GL_OES_EGL_image", F(OES_EGL_image) }, +#endif +#if FEATURE_OES_draw_texture + { OFF, "GL_OES_draw_texture", F(OES_draw_texture) }, +#endif /* FEATURE_OES_draw_texture */ +}; + + + +/** + * Enable all extensions suitable for a software-only renderer. + * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. + */ +void +_mesa_enable_sw_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/ + ctx->Extensions.ARB_depth_clamp = GL_TRUE; + ctx->Extensions.ARB_depth_texture = GL_TRUE; + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ + ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; + ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; +#if FEATURE_ARB_fragment_program + ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; +#endif +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_ARB_geometry_shader4 && 0 + /* XXX re-enable when GLSL compiler again supports geometry shaders */ + ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; +#endif + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; + ctx->Extensions.ARB_multitexture = GL_TRUE; +#if FEATURE_queryobj + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow_ambient = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.ARB_texture_rg = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; +#if FEATURE_ARB_vertex_program + ctx->Extensions.ARB_vertex_program = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_buffer_object + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ +#endif +#if FEATURE_ARB_sync + ctx->Extensions.ARB_sync = GL_TRUE; +#endif + ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; +#if FEATURE_APPLE_object_purgeable + ctx->Extensions.APPLE_object_purgeable = GL_TRUE; +#endif + ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; +#if FEATURE_ATI_fragment_shader + ctx->Extensions.ATI_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; + ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; +#if FEATURE_EXT_framebuffer_object + ctx->Extensions.EXT_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_framebuffer_blit + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; +#endif + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + ctx->Extensions.EXT_paletted_texture = GL_TRUE; +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + ctx->Extensions.EXT_texture_env_combine = GL_TRUE; + ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; +#endif + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; +#if FEATURE_EXT_transform_feedback + /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ +#endif + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ + ctx->Extensions.MESA_pack_invert = GL_TRUE; + ctx->Extensions.MESA_resize_buffers = GL_TRUE; + ctx->Extensions.MESA_texture_array = GL_TRUE; + ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; + ctx->Extensions.NV_blend_square = GL_TRUE; + ctx->Extensions.NV_conditional_render = GL_TRUE; + /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ + ctx->Extensions.NV_point_sprite = GL_TRUE; + ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; + /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ +#if FEATURE_NV_vertex_program + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program + ctx->Extensions.NV_fragment_program = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program + ctx->Extensions.NV_fragment_program_option = GL_TRUE; +#endif + ctx->Extensions.SGI_texture_color_table = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ + ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; +#endif +#if FEATURE_texture_fxt1 + _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); +#endif +#if FEATURE_texture_s3tc + if (ctx->Mesa_DXTn) { + _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); + _mesa_enable_extension(ctx, "GL_S3_s3tc"); + } +#endif +} + + +/** + * Enable common EXT extensions in the ARB_imaging subset. + */ +void +_mesa_enable_imaging_extensions(struct gl_context *ctx) +{ + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; +} + + + +/** + * Enable all OpenGL 1.3 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_3_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ + ctx->Extensions.ARB_multitexture = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ +} + + + +/** + * Enable all OpenGL 1.4 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_4_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ +} + + +/** + * Enable all OpenGL 1.5 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_5_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; +} + + +/** + * Enable all OpenGL 2.0 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_0_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +} + + +/** + * Enable all OpenGL 2.1 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_1_extensions(struct gl_context *ctx) +{ +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; +#endif +} + + +/** + * Either enable or disable the named extension. + * \return GL_TRUE for success, GL_FALSE if invalid extension name + */ +static GLboolean +set_extension( struct gl_context *ctx, const char *name, GLboolean state ) +{ + GLboolean *base = (GLboolean *) &ctx->Extensions; + GLuint i; + + if (ctx->Extensions.String) { + /* The string was already queried - can't change it now! */ + _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); + return GL_FALSE; + } + + for (i = 0 ; i < Elements(default_extensions) ; i++) { + if (strcmp(default_extensions[i].name, name) == 0) { + if (default_extensions[i].flag_offset) { + GLboolean *enabled = base + default_extensions[i].flag_offset; + *enabled = state; + } + return GL_TRUE; + } + } + return GL_FALSE; +} + + +/** + * Enable the named extension. + * Typically called by drivers. + */ +void +_mesa_enable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_TRUE)) + _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); +} + + +/** + * Disable the named extension. + * XXX is this really needed??? + */ +void +_mesa_disable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_FALSE)) + _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); +} + + +/** + * Check if the i-th extension is enabled. + */ +static GLboolean +extension_enabled(struct gl_context *ctx, GLuint index) +{ + const GLboolean *base = (const GLboolean *) &ctx->Extensions; + if (!default_extensions[index].flag_offset || + *(base + default_extensions[index].flag_offset)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + +/** + * Test if the named extension is enabled in this context. + */ +GLboolean +_mesa_extension_is_enabled( struct gl_context *ctx, const char *name ) +{ + GLuint i; + + for (i = 0 ; i < Elements(default_extensions) ; i++) { + if (strcmp(default_extensions[i].name, name) == 0) { + return extension_enabled(ctx, i); + } + } + return GL_FALSE; +} + + +/** + * Append string 'b' onto string 'a'. Free 'a' and return new string. + */ +static char * +append(const char *a, const char *b) +{ + const GLuint aLen = a ? strlen(a) : 0; + const GLuint bLen = b ? strlen(b) : 0; + char *s = calloc(1, aLen + bLen + 1); + if (s) { + if (a) + memcpy(s, a, aLen); + if (b) + memcpy(s + aLen, b, bLen); + s[aLen + bLen] = '\0'; + } + if (a) + free((void *) a); + return s; +} + + +/** + * Check the MESA_EXTENSION_OVERRIDE env var. + * For extension names that are recognized, turn them on. For extension + * names that are recognized and prefixed with '-', turn them off. + * Return a string of the unknown/leftover names. + */ +static const char * +get_extension_override( struct gl_context *ctx ) +{ + const char *envExt = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); + char *extraExt = NULL; + char ext[1000]; + GLuint extLen = 0; + GLuint i; + GLboolean disableExt = GL_FALSE; + + if (!envExt) + return NULL; + + for (i = 0; ; i++) { + if (envExt[i] == '\0' || envExt[i] == ' ') { + /* terminate/process 'ext' if extLen > 0 */ + if (extLen > 0) { + assert(extLen < sizeof(ext)); + /* enable extension named by 'ext' */ + ext[extLen] = 0; + if (!set_extension(ctx, ext, !disableExt)) { + /* unknown extension name, append it to extraExt */ + if (extraExt) { + extraExt = append(extraExt, " "); + } + extraExt = append(extraExt, ext); + } + extLen = 0; + disableExt = GL_FALSE; + } + if (envExt[i] == '\0') + break; + } + else if (envExt[i] == '-') { + disableExt = GL_TRUE; + } + else { + /* accumulate this non-space character */ + ext[extLen++] = envExt[i]; + } + } + + return extraExt; +} + + +/** + * Run through the default_extensions array above and set the + * ctx->Extensions.ARB/EXT_* flags accordingly. + * To be called during context initialization. + */ +void +_mesa_init_extensions( struct gl_context *ctx ) +{ + GLboolean *base = (GLboolean *) &ctx->Extensions; + GLuint i; + + for (i = 0 ; i < Elements(default_extensions) ; i++) { + if (default_extensions[i].enabled && + default_extensions[i].flag_offset) { + *(base + default_extensions[i].flag_offset) = GL_TRUE; + } + } +} + + +/** + * Construct the GL_EXTENSIONS string. Called the first time that + * glGetString(GL_EXTENSIONS) is called. + */ +static GLubyte * +compute_extensions( struct gl_context *ctx ) +{ + const char *extraExt = get_extension_override(ctx); + GLuint extStrLen = 0; + char *s; + GLuint i; + + /* first, compute length of the extension string */ + for (i = 0 ; i < Elements(default_extensions) ; i++) { + if (extension_enabled(ctx, i)) { + extStrLen += (GLuint) strlen(default_extensions[i].name) + 1; + } + } + + if (extraExt) + extStrLen += strlen(extraExt) + 1; /* +1 for space */ + + /* allocate the extension string */ + s = (char *) malloc(extStrLen); + if (!s) + return NULL; + + /* second, build the extension string */ + extStrLen = 0; + for (i = 0 ; i < Elements(default_extensions) ; i++) { + if (extension_enabled(ctx, i)) { + GLuint len = (GLuint) strlen(default_extensions[i].name); + memcpy(s + extStrLen, default_extensions[i].name, len); + extStrLen += len; + s[extStrLen] = ' '; + extStrLen++; + } + } + ASSERT(extStrLen > 0); + + s[extStrLen - 1] = 0; /* -1 to overwrite trailing the ' ' */ + + if (extraExt) { + s = append(s, " "); + s = append(s, extraExt); + } + + return (GLubyte *) s; +} + +static size_t +append_extension(GLubyte **str, const char *ext) +{ + GLubyte *s = *str; + size_t len = strlen(ext); + + if (s) { + memcpy(s, ext, len); + s[len++] = ' '; + s[len] = '\0'; + + *str += len; + } + else { + len++; + } + + return len; +} + + +static size_t +make_extension_string_es1(const struct gl_context *ctx, GLubyte *str) +{ + size_t len = 0; + + /* Core additions */ + len += append_extension(&str, "GL_OES_byte_coordinates"); + len += append_extension(&str, "GL_OES_fixed_point"); + len += append_extension(&str, "GL_OES_single_precision"); + len += append_extension(&str, "GL_OES_matrix_get"); + + /* 1.1 required extensions */ + len += append_extension(&str, "GL_OES_read_format"); + len += append_extension(&str, "GL_OES_compressed_paletted_texture"); + len += append_extension(&str, "GL_OES_point_size_array"); + len += append_extension(&str, "GL_OES_point_sprite"); + + /* 1.1 deprecated extensions */ + len += append_extension(&str, "GL_OES_query_matrix"); + +#if FEATURE_OES_draw_texture + if (ctx->Extensions.OES_draw_texture) + len += append_extension(&str, "GL_OES_draw_texture"); +#endif + + if (ctx->Extensions.EXT_blend_equation_separate) + len += append_extension(&str, "GL_OES_blend_equation_separate"); + if (ctx->Extensions.EXT_blend_func_separate) + len += append_extension(&str, "GL_OES_blend_func_separate"); + if (ctx->Extensions.EXT_blend_subtract) + len += append_extension(&str, "GL_OES_blend_subtract"); + + if (ctx->Extensions.EXT_stencil_wrap) + len += append_extension(&str, "GL_OES_stencil_wrap"); + + if (ctx->Extensions.ARB_texture_cube_map) + len += append_extension(&str, "GL_OES_texture_cube_map"); + if (ctx->Extensions.ARB_texture_env_crossbar) + len += append_extension(&str, "GL_OES_texture_env_crossbar"); + if (ctx->Extensions.ARB_texture_mirrored_repeat) + len += append_extension(&str, "GL_OES_texture_mirrored_repeat"); + + if (ctx->Extensions.ARB_framebuffer_object) { + len += append_extension(&str, "GL_OES_framebuffer_object"); + len += append_extension(&str, "GL_OES_depth24"); + len += append_extension(&str, "GL_OES_depth32"); + len += append_extension(&str, "GL_OES_fbo_render_mipmap"); + len += append_extension(&str, "GL_OES_rgb8_rgba8"); + len += append_extension(&str, "GL_OES_stencil1"); + len += append_extension(&str, "GL_OES_stencil4"); + len += append_extension(&str, "GL_OES_stencil8"); + } + + if (ctx->Extensions.EXT_vertex_array) + len += append_extension(&str, "GL_OES_element_index_uint"); + if (ctx->Extensions.ARB_vertex_buffer_object) + len += append_extension(&str, "GL_OES_mapbuffer"); + if (ctx->Extensions.EXT_texture_filter_anisotropic) + len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + + /* some applications check this for NPOT support */ + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); + + if (ctx->Extensions.EXT_texture_compression_s3tc) + len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); + if (ctx->Extensions.EXT_texture_lod_bias) + len += append_extension(&str, "GL_EXT_texture_lod_bias"); + if (ctx->Extensions.EXT_blend_minmax) + len += append_extension(&str, "GL_EXT_blend_minmax"); + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + +#if FEATURE_OES_EGL_image + if (ctx->Extensions.OES_EGL_image) + len += append_extension(&str, "GL_OES_EGL_image"); +#endif + + return len; +} + + +static GLubyte * +compute_extensions_es1(const struct gl_context *ctx) +{ + GLubyte *s; + unsigned int len; + + len = make_extension_string_es1(ctx, NULL); + s = malloc(len + 1); + if (!s) + return NULL; + make_extension_string_es1(ctx, s); + + return s; +} + +static size_t +make_extension_string_es2(const struct gl_context *ctx, GLubyte *str) +{ + size_t len = 0; + + if (ctx->Extensions.ARB_framebuffer_object) { + len += append_extension(&str, "GL_OES_depth24"); + len += append_extension(&str, "GL_OES_depth32"); + len += append_extension(&str, "GL_OES_fbo_render_mipmap"); + len += append_extension(&str, "GL_OES_rgb8_rgba8"); + len += append_extension(&str, "GL_OES_stencil1"); + len += append_extension(&str, "GL_OES_stencil4"); + } + + if (ctx->Extensions.EXT_vertex_array) + len += append_extension(&str, "GL_OES_element_index_uint"); + if (ctx->Extensions.ARB_vertex_buffer_object) + len += append_extension(&str, "GL_OES_mapbuffer"); + +#if 0 + /* disabled because of missing GLSL support */ + if (ctx->Extensions.EXT_texture3D) + len += append_extension(&str, "GL_OES_texture_3D"); +#endif + + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_OES_texture_npot"); + if (ctx->Extensions.EXT_texture_filter_anisotropic) + len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + + len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV"); + if (ctx->Extensions.ARB_depth_texture) + len += append_extension(&str, "GL_OES_depth_texture"); + if (ctx->Extensions.EXT_packed_depth_stencil) + len += append_extension(&str, "GL_OES_packed_depth_stencil"); + if (ctx->Extensions.ARB_fragment_shader) + len += append_extension(&str, "GL_OES_standard_derivatives"); + + if (ctx->Extensions.EXT_texture_compression_s3tc) + len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); + if (ctx->Extensions.EXT_blend_minmax) + len += append_extension(&str, "GL_EXT_blend_minmax"); + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + +#if FEATURE_OES_EGL_image + if (ctx->Extensions.OES_EGL_image) + len += append_extension(&str, "GL_OES_EGL_image"); +#endif + + if (ctx->Extensions.EXT_texture_format_BGRA8888) + len += append_extension(&str, "GL_EXT_texture_format_BGRA8888"); + + return len; +} + +static GLubyte * +compute_extensions_es2(struct gl_context *ctx) +{ + GLubyte *s; + unsigned int len; + + len = make_extension_string_es2(ctx, NULL); + s = malloc(len + 1); + if (!s) + return NULL; + make_extension_string_es2(ctx, s); + + return s; +} + + +GLubyte * +_mesa_make_extension_string(struct gl_context *ctx) +{ + switch (ctx->API) { + case API_OPENGL: + return compute_extensions(ctx); + case API_OPENGLES2: + return compute_extensions_es2(ctx); + case API_OPENGLES: + return compute_extensions_es1(ctx); + default: + assert(0); + return NULL; + } +} + +/** + * Return number of enabled extensions. + */ +GLuint +_mesa_get_extension_count(struct gl_context *ctx) +{ + GLuint i; + + /* only count once */ + if (!ctx->Extensions.Count) { + for (i = 0; i < Elements(default_extensions); i++) { + if (extension_enabled(ctx, i)) { + ctx->Extensions.Count++; + } + } + } + + if (0) + _mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count, + (int) Elements(default_extensions)); + + return ctx->Extensions.Count; +} + + +/** + * Return name of i-th enabled extension + */ +const GLubyte * +_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) +{ + GLuint i; + + for (i = 0; i < Elements(default_extensions); i++) { + if (extension_enabled(ctx, i)) { + if (index == 0) + return (const GLubyte *) default_extensions[i].name; + index--; + } + } + + return NULL; +} diff --git a/mesalib/src/mesa/main/extensions.h b/mesalib/src/mesa/main/extensions.h index a25472440..078e184a9 100644 --- a/mesalib/src/mesa/main/extensions.h +++ b/mesalib/src/mesa/main/extensions.h @@ -1,93 +1,96 @@ -/** - * \file extensions.h - * Extension handling. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _EXTENSIONS_H_ -#define _EXTENSIONS_H_ - -#include "mtypes.h" - -#if _HAVE_FULL_GL - -extern void _mesa_enable_sw_extensions(GLcontext *ctx); - -extern void _mesa_enable_imaging_extensions(GLcontext *ctx); - -extern void _mesa_enable_1_3_extensions(GLcontext *ctx); - -extern void _mesa_enable_1_4_extensions(GLcontext *ctx); - -extern void _mesa_enable_1_5_extensions(GLcontext *ctx); - -extern void _mesa_enable_2_0_extensions(GLcontext *ctx); - -extern void _mesa_enable_2_1_extensions(GLcontext *ctx); - -extern void _mesa_enable_extension(GLcontext *ctx, const char *name); - -extern void _mesa_disable_extension(GLcontext *ctx, const char *name); - -extern GLboolean _mesa_extension_is_enabled(GLcontext *ctx, const char *name); - -extern void _mesa_init_extensions(GLcontext *ctx); - -extern GLubyte *_mesa_make_extension_string(GLcontext *ctx); - -extern GLuint -_mesa_get_extension_count(GLcontext *ctx); - -extern const GLubyte * -_mesa_get_enabled_extension(GLcontext *ctx, GLuint index); - - -#else - -/** No-op */ -#define _mesa_extensions_dtr( ctx ) ((void)0) - -/** No-op */ -#define _mesa_extensions_ctr( ctx ) ((void)0) - -/** No-op */ -#define _mesa_extensions_get_string( ctx ) "GL_EXT_texture_object" - -/** No-op */ -#define _mesa_enable_imaging_extensions( c ) ((void)0) - -/** No-op */ -#define _mesa_enable_extension( c, n ) ((void)0) - -#endif - -#endif +/** + * \file extensions.h + * Extension handling. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _EXTENSIONS_H_ +#define _EXTENSIONS_H_ + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + +#if _HAVE_FULL_GL + +extern void _mesa_enable_sw_extensions(struct gl_context *ctx); + +extern void _mesa_enable_imaging_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_3_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_4_extensions(struct gl_context *ctx); + +extern void _mesa_enable_1_5_extensions(struct gl_context *ctx); + +extern void _mesa_enable_2_0_extensions(struct gl_context *ctx); + +extern void _mesa_enable_2_1_extensions(struct gl_context *ctx); + +extern void _mesa_enable_extension(struct gl_context *ctx, const char *name); + +extern void _mesa_disable_extension(struct gl_context *ctx, const char *name); + +extern GLboolean _mesa_extension_is_enabled(struct gl_context *ctx, const char *name); + +extern void _mesa_init_extensions(struct gl_context *ctx); + +extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); + +extern GLuint +_mesa_get_extension_count(struct gl_context *ctx); + +extern const GLubyte * +_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); + + +#else + +/** No-op */ +#define _mesa_extensions_dtr( ctx ) ((void)0) + +/** No-op */ +#define _mesa_extensions_ctr( ctx ) ((void)0) + +/** No-op */ +#define _mesa_extensions_get_string( ctx ) "GL_EXT_texture_object" + +/** No-op */ +#define _mesa_enable_imaging_extensions( c ) ((void)0) + +/** No-op */ +#define _mesa_enable_extension( c, n ) ((void)0) + +#endif + +#endif diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 5201f5025..fce9e5bba 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -1,2342 +1,2393 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * GL_EXT/ARB_framebuffer_object extensions - * - * Authors: - * Brian Paul - */ - - -#include "buffers.h" -#include "context.h" -#include "enums.h" -#include "fbobject.h" -#include "formats.h" -#include "framebuffer.h" -#include "hash.h" -#include "macros.h" -#include "renderbuffer.h" -#include "state.h" -#include "teximage.h" -#include "texobj.h" - - -/** Set this to 1 to help debug FBO incompleteness problems */ -#define DEBUG_FBO 0 - -/** Set this to 1 to debug/log glBlitFramebuffer() calls */ -#define DEBUG_BLIT 0 - - -/** - * Notes: - * - * None of the GL_EXT_framebuffer_object functions are compiled into - * display lists. - */ - - - -/* - * When glGenRender/FramebuffersEXT() is called we insert pointers to - * these placeholder objects into the hash table. - * Later, when the object ID is first bound, we replace the placeholder - * with the real frame/renderbuffer. - */ -static struct gl_framebuffer DummyFramebuffer; -static struct gl_renderbuffer DummyRenderbuffer; - -/* We bind this framebuffer when applications pass a NULL - * drawable/surface in make current. */ -static struct gl_framebuffer IncompleteFramebuffer; - - -#define IS_CUBE_FACE(TARGET) \ - ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \ - (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) - - -static void -delete_dummy_renderbuffer(struct gl_renderbuffer *rb) -{ - /* no op */ -} - -static void -delete_dummy_framebuffer(struct gl_framebuffer *fb) -{ - /* no op */ -} - - -void -_mesa_init_fbobjects(GLcontext *ctx) -{ - _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); - _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); - _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); - DummyFramebuffer.Delete = delete_dummy_framebuffer; - DummyRenderbuffer.Delete = delete_dummy_renderbuffer; - IncompleteFramebuffer.Delete = delete_dummy_framebuffer; -} - -struct gl_framebuffer * -_mesa_get_incomplete_framebuffer(void) -{ - return &IncompleteFramebuffer; -} - -/** - * Helper routine for getting a gl_renderbuffer. - */ -struct gl_renderbuffer * -_mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id) -{ - struct gl_renderbuffer *rb; - - if (id == 0) - return NULL; - - rb = (struct gl_renderbuffer *) - _mesa_HashLookup(ctx->Shared->RenderBuffers, id); - return rb; -} - - -/** - * Helper routine for getting a gl_framebuffer. - */ -struct gl_framebuffer * -_mesa_lookup_framebuffer(GLcontext *ctx, GLuint id) -{ - struct gl_framebuffer *fb; - - if (id == 0) - return NULL; - - fb = (struct gl_framebuffer *) - _mesa_HashLookup(ctx->Shared->FrameBuffers, id); - return fb; -} - - -/** - * Mark the given framebuffer as invalid. This will force the - * test for framebuffer completeness to be done before the framebuffer - * is used. - */ -static void -invalidate_framebuffer(struct gl_framebuffer *fb) -{ - fb->_Status = 0; /* "indeterminate" */ -} - - -/** - * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding - * gl_renderbuffer_attachment object. - * This function is only used for user-created FB objects, not the - * default / window-system FB object. - * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to - * the depth buffer attachment point. - */ -struct gl_renderbuffer_attachment * -_mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, - GLenum attachment) -{ - GLuint i; - - assert(fb->Name > 0); - - switch (attachment) { - case GL_COLOR_ATTACHMENT0_EXT: - case GL_COLOR_ATTACHMENT1_EXT: - case GL_COLOR_ATTACHMENT2_EXT: - case GL_COLOR_ATTACHMENT3_EXT: - case GL_COLOR_ATTACHMENT4_EXT: - case GL_COLOR_ATTACHMENT5_EXT: - case GL_COLOR_ATTACHMENT6_EXT: - case GL_COLOR_ATTACHMENT7_EXT: - case GL_COLOR_ATTACHMENT8_EXT: - case GL_COLOR_ATTACHMENT9_EXT: - case GL_COLOR_ATTACHMENT10_EXT: - case GL_COLOR_ATTACHMENT11_EXT: - case GL_COLOR_ATTACHMENT12_EXT: - case GL_COLOR_ATTACHMENT13_EXT: - case GL_COLOR_ATTACHMENT14_EXT: - case GL_COLOR_ATTACHMENT15_EXT: - i = attachment - GL_COLOR_ATTACHMENT0_EXT; - if (i >= ctx->Const.MaxColorAttachments) { - return NULL; - } - return &fb->Attachment[BUFFER_COLOR0 + i]; - case GL_DEPTH_STENCIL_ATTACHMENT: - /* fall-through */ - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_DEPTH_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_STENCIL_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_STENCIL]; - default: - return NULL; - } -} - - -/** - * As above, but only used for getting attachments of the default / - * window-system framebuffer (not user-created framebuffer objects). - */ -static struct gl_renderbuffer_attachment * -_mesa_get_fb0_attachment(GLcontext *ctx, struct gl_framebuffer *fb, - GLenum attachment) -{ - assert(fb->Name == 0); - - switch (attachment) { - case GL_FRONT_LEFT: - return &fb->Attachment[BUFFER_FRONT_LEFT]; - case GL_FRONT_RIGHT: - return &fb->Attachment[BUFFER_FRONT_RIGHT]; - case GL_BACK_LEFT: - return &fb->Attachment[BUFFER_BACK_LEFT]; - case GL_BACK_RIGHT: - return &fb->Attachment[BUFFER_BACK_RIGHT]; - case GL_AUX0: - if (fb->Visual.numAuxBuffers == 1) { - return &fb->Attachment[BUFFER_AUX0]; - } - return NULL; - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_DEPTH_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_STENCIL_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_STENCIL]; - default: - return NULL; - } -} - - - -/** - * Remove any texture or renderbuffer attached to the given attachment - * point. Update reference counts, etc. - */ -void -_mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att) -{ - if (att->Type == GL_TEXTURE) { - ASSERT(att->Texture); - if (ctx->Driver.FinishRenderTexture) { - /* tell driver that we're done rendering to this texture. */ - ctx->Driver.FinishRenderTexture(ctx, att); - } - _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ - ASSERT(!att->Texture); - } - if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { - ASSERT(!att->Texture); - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ - ASSERT(!att->Renderbuffer); - } - att->Type = GL_NONE; - att->Complete = GL_TRUE; -} - - -/** - * Bind a texture object to an attachment point. - * The previous binding, if any, will be removed first. - */ -void -_mesa_set_texture_attachment(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att, - struct gl_texture_object *texObj, - GLenum texTarget, GLuint level, GLuint zoffset) -{ - if (att->Texture == texObj) { - /* re-attaching same texture */ - ASSERT(att->Type == GL_TEXTURE); - if (ctx->Driver.FinishRenderTexture) - ctx->Driver.FinishRenderTexture(ctx, att); - } - else { - /* new attachment */ - if (ctx->Driver.FinishRenderTexture && att->Texture) - ctx->Driver.FinishRenderTexture(ctx, att); - _mesa_remove_attachment(ctx, att); - att->Type = GL_TEXTURE; - assert(!att->Texture); - _mesa_reference_texobj(&att->Texture, texObj); - } - - /* always update these fields */ - att->TextureLevel = level; - att->CubeMapFace = _mesa_tex_target_to_face(texTarget); - att->Zoffset = zoffset; - att->Complete = GL_FALSE; - - if (att->Texture->Image[att->CubeMapFace][att->TextureLevel]) { - ctx->Driver.RenderTexture(ctx, fb, att); - } - - invalidate_framebuffer(fb); -} - - -/** - * Bind a renderbuffer to an attachment point. - * The previous binding, if any, will be removed first. - */ -void -_mesa_set_renderbuffer_attachment(GLcontext *ctx, - struct gl_renderbuffer_attachment *att, - struct gl_renderbuffer *rb) -{ - /* XXX check if re-doing same attachment, exit early */ - _mesa_remove_attachment(ctx, att); - att->Type = GL_RENDERBUFFER_EXT; - att->Texture = NULL; /* just to be safe */ - att->Complete = GL_FALSE; - _mesa_reference_renderbuffer(&att->Renderbuffer, rb); -} - - -/** - * Fallback for ctx->Driver.FramebufferRenderbuffer() - * Attach a renderbuffer object to a framebuffer object. - */ -void -_mesa_framebuffer_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLenum attachment, struct gl_renderbuffer *rb) -{ - struct gl_renderbuffer_attachment *att; - - _glthread_LOCK_MUTEX(fb->Mutex); - - att = _mesa_get_attachment(ctx, fb, attachment); - ASSERT(att); - if (rb) { - _mesa_set_renderbuffer_attachment(ctx, att, rb); - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - /* do stencil attachment here (depth already done above) */ - att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); - assert(att); - _mesa_set_renderbuffer_attachment(ctx, att, rb); - } - } - else { - _mesa_remove_attachment(ctx, att); - } - - invalidate_framebuffer(fb); - - _glthread_UNLOCK_MUTEX(fb->Mutex); -} - - -/** - * For debug only. - */ -static void -att_incomplete(const char *msg) -{ -#if DEBUG_FBO - _mesa_debug(NULL, "attachment incomplete: %s\n", msg); -#else - (void) msg; -#endif -} - - -/** - * For debug only. - */ -static void -fbo_incomplete(const char *msg, int index) -{ -#if DEBUG_FBO - _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); -#else - (void) msg; - (void) index; -#endif -} - - - - -/** - * Test if an attachment point is complete and update its Complete field. - * \param format if GL_COLOR, this is a color attachment point, - * if GL_DEPTH, this is a depth component attachment point, - * if GL_STENCIL, this is a stencil component attachment point. - */ -static void -test_attachment_completeness(const GLcontext *ctx, GLenum format, - struct gl_renderbuffer_attachment *att) -{ - assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); - - /* assume complete */ - att->Complete = GL_TRUE; - - /* Look for reasons why the attachment might be incomplete */ - if (att->Type == GL_TEXTURE) { - const struct gl_texture_object *texObj = att->Texture; - struct gl_texture_image *texImage; - GLenum baseFormat; - - if (!texObj) { - att_incomplete("no texobj"); - att->Complete = GL_FALSE; - return; - } - - texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; - if (!texImage) { - att_incomplete("no teximage"); - att->Complete = GL_FALSE; - return; - } - if (texImage->Width < 1 || texImage->Height < 1) { - att_incomplete("teximage width/height=0"); - printf("texobj = %u\n", texObj->Name); - printf("level = %d\n", att->TextureLevel); - att->Complete = GL_FALSE; - return; - } - if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { - att_incomplete("bad z offset"); - att->Complete = GL_FALSE; - return; - } - - baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - if (format == GL_COLOR) { - if (baseFormat != GL_RGB && - baseFormat != GL_RGBA && - (!ctx->Extensions.ARB_framebuffer_object || - baseFormat != GL_ALPHA)) { - att_incomplete("bad format"); - att->Complete = GL_FALSE; - return; - } - if (_mesa_is_format_compressed(texImage->TexFormat)) { - att_incomplete("compressed internalformat"); - att->Complete = GL_FALSE; - return; - } - } - else if (format == GL_DEPTH) { - if (baseFormat == GL_DEPTH_COMPONENT) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - ctx->Extensions.ARB_depth_texture && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att->Complete = GL_FALSE; - att_incomplete("bad depth format"); - return; - } - } - else { - ASSERT(format == GL_STENCIL); - if (ctx->Extensions.EXT_packed_depth_stencil && - ctx->Extensions.ARB_depth_texture && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - /* no such thing as stencil-only textures */ - att_incomplete("illegal stencil texture"); - att->Complete = GL_FALSE; - return; - } - } - } - else if (att->Type == GL_RENDERBUFFER_EXT) { - const GLenum baseFormat = - _mesa_get_format_base_format(att->Renderbuffer->Format); - - ASSERT(att->Renderbuffer); - if (!att->Renderbuffer->InternalFormat || - att->Renderbuffer->Width < 1 || - att->Renderbuffer->Height < 1) { - att_incomplete("0x0 renderbuffer"); - att->Complete = GL_FALSE; - return; - } - if (format == GL_COLOR) { - if (baseFormat != GL_RGB && - baseFormat != GL_RGBA) { - att_incomplete("bad renderbuffer color format"); - att->Complete = GL_FALSE; - return; - } - } - else if (format == GL_DEPTH) { - if (baseFormat == GL_DEPTH_COMPONENT) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att_incomplete("bad renderbuffer depth format"); - att->Complete = GL_FALSE; - return; - } - } - else { - assert(format == GL_STENCIL); - if (baseFormat == GL_STENCIL_INDEX) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att->Complete = GL_FALSE; - att_incomplete("bad renderbuffer stencil format"); - return; - } - } - } - else { - ASSERT(att->Type == GL_NONE); - /* complete */ - return; - } -} - - -/** - * Test if the given framebuffer object is complete and update its - * Status field with the results. - * Calls the ctx->Driver.ValidateFramebuffer() function to allow the - * driver to make hardware-specific validation/completeness checks. - * Also update the framebuffer's Width and Height fields if the - * framebuffer is complete. - */ -void -_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb) -{ - GLuint numImages; - GLenum intFormat = GL_NONE; /* color buffers' internal format */ - GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; - GLint numSamples = -1; - GLint i; - GLuint j; - - assert(fb->Name != 0); - - numImages = 0; - fb->Width = 0; - fb->Height = 0; - - /* Start at -2 to more easily loop over all attachment points. - * -2: depth buffer - * -1: stencil buffer - * >=0: color buffer - */ - for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { - struct gl_renderbuffer_attachment *att; - GLenum f; - - /* - * XXX for ARB_fbo, only check color buffers that are named by - * GL_READ_BUFFER and GL_DRAW_BUFFERi. - */ - - /* check for attachment completeness - */ - if (i == -2) { - att = &fb->Attachment[BUFFER_DEPTH]; - test_attachment_completeness(ctx, GL_DEPTH, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("depth attachment incomplete", -1); - return; - } - } - else if (i == -1) { - att = &fb->Attachment[BUFFER_STENCIL]; - test_attachment_completeness(ctx, GL_STENCIL, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("stencil attachment incomplete", -1); - return; - } - } - else { - att = &fb->Attachment[BUFFER_COLOR0 + i]; - test_attachment_completeness(ctx, GL_COLOR, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("color attachment incomplete", i); - return; - } - } - - /* get width, height, format of the renderbuffer/texture - */ - if (att->Type == GL_TEXTURE) { - const struct gl_texture_image *texImg - = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; - minWidth = MIN2(minWidth, texImg->Width); - maxWidth = MAX2(maxWidth, texImg->Width); - minHeight = MIN2(minHeight, texImg->Height); - maxHeight = MAX2(maxHeight, texImg->Height); - f = texImg->_BaseFormat; - numImages++; - if (f != GL_RGB && f != GL_RGBA && f != GL_DEPTH_COMPONENT - && f != GL_DEPTH_STENCIL_EXT - && (!ctx->Extensions.ARB_framebuffer_object || f != GL_ALPHA)) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; - fbo_incomplete("texture attachment incomplete", -1); - return; - } - } - else if (att->Type == GL_RENDERBUFFER_EXT) { - minWidth = MIN2(minWidth, att->Renderbuffer->Width); - maxWidth = MAX2(minWidth, att->Renderbuffer->Width); - minHeight = MIN2(minHeight, att->Renderbuffer->Height); - maxHeight = MAX2(minHeight, att->Renderbuffer->Height); - f = att->Renderbuffer->InternalFormat; - numImages++; - } - else { - assert(att->Type == GL_NONE); - continue; - } - - if (numSamples < 0) { - /* first buffer */ - numSamples = att->Renderbuffer->NumSamples; - } - - /* Error-check width, height, format, samples - */ - if (numImages == 1) { - /* save format, num samples */ - if (i >= 0) { - intFormat = f; - } - } - else { - if (!ctx->Extensions.ARB_framebuffer_object) { - /* check that width, height, format are same */ - if (minWidth != maxWidth || minHeight != maxHeight) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; - fbo_incomplete("width or height mismatch", -1); - return; - } - /* check that all color buffer have same format */ - if (intFormat != GL_NONE && f != intFormat) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; - fbo_incomplete("format mismatch", -1); - return; - } - } - if (att->Renderbuffer && - att->Renderbuffer->NumSamples != numSamples) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; - fbo_incomplete("inconsistant number of samples", i); - return; - } - - } - } - -#if FEATURE_GL - if (ctx->API == API_OPENGL) { - /* Check that all DrawBuffers are present */ - for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { - if (fb->ColorDrawBuffer[j] != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; - fbo_incomplete("missing drawbuffer", j); - return; - } - } - } - - /* Check that the ReadBuffer is present */ - if (fb->ColorReadBuffer != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; - fbo_incomplete("missing readbuffer", -1); - return; - } - } - } -#else - (void) j; -#endif - - if (numImages == 0) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; - fbo_incomplete("no attachments", -1); - return; - } - - /* Provisionally set status = COMPLETE ... */ - fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; - - /* ... but the driver may say the FB is incomplete. - * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED - * if anything. - */ - if (ctx->Driver.ValidateFramebuffer) { - ctx->Driver.ValidateFramebuffer(ctx, fb); - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - fbo_incomplete("driver marked FBO as incomplete", -1); - } - } - - if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { - /* - * Note that if ARB_framebuffer_object is supported and the attached - * renderbuffers/textures are different sizes, the framebuffer - * width/height will be set to the smallest width/height. - */ - fb->Width = minWidth; - fb->Height = minHeight; - - /* finally, update the visual info for the framebuffer */ - _mesa_update_framebuffer_visual(fb); - } -} - - -GLboolean GLAPIENTRY -_mesa_IsRenderbufferEXT(GLuint renderbuffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - if (renderbuffer) { - struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (rb != NULL && rb != &DummyRenderbuffer) - return GL_TRUE; - } - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) -{ - struct gl_renderbuffer *newRb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); - return; - } - - /* No need to flush here since the render buffer binding has no - * effect on rendering state. - */ - - if (renderbuffer) { - newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (newRb == &DummyRenderbuffer) { - /* ID was reserved, but no real renderbuffer object made yet */ - newRb = NULL; - } - else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { - /* All RB IDs must be Gen'd */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); - return; - } - - if (!newRb) { - /* create new renderbuffer object */ - newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); - if (!newRb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); - return; - } - ASSERT(newRb->AllocStorage); - _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); - newRb->RefCount = 1; /* referenced by hash table */ - } - } - else { - newRb = NULL; - } - - ASSERT(newRb != &DummyRenderbuffer); - - _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); -} - - -/** - * If the given renderbuffer is anywhere attached to the framebuffer, detach - * the renderbuffer. - * This is used when a renderbuffer object is deleted. - * The spec calls for unbinding. - */ -static void -detach_renderbuffer(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer *rb) -{ - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - if (fb->Attachment[i].Renderbuffer == rb) { - _mesa_remove_attachment(ctx, &fb->Attachment[i]); - } - } - invalidate_framebuffer(fb); -} - - -void GLAPIENTRY -_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - for (i = 0; i < n; i++) { - if (renderbuffers[i] > 0) { - struct gl_renderbuffer *rb; - rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); - if (rb) { - /* check if deleting currently bound renderbuffer object */ - if (rb == ctx->CurrentRenderbuffer) { - /* bind default */ - ASSERT(rb->RefCount >= 2); - _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); - } - - if (ctx->DrawBuffer->Name) { - detach_renderbuffer(ctx, ctx->DrawBuffer, rb); - } - if (ctx->ReadBuffer->Name && ctx->ReadBuffer != ctx->DrawBuffer) { - detach_renderbuffer(ctx, ctx->ReadBuffer, rb); - } - - /* Remove from hash table immediately, to free the ID. - * But the object will not be freed until it's no longer - * referenced anywhere else. - */ - _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); - - if (rb != &DummyRenderbuffer) { - /* no longer referenced by hash table */ - _mesa_reference_renderbuffer(&rb, NULL); - } - } - } - } -} - - -void GLAPIENTRY -_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); - return; - } - - if (!renderbuffers) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); - - for (i = 0; i < n; i++) { - GLuint name = first + i; - renderbuffers[i] = name; - /* insert dummy placeholder into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } -} - - -/** - * Given an internal format token for a render buffer, return the - * corresponding base format. - * This is very similar to _mesa_base_tex_format() but the set of valid - * internal formats is somewhat different. - * - * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT - * GL_DEPTH_STENCIL_EXT or zero if error. - * - * XXX in the future when we support red-only and red-green formats - * we'll also return GL_RED and GL_RG. - */ -GLenum -_mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat) -{ - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - case GL_RGBA16_SNORM: - return GL_RGBA; - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - return GL_STENCIL_INDEX; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_DEPTH_COMPONENT; - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - if (ctx->Extensions.EXT_packed_depth_stencil) - return GL_DEPTH_STENCIL_EXT; - else - return 0; - /* XXX add floating point formats eventually */ - default: - return 0; - } -} - - -/** sentinal value, see below */ -#define NO_SAMPLES 1000 - - -/** - * Helper function used by _mesa_RenderbufferStorageEXT() and - * _mesa_RenderbufferStorageMultisample(). - * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). - */ -static void -renderbuffer_storage(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei samples) -{ - const char *func = samples == NO_SAMPLES ? - "glRenderbufferStorage" : "RenderbufferStorageMultisample"; - struct gl_renderbuffer *rb; - GLenum baseFormat; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); - return; - } - - baseFormat = _mesa_base_fbo_format(ctx, internalFormat); - if (baseFormat == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); - return; - } - - if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); - return; - } - - if (height < 1 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); - return; - } - - if (samples == NO_SAMPLES) { - /* NumSamples == 0 indicates non-multisampling */ - samples = 0; - } - else if (samples > (GLsizei) ctx->Const.MaxSamples) { - /* note: driver may choose to use more samples than what's requested */ - _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - if (rb->InternalFormat == internalFormat && - rb->Width == (GLuint) width && - rb->Height == (GLuint) height) { - /* no change in allocation needed */ - return; - } - - /* These MUST get set by the AllocStorage func */ - rb->Format = MESA_FORMAT_NONE; - rb->NumSamples = samples; - - /* Now allocate the storage */ - ASSERT(rb->AllocStorage); - if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { - /* No error - check/set fields now */ - assert(rb->Format != MESA_FORMAT_NONE); - assert(rb->Width == (GLuint) width); - assert(rb->Height == (GLuint) height); - rb->InternalFormat = internalFormat; - rb->_BaseFormat = baseFormat; - assert(rb->_BaseFormat != 0); - } - else { - /* Probably ran out of memory - clear the fields */ - rb->Width = 0; - rb->Height = 0; - rb->Format = MESA_FORMAT_NONE; - rb->InternalFormat = GL_NONE; - rb->_BaseFormat = GL_NONE; - rb->NumSamples = 0; - } - - /* - test_framebuffer_completeness(ctx, fb); - */ - /* XXX if this renderbuffer is attached anywhere, invalidate attachment - * points??? - */ -} - - -#if FEATURE_OES_EGL_image -void GLAPIENTRY -_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) -{ - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.OES_EGL_image) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetRenderbufferStorageOES(unsupported)"); - return; - } - - if (target != GL_RENDERBUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, - "EGLImageTargetRenderbufferStorageOES"); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "EGLImageTargetRenderbufferStorageOES"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); -} -#endif - - -/** - * Helper function for _mesa_GetRenderbufferParameterivEXT() and - * _mesa_GetFramebufferAttachmentParameterivEXT() - * We have to be careful to respect the base format. For example, if a - * renderbuffer/texture was created with internalFormat=GL_RGB but the - * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE - * we need to return zero. - */ -static GLint -get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) -{ - switch (pname) { - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - default: - return 0; - } -} - - - -void GLAPIENTRY -_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) -{ - /* GL_ARB_fbo says calling this function is equivalent to calling - * glRenderbufferStorageMultisample() with samples=0. We pass in - * a token value here just for error reporting purposes. - */ - renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); -} - - -void GLAPIENTRY -_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, - GLenum internalFormat, - GLsizei width, GLsizei height) -{ - renderbuffer_storage(target, internalFormat, width, height, samples); -} - - -/** - * OpenGL ES version of glRenderBufferStorage. - */ -void GLAPIENTRY -_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) -{ - switch (internalFormat) { - case GL_RGB565: - /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ - /* choose a closest format */ - internalFormat = GL_RGB5; - break; - default: - break; - } - - renderbuffer_storage(target, internalFormat, width, height, 0); -} - - -void GLAPIENTRY -_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) -{ - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetRenderbufferParameterivEXT(target)"); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetRenderbufferParameterivEXT"); - return; - } - - /* No need to flush here since we're just quering state which is - * not effected by rendering. - */ - - switch (pname) { - case GL_RENDERBUFFER_WIDTH_EXT: - *params = rb->Width; - return; - case GL_RENDERBUFFER_HEIGHT_EXT: - *params = rb->Height; - return; - case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: - *params = rb->InternalFormat; - return; - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); - break; - case GL_RENDERBUFFER_SAMPLES: - if (ctx->Extensions.ARB_framebuffer_object) { - *params = rb->NumSamples; - break; - } - /* fallthrough */ - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetRenderbufferParameterivEXT(target)"); - return; - } -} - - -GLboolean GLAPIENTRY -_mesa_IsFramebufferEXT(GLuint framebuffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - if (framebuffer) { - struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); - if (rb != NULL && rb != &DummyFramebuffer) - return GL_TRUE; - } - return GL_FALSE; -} - - -/** - * Check if any of the attachments of the given framebuffer are textures - * (render to texture). Call ctx->Driver.RenderTexture() for such - * attachments. - */ -static void -check_begin_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) -{ - GLuint i; - ASSERT(ctx->Driver.RenderTexture); - - if (fb->Name == 0) - return; /* can't render to texture with winsys framebuffers */ - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - struct gl_texture_object *texObj = att->Texture; - if (texObj - && texObj->Image[att->CubeMapFace][att->TextureLevel]) { - ctx->Driver.RenderTexture(ctx, fb, att); - } - } -} - - -/** - * Examine all the framebuffer's attachments to see if any are textures. - * If so, call ctx->Driver.FinishRenderTexture() for each texture to - * notify the device driver that the texture image may have changed. - */ -static void -check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) -{ - if (fb->Name == 0) - return; /* can't render to texture with winsys framebuffers */ - - if (ctx->Driver.FinishRenderTexture) { - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Texture && att->Renderbuffer) { - ctx->Driver.FinishRenderTexture(ctx, att); - } - } - } -} - - -void GLAPIENTRY -_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) -{ - struct gl_framebuffer *newDrawFb, *newReadFb; - struct gl_framebuffer *oldDrawFb, *oldReadFb; - GLboolean bindReadBuf, bindDrawBuf; - GET_CURRENT_CONTEXT(ctx); - -#ifdef DEBUG - if (ctx->Extensions.ARB_framebuffer_object) { - ASSERT(ctx->Extensions.EXT_framebuffer_object); - ASSERT(ctx->Extensions.EXT_framebuffer_blit); - } -#endif - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindFramebufferEXT(unsupported)"); - return; - } - - switch (target) { -#if FEATURE_EXT_framebuffer_blit - case GL_DRAW_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - bindDrawBuf = GL_TRUE; - bindReadBuf = GL_FALSE; - break; - case GL_READ_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - bindDrawBuf = GL_FALSE; - bindReadBuf = GL_TRUE; - break; -#endif - case GL_FRAMEBUFFER_EXT: - bindDrawBuf = GL_TRUE; - bindReadBuf = GL_TRUE; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - - if (framebuffer) { - /* Binding a user-created framebuffer object */ - newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); - if (newDrawFb == &DummyFramebuffer) { - /* ID was reserved, but no real framebuffer object made yet */ - newDrawFb = NULL; - } - else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { - /* All FBO IDs must be Gen'd */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); - return; - } - - if (!newDrawFb) { - /* create new framebuffer object */ - newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); - if (!newDrawFb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); - return; - } - _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); - } - newReadFb = newDrawFb; - } - else { - /* Binding the window system framebuffer (which was originally set - * with MakeCurrent). - */ - newDrawFb = ctx->WinSysDrawBuffer; - newReadFb = ctx->WinSysReadBuffer; - } - - ASSERT(newDrawFb); - ASSERT(newDrawFb != &DummyFramebuffer); - - /* save pointers to current/old framebuffers */ - oldDrawFb = ctx->DrawBuffer; - oldReadFb = ctx->ReadBuffer; - - /* check if really changing bindings */ - if (oldDrawFb == newDrawFb) - bindDrawBuf = GL_FALSE; - if (oldReadFb == newReadFb) - bindReadBuf = GL_FALSE; - - /* - * OK, now bind the new Draw/Read framebuffers, if they're changing. - * - * We also check if we're beginning and/or ending render-to-texture. - * When a framebuffer with texture attachments is unbound, call - * ctx->Driver.FinishRenderTexture(). - * When a framebuffer with texture attachments is bound, call - * ctx->Driver.RenderTexture(). - * - * Note that if the ReadBuffer has texture attachments we don't consider - * that a render-to-texture case. - */ - if (bindReadBuf) { - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - /* check if old readbuffer was render-to-texture */ - check_end_texture_render(ctx, oldReadFb); - - _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); - } - - if (bindDrawBuf) { - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - /* check if old read/draw buffers were render-to-texture */ - if (!bindReadBuf) - check_end_texture_render(ctx, oldReadFb); - - if (oldDrawFb != oldReadFb) - check_end_texture_render(ctx, oldDrawFb); - - /* check if newly bound framebuffer has any texture attachments */ - check_begin_texture_render(ctx, newDrawFb); - - _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); - } - - if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { - ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); - } -} - - -void GLAPIENTRY -_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - for (i = 0; i < n; i++) { - if (framebuffers[i] > 0) { - struct gl_framebuffer *fb; - fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); - if (fb) { - ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); - - /* check if deleting currently bound framebuffer object */ - if (ctx->Extensions.EXT_framebuffer_blit) { - /* separate draw/read binding points */ - if (fb == ctx->DrawBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); - } - if (fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); - } - } - else { - /* only one binding point for read/draw buffers */ - if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - } - - /* remove from hash table immediately, to free the ID */ - _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); - - if (fb != &DummyFramebuffer) { - /* But the object will not be freed until it's no longer - * bound in any context. - */ - _mesa_reference_framebuffer(&fb, NULL); - } - } - } - } -} - - -void GLAPIENTRY -_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); - return; - } - - if (!framebuffers) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); - - for (i = 0; i < n; i++) { - GLuint name = first + i; - framebuffers[i] = name; - /* insert dummy placeholder into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } -} - - - -GLenum GLAPIENTRY -_mesa_CheckFramebufferStatusEXT(GLenum target) -{ - struct gl_framebuffer *buffer; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - switch (target) { -#if FEATURE_EXT_framebuffer_blit - case GL_DRAW_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); - return 0; - } - buffer = ctx->DrawBuffer; - break; - case GL_READ_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); - return 0; - } - buffer = ctx->ReadBuffer; - break; -#endif - case GL_FRAMEBUFFER_EXT: - buffer = ctx->DrawBuffer; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); - return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - } - - if (buffer->Name == 0) { - /* The window system / default framebuffer is always complete */ - return GL_FRAMEBUFFER_COMPLETE_EXT; - } - - /* No need to flush here */ - - if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { - _mesa_test_framebuffer_completeness(ctx, buffer); - } - - return buffer->_Status; -} - - - -/** - * Common code called by glFramebufferTexture1D/2D/3DEXT(). - */ -static void -framebuffer_texture(GLcontext *ctx, const char *caller, GLenum target, - GLenum attachment, GLenum textarget, GLuint texture, - GLint level, GLint zoffset) -{ - struct gl_renderbuffer_attachment *att; - struct gl_texture_object *texObj = NULL; - struct gl_framebuffer *fb; - GLboolean error = GL_FALSE; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { - case GL_READ_FRAMEBUFFER_EXT: - error = !ctx->Extensions.EXT_framebuffer_blit; - fb = ctx->ReadBuffer; - break; - case GL_DRAW_FRAMEBUFFER_EXT: - error = !ctx->Extensions.EXT_framebuffer_blit; - /* fall-through */ - case GL_FRAMEBUFFER_EXT: - fb = ctx->DrawBuffer; - break; - default: - error = GL_TRUE; - } - - if (error) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%sEXT(target=0x%x)", caller, target); - return; - } - - ASSERT(fb); - - /* check framebuffer binding */ - if (fb->Name == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT", caller); - return; - } - - - /* The textarget, level, and zoffset parameters are only validated if - * texture is non-zero. - */ - if (texture) { - GLboolean err = GL_TRUE; - - texObj = _mesa_lookup_texture(ctx, texture); - if (texObj != NULL) { - if (textarget == 0) { - /* XXX what's the purpose of this? */ - err = (texObj->Target != GL_TEXTURE_3D) && - (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && - (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); - } - else { - err = (texObj->Target == GL_TEXTURE_CUBE_MAP) - ? !IS_CUBE_FACE(textarget) - : (texObj->Target != textarget); - } - } - else { - /* can't render to a non-existant texture */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT(non existant texture)", - caller); - return; - } - - if (err) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT(texture target mismatch)", - caller); - return; - } - - if (texObj->Target == GL_TEXTURE_3D) { - const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); - if (zoffset < 0 || zoffset >= maxSize) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(zoffset)", caller); - return; - } - } - else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || - (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(layer)", caller); - return; - } - } - - if ((level < 0) || - (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(level)", caller); - return; - } - } - - att = _mesa_get_attachment(ctx, fb, attachment); - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%sEXT(attachment)", caller); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - _glthread_LOCK_MUTEX(fb->Mutex); - if (texObj) { - _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, - level, zoffset); - /* Set the render-to-texture flag. We'll check this flag in - * glTexImage() and friends to determine if we need to revalidate - * any FBOs that might be rendering into this texture. - * This flag never gets cleared since it's non-trivial to determine - * when all FBOs might be done rendering to this texture. That's OK - * though since it's uncommon to render to a texture then repeatedly - * call glTexImage() to change images in the texture. - */ - texObj->_RenderToTexture = GL_TRUE; - } - else { - _mesa_remove_attachment(ctx, att); - } - - invalidate_framebuffer(fb); - - _glthread_UNLOCK_MUTEX(fb->Mutex); -} - - - -void GLAPIENTRY -_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - - if ((texture != 0) && (textarget != GL_TEXTURE_1D)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture1DEXT(textarget)"); - return; - } - - framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, - level, 0); -} - - -void GLAPIENTRY -_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - - if ((texture != 0) && - (textarget != GL_TEXTURE_2D) && - (textarget != GL_TEXTURE_RECTANGLE_ARB) && - (!IS_CUBE_FACE(textarget))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture2DEXT(textarget=0x%x)", textarget); - return; - } - - framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, - level, 0); -} - - -void GLAPIENTRY -_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset) -{ - GET_CURRENT_CONTEXT(ctx); - - if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture3DEXT(textarget)"); - return; - } - - framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, - level, zoffset); -} - - -void GLAPIENTRY -_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLint layer) -{ - GET_CURRENT_CONTEXT(ctx); - - framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, - level, layer); -} - - -void GLAPIENTRY -_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, - GLenum renderbufferTarget, - GLuint renderbuffer) -{ - struct gl_renderbuffer_attachment *att; - struct gl_framebuffer *fb; - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { -#if FEATURE_EXT_framebuffer_blit - case GL_DRAW_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(target)"); - return; - } - fb = ctx->DrawBuffer; - break; - case GL_READ_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(target)"); - return; - } - fb = ctx->ReadBuffer; - break; -#endif - case GL_FRAMEBUFFER_EXT: - fb = ctx->DrawBuffer; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(target)"); - return; - } - - if (renderbufferTarget != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(renderbufferTarget)"); - return; - } - - if (fb->Name == 0) { - /* Can't attach new renderbuffers to a window system framebuffer */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); - return; - } - - att = _mesa_get_attachment(ctx, fb, attachment); - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(invalid attachment %s)", - _mesa_lookup_enum_by_nr(attachment)); - return; - } - - if (renderbuffer) { - rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbufferEXT(non-existant" - " renderbuffer %u)", renderbuffer); - return; - } - } - else { - /* remove renderbuffer attachment */ - rb = NULL; - } - - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && - rb && rb->Format != MESA_FORMAT_NONE) { - /* make sure the renderbuffer is a depth/stencil format */ - const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); - if (baseFormat != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbufferEXT(renderbuffer" - " is not DEPTH_STENCIL format)"); - return; - } - } - - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - assert(ctx->Driver.FramebufferRenderbuffer); - ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); - - /* Some subsequent GL commands may depend on the framebuffer's visual - * after the binding is updated. Update visual info now. - */ - _mesa_update_framebuffer_visual(fb); -} - - -void GLAPIENTRY -_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, - GLenum pname, GLint *params) -{ - const struct gl_renderbuffer_attachment *att; - struct gl_framebuffer *buffer; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (target) { -#if FEATURE_EXT_framebuffer_blit - case GL_DRAW_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(target)"); - return; - } - buffer = ctx->DrawBuffer; - break; - case GL_READ_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(target)"); - return; - } - buffer = ctx->ReadBuffer; - break; -#endif - case GL_FRAMEBUFFER_EXT: - buffer = ctx->DrawBuffer; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(target)"); - return; - } - - if (buffer->Name == 0) { - /* the default / window-system FBO */ - att = _mesa_get_fb0_attachment(ctx, buffer, attachment); - } - else { - /* user-created framebuffer FBO */ - att = _mesa_get_attachment(ctx, buffer, attachment); - } - - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(attachment)"); - return; - } - - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - /* the depth and stencil attachments must point to the same buffer */ - const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; - depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); - stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); - if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" - " attachments differ)"); - return; - } - } - - /* No need to flush here */ - - switch (pname) { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: - *params = att->Type; - return; - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: - if (att->Type == GL_RENDERBUFFER_EXT) { - *params = att->Renderbuffer->Name; - } - else if (att->Type == GL_TEXTURE) { - *params = att->Texture->Name; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: - if (att->Type == GL_TEXTURE) { - *params = att->TextureLevel; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: - if (att->Type == GL_TEXTURE) { - if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { - *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; - } - else { - *params = 0; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: - if (att->Type == GL_TEXTURE) { - if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { - *params = att->Zoffset; - } - else { - *params = 0; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - return; - } - else { - gl_format format = att->Renderbuffer->Format; - if (format == MESA_FORMAT_CI8 || format == MESA_FORMAT_S8) { - /* special cases */ - *params = GL_INDEX; - } - else { - *params = _mesa_get_format_datatype(format); - } - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else if (att->Texture) { - const struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, - att->TextureLevel); - if (texImage) { - *params = get_component_bits(pname, texImage->_BaseFormat, - texImage->TexFormat); - } - else { - *params = 0; - } - } - else if (att->Renderbuffer) { - *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, - att->Renderbuffer->Format); - } - else { - *params = 0; - } - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - return; - } -} - - -void GLAPIENTRY -_mesa_GenerateMipmapEXT(GLenum target) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - switch (target) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - case GL_TEXTURE_CUBE_MAP: - /* OK, legal value */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target)"); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - if (texObj->BaseLevel >= texObj->MaxLevel) { - /* nothing to do */ - return; - } - - _mesa_lock_texture(ctx, texObj); - if (target == GL_TEXTURE_CUBE_MAP) { - GLuint face; - for (face = 0; face < 6; face++) - ctx->Driver.GenerateMipmap(ctx, - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, - texObj); - } - else { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } - _mesa_unlock_texture(ctx, texObj); -} - - -#if FEATURE_EXT_framebuffer_blit - -static const struct gl_renderbuffer_attachment * -find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb) -{ - GLuint i; - for (i = 0; i < Elements(fb->Attachment); i++) { - if (fb->Attachment[i].Renderbuffer == rb) - return &fb->Attachment[i]; - } - return NULL; -} - - - -/** - * Blit rectangular region, optionally from one framebuffer to another. - * - * Note, if the src buffer is multisampled and the dest is not, this is - * when the samples must be resolved to a single color. - */ -void GLAPIENTRY -_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter) -{ - const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT); - const struct gl_framebuffer *readFb, *drawFb; - const struct gl_renderbuffer *colorReadRb, *colorDrawRb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - readFb = ctx->ReadBuffer; - drawFb = ctx->DrawBuffer; - - if (!readFb || !drawFb) { - /* This will normally never happen but someday we may want to - * support MakeCurrent() with no drawables. - */ - return; - } - - /* check for complete framebuffers */ - if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || - readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glBlitFramebufferEXT(incomplete draw/read buffers)"); - return; - } - - if (filter != GL_NEAREST && filter != GL_LINEAR) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); - return; - } - - if (mask & ~legalMaskBits) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); - return; - } - - /* depth/stencil must be blitted with nearest filtering */ - if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) - && filter != GL_NEAREST) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter"); - return; - } - - /* get color read/draw renderbuffers */ - if (mask & GL_COLOR_BUFFER_BIT) { - colorReadRb = readFb->_ColorReadBuffer; - colorDrawRb = drawFb->_ColorDrawBuffers[0]; - } - else { - colorReadRb = colorDrawRb = NULL; - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_StencilBuffer; - struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer; - if (!readRb || - !drawRb || - _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != - _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(stencil buffer size mismatch"); - return; - } - } - - if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_DepthBuffer; - struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer; - if (!readRb || - !drawRb || - _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != - _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(depth buffer size mismatch"); - return; - } - } - - if (readFb->Visual.samples > 0 && - drawFb->Visual.samples > 0 && - readFb->Visual.samples != drawFb->Visual.samples) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(mismatched samples"); - return; - } - - /* extra checks for multisample copies... */ - if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { - /* src and dest region sizes must be the same */ - if (srcX1 - srcX0 != dstX1 - dstX0 || - srcY1 - srcY0 != dstY1 - dstY0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(bad src/dst multisample region sizes"); - return; - } - - /* color formats must match */ - if (colorReadRb && - colorDrawRb && - colorReadRb->Format != colorDrawRb->Format) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(bad src/dst multisample pixel formats"); - return; - } - } - - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); - return; - } - - /* Debug code */ - if (DEBUG_BLIT) { - printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," - " 0x%x, 0x%x)\n", - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); - if (colorReadRb) { - const struct gl_renderbuffer_attachment *att; - - att = find_attachment(readFb, colorReadRb); - printf(" Src FBO %u RB %u (%dx%d) ", - readFb->Name, colorReadRb->Name, - colorReadRb->Width, colorReadRb->Height); - if (att && att->Texture) { - printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); - } - printf("\n"); - - att = find_attachment(drawFb, colorDrawRb); - printf(" Dst FBO %u RB %u (%dx%d) ", - drawFb->Name, colorDrawRb->Name, - colorDrawRb->Width, colorDrawRb->Height); - if (att && att->Texture) { - printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); - } - printf("\n"); - } - } - - ASSERT(ctx->Driver.BlitFramebuffer); - ctx->Driver.BlitFramebuffer(ctx, - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); -} -#endif /* FEATURE_EXT_framebuffer_blit */ - -#if FEATURE_ARB_geometry_shader4 -void GLAPIENTRY -_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, - GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTextureARB " - "not implemented!"); -} - -void GLAPIENTRY -_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTextureFaceARB " - "not implemented!"); -} -#endif /* FEATURE_ARB_geometry_shader4 */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* + * GL_EXT/ARB_framebuffer_object extensions + * + * Authors: + * Brian Paul + */ + + +#include "buffers.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "formats.h" +#include "framebuffer.h" +#include "hash.h" +#include "macros.h" +#include "renderbuffer.h" +#include "state.h" +#include "teximage.h" +#include "texobj.h" + + +/** Set this to 1 to help debug FBO incompleteness problems */ +#define DEBUG_FBO 0 + +/** Set this to 1 to debug/log glBlitFramebuffer() calls */ +#define DEBUG_BLIT 0 + + +/** + * Notes: + * + * None of the GL_EXT_framebuffer_object functions are compiled into + * display lists. + */ + + + +/* + * When glGenRender/FramebuffersEXT() is called we insert pointers to + * these placeholder objects into the hash table. + * Later, when the object ID is first bound, we replace the placeholder + * with the real frame/renderbuffer. + */ +static struct gl_framebuffer DummyFramebuffer; +static struct gl_renderbuffer DummyRenderbuffer; + +/* We bind this framebuffer when applications pass a NULL + * drawable/surface in make current. */ +static struct gl_framebuffer IncompleteFramebuffer; + + +#define IS_CUBE_FACE(TARGET) \ + ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \ + (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) + + +static void +delete_dummy_renderbuffer(struct gl_renderbuffer *rb) +{ + /* no op */ +} + +static void +delete_dummy_framebuffer(struct gl_framebuffer *fb) +{ + /* no op */ +} + + +void +_mesa_init_fbobjects(struct gl_context *ctx) +{ + _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); + _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); + _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); + DummyFramebuffer.Delete = delete_dummy_framebuffer; + DummyRenderbuffer.Delete = delete_dummy_renderbuffer; + IncompleteFramebuffer.Delete = delete_dummy_framebuffer; +} + +struct gl_framebuffer * +_mesa_get_incomplete_framebuffer(void) +{ + return &IncompleteFramebuffer; +} + +/** + * Helper routine for getting a gl_renderbuffer. + */ +struct gl_renderbuffer * +_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) +{ + struct gl_renderbuffer *rb; + + if (id == 0) + return NULL; + + rb = (struct gl_renderbuffer *) + _mesa_HashLookup(ctx->Shared->RenderBuffers, id); + return rb; +} + + +/** + * Helper routine for getting a gl_framebuffer. + */ +struct gl_framebuffer * +_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) +{ + struct gl_framebuffer *fb; + + if (id == 0) + return NULL; + + fb = (struct gl_framebuffer *) + _mesa_HashLookup(ctx->Shared->FrameBuffers, id); + return fb; +} + + +/** + * Mark the given framebuffer as invalid. This will force the + * test for framebuffer completeness to be done before the framebuffer + * is used. + */ +static void +invalidate_framebuffer(struct gl_framebuffer *fb) +{ + fb->_Status = 0; /* "indeterminate" */ +} + + +/** + * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding + * gl_renderbuffer_attachment object. + * This function is only used for user-created FB objects, not the + * default / window-system FB object. + * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to + * the depth buffer attachment point. + */ +struct gl_renderbuffer_attachment * +_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment) +{ + GLuint i; + + assert(fb->Name > 0); + + switch (attachment) { + case GL_COLOR_ATTACHMENT0_EXT: + case GL_COLOR_ATTACHMENT1_EXT: + case GL_COLOR_ATTACHMENT2_EXT: + case GL_COLOR_ATTACHMENT3_EXT: + case GL_COLOR_ATTACHMENT4_EXT: + case GL_COLOR_ATTACHMENT5_EXT: + case GL_COLOR_ATTACHMENT6_EXT: + case GL_COLOR_ATTACHMENT7_EXT: + case GL_COLOR_ATTACHMENT8_EXT: + case GL_COLOR_ATTACHMENT9_EXT: + case GL_COLOR_ATTACHMENT10_EXT: + case GL_COLOR_ATTACHMENT11_EXT: + case GL_COLOR_ATTACHMENT12_EXT: + case GL_COLOR_ATTACHMENT13_EXT: + case GL_COLOR_ATTACHMENT14_EXT: + case GL_COLOR_ATTACHMENT15_EXT: + i = attachment - GL_COLOR_ATTACHMENT0_EXT; + if (i >= ctx->Const.MaxColorAttachments) { + return NULL; + } + return &fb->Attachment[BUFFER_COLOR0 + i]; + case GL_DEPTH_STENCIL_ATTACHMENT: + /* fall-through */ + case GL_DEPTH_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_DEPTH_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_DEPTH]; + case GL_STENCIL_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_STENCIL_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_STENCIL]; + default: + return NULL; + } +} + + +/** + * As above, but only used for getting attachments of the default / + * window-system framebuffer (not user-created framebuffer objects). + */ +static struct gl_renderbuffer_attachment * +_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment) +{ + assert(fb->Name == 0); + + switch (attachment) { + case GL_FRONT_LEFT: + return &fb->Attachment[BUFFER_FRONT_LEFT]; + case GL_FRONT_RIGHT: + return &fb->Attachment[BUFFER_FRONT_RIGHT]; + case GL_BACK_LEFT: + return &fb->Attachment[BUFFER_BACK_LEFT]; + case GL_BACK_RIGHT: + return &fb->Attachment[BUFFER_BACK_RIGHT]; + case GL_AUX0: + if (fb->Visual.numAuxBuffers == 1) { + return &fb->Attachment[BUFFER_AUX0]; + } + return NULL; + case GL_DEPTH_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_DEPTH_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_DEPTH]; + case GL_STENCIL_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_STENCIL_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_STENCIL]; + default: + return NULL; + } +} + + + +/** + * Remove any texture or renderbuffer attached to the given attachment + * point. Update reference counts, etc. + */ +void +_mesa_remove_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att) +{ + if (att->Type == GL_TEXTURE) { + ASSERT(att->Texture); + if (ctx->Driver.FinishRenderTexture) { + /* tell driver that we're done rendering to this texture. */ + ctx->Driver.FinishRenderTexture(ctx, att); + } + _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ + ASSERT(!att->Texture); + } + if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { + ASSERT(!att->Texture); + _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ + ASSERT(!att->Renderbuffer); + } + att->Type = GL_NONE; + att->Complete = GL_TRUE; +} + + +/** + * Bind a texture object to an attachment point. + * The previous binding, if any, will be removed first. + */ +void +_mesa_set_texture_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att, + struct gl_texture_object *texObj, + GLenum texTarget, GLuint level, GLuint zoffset) +{ + if (att->Texture == texObj) { + /* re-attaching same texture */ + ASSERT(att->Type == GL_TEXTURE); + if (ctx->Driver.FinishRenderTexture) + ctx->Driver.FinishRenderTexture(ctx, att); + } + else { + /* new attachment */ + if (ctx->Driver.FinishRenderTexture && att->Texture) + ctx->Driver.FinishRenderTexture(ctx, att); + _mesa_remove_attachment(ctx, att); + att->Type = GL_TEXTURE; + assert(!att->Texture); + _mesa_reference_texobj(&att->Texture, texObj); + } + + /* always update these fields */ + att->TextureLevel = level; + att->CubeMapFace = _mesa_tex_target_to_face(texTarget); + att->Zoffset = zoffset; + att->Complete = GL_FALSE; + + if (att->Texture->Image[att->CubeMapFace][att->TextureLevel]) { + ctx->Driver.RenderTexture(ctx, fb, att); + } + + invalidate_framebuffer(fb); +} + + +/** + * Bind a renderbuffer to an attachment point. + * The previous binding, if any, will be removed first. + */ +void +_mesa_set_renderbuffer_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att, + struct gl_renderbuffer *rb) +{ + /* XXX check if re-doing same attachment, exit early */ + _mesa_remove_attachment(ctx, att); + att->Type = GL_RENDERBUFFER_EXT; + att->Texture = NULL; /* just to be safe */ + att->Complete = GL_FALSE; + _mesa_reference_renderbuffer(&att->Renderbuffer, rb); +} + + +/** + * Fallback for ctx->Driver.FramebufferRenderbuffer() + * Attach a renderbuffer object to a framebuffer object. + */ +void +_mesa_framebuffer_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb) +{ + struct gl_renderbuffer_attachment *att; + + _glthread_LOCK_MUTEX(fb->Mutex); + + att = _mesa_get_attachment(ctx, fb, attachment); + ASSERT(att); + if (rb) { + _mesa_set_renderbuffer_attachment(ctx, att, rb); + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* do stencil attachment here (depth already done above) */ + att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); + assert(att); + _mesa_set_renderbuffer_attachment(ctx, att, rb); + } + } + else { + _mesa_remove_attachment(ctx, att); + } + + invalidate_framebuffer(fb); + + _glthread_UNLOCK_MUTEX(fb->Mutex); +} + + +/** + * For debug only. + */ +static void +att_incomplete(const char *msg) +{ +#if DEBUG_FBO + _mesa_debug(NULL, "attachment incomplete: %s\n", msg); +#else + (void) msg; +#endif +} + + +/** + * For debug only. + */ +static void +fbo_incomplete(const char *msg, int index) +{ +#if DEBUG_FBO + _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); +#else + (void) msg; + (void) index; +#endif +} + + +/** + * Is the given base format a legal format for a color renderbuffer? + */ +static GLboolean +is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_RGB: + case GL_RGBA: + return GL_TRUE; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + return ctx->Extensions.ARB_framebuffer_object; + case GL_RED: + case GL_RG: + return ctx->Extensions.ARB_texture_rg; + default: + return GL_FALSE; + } +} + + +/** + * Is the given base format a legal format for a depth/stencil renderbuffer? + */ +static GLboolean +is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if an attachment point is complete and update its Complete field. + * \param format if GL_COLOR, this is a color attachment point, + * if GL_DEPTH, this is a depth component attachment point, + * if GL_STENCIL, this is a stencil component attachment point. + */ +static void +test_attachment_completeness(const struct gl_context *ctx, GLenum format, + struct gl_renderbuffer_attachment *att) +{ + assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); + + /* assume complete */ + att->Complete = GL_TRUE; + + /* Look for reasons why the attachment might be incomplete */ + if (att->Type == GL_TEXTURE) { + const struct gl_texture_object *texObj = att->Texture; + struct gl_texture_image *texImage; + GLenum baseFormat; + + if (!texObj) { + att_incomplete("no texobj"); + att->Complete = GL_FALSE; + return; + } + + texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; + if (!texImage) { + att_incomplete("no teximage"); + att->Complete = GL_FALSE; + return; + } + if (texImage->Width < 1 || texImage->Height < 1) { + att_incomplete("teximage width/height=0"); + printf("texobj = %u\n", texObj->Name); + printf("level = %d\n", att->TextureLevel); + att->Complete = GL_FALSE; + return; + } + if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { + att_incomplete("bad z offset"); + att->Complete = GL_FALSE; + return; + } + + baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + if (format == GL_COLOR) { + if (!is_legal_color_format(ctx, baseFormat)) { + att_incomplete("bad format"); + att->Complete = GL_FALSE; + return; + } + if (_mesa_is_format_compressed(texImage->TexFormat)) { + att_incomplete("compressed internalformat"); + att->Complete = GL_FALSE; + return; + } + } + else if (format == GL_DEPTH) { + if (baseFormat == GL_DEPTH_COMPONENT) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att->Complete = GL_FALSE; + att_incomplete("bad depth format"); + return; + } + } + else { + ASSERT(format == GL_STENCIL); + if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + /* no such thing as stencil-only textures */ + att_incomplete("illegal stencil texture"); + att->Complete = GL_FALSE; + return; + } + } + } + else if (att->Type == GL_RENDERBUFFER_EXT) { + const GLenum baseFormat = + _mesa_get_format_base_format(att->Renderbuffer->Format); + + ASSERT(att->Renderbuffer); + if (!att->Renderbuffer->InternalFormat || + att->Renderbuffer->Width < 1 || + att->Renderbuffer->Height < 1) { + att_incomplete("0x0 renderbuffer"); + att->Complete = GL_FALSE; + return; + } + if (format == GL_COLOR) { + if (baseFormat != GL_RGB && + baseFormat != GL_RGBA) { + att_incomplete("bad renderbuffer color format"); + att->Complete = GL_FALSE; + return; + } + } + else if (format == GL_DEPTH) { + if (baseFormat == GL_DEPTH_COMPONENT) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att_incomplete("bad renderbuffer depth format"); + att->Complete = GL_FALSE; + return; + } + } + else { + assert(format == GL_STENCIL); + if (baseFormat == GL_STENCIL_INDEX) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att->Complete = GL_FALSE; + att_incomplete("bad renderbuffer stencil format"); + return; + } + } + } + else { + ASSERT(att->Type == GL_NONE); + /* complete */ + return; + } +} + + +/** + * Test if the given framebuffer object is complete and update its + * Status field with the results. + * Calls the ctx->Driver.ValidateFramebuffer() function to allow the + * driver to make hardware-specific validation/completeness checks. + * Also update the framebuffer's Width and Height fields if the + * framebuffer is complete. + */ +void +_mesa_test_framebuffer_completeness(struct gl_context *ctx, + struct gl_framebuffer *fb) +{ + GLuint numImages; + GLenum intFormat = GL_NONE; /* color buffers' internal format */ + GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; + GLint numSamples = -1; + GLint i; + GLuint j; + + assert(fb->Name != 0); + + numImages = 0; + fb->Width = 0; + fb->Height = 0; + + /* Start at -2 to more easily loop over all attachment points. + * -2: depth buffer + * -1: stencil buffer + * >=0: color buffer + */ + for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { + struct gl_renderbuffer_attachment *att; + GLenum f; + gl_format mesaFormat; + + /* + * XXX for ARB_fbo, only check color buffers that are named by + * GL_READ_BUFFER and GL_DRAW_BUFFERi. + */ + + /* check for attachment completeness + */ + if (i == -2) { + att = &fb->Attachment[BUFFER_DEPTH]; + test_attachment_completeness(ctx, GL_DEPTH, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("depth attachment incomplete", -1); + return; + } + } + else if (i == -1) { + att = &fb->Attachment[BUFFER_STENCIL]; + test_attachment_completeness(ctx, GL_STENCIL, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("stencil attachment incomplete", -1); + return; + } + } + else { + att = &fb->Attachment[BUFFER_COLOR0 + i]; + test_attachment_completeness(ctx, GL_COLOR, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("color attachment incomplete", i); + return; + } + } + + /* get width, height, format of the renderbuffer/texture + */ + if (att->Type == GL_TEXTURE) { + const struct gl_texture_image *texImg + = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + minWidth = MIN2(minWidth, texImg->Width); + maxWidth = MAX2(maxWidth, texImg->Width); + minHeight = MIN2(minHeight, texImg->Height); + maxHeight = MAX2(maxHeight, texImg->Height); + f = texImg->_BaseFormat; + mesaFormat = texImg->TexFormat; + numImages++; + if (!is_legal_color_format(ctx, f) && + !is_legal_depth_format(ctx, f)) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; + fbo_incomplete("texture attachment incomplete", -1); + return; + } + } + else if (att->Type == GL_RENDERBUFFER_EXT) { + minWidth = MIN2(minWidth, att->Renderbuffer->Width); + maxWidth = MAX2(minWidth, att->Renderbuffer->Width); + minHeight = MIN2(minHeight, att->Renderbuffer->Height); + maxHeight = MAX2(minHeight, att->Renderbuffer->Height); + f = att->Renderbuffer->InternalFormat; + mesaFormat = att->Renderbuffer->Format; + numImages++; + } + else { + assert(att->Type == GL_NONE); + continue; + } + + if (numSamples < 0) { + /* first buffer */ + numSamples = att->Renderbuffer->NumSamples; + } + + /* check if integer color */ + fb->_IntegerColor = _mesa_is_format_integer_color(mesaFormat); + + /* Error-check width, height, format, samples + */ + if (numImages == 1) { + /* save format, num samples */ + if (i >= 0) { + intFormat = f; + } + } + else { + if (!ctx->Extensions.ARB_framebuffer_object) { + /* check that width, height, format are same */ + if (minWidth != maxWidth || minHeight != maxHeight) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; + fbo_incomplete("width or height mismatch", -1); + return; + } + /* check that all color buffer have same format */ + if (intFormat != GL_NONE && f != intFormat) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; + fbo_incomplete("format mismatch", -1); + return; + } + } + if (att->Renderbuffer && + att->Renderbuffer->NumSamples != numSamples) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; + fbo_incomplete("inconsistant number of samples", i); + return; + } + + } + } + +#if FEATURE_GL + if (ctx->API == API_OPENGL) { + /* Check that all DrawBuffers are present */ + for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { + if (fb->ColorDrawBuffer[j] != GL_NONE) { + const struct gl_renderbuffer_attachment *att + = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; + fbo_incomplete("missing drawbuffer", j); + return; + } + } + } + + /* Check that the ReadBuffer is present */ + if (fb->ColorReadBuffer != GL_NONE) { + const struct gl_renderbuffer_attachment *att + = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; + fbo_incomplete("missing readbuffer", -1); + return; + } + } + } +#else + (void) j; +#endif + + if (numImages == 0) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; + fbo_incomplete("no attachments", -1); + return; + } + + /* Provisionally set status = COMPLETE ... */ + fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; + + /* ... but the driver may say the FB is incomplete. + * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED + * if anything. + */ + if (ctx->Driver.ValidateFramebuffer) { + ctx->Driver.ValidateFramebuffer(ctx, fb); + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + fbo_incomplete("driver marked FBO as incomplete", -1); + } + } + + if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { + /* + * Note that if ARB_framebuffer_object is supported and the attached + * renderbuffers/textures are different sizes, the framebuffer + * width/height will be set to the smallest width/height. + */ + fb->Width = minWidth; + fb->Height = minHeight; + + /* finally, update the visual info for the framebuffer */ + _mesa_update_framebuffer_visual(fb); + } +} + + +GLboolean GLAPIENTRY +_mesa_IsRenderbufferEXT(GLuint renderbuffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + if (renderbuffer) { + struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (rb != NULL && rb != &DummyRenderbuffer) + return GL_TRUE; + } + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) +{ + struct gl_renderbuffer *newRb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); + return; + } + + /* No need to flush here since the render buffer binding has no + * effect on rendering state. + */ + + if (renderbuffer) { + newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (newRb == &DummyRenderbuffer) { + /* ID was reserved, but no real renderbuffer object made yet */ + newRb = NULL; + } + else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { + /* All RB IDs must be Gen'd */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); + return; + } + + if (!newRb) { + /* create new renderbuffer object */ + newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); + if (!newRb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); + return; + } + ASSERT(newRb->AllocStorage); + _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); + newRb->RefCount = 1; /* referenced by hash table */ + } + } + else { + newRb = NULL; + } + + ASSERT(newRb != &DummyRenderbuffer); + + _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); +} + + +/** + * If the given renderbuffer is anywhere attached to the framebuffer, detach + * the renderbuffer. + * This is used when a renderbuffer object is deleted. + * The spec calls for unbinding. + */ +static void +detach_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer *rb) +{ + GLuint i; + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer == rb) { + _mesa_remove_attachment(ctx, &fb->Attachment[i]); + } + } + invalidate_framebuffer(fb); +} + + +void GLAPIENTRY +_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + for (i = 0; i < n; i++) { + if (renderbuffers[i] > 0) { + struct gl_renderbuffer *rb; + rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); + if (rb) { + /* check if deleting currently bound renderbuffer object */ + if (rb == ctx->CurrentRenderbuffer) { + /* bind default */ + ASSERT(rb->RefCount >= 2); + _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + } + + if (ctx->DrawBuffer->Name) { + detach_renderbuffer(ctx, ctx->DrawBuffer, rb); + } + if (ctx->ReadBuffer->Name && ctx->ReadBuffer != ctx->DrawBuffer) { + detach_renderbuffer(ctx, ctx->ReadBuffer, rb); + } + + /* Remove from hash table immediately, to free the ID. + * But the object will not be freed until it's no longer + * referenced anywhere else. + */ + _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); + + if (rb != &DummyRenderbuffer) { + /* no longer referenced by hash table */ + _mesa_reference_renderbuffer(&rb, NULL); + } + } + } + } +} + + +void GLAPIENTRY +_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); + return; + } + + if (!renderbuffers) + return; + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); + + for (i = 0; i < n; i++) { + GLuint name = first + i; + renderbuffers[i] = name; + /* insert dummy placeholder into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } +} + + +/** + * Given an internal format token for a render buffer, return the + * corresponding base format. + * This is very similar to _mesa_base_tex_format() but the set of valid + * internal formats is somewhat different. + * + * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT + * GL_DEPTH_STENCIL_EXT or zero if error. + * + * XXX in the future when we support red-only and red-green formats + * we'll also return GL_RED and GL_RG. + */ +GLenum +_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) +{ + switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + case GL_RGBA16_SNORM: + return GL_RGBA; + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + return GL_STENCIL_INDEX; + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + if (ctx->Extensions.EXT_packed_depth_stencil) + return GL_DEPTH_STENCIL_EXT; + else + return 0; + /* XXX add floating point formats eventually */ + default: + return 0; + } +} + + +/** sentinal value, see below */ +#define NO_SAMPLES 1000 + + +/** + * Helper function used by _mesa_RenderbufferStorageEXT() and + * _mesa_RenderbufferStorageMultisample(). + * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). + */ +static void +renderbuffer_storage(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei samples) +{ + const char *func = samples == NO_SAMPLES ? + "glRenderbufferStorage" : "RenderbufferStorageMultisample"; + struct gl_renderbuffer *rb; + GLenum baseFormat; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); + return; + } + + baseFormat = _mesa_base_fbo_format(ctx, internalFormat); + if (baseFormat == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); + return; + } + + if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); + return; + } + + if (height < 1 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); + return; + } + + if (samples == NO_SAMPLES) { + /* NumSamples == 0 indicates non-multisampling */ + samples = 0; + } + else if (samples > (GLsizei) ctx->Const.MaxSamples) { + /* note: driver may choose to use more samples than what's requested */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + if (rb->InternalFormat == internalFormat && + rb->Width == (GLuint) width && + rb->Height == (GLuint) height) { + /* no change in allocation needed */ + return; + } + + /* These MUST get set by the AllocStorage func */ + rb->Format = MESA_FORMAT_NONE; + rb->NumSamples = samples; + + /* Now allocate the storage */ + ASSERT(rb->AllocStorage); + if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { + /* No error - check/set fields now */ + assert(rb->Format != MESA_FORMAT_NONE); + assert(rb->Width == (GLuint) width); + assert(rb->Height == (GLuint) height); + rb->InternalFormat = internalFormat; + rb->_BaseFormat = baseFormat; + assert(rb->_BaseFormat != 0); + } + else { + /* Probably ran out of memory - clear the fields */ + rb->Width = 0; + rb->Height = 0; + rb->Format = MESA_FORMAT_NONE; + rb->InternalFormat = GL_NONE; + rb->_BaseFormat = GL_NONE; + rb->NumSamples = 0; + } + + /* + test_framebuffer_completeness(ctx, fb); + */ + /* XXX if this renderbuffer is attached anywhere, invalidate attachment + * points??? + */ +} + + +#if FEATURE_OES_EGL_image +void GLAPIENTRY +_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetRenderbufferStorageOES(unsupported)"); + return; + } + + if (target != GL_RENDERBUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, + "EGLImageTargetRenderbufferStorageOES"); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "EGLImageTargetRenderbufferStorageOES"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); +} +#endif + + +/** + * Helper function for _mesa_GetRenderbufferParameterivEXT() and + * _mesa_GetFramebufferAttachmentParameterivEXT() + * We have to be careful to respect the base format. For example, if a + * renderbuffer/texture was created with internalFormat=GL_RGB but the + * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE + * we need to return zero. + */ +static GLint +get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) +{ + switch (pname) { + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL) + return _mesa_get_format_bits(format, pname); + else + return 0; + default: + return 0; + } +} + + + +void GLAPIENTRY +_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) +{ + /* GL_ARB_fbo says calling this function is equivalent to calling + * glRenderbufferStorageMultisample() with samples=0. We pass in + * a token value here just for error reporting purposes. + */ + renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); +} + + +void GLAPIENTRY +_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, + GLenum internalFormat, + GLsizei width, GLsizei height) +{ + renderbuffer_storage(target, internalFormat, width, height, samples); +} + + +/** + * OpenGL ES version of glRenderBufferStorage. + */ +void GLAPIENTRY +_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) +{ + switch (internalFormat) { + case GL_RGB565: + /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ + /* choose a closest format */ + internalFormat = GL_RGB5; + break; + default: + break; + } + + renderbuffer_storage(target, internalFormat, width, height, 0); +} + + +void GLAPIENTRY +_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) +{ + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetRenderbufferParameterivEXT(target)"); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetRenderbufferParameterivEXT"); + return; + } + + /* No need to flush here since we're just quering state which is + * not effected by rendering. + */ + + switch (pname) { + case GL_RENDERBUFFER_WIDTH_EXT: + *params = rb->Width; + return; + case GL_RENDERBUFFER_HEIGHT_EXT: + *params = rb->Height; + return; + case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: + *params = rb->InternalFormat; + return; + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); + break; + case GL_RENDERBUFFER_SAMPLES: + if (ctx->Extensions.ARB_framebuffer_object) { + *params = rb->NumSamples; + break; + } + /* fallthrough */ + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetRenderbufferParameterivEXT(target)"); + return; + } +} + + +GLboolean GLAPIENTRY +_mesa_IsFramebufferEXT(GLuint framebuffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + if (framebuffer) { + struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); + if (rb != NULL && rb != &DummyFramebuffer) + return GL_TRUE; + } + return GL_FALSE; +} + + +/** + * Check if any of the attachments of the given framebuffer are textures + * (render to texture). Call ctx->Driver.RenderTexture() for such + * attachments. + */ +static void +check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint i; + ASSERT(ctx->Driver.RenderTexture); + + if (fb->Name == 0) + return; /* can't render to texture with winsys framebuffers */ + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + struct gl_texture_object *texObj = att->Texture; + if (texObj + && texObj->Image[att->CubeMapFace][att->TextureLevel]) { + ctx->Driver.RenderTexture(ctx, fb, att); + } + } +} + + +/** + * Examine all the framebuffer's attachments to see if any are textures. + * If so, call ctx->Driver.FinishRenderTexture() for each texture to + * notify the device driver that the texture image may have changed. + */ +static void +check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Name == 0) + return; /* can't render to texture with winsys framebuffers */ + + if (ctx->Driver.FinishRenderTexture) { + GLuint i; + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Texture && att->Renderbuffer) { + ctx->Driver.FinishRenderTexture(ctx, att); + } + } + } +} + + +void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) +{ + struct gl_framebuffer *newDrawFb, *newReadFb; + struct gl_framebuffer *oldDrawFb, *oldReadFb; + GLboolean bindReadBuf, bindDrawBuf; + GET_CURRENT_CONTEXT(ctx); + +#ifdef DEBUG + if (ctx->Extensions.ARB_framebuffer_object) { + ASSERT(ctx->Extensions.EXT_framebuffer_object); + ASSERT(ctx->Extensions.EXT_framebuffer_blit); + } +#endif + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.EXT_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindFramebufferEXT(unsupported)"); + return; + } + + switch (target) { +#if FEATURE_EXT_framebuffer_blit + case GL_DRAW_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + bindDrawBuf = GL_TRUE; + bindReadBuf = GL_FALSE; + break; + case GL_READ_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + bindDrawBuf = GL_FALSE; + bindReadBuf = GL_TRUE; + break; +#endif + case GL_FRAMEBUFFER_EXT: + bindDrawBuf = GL_TRUE; + bindReadBuf = GL_TRUE; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + + if (framebuffer) { + /* Binding a user-created framebuffer object */ + newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); + if (newDrawFb == &DummyFramebuffer) { + /* ID was reserved, but no real framebuffer object made yet */ + newDrawFb = NULL; + } + else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { + /* All FBO IDs must be Gen'd */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); + return; + } + + if (!newDrawFb) { + /* create new framebuffer object */ + newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); + if (!newDrawFb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); + return; + } + _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); + } + newReadFb = newDrawFb; + } + else { + /* Binding the window system framebuffer (which was originally set + * with MakeCurrent). + */ + newDrawFb = ctx->WinSysDrawBuffer; + newReadFb = ctx->WinSysReadBuffer; + } + + ASSERT(newDrawFb); + ASSERT(newDrawFb != &DummyFramebuffer); + + /* save pointers to current/old framebuffers */ + oldDrawFb = ctx->DrawBuffer; + oldReadFb = ctx->ReadBuffer; + + /* check if really changing bindings */ + if (oldDrawFb == newDrawFb) + bindDrawBuf = GL_FALSE; + if (oldReadFb == newReadFb) + bindReadBuf = GL_FALSE; + + /* + * OK, now bind the new Draw/Read framebuffers, if they're changing. + * + * We also check if we're beginning and/or ending render-to-texture. + * When a framebuffer with texture attachments is unbound, call + * ctx->Driver.FinishRenderTexture(). + * When a framebuffer with texture attachments is bound, call + * ctx->Driver.RenderTexture(). + * + * Note that if the ReadBuffer has texture attachments we don't consider + * that a render-to-texture case. + */ + if (bindReadBuf) { + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + /* check if old readbuffer was render-to-texture */ + check_end_texture_render(ctx, oldReadFb); + + _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); + } + + if (bindDrawBuf) { + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + /* check if old read/draw buffers were render-to-texture */ + if (!bindReadBuf) + check_end_texture_render(ctx, oldReadFb); + + if (oldDrawFb != oldReadFb) + check_end_texture_render(ctx, oldDrawFb); + + /* check if newly bound framebuffer has any texture attachments */ + check_begin_texture_render(ctx, newDrawFb); + + _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); + } + + if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { + ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); + } +} + + +void GLAPIENTRY +_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + for (i = 0; i < n; i++) { + if (framebuffers[i] > 0) { + struct gl_framebuffer *fb; + fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); + if (fb) { + ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); + + /* check if deleting currently bound framebuffer object */ + if (ctx->Extensions.EXT_framebuffer_blit) { + /* separate draw/read binding points */ + if (fb == ctx->DrawBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + } + if (fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + } + } + else { + /* only one binding point for read/draw buffers */ + if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + } + + /* remove from hash table immediately, to free the ID */ + _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); + + if (fb != &DummyFramebuffer) { + /* But the object will not be freed until it's no longer + * bound in any context. + */ + _mesa_reference_framebuffer(&fb, NULL); + } + } + } + } +} + + +void GLAPIENTRY +_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); + return; + } + + if (!framebuffers) + return; + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); + + for (i = 0; i < n; i++) { + GLuint name = first + i; + framebuffers[i] = name; + /* insert dummy placeholder into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } +} + + + +GLenum GLAPIENTRY +_mesa_CheckFramebufferStatusEXT(GLenum target) +{ + struct gl_framebuffer *buffer; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + switch (target) { +#if FEATURE_EXT_framebuffer_blit + case GL_DRAW_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); + return 0; + } + buffer = ctx->DrawBuffer; + break; + case GL_READ_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); + return 0; + } + buffer = ctx->ReadBuffer; + break; +#endif + case GL_FRAMEBUFFER_EXT: + buffer = ctx->DrawBuffer; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); + return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */ + } + + if (buffer->Name == 0) { + /* The window system / default framebuffer is always complete */ + return GL_FRAMEBUFFER_COMPLETE_EXT; + } + + /* No need to flush here */ + + if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { + _mesa_test_framebuffer_completeness(ctx, buffer); + } + + return buffer->_Status; +} + + + +/** + * Common code called by glFramebufferTexture1D/2D/3DEXT(). + */ +static void +framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + struct gl_renderbuffer_attachment *att; + struct gl_texture_object *texObj = NULL; + struct gl_framebuffer *fb; + GLboolean error = GL_FALSE; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (target) { + case GL_READ_FRAMEBUFFER_EXT: + error = !ctx->Extensions.EXT_framebuffer_blit; + fb = ctx->ReadBuffer; + break; + case GL_DRAW_FRAMEBUFFER_EXT: + error = !ctx->Extensions.EXT_framebuffer_blit; + /* fall-through */ + case GL_FRAMEBUFFER_EXT: + fb = ctx->DrawBuffer; + break; + default: + error = GL_TRUE; + } + + if (error) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture%sEXT(target=0x%x)", caller, target); + return; + } + + ASSERT(fb); + + /* check framebuffer binding */ + if (fb->Name == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT", caller); + return; + } + + + /* The textarget, level, and zoffset parameters are only validated if + * texture is non-zero. + */ + if (texture) { + GLboolean err = GL_TRUE; + + texObj = _mesa_lookup_texture(ctx, texture); + if (texObj != NULL) { + if (textarget == 0) { + /* XXX what's the purpose of this? */ + err = (texObj->Target != GL_TEXTURE_3D) && + (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && + (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); + } + else { + err = (texObj->Target == GL_TEXTURE_CUBE_MAP) + ? !IS_CUBE_FACE(textarget) + : (texObj->Target != textarget); + } + } + else { + /* can't render to a non-existant texture */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT(non existant texture)", + caller); + return; + } + + if (err) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT(texture target mismatch)", + caller); + return; + } + + if (texObj->Target == GL_TEXTURE_3D) { + const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); + if (zoffset < 0 || zoffset >= maxSize) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(zoffset)", caller); + return; + } + } + else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || + (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(layer)", caller); + return; + } + } + + if ((level < 0) || + (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(level)", caller); + return; + } + } + + att = _mesa_get_attachment(ctx, fb, attachment); + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture%sEXT(attachment)", caller); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + _glthread_LOCK_MUTEX(fb->Mutex); + if (texObj) { + _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, + level, zoffset); + /* Set the render-to-texture flag. We'll check this flag in + * glTexImage() and friends to determine if we need to revalidate + * any FBOs that might be rendering into this texture. + * This flag never gets cleared since it's non-trivial to determine + * when all FBOs might be done rendering to this texture. That's OK + * though since it's uncommon to render to a texture then repeatedly + * call glTexImage() to change images in the texture. + */ + texObj->_RenderToTexture = GL_TRUE; + } + else { + _mesa_remove_attachment(ctx, att); + } + + invalidate_framebuffer(fb); + + _glthread_UNLOCK_MUTEX(fb->Mutex); +} + + + +void GLAPIENTRY +_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_1D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture1DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, + level, 0); +} + + +void GLAPIENTRY +_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && + (textarget != GL_TEXTURE_2D) && + (textarget != GL_TEXTURE_RECTANGLE_ARB) && + (!IS_CUBE_FACE(textarget))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture2DEXT(textarget=0x%x)", textarget); + return; + } + + framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, + level, 0); +} + + +void GLAPIENTRY +_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture3DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, + level, zoffset); +} + + +void GLAPIENTRY +_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLint layer) +{ + GET_CURRENT_CONTEXT(ctx); + + framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, + level, layer); +} + + +void GLAPIENTRY +_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, + GLenum renderbufferTarget, + GLuint renderbuffer) +{ + struct gl_renderbuffer_attachment *att; + struct gl_framebuffer *fb; + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (target) { +#if FEATURE_EXT_framebuffer_blit + case GL_DRAW_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(target)"); + return; + } + fb = ctx->DrawBuffer; + break; + case GL_READ_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(target)"); + return; + } + fb = ctx->ReadBuffer; + break; +#endif + case GL_FRAMEBUFFER_EXT: + fb = ctx->DrawBuffer; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(target)"); + return; + } + + if (renderbufferTarget != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(renderbufferTarget)"); + return; + } + + if (fb->Name == 0) { + /* Can't attach new renderbuffers to a window system framebuffer */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); + return; + } + + att = _mesa_get_attachment(ctx, fb, attachment); + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(invalid attachment %s)", + _mesa_lookup_enum_by_nr(attachment)); + return; + } + + if (renderbuffer) { + rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbufferEXT(non-existant" + " renderbuffer %u)", renderbuffer); + return; + } + } + else { + /* remove renderbuffer attachment */ + rb = NULL; + } + + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && + rb && rb->Format != MESA_FORMAT_NONE) { + /* make sure the renderbuffer is a depth/stencil format */ + const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); + if (baseFormat != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbufferEXT(renderbuffer" + " is not DEPTH_STENCIL format)"); + return; + } + } + + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + assert(ctx->Driver.FramebufferRenderbuffer); + ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); + + /* Some subsequent GL commands may depend on the framebuffer's visual + * after the binding is updated. Update visual info now. + */ + _mesa_update_framebuffer_visual(fb); +} + + +void GLAPIENTRY +_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, + GLenum pname, GLint *params) +{ + const struct gl_renderbuffer_attachment *att; + struct gl_framebuffer *buffer; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (target) { +#if FEATURE_EXT_framebuffer_blit + case GL_DRAW_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(target)"); + return; + } + buffer = ctx->DrawBuffer; + break; + case GL_READ_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(target)"); + return; + } + buffer = ctx->ReadBuffer; + break; +#endif + case GL_FRAMEBUFFER_EXT: + buffer = ctx->DrawBuffer; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(target)"); + return; + } + + if (buffer->Name == 0) { + /* the default / window-system FBO */ + att = _mesa_get_fb0_attachment(ctx, buffer, attachment); + } + else { + /* user-created framebuffer FBO */ + att = _mesa_get_attachment(ctx, buffer, attachment); + } + + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(attachment)"); + return; + } + + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* the depth and stencil attachments must point to the same buffer */ + const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; + depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); + stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); + if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" + " attachments differ)"); + return; + } + } + + /* No need to flush here */ + + switch (pname) { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: + *params = buffer->Name == 0 ? GL_FRAMEBUFFER_DEFAULT : att->Type; + return; + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: + if (att->Type == GL_RENDERBUFFER_EXT) { + *params = att->Renderbuffer->Name; + } + else if (att->Type == GL_TEXTURE) { + *params = att->Texture->Name; + } + else { + assert(att->Type == GL_NONE); + *params = 0; + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: + if (att->Type == GL_TEXTURE) { + *params = att->TextureLevel; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: + if (att->Type == GL_TEXTURE) { + if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { + *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + } + else { + *params = 0; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: + if (att->Type == GL_TEXTURE) { + if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { + *params = att->Zoffset; + } + else { + *params = 0; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + return; + } + else { + gl_format format = att->Renderbuffer->Format; + if (format == MESA_FORMAT_CI8 || format == MESA_FORMAT_S8) { + /* special cases */ + *params = GL_INDEX; + } + else { + *params = _mesa_get_format_datatype(format); + } + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else if (att->Texture) { + const struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, + att->TextureLevel); + if (texImage) { + *params = get_component_bits(pname, texImage->_BaseFormat, + texImage->TexFormat); + } + else { + *params = 0; + } + } + else if (att->Renderbuffer) { + *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, + att->Renderbuffer->Format); + } + else { + *params = 0; + } + return; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + return; + } +} + + +void GLAPIENTRY +_mesa_GenerateMipmapEXT(GLenum target) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + switch (target) { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_CUBE_MAP: + /* OK, legal value */ + break; + default: + /* XXX need to implement GL_TEXTURE_1D_ARRAY and GL_TEXTURE_2D_ARRAY */ + _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target)"); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + if (texObj->BaseLevel >= texObj->MaxLevel) { + /* nothing to do */ + return; + } + + if (texObj->Target == GL_TEXTURE_CUBE_MAP && + !_mesa_cube_complete(texObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGenerateMipmap(incomplete cube map)"); + return; + } + + _mesa_lock_texture(ctx, texObj); + if (target == GL_TEXTURE_CUBE_MAP) { + GLuint face; + for (face = 0; face < 6; face++) + ctx->Driver.GenerateMipmap(ctx, + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, + texObj); + } + else { + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } + _mesa_unlock_texture(ctx, texObj); +} + + +#if FEATURE_EXT_framebuffer_blit + +static const struct gl_renderbuffer_attachment * +find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb) +{ + GLuint i; + for (i = 0; i < Elements(fb->Attachment); i++) { + if (fb->Attachment[i].Renderbuffer == rb) + return &fb->Attachment[i]; + } + return NULL; +} + + + +/** + * Blit rectangular region, optionally from one framebuffer to another. + * + * Note, if the src buffer is multisampled and the dest is not, this is + * when the samples must be resolved to a single color. + */ +void GLAPIENTRY +_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | + GL_DEPTH_BUFFER_BIT | + GL_STENCIL_BUFFER_BIT); + const struct gl_framebuffer *readFb, *drawFb; + const struct gl_renderbuffer *colorReadRb, *colorDrawRb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + if (ctx->NewState) { + _mesa_update_state(ctx); + } + + readFb = ctx->ReadBuffer; + drawFb = ctx->DrawBuffer; + + if (!readFb || !drawFb) { + /* This will normally never happen but someday we may want to + * support MakeCurrent() with no drawables. + */ + return; + } + + /* check for complete framebuffers */ + if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || + readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glBlitFramebufferEXT(incomplete draw/read buffers)"); + return; + } + + if (filter != GL_NEAREST && filter != GL_LINEAR) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); + return; + } + + if (mask & ~legalMaskBits) { + _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); + return; + } + + /* depth/stencil must be blitted with nearest filtering */ + if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) + && filter != GL_NEAREST) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter"); + return; + } + + /* get color read/draw renderbuffers */ + if (mask & GL_COLOR_BUFFER_BIT) { + colorReadRb = readFb->_ColorReadBuffer; + colorDrawRb = drawFb->_ColorDrawBuffers[0]; + } + else { + colorReadRb = colorDrawRb = NULL; + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + struct gl_renderbuffer *readRb = readFb->_StencilBuffer; + struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer; + if (!readRb || + !drawRb || + _mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != + _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(stencil buffer size mismatch"); + return; + } + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + struct gl_renderbuffer *readRb = readFb->_DepthBuffer; + struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer; + if (!readRb || + !drawRb || + _mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != + _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(depth buffer size mismatch"); + return; + } + } + + if (readFb->Visual.samples > 0 && + drawFb->Visual.samples > 0 && + readFb->Visual.samples != drawFb->Visual.samples) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(mismatched samples"); + return; + } + + /* extra checks for multisample copies... */ + if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { + /* src and dest region sizes must be the same */ + if (srcX1 - srcX0 != dstX1 - dstX0 || + srcY1 - srcY0 != dstY1 - dstY0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(bad src/dst multisample region sizes"); + return; + } + + /* color formats must match */ + if (colorReadRb && + colorDrawRb && + colorReadRb->Format != colorDrawRb->Format) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(bad src/dst multisample pixel formats"); + return; + } + } + + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); + return; + } + + /* Debug code */ + if (DEBUG_BLIT) { + printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," + " 0x%x, 0x%x)\n", + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); + if (colorReadRb) { + const struct gl_renderbuffer_attachment *att; + + att = find_attachment(readFb, colorReadRb); + printf(" Src FBO %u RB %u (%dx%d) ", + readFb->Name, colorReadRb->Name, + colorReadRb->Width, colorReadRb->Height); + if (att && att->Texture) { + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); + } + printf("\n"); + + att = find_attachment(drawFb, colorDrawRb); + printf(" Dst FBO %u RB %u (%dx%d) ", + drawFb->Name, colorDrawRb->Name, + colorDrawRb->Width, colorDrawRb->Height); + if (att && att->Texture) { + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); + } + printf("\n"); + } + } + + ASSERT(ctx->Driver.BlitFramebuffer); + ctx->Driver.BlitFramebuffer(ctx, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); +} +#endif /* FEATURE_EXT_framebuffer_blit */ + +#if FEATURE_ARB_geometry_shader4 +void GLAPIENTRY +_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, + GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTextureARB " + "not implemented!"); +} + +void GLAPIENTRY +_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTextureFaceARB " + "not implemented!"); +} +#endif /* FEATURE_ARB_geometry_shader4 */ diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h index 9850ee9aa..5d250fba1 100644 --- a/mesalib/src/mesa/main/fbobject.h +++ b/mesalib/src/mesa/main/fbobject.h @@ -1,165 +1,168 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FBOBJECT_H -#define FBOBJECT_H - -#include "mtypes.h" - -extern void -_mesa_init_fbobjects(GLcontext *ctx); - -extern struct gl_framebuffer * -_mesa_get_incomplete_framebuffer(void); - -extern struct gl_renderbuffer * -_mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id); - -extern struct gl_framebuffer * -_mesa_lookup_framebuffer(GLcontext *ctx, GLuint id); - -extern struct gl_renderbuffer_attachment * -_mesa_get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, - GLenum attachment); - - -extern void -_mesa_remove_attachment(GLcontext *ctx, - struct gl_renderbuffer_attachment *att); - -extern void -_mesa_set_texture_attachment(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att, - struct gl_texture_object *texObj, - GLenum texTarget, GLuint level, GLuint zoffset); - -extern void -_mesa_set_renderbuffer_attachment(GLcontext *ctx, - struct gl_renderbuffer_attachment *att, - struct gl_renderbuffer *rb); - -extern void -_mesa_framebuffer_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLenum attachment, struct gl_renderbuffer *rb); - -extern void -_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb); - -extern GLenum -_mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat); - -extern GLboolean GLAPIENTRY -_mesa_IsRenderbufferEXT(GLuint renderbuffer); - -extern void GLAPIENTRY -_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); - -extern void GLAPIENTRY -_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); - -extern void GLAPIENTRY -_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers); - -extern void GLAPIENTRY -_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat, - GLsizei width, GLsizei height); - -extern void GLAPIENTRY -_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, - GLenum internalformat, - GLsizei width, GLsizei height); - -extern void GLAPIENTRY -_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height); - -extern void GLAPIENTRY -_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); - -extern void GLAPIENTRY -_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, - GLint *params); - -extern GLboolean GLAPIENTRY -_mesa_IsFramebufferEXT(GLuint framebuffer); - -extern void GLAPIENTRY -_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); - -extern void GLAPIENTRY -_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); - -extern void GLAPIENTRY -_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers); - -extern GLenum GLAPIENTRY -_mesa_CheckFramebufferStatusEXT(GLenum target); - -extern void GLAPIENTRY -_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level); - -extern void GLAPIENTRY -_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level); - -extern void GLAPIENTRY -_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset); - -extern void GLAPIENTRY -_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLint layer); - -extern void GLAPIENTRY -_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer); - -extern void GLAPIENTRY -_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, - GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GenerateMipmapEXT(GLenum target); - - -extern void GLAPIENTRY -_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); - -extern void GLAPIENTRY -_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, - GLuint texture, GLint level); - -extern void GLAPIENTRY -_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLenum face); - - -#endif /* FBOBJECT_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef FBOBJECT_H +#define FBOBJECT_H + +#include "glheader.h" + +struct gl_context; +struct gl_texture_object; + +extern void +_mesa_init_fbobjects(struct gl_context *ctx); + +extern struct gl_framebuffer * +_mesa_get_incomplete_framebuffer(void); + +extern struct gl_renderbuffer * +_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id); + +extern struct gl_framebuffer * +_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id); + +extern struct gl_renderbuffer_attachment * +_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment); + + +extern void +_mesa_remove_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + +extern void +_mesa_set_texture_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att, + struct gl_texture_object *texObj, + GLenum texTarget, GLuint level, GLuint zoffset); + +extern void +_mesa_set_renderbuffer_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att, + struct gl_renderbuffer *rb); + +extern void +_mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb); + +extern void +_mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb); + +extern GLenum +_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat); + +extern GLboolean GLAPIENTRY +_mesa_IsRenderbufferEXT(GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); + +extern void GLAPIENTRY +_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers); + +extern void GLAPIENTRY +_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, + GLenum internalformat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); + +extern void GLAPIENTRY +_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, + GLint *params); + +extern GLboolean GLAPIENTRY +_mesa_IsFramebufferEXT(GLuint framebuffer); + +extern void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); + +extern void GLAPIENTRY +_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); + +extern void GLAPIENTRY +_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers); + +extern GLenum GLAPIENTRY +_mesa_CheckFramebufferStatusEXT(GLenum target); + +extern void GLAPIENTRY +_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset); + +extern void GLAPIENTRY +_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLint layer); + +extern void GLAPIENTRY +_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer); + +extern void GLAPIENTRY +_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, + GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GenerateMipmapEXT(GLenum target); + + +extern void GLAPIENTRY +_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + +extern void GLAPIENTRY +_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, + GLuint texture, GLint level); + +extern void GLAPIENTRY +_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face); + + +#endif /* FBOBJECT_H */ diff --git a/mesalib/src/mesa/main/feedback.c b/mesalib/src/mesa/main/feedback.c index c72b91280..5ce0880c2 100644 --- a/mesalib/src/mesa/main/feedback.c +++ b/mesalib/src/mesa/main/feedback.c @@ -1,541 +1,541 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file feedback.c - * Selection and feedback modes functions. - */ - - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "enums.h" -#include "feedback.h" -#include "macros.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_feedback - - -#define FB_3D 0x01 -#define FB_4D 0x02 -#define FB_COLOR 0x04 -#define FB_TEXTURE 0X08 - - - -static void GLAPIENTRY -_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode==GL_FEEDBACK) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" ); - return; - } - if (size<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" ); - return; - } - if (!buffer) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" ); - ctx->Feedback.BufferSize = 0; - return; - } - - switch (type) { - case GL_2D: - ctx->Feedback._Mask = 0; - break; - case GL_3D: - ctx->Feedback._Mask = FB_3D; - break; - case GL_3D_COLOR: - ctx->Feedback._Mask = (FB_3D | FB_COLOR); - break; - case GL_3D_COLOR_TEXTURE: - ctx->Feedback._Mask = (FB_3D | FB_COLOR | FB_TEXTURE); - break; - case GL_4D_COLOR_TEXTURE: - ctx->Feedback._Mask = (FB_3D | FB_4D | FB_COLOR | FB_TEXTURE); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); /* Always flush */ - ctx->Feedback.Type = type; - ctx->Feedback.BufferSize = size; - ctx->Feedback.Buffer = buffer; - ctx->Feedback.Count = 0; /* Becaues of this. */ -} - - -static void GLAPIENTRY -_mesa_PassThrough( GLfloat token ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode==GL_FEEDBACK) { - FLUSH_VERTICES(ctx, 0); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN ); - _mesa_feedback_token( ctx, token ); - } -} - - -/** - * Put a vertex into the feedback buffer. - */ -void -_mesa_feedback_vertex(GLcontext *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4]) -{ - _mesa_feedback_token( ctx, win[0] ); - _mesa_feedback_token( ctx, win[1] ); - if (ctx->Feedback._Mask & FB_3D) { - _mesa_feedback_token( ctx, win[2] ); - } - if (ctx->Feedback._Mask & FB_4D) { - _mesa_feedback_token( ctx, win[3] ); - } - if (ctx->Feedback._Mask & FB_COLOR) { - _mesa_feedback_token( ctx, color[0] ); - _mesa_feedback_token( ctx, color[1] ); - _mesa_feedback_token( ctx, color[2] ); - _mesa_feedback_token( ctx, color[3] ); - } - if (ctx->Feedback._Mask & FB_TEXTURE) { - _mesa_feedback_token( ctx, texcoord[0] ); - _mesa_feedback_token( ctx, texcoord[1] ); - _mesa_feedback_token( ctx, texcoord[2] ); - _mesa_feedback_token( ctx, texcoord[3] ); - } -} - - -/**********************************************************************/ -/** \name Selection */ -/*@{*/ - -/** - * Establish a buffer for selection mode values. - * - * \param size buffer size. - * \param buffer buffer. - * - * \sa glSelectBuffer(). - * - * \note this function can't be put in a display list. - * - * Verifies we're not in selection mode, flushes the vertices and initialize - * the fields in __GLcontextRec::Select with the given buffer. - */ -static void GLAPIENTRY -_mesa_SelectBuffer( GLsizei size, GLuint *buffer ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode==GL_SELECT) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); - return; /* KW: added return */ - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - ctx->Select.Buffer = buffer; - ctx->Select.BufferSize = size; - ctx->Select.BufferCount = 0; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = 0.0; -} - - -/** - * Write a value of a record into the selection buffer. - * - * \param ctx GL context. - * \param value value. - * - * Verifies there is free space in the buffer to write the value and - * increments the pointer. - */ -static INLINE void -write_record(GLcontext *ctx, GLuint value) -{ - if (ctx->Select.BufferCount < ctx->Select.BufferSize) { - ctx->Select.Buffer[ctx->Select.BufferCount] = value; - } - ctx->Select.BufferCount++; -} - - -/** - * Update the hit flag and the maximum and minimum depth values. - * - * \param ctx GL context. - * \param z depth. - * - * Sets gl_selection::HitFlag and updates gl_selection::HitMinZ and - * gl_selection::HitMaxZ. - */ -void -_mesa_update_hitflag(GLcontext *ctx, GLfloat z) -{ - ctx->Select.HitFlag = GL_TRUE; - if (z < ctx->Select.HitMinZ) { - ctx->Select.HitMinZ = z; - } - if (z > ctx->Select.HitMaxZ) { - ctx->Select.HitMaxZ = z; - } -} - - -/** - * Write the hit record. - * - * \param ctx GL context. - * - * Write the hit record, i.e., the number of names in the stack, the minimum and - * maximum depth values and the number of names in the name stack at the time - * of the event. Resets the hit flag. - * - * \sa gl_selection. - */ -static void -write_hit_record(GLcontext *ctx) -{ - GLuint i; - GLuint zmin, zmax, zscale = (~0u); - - /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */ - /* 2^32-1 and round to nearest unsigned integer. */ - - assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */ - zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ); - zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ); - - write_record( ctx, ctx->Select.NameStackDepth ); - write_record( ctx, zmin ); - write_record( ctx, zmax ); - for (i = 0; i < ctx->Select.NameStackDepth; i++) { - write_record( ctx, ctx->Select.NameStack[i] ); - } - - ctx->Select.Hits++; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = -1.0; -} - - -/** - * Initialize the name stack. - * - * Verifies we are in select mode and resets the name stack depth and resets - * the hit record data in gl_selection. Marks new render mode in - * __GLcontextRec::NewState. - */ -static void GLAPIENTRY -_mesa_InitNames( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - /* Record the hit before the HitFlag is wiped out again. */ - if (ctx->RenderMode == GL_SELECT) { - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - } - ctx->Select.NameStackDepth = 0; - ctx->Select.HitFlag = GL_FALSE; - ctx->Select.HitMinZ = 1.0; - ctx->Select.HitMaxZ = 0.0; - ctx->NewState |= _NEW_RENDERMODE; -} - - -/** - * Load the top-most name of the name stack. - * - * \param name name. - * - * Verifies we are in selection mode and that the name stack is not empty. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and replace the top-most name in the stack. - * - * sa __GLcontextRec::Select. - */ -static void GLAPIENTRY -_mesa_LoadName( GLuint name ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - if (ctx->Select.NameStackDepth == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { - ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; - } - else { - ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; - } -} - - -/** - * Push a name into the name stack. - * - * \param name name. - * - * Verifies we are in selection mode and that the name stack is not full. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and adds the name to the top of the name stack. - * - * sa __GLcontextRec::Select. - */ -static void GLAPIENTRY -_mesa_PushName( GLuint name ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth >= MAX_NAME_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); - } - else - ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; -} - - -/** - * Pop a name into the name stack. - * - * Verifies we are in selection mode and that the name stack is not empty. - * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), - * and removes top-most name in the name stack. - * - * sa __GLcontextRec::Select. - */ -static void GLAPIENTRY -_mesa_PopName( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->RenderMode != GL_SELECT) { - return; - } - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.NameStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); - } - else - ctx->Select.NameStackDepth--; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Render Mode */ -/*@{*/ - -/** - * Set rasterization mode. - * - * \param mode rasterization mode. - * - * \note this function can't be put in a display list. - * - * \sa glRenderMode(). - * - * Flushes the vertices and do the necessary cleanup according to the previous - * rasterization mode, such as writing the hit record or resent the select - * buffer index when exiting the select mode. Updates - * __GLcontextRec::RenderMode and notifies the driver via the - * dd_function_table::RenderMode callback. - */ -static GLint GLAPIENTRY -_mesa_RenderMode( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint result; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); - - FLUSH_VERTICES(ctx, _NEW_RENDERMODE); - - switch (ctx->RenderMode) { - case GL_RENDER: - result = 0; - break; - case GL_SELECT: - if (ctx->Select.HitFlag) { - write_hit_record( ctx ); - } - if (ctx->Select.BufferCount > ctx->Select.BufferSize) { - /* overflow */ -#ifdef DEBUG - _mesa_warning(ctx, "Feedback buffer overflow"); -#endif - result = -1; - } - else { - result = ctx->Select.Hits; - } - ctx->Select.BufferCount = 0; - ctx->Select.Hits = 0; - ctx->Select.NameStackDepth = 0; - break; -#if _HAVE_FULL_GL - case GL_FEEDBACK: - if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { - /* overflow */ - result = -1; - } - else { - result = ctx->Feedback.Count; - } - ctx->Feedback.Count = 0; - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); - return 0; - } - - switch (mode) { - case GL_RENDER: - break; - case GL_SELECT: - if (ctx->Select.BufferSize==0) { - /* haven't called glSelectBuffer yet */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); - } - break; -#if _HAVE_FULL_GL - case GL_FEEDBACK: - if (ctx->Feedback.BufferSize==0) { - /* haven't called glFeedbackBuffer yet */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); - } - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); - return 0; - } - - ctx->RenderMode = mode; - if (ctx->Driver.RenderMode) - ctx->Driver.RenderMode( ctx, mode ); - - return result; -} - -/*@}*/ - - -void -_mesa_init_feedback_dispatch(struct _glapi_table *disp) -{ - SET_InitNames(disp, _mesa_InitNames); - SET_FeedbackBuffer(disp, _mesa_FeedbackBuffer); - SET_LoadName(disp, _mesa_LoadName); - SET_PassThrough(disp, _mesa_PassThrough); - SET_PopName(disp, _mesa_PopName); - SET_PushName(disp, _mesa_PushName); - SET_SelectBuffer(disp, _mesa_SelectBuffer); - SET_RenderMode(disp, _mesa_RenderMode); -} - - -#endif /* FEATURE_feedback */ - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialize context feedback data. - */ -void _mesa_init_feedback( GLcontext * ctx ) -{ - /* Feedback */ - ctx->Feedback.Type = GL_2D; /* TODO: verify */ - ctx->Feedback.Buffer = NULL; - ctx->Feedback.BufferSize = 0; - ctx->Feedback.Count = 0; - - /* Selection/picking */ - ctx->Select.Buffer = NULL; - ctx->Select.BufferSize = 0; - ctx->Select.BufferCount = 0; - ctx->Select.Hits = 0; - ctx->Select.NameStackDepth = 0; - - /* Miscellaneous */ - ctx->RenderMode = GL_RENDER; -} - -/*@}*/ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file feedback.c + * Selection and feedback modes functions. + */ + + +#include "glheader.h" +#include "colormac.h" +#include "context.h" +#include "enums.h" +#include "feedback.h" +#include "macros.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_feedback + + +#define FB_3D 0x01 +#define FB_4D 0x02 +#define FB_COLOR 0x04 +#define FB_TEXTURE 0X08 + + + +static void GLAPIENTRY +_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode==GL_FEEDBACK) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" ); + return; + } + if (size<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" ); + return; + } + if (!buffer) { + _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" ); + ctx->Feedback.BufferSize = 0; + return; + } + + switch (type) { + case GL_2D: + ctx->Feedback._Mask = 0; + break; + case GL_3D: + ctx->Feedback._Mask = FB_3D; + break; + case GL_3D_COLOR: + ctx->Feedback._Mask = (FB_3D | FB_COLOR); + break; + case GL_3D_COLOR_TEXTURE: + ctx->Feedback._Mask = (FB_3D | FB_COLOR | FB_TEXTURE); + break; + case GL_4D_COLOR_TEXTURE: + ctx->Feedback._Mask = (FB_3D | FB_4D | FB_COLOR | FB_TEXTURE); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" ); + return; + } + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); /* Always flush */ + ctx->Feedback.Type = type; + ctx->Feedback.BufferSize = size; + ctx->Feedback.Buffer = buffer; + ctx->Feedback.Count = 0; /* Becaues of this. */ +} + + +static void GLAPIENTRY +_mesa_PassThrough( GLfloat token ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode==GL_FEEDBACK) { + FLUSH_VERTICES(ctx, 0); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN ); + _mesa_feedback_token( ctx, token ); + } +} + + +/** + * Put a vertex into the feedback buffer. + */ +void +_mesa_feedback_vertex(struct gl_context *ctx, + const GLfloat win[4], + const GLfloat color[4], + const GLfloat texcoord[4]) +{ + _mesa_feedback_token( ctx, win[0] ); + _mesa_feedback_token( ctx, win[1] ); + if (ctx->Feedback._Mask & FB_3D) { + _mesa_feedback_token( ctx, win[2] ); + } + if (ctx->Feedback._Mask & FB_4D) { + _mesa_feedback_token( ctx, win[3] ); + } + if (ctx->Feedback._Mask & FB_COLOR) { + _mesa_feedback_token( ctx, color[0] ); + _mesa_feedback_token( ctx, color[1] ); + _mesa_feedback_token( ctx, color[2] ); + _mesa_feedback_token( ctx, color[3] ); + } + if (ctx->Feedback._Mask & FB_TEXTURE) { + _mesa_feedback_token( ctx, texcoord[0] ); + _mesa_feedback_token( ctx, texcoord[1] ); + _mesa_feedback_token( ctx, texcoord[2] ); + _mesa_feedback_token( ctx, texcoord[3] ); + } +} + + +/**********************************************************************/ +/** \name Selection */ +/*@{*/ + +/** + * Establish a buffer for selection mode values. + * + * \param size buffer size. + * \param buffer buffer. + * + * \sa glSelectBuffer(). + * + * \note this function can't be put in a display list. + * + * Verifies we're not in selection mode, flushes the vertices and initialize + * the fields in __struct gl_contextRec::Select with the given buffer. + */ +static void GLAPIENTRY +_mesa_SelectBuffer( GLsizei size, GLuint *buffer ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode==GL_SELECT) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); + return; /* KW: added return */ + } + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); + ctx->Select.Buffer = buffer; + ctx->Select.BufferSize = size; + ctx->Select.BufferCount = 0; + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = 0.0; +} + + +/** + * Write a value of a record into the selection buffer. + * + * \param ctx GL context. + * \param value value. + * + * Verifies there is free space in the buffer to write the value and + * increments the pointer. + */ +static INLINE void +write_record(struct gl_context *ctx, GLuint value) +{ + if (ctx->Select.BufferCount < ctx->Select.BufferSize) { + ctx->Select.Buffer[ctx->Select.BufferCount] = value; + } + ctx->Select.BufferCount++; +} + + +/** + * Update the hit flag and the maximum and minimum depth values. + * + * \param ctx GL context. + * \param z depth. + * + * Sets gl_selection::HitFlag and updates gl_selection::HitMinZ and + * gl_selection::HitMaxZ. + */ +void +_mesa_update_hitflag(struct gl_context *ctx, GLfloat z) +{ + ctx->Select.HitFlag = GL_TRUE; + if (z < ctx->Select.HitMinZ) { + ctx->Select.HitMinZ = z; + } + if (z > ctx->Select.HitMaxZ) { + ctx->Select.HitMaxZ = z; + } +} + + +/** + * Write the hit record. + * + * \param ctx GL context. + * + * Write the hit record, i.e., the number of names in the stack, the minimum and + * maximum depth values and the number of names in the name stack at the time + * of the event. Resets the hit flag. + * + * \sa gl_selection. + */ +static void +write_hit_record(struct gl_context *ctx) +{ + GLuint i; + GLuint zmin, zmax, zscale = (~0u); + + /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */ + /* 2^32-1 and round to nearest unsigned integer. */ + + assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */ + zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ); + zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ); + + write_record( ctx, ctx->Select.NameStackDepth ); + write_record( ctx, zmin ); + write_record( ctx, zmax ); + for (i = 0; i < ctx->Select.NameStackDepth; i++) { + write_record( ctx, ctx->Select.NameStack[i] ); + } + + ctx->Select.Hits++; + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = -1.0; +} + + +/** + * Initialize the name stack. + * + * Verifies we are in select mode and resets the name stack depth and resets + * the hit record data in gl_selection. Marks new render mode in + * __struct gl_contextRec::NewState. + */ +static void GLAPIENTRY +_mesa_InitNames( void ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + /* Record the hit before the HitFlag is wiped out again. */ + if (ctx->RenderMode == GL_SELECT) { + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + } + ctx->Select.NameStackDepth = 0; + ctx->Select.HitFlag = GL_FALSE; + ctx->Select.HitMinZ = 1.0; + ctx->Select.HitMaxZ = 0.0; + ctx->NewState |= _NEW_RENDERMODE; +} + + +/** + * Load the top-most name of the name stack. + * + * \param name name. + * + * Verifies we are in selection mode and that the name stack is not empty. + * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), + * and replace the top-most name in the stack. + * + * sa __struct gl_contextRec::Select. + */ +static void GLAPIENTRY +_mesa_LoadName( GLuint name ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode != GL_SELECT) { + return; + } + if (ctx->Select.NameStackDepth == 0) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); + return; + } + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); + + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { + ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; + } + else { + ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; + } +} + + +/** + * Push a name into the name stack. + * + * \param name name. + * + * Verifies we are in selection mode and that the name stack is not full. + * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), + * and adds the name to the top of the name stack. + * + * sa __struct gl_contextRec::Select. + */ +static void GLAPIENTRY +_mesa_PushName( GLuint name ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode != GL_SELECT) { + return; + } + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepth >= MAX_NAME_STACK_DEPTH) { + _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); + } + else + ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; +} + + +/** + * Pop a name into the name stack. + * + * Verifies we are in selection mode and that the name stack is not empty. + * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), + * and removes top-most name in the name stack. + * + * sa __struct gl_contextRec::Select. + */ +static void GLAPIENTRY +_mesa_PopName( void ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->RenderMode != GL_SELECT) { + return; + } + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.NameStackDepth == 0) { + _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); + } + else + ctx->Select.NameStackDepth--; +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Render Mode */ +/*@{*/ + +/** + * Set rasterization mode. + * + * \param mode rasterization mode. + * + * \note this function can't be put in a display list. + * + * \sa glRenderMode(). + * + * Flushes the vertices and do the necessary cleanup according to the previous + * rasterization mode, such as writing the hit record or resent the select + * buffer index when exiting the select mode. Updates + * __struct gl_contextRec::RenderMode and notifies the driver via the + * dd_function_table::RenderMode callback. + */ +static GLint GLAPIENTRY +_mesa_RenderMode( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint result; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); + + FLUSH_VERTICES(ctx, _NEW_RENDERMODE); + + switch (ctx->RenderMode) { + case GL_RENDER: + result = 0; + break; + case GL_SELECT: + if (ctx->Select.HitFlag) { + write_hit_record( ctx ); + } + if (ctx->Select.BufferCount > ctx->Select.BufferSize) { + /* overflow */ +#ifdef DEBUG + _mesa_warning(ctx, "Feedback buffer overflow"); +#endif + result = -1; + } + else { + result = ctx->Select.Hits; + } + ctx->Select.BufferCount = 0; + ctx->Select.Hits = 0; + ctx->Select.NameStackDepth = 0; + break; +#if _HAVE_FULL_GL + case GL_FEEDBACK: + if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { + /* overflow */ + result = -1; + } + else { + result = ctx->Feedback.Count; + } + ctx->Feedback.Count = 0; + break; +#endif + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); + return 0; + } + + switch (mode) { + case GL_RENDER: + break; + case GL_SELECT: + if (ctx->Select.BufferSize==0) { + /* haven't called glSelectBuffer yet */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); + } + break; +#if _HAVE_FULL_GL + case GL_FEEDBACK: + if (ctx->Feedback.BufferSize==0) { + /* haven't called glFeedbackBuffer yet */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); + } + break; +#endif + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); + return 0; + } + + ctx->RenderMode = mode; + if (ctx->Driver.RenderMode) + ctx->Driver.RenderMode( ctx, mode ); + + return result; +} + +/*@}*/ + + +void +_mesa_init_feedback_dispatch(struct _glapi_table *disp) +{ + SET_InitNames(disp, _mesa_InitNames); + SET_FeedbackBuffer(disp, _mesa_FeedbackBuffer); + SET_LoadName(disp, _mesa_LoadName); + SET_PassThrough(disp, _mesa_PassThrough); + SET_PopName(disp, _mesa_PopName); + SET_PushName(disp, _mesa_PushName); + SET_SelectBuffer(disp, _mesa_SelectBuffer); + SET_RenderMode(disp, _mesa_RenderMode); +} + + +#endif /* FEATURE_feedback */ + + +/**********************************************************************/ +/** \name Initialization */ +/*@{*/ + +/** + * Initialize context feedback data. + */ +void _mesa_init_feedback( struct gl_context * ctx ) +{ + /* Feedback */ + ctx->Feedback.Type = GL_2D; /* TODO: verify */ + ctx->Feedback.Buffer = NULL; + ctx->Feedback.BufferSize = 0; + ctx->Feedback.Count = 0; + + /* Selection/picking */ + ctx->Select.Buffer = NULL; + ctx->Select.BufferSize = 0; + ctx->Select.BufferCount = 0; + ctx->Select.Hits = 0; + ctx->Select.NameStackDepth = 0; + + /* Miscellaneous */ + ctx->RenderMode = GL_RENDER; +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/feedback.h b/mesalib/src/mesa/main/feedback.h index c6354b97b..06a07725d 100644 --- a/mesalib/src/mesa/main/feedback.h +++ b/mesalib/src/mesa/main/feedback.h @@ -1,98 +1,98 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef FEEDBACK_H -#define FEEDBACK_H - - -#include "main/mtypes.h" - - -#if FEATURE_feedback - -extern void -_mesa_feedback_vertex( GLcontext *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4] ); - - -static INLINE void -_mesa_feedback_token( GLcontext *ctx, GLfloat token ) -{ - if (ctx->Feedback.Count < ctx->Feedback.BufferSize) { - ctx->Feedback.Buffer[ctx->Feedback.Count] = token; - } - ctx->Feedback.Count++; -} - - -extern void -_mesa_update_hitflag( GLcontext *ctx, GLfloat z ); - - -extern void -_mesa_init_feedback_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_feedback */ - -#include "main/compiler.h" - -static INLINE void -_mesa_feedback_vertex( GLcontext *ctx, - const GLfloat win[4], - const GLfloat color[4], - const GLfloat texcoord[4] ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - - -static INLINE void -_mesa_feedback_token( GLcontext *ctx, GLfloat token ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_update_hitflag( GLcontext *ctx, GLfloat z ) -{ - /* render mode is always GL_RENDER */ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_init_feedback_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_feedback */ - -extern void -_mesa_init_feedback( GLcontext *ctx ); - -#endif /* FEEDBACK_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef FEEDBACK_H +#define FEEDBACK_H + + +#include "main/mtypes.h" + + +#if FEATURE_feedback + +extern void +_mesa_feedback_vertex( struct gl_context *ctx, + const GLfloat win[4], + const GLfloat color[4], + const GLfloat texcoord[4] ); + + +static INLINE void +_mesa_feedback_token( struct gl_context *ctx, GLfloat token ) +{ + if (ctx->Feedback.Count < ctx->Feedback.BufferSize) { + ctx->Feedback.Buffer[ctx->Feedback.Count] = token; + } + ctx->Feedback.Count++; +} + + +extern void +_mesa_update_hitflag( struct gl_context *ctx, GLfloat z ); + + +extern void +_mesa_init_feedback_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_feedback */ + +#include "main/compiler.h" + +static INLINE void +_mesa_feedback_vertex( struct gl_context *ctx, + const GLfloat win[4], + const GLfloat color[4], + const GLfloat texcoord[4] ) +{ + /* render mode is always GL_RENDER */ + ASSERT_NO_FEATURE(); +} + + +static INLINE void +_mesa_feedback_token( struct gl_context *ctx, GLfloat token ) +{ + /* render mode is always GL_RENDER */ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_update_hitflag( struct gl_context *ctx, GLfloat z ) +{ + /* render mode is always GL_RENDER */ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_init_feedback_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_feedback */ + +extern void +_mesa_init_feedback( struct gl_context *ctx ); + +#endif /* FEEDBACK_H */ diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c index 92fec09ba..60b200419 100644 --- a/mesalib/src/mesa/main/ffvertex_prog.c +++ b/mesalib/src/mesa/main/ffvertex_prog.c @@ -1,1679 +1,1679 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * \file ffvertex_prog.c - * - * Create a vertex program to execute the current fixed function T&L pipeline. - * \author Keith Whitwell - */ - - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/enums.h" -#include "main/ffvertex_prog.h" -#include "program/program.h" -#include "program/prog_cache.h" -#include "program/prog_instruction.h" -#include "program/prog_parameter.h" -#include "program/prog_print.h" -#include "program/prog_statevars.h" - - -/** Max of number of lights and texture coord units */ -#define NUM_UNITS MAX2(MAX_TEXTURE_COORD_UNITS, MAX_LIGHTS) - -struct state_key { - unsigned light_color_material_mask:12; - unsigned light_global_enabled:1; - unsigned light_local_viewer:1; - unsigned light_twoside:1; - unsigned material_shininess_is_zero:1; - unsigned need_eye_coords:1; - unsigned normalize:1; - unsigned rescale_normals:1; - - unsigned fog_source_is_depth:1; - unsigned separate_specular:1; - unsigned point_attenuated:1; - unsigned point_array:1; - unsigned texture_enabled_global:1; - unsigned fragprog_inputs_read:12; - - unsigned varying_vp_inputs; - - struct { - unsigned light_enabled:1; - unsigned light_eyepos3_is_zero:1; - unsigned light_spotcutoff_is_180:1; - unsigned light_attenuated:1; - unsigned texunit_really_enabled:1; - unsigned texmat_enabled:1; - unsigned coord_replace:1; - unsigned texgen_enabled:4; - unsigned texgen_mode0:4; - unsigned texgen_mode1:4; - unsigned texgen_mode2:4; - unsigned texgen_mode3:4; - } unit[NUM_UNITS]; -}; - - -#define TXG_NONE 0 -#define TXG_OBJ_LINEAR 1 -#define TXG_EYE_LINEAR 2 -#define TXG_SPHERE_MAP 3 -#define TXG_REFLECTION_MAP 4 -#define TXG_NORMAL_MAP 5 - -static GLuint translate_texgen( GLboolean enabled, GLenum mode ) -{ - if (!enabled) - return TXG_NONE; - - switch (mode) { - case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR; - case GL_EYE_LINEAR: return TXG_EYE_LINEAR; - case GL_SPHERE_MAP: return TXG_SPHERE_MAP; - case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP; - case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP; - default: return TXG_NONE; - } -} - - - -static GLboolean check_active_shininess( GLcontext *ctx, - const struct state_key *key, - GLuint side ) -{ - GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side); - - if ((key->varying_vp_inputs & VERT_BIT_COLOR0) && - (key->light_color_material_mask & bit)) - return GL_TRUE; - - if (key->varying_vp_inputs & (bit << 16)) - return GL_TRUE; - - if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 0.0F) - return GL_TRUE; - - return GL_FALSE; -} - - -static void make_state_key( GLcontext *ctx, struct state_key *key ) -{ - const struct gl_fragment_program *fp; - GLuint i; - - memset(key, 0, sizeof(struct state_key)); - fp = ctx->FragmentProgram._Current; - - /* This now relies on texenvprogram.c being active: - */ - assert(fp); - - key->need_eye_coords = ctx->_NeedEyeCoords; - - key->fragprog_inputs_read = fp->Base.InputsRead; - key->varying_vp_inputs = ctx->varying_vp_inputs; - - if (ctx->RenderMode == GL_FEEDBACK) { - /* make sure the vertprog emits color and tex0 */ - key->fragprog_inputs_read |= (FRAG_BIT_COL0 | FRAG_BIT_TEX0); - } - - key->separate_specular = (ctx->Light.Model.ColorControl == - GL_SEPARATE_SPECULAR_COLOR); - - if (ctx->Light.Enabled) { - key->light_global_enabled = 1; - - if (ctx->Light.Model.LocalViewer) - key->light_local_viewer = 1; - - if (ctx->Light.Model.TwoSide) - key->light_twoside = 1; - - if (ctx->Light.ColorMaterialEnabled) { - key->light_color_material_mask = ctx->Light.ColorMaterialBitmask; - } - - for (i = 0; i < MAX_LIGHTS; i++) { - struct gl_light *light = &ctx->Light.Light[i]; - - if (light->Enabled) { - key->unit[i].light_enabled = 1; - - if (light->EyePosition[3] == 0.0) - key->unit[i].light_eyepos3_is_zero = 1; - - if (light->SpotCutoff == 180.0) - key->unit[i].light_spotcutoff_is_180 = 1; - - if (light->ConstantAttenuation != 1.0 || - light->LinearAttenuation != 0.0 || - light->QuadraticAttenuation != 0.0) - key->unit[i].light_attenuated = 1; - } - } - - if (check_active_shininess(ctx, key, 0)) { - key->material_shininess_is_zero = 0; - } - else if (key->light_twoside && - check_active_shininess(ctx, key, 1)) { - key->material_shininess_is_zero = 0; - } - else { - key->material_shininess_is_zero = 1; - } - } - - if (ctx->Transform.Normalize) - key->normalize = 1; - - if (ctx->Transform.RescaleNormals) - key->rescale_normals = 1; - - if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) - key->fog_source_is_depth = 1; - - if (ctx->Point._Attenuated) - key->point_attenuated = 1; - -#if FEATURE_point_size_array - if (ctx->Array.ArrayObj->PointSize.Enabled) - key->point_array = 1; -#endif - - if (ctx->Texture._TexGenEnabled || - ctx->Texture._TexMatEnabled || - ctx->Texture._EnabledUnits) - key->texture_enabled_global = 1; - - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; - - if (texUnit->_ReallyEnabled) - key->unit[i].texunit_really_enabled = 1; - - if (ctx->Point.PointSprite) - if (ctx->Point.CoordReplace[i]) - key->unit[i].coord_replace = 1; - - if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) - key->unit[i].texmat_enabled = 1; - - if (texUnit->TexGenEnabled) { - key->unit[i].texgen_enabled = 1; - - key->unit[i].texgen_mode0 = - translate_texgen( texUnit->TexGenEnabled & (1<<0), - texUnit->GenS.Mode ); - key->unit[i].texgen_mode1 = - translate_texgen( texUnit->TexGenEnabled & (1<<1), - texUnit->GenT.Mode ); - key->unit[i].texgen_mode2 = - translate_texgen( texUnit->TexGenEnabled & (1<<2), - texUnit->GenR.Mode ); - key->unit[i].texgen_mode3 = - translate_texgen( texUnit->TexGenEnabled & (1<<3), - texUnit->GenQ.Mode ); - } - } -} - - - -/* Very useful debugging tool - produces annotated listing of - * generated program with line/function references for each - * instruction back into this file: - */ -#define DISASSEM 0 - - -/* Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. - * - * NOTE: These are passed by value extensively in this file rather - * than as usual by pointer reference. If this disturbs you, try - * remembering they are just 32bits in size. - * - * GCC is smart enough to deal with these dword-sized structures in - * much the same way as if I had defined them as dwords and was using - * macros to access and set the fields. This is much nicer and easier - * to evolve. - */ -struct ureg { - GLuint file:4; - GLint idx:9; /* relative addressing may be negative */ - /* sizeof(idx) should == sizeof(prog_src_reg::Index) */ - GLuint negate:1; - GLuint swz:12; - GLuint pad:6; -}; - - -struct tnl_program { - const struct state_key *state; - struct gl_vertex_program *program; - GLint max_inst; /** number of instructions allocated for program */ - GLboolean mvp_with_dp4; - - GLuint temp_in_use; - GLuint temp_reserved; - - struct ureg eye_position; - struct ureg eye_position_z; - struct ureg eye_position_normalized; - struct ureg transformed_normal; - struct ureg identity; - - GLuint materials; - GLuint color_materials; -}; - - -static const struct ureg undef = { - PROGRAM_UNDEFINED, - 0, - 0, - 0, - 0 -}; - -/* Local shorthand: - */ -#define X SWIZZLE_X -#define Y SWIZZLE_Y -#define Z SWIZZLE_Z -#define W SWIZZLE_W - - -/* Construct a ureg: - */ -static struct ureg make_ureg(GLuint file, GLint idx) -{ - struct ureg reg; - reg.file = file; - reg.idx = idx; - reg.negate = 0; - reg.swz = SWIZZLE_NOOP; - reg.pad = 0; - return reg; -} - - - -static struct ureg negate( struct ureg reg ) -{ - reg.negate ^= 1; - return reg; -} - - -static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) -{ - reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), - GET_SWZ(reg.swz, y), - GET_SWZ(reg.swz, z), - GET_SWZ(reg.swz, w)); - return reg; -} - - -static struct ureg swizzle1( struct ureg reg, int x ) -{ - return swizzle(reg, x, x, x, x); -} - - -static struct ureg get_temp( struct tnl_program *p ) -{ - int bit = _mesa_ffs( ~p->temp_in_use ); - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, bit-1); -} - - -static struct ureg reserve_temp( struct tnl_program *p ) -{ - struct ureg temp = get_temp( p ); - p->temp_reserved |= 1<temp_in_use &= ~(1<temp_in_use |= p->temp_reserved; /* can't release reserved temps */ - } -} - -static void release_temps( struct tnl_program *p ) -{ - p->temp_in_use = p->temp_reserved; -} - - -static struct ureg register_param5(struct tnl_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4) -{ - gl_state_index tokens[STATE_LENGTH]; - GLint idx; - tokens[0] = s0; - tokens[1] = s1; - tokens[2] = s2; - tokens[3] = s3; - tokens[4] = s4; - idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); - return make_ureg(PROGRAM_STATE_VAR, idx); -} - - -#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) -#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) -#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) - - - -/** - * \param input one of VERT_ATTRIB_x tokens. - */ -static struct ureg register_input( struct tnl_program *p, GLuint input ) -{ - assert(input < 32); - - if (p->state->varying_vp_inputs & (1<program->Base.InputsRead |= (1<program->Base.OutputsWritten |= BITFIELD64_BIT(output); - return make_ureg(PROGRAM_OUTPUT, output); -} - - -static struct ureg register_const4f( struct tnl_program *p, - GLfloat s0, - GLfloat s1, - GLfloat s2, - GLfloat s3) -{ - GLfloat values[4]; - GLint idx; - GLuint swizzle; - values[0] = s0; - values[1] = s1; - values[2] = s2; - values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, - &swizzle ); - ASSERT(swizzle == SWIZZLE_NOOP); - return make_ureg(PROGRAM_CONSTANT, idx); -} - -#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) -#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) -#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) - -static GLboolean is_undef( struct ureg reg ) -{ - return reg.file == PROGRAM_UNDEFINED; -} - - -static struct ureg get_identity_param( struct tnl_program *p ) -{ - if (is_undef(p->identity)) - p->identity = register_const4f(p, 0,0,0,1); - - return p->identity; -} - -static void register_matrix_param5( struct tnl_program *p, - GLint s0, /* modelview, projection, etc */ - GLint s1, /* texture matrix number */ - GLint s2, /* first row */ - GLint s3, /* last row */ - GLint s4, /* inverse, transpose, etc */ - struct ureg *matrix ) -{ - GLint i; - - /* This is a bit sad as the support is there to pull the whole - * matrix out in one go: - */ - for (i = 0; i <= s3 - s2; i++) - matrix[i] = register_param5( p, s0, s1, i, i, s4 ); -} - - -static void emit_arg( struct prog_src_register *src, - struct ureg reg ) -{ - src->File = reg.file; - src->Index = reg.idx; - src->Swizzle = reg.swz; - src->Negate = reg.negate ? NEGATE_XYZW : NEGATE_NONE; - src->Abs = 0; - src->RelAddr = 0; - /* Check that bitfield sizes aren't exceeded */ - ASSERT(src->Index == reg.idx); -} - - -static void emit_dst( struct prog_dst_register *dst, - struct ureg reg, GLuint mask ) -{ - dst->File = reg.file; - dst->Index = reg.idx; - /* allow zero as a shorthand for xyzw */ - dst->WriteMask = mask ? mask : WRITEMASK_XYZW; - dst->CondMask = COND_TR; /* always pass cond test */ - dst->CondSwizzle = SWIZZLE_NOOP; - dst->CondSrc = 0; - /* Check that bitfield sizes aren't exceeded */ - ASSERT(dst->Index == reg.idx); -} - - -static void debug_insn( struct prog_instruction *inst, const char *fn, - GLuint line ) -{ - if (DISASSEM) { - static const char *last_fn; - - if (fn != last_fn) { - last_fn = fn; - printf("%s:\n", fn); - } - - printf("%d:\t", line); - _mesa_print_instruction(inst); - } -} - - -static void emit_op3fn(struct tnl_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - struct ureg src0, - struct ureg src1, - struct ureg src2, - const char *fn, - GLuint line) -{ - GLuint nr; - struct prog_instruction *inst; - - assert((GLint) p->program->Base.NumInstructions <= p->max_inst); - - if (p->program->Base.NumInstructions == p->max_inst) { - /* need to extend the program's instruction array */ - struct prog_instruction *newInst; - - /* double the size */ - p->max_inst *= 2; - - newInst = _mesa_alloc_instructions(p->max_inst); - if (!newInst) { - _mesa_error(NULL, GL_OUT_OF_MEMORY, "vertex program build"); - return; - } - - _mesa_copy_instructions(newInst, - p->program->Base.Instructions, - p->program->Base.NumInstructions); - - _mesa_free_instructions(p->program->Base.Instructions, - p->program->Base.NumInstructions); - - p->program->Base.Instructions = newInst; - } - - nr = p->program->Base.NumInstructions++; - - inst = &p->program->Base.Instructions[nr]; - inst->Opcode = (enum prog_opcode) op; - inst->Data = 0; - - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); - - emit_dst( &inst->DstReg, dest, mask ); - - debug_insn(inst, fn, line); -} - - -#define emit_op3(p, op, dst, mask, src0, src1, src2) \ - emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__) - -#define emit_op2(p, op, dst, mask, src0, src1) \ - emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__) - -#define emit_op1(p, op, dst, mask, src0) \ - emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__) - - -static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) -{ - if (reg.file == PROGRAM_TEMPORARY && - !(p->temp_reserved & (1<eye_position)) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); - struct ureg modelview[4]; - - p->eye_position = reserve_temp(p); - - if (p->mvp_with_dp4) { - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - 0, modelview ); - - emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); - } - else { - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, modelview ); - - emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); - } - } - - return p->eye_position; -} - - -static struct ureg get_eye_position_z( struct tnl_program *p ) -{ - if (!is_undef(p->eye_position)) - return swizzle1(p->eye_position, Z); - - if (is_undef(p->eye_position_z)) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); - struct ureg modelview[4]; - - p->eye_position_z = reserve_temp(p); - - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, - 0, modelview ); - - emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]); - } - - return p->eye_position_z; -} - - -static struct ureg get_eye_position_normalized( struct tnl_program *p ) -{ - if (is_undef(p->eye_position_normalized)) { - struct ureg eye = get_eye_position(p); - p->eye_position_normalized = reserve_temp(p); - emit_normalize_vec3(p, p->eye_position_normalized, eye); - } - - return p->eye_position_normalized; -} - - -static struct ureg get_transformed_normal( struct tnl_program *p ) -{ - if (is_undef(p->transformed_normal) && - !p->state->need_eye_coords && - !p->state->normalize && - !(p->state->need_eye_coords == p->state->rescale_normals)) - { - p->transformed_normal = register_input(p, VERT_ATTRIB_NORMAL ); - } - else if (is_undef(p->transformed_normal)) - { - struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); - struct ureg mvinv[3]; - struct ureg transformed_normal = reserve_temp(p); - - if (p->state->need_eye_coords) { - register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, - STATE_MATRIX_INVTRANS, mvinv ); - - /* Transform to eye space: - */ - emit_matrix_transform_vec3( p, transformed_normal, mvinv, normal ); - normal = transformed_normal; - } - - /* Normalize/Rescale: - */ - if (p->state->normalize) { - emit_normalize_vec3( p, transformed_normal, normal ); - normal = transformed_normal; - } - else if (p->state->need_eye_coords == p->state->rescale_normals) { - /* This is already adjusted for eye/non-eye rendering: - */ - struct ureg rescale = register_param2(p, STATE_INTERNAL, - STATE_NORMAL_SCALE); - - emit_op2( p, OPCODE_MUL, transformed_normal, 0, normal, rescale ); - normal = transformed_normal; - } - - assert(normal.file == PROGRAM_TEMPORARY); - p->transformed_normal = normal; - } - - return p->transformed_normal; -} - - -static void build_hpos( struct tnl_program *p ) -{ - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); - struct ureg hpos = register_output( p, VERT_RESULT_HPOS ); - struct ureg mvp[4]; - - if (p->mvp_with_dp4) { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, - 0, mvp ); - emit_matrix_transform_vec4( p, hpos, mvp, pos ); - } - else { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, - STATE_MATRIX_TRANSPOSE, mvp ); - emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); - } -} - - -static GLuint material_attrib( GLuint side, GLuint property ) -{ - return (property - STATE_AMBIENT) * 2 + side; -} - - -/** - * Get a bitmask of which material values vary on a per-vertex basis. - */ -static void set_material_flags( struct tnl_program *p ) -{ - p->color_materials = 0; - p->materials = 0; - - if (p->state->varying_vp_inputs & VERT_BIT_COLOR0) { - p->materials = - p->color_materials = p->state->light_color_material_mask; - } - - p->materials |= (p->state->varying_vp_inputs >> 16); -} - - -static struct ureg get_material( struct tnl_program *p, GLuint side, - GLuint property ) -{ - GLuint attrib = material_attrib(side, property); - - if (p->color_materials & (1<materials & (1<materials & SCENE_COLOR_BITS(side)) { - struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT); - struct ureg material_emission = get_material(p, side, STATE_EMISSION); - struct ureg material_ambient = get_material(p, side, STATE_AMBIENT); - struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE); - struct ureg tmp = make_temp(p, material_diffuse); - emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, - material_ambient, material_emission); - return tmp; - } - else - return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side ); -} - - -static struct ureg get_lightprod( struct tnl_program *p, GLuint light, - GLuint side, GLuint property ) -{ - GLuint attrib = material_attrib(side, property); - if (p->materials & (1<state->unit[i].light_spotcutoff_is_180) { - struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_SPOT_DIR_NORMALIZED, i); - struct ureg spot = get_temp(p); - struct ureg slt = get_temp(p); - - emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm); - emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot); - emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W)); - emit_op2(p, OPCODE_MUL, att, 0, slt, spot); - - release_temp(p, spot); - release_temp(p, slt); - } - - /* Calculate distance attenuation: - */ - if (p->state->unit[i].light_attenuated) { - /* 1/d,d,d,1/d */ - emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); - /* 1,d,d*d,1/d */ - emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); - /* 1/dist-atten */ - emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); - - if (!p->state->unit[i].light_spotcutoff_is_180) { - /* dist-atten */ - emit_op1(p, OPCODE_RCP, dist, 0, dist); - /* spot-atten * dist-atten */ - emit_op2(p, OPCODE_MUL, att, 0, dist, att); - } - else { - /* dist-atten */ - emit_op1(p, OPCODE_RCP, att, 0, dist); - } - } - - return att; -} - - -/** - * Compute: - * lit.y = MAX(0, dots.x) - * lit.z = SLT(0, dots.x) - */ -static void emit_degenerate_lit( struct tnl_program *p, - struct ureg lit, - struct ureg dots ) -{ - struct ureg id = get_identity_param(p); /* id = {0,0,0,1} */ - - /* Note that lit.x & lit.w will not be examined. Note also that - * dots.xyzw == dots.xxxx. - */ - - /* MAX lit, id, dots; - */ - emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots); - - /* result[2] = (in > 0 ? 1 : 0) - * SLT lit.z, id.z, dots; # lit.z = (0 < dots.z) ? 1 : 0 - */ - emit_op2(p, OPCODE_SLT, lit, WRITEMASK_Z, swizzle1(id,Z), dots); -} - - -/* Need to add some addtional parameters to allow lighting in object - * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye - * space lighting. - */ -static void build_lighting( struct tnl_program *p ) -{ - const GLboolean twoside = p->state->light_twoside; - const GLboolean separate = p->state->separate_specular; - GLuint nr_lights = 0, count = 0; - struct ureg normal = get_transformed_normal(p); - struct ureg lit = get_temp(p); - struct ureg dots = get_temp(p); - struct ureg _col0 = undef, _col1 = undef; - struct ureg _bfc0 = undef, _bfc1 = undef; - GLuint i; - - /* - * NOTE: - * dots.x = dot(normal, VPpli) - * dots.y = dot(normal, halfAngle) - * dots.z = back.shininess - * dots.w = front.shininess - */ - - for (i = 0; i < MAX_LIGHTS; i++) - if (p->state->unit[i].light_enabled) - nr_lights++; - - set_material_flags(p); - - { - if (!p->state->material_shininess_is_zero) { - struct ureg shininess = get_material(p, 0, STATE_SHININESS); - emit_op1(p, OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X)); - release_temp(p, shininess); - } - - _col0 = make_temp(p, get_scenecolor(p, 0)); - if (separate) - _col1 = make_temp(p, get_identity_param(p)); - else - _col1 = _col0; - } - - if (twoside) { - if (!p->state->material_shininess_is_zero) { - /* Note that we negate the back-face specular exponent here. - * The negation will be un-done later in the back-face code below. - */ - struct ureg shininess = get_material(p, 1, STATE_SHININESS); - emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, - negate(swizzle1(shininess,X))); - release_temp(p, shininess); - } - - _bfc0 = make_temp(p, get_scenecolor(p, 1)); - if (separate) - _bfc1 = make_temp(p, get_identity_param(p)); - else - _bfc1 = _bfc0; - } - - /* If no lights, still need to emit the scenecolor. - */ - { - struct ureg res0 = register_output( p, VERT_RESULT_COL0 ); - emit_op1(p, OPCODE_MOV, res0, 0, _col0); - } - - if (separate) { - struct ureg res1 = register_output( p, VERT_RESULT_COL1 ); - emit_op1(p, OPCODE_MOV, res1, 0, _col1); - } - - if (twoside) { - struct ureg res0 = register_output( p, VERT_RESULT_BFC0 ); - emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); - } - - if (twoside && separate) { - struct ureg res1 = register_output( p, VERT_RESULT_BFC1 ); - emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); - } - - if (nr_lights == 0) { - release_temps(p); - return; - } - - for (i = 0; i < MAX_LIGHTS; i++) { - if (p->state->unit[i].light_enabled) { - struct ureg half = undef; - struct ureg att = undef, VPpli = undef; - - count++; - - if (p->state->unit[i].light_eyepos3_is_zero) { - /* Can used precomputed constants in this case. - * Attenuation never applies to infinite lights. - */ - VPpli = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_POSITION_NORMALIZED, i); - - if (!p->state->material_shininess_is_zero) { - if (p->state->light_local_viewer) { - struct ureg eye_hat = get_eye_position_normalized(p); - half = get_temp(p); - emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); - emit_normalize_vec3(p, half, half); - } - else { - half = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_HALF_VECTOR, i); - } - } - } - else { - struct ureg Ppli = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_POSITION, i); - struct ureg V = get_eye_position(p); - struct ureg dist = get_temp(p); - - VPpli = get_temp(p); - - /* Calculate VPpli vector - */ - emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); - - /* Normalize VPpli. The dist value also used in - * attenuation below. - */ - emit_op2(p, OPCODE_DP3, dist, 0, VPpli, VPpli); - emit_op1(p, OPCODE_RSQ, dist, 0, dist); - emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist); - - /* Calculate attenuation: - */ - if (!p->state->unit[i].light_spotcutoff_is_180 || - p->state->unit[i].light_attenuated) { - att = calculate_light_attenuation(p, i, VPpli, dist); - } - - /* Calculate viewer direction, or use infinite viewer: - */ - if (!p->state->material_shininess_is_zero) { - half = get_temp(p); - - if (p->state->light_local_viewer) { - struct ureg eye_hat = get_eye_position_normalized(p); - emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); - } - else { - struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); - emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir); - } - - emit_normalize_vec3(p, half, half); - } - - release_temp(p, dist); - } - - /* Calculate dot products: - */ - if (p->state->material_shininess_is_zero) { - emit_op2(p, OPCODE_DP3, dots, 0, normal, VPpli); - } - else { - emit_op2(p, OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli); - emit_op2(p, OPCODE_DP3, dots, WRITEMASK_Y, normal, half); - } - - /* Front face lighting: - */ - { - struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT); - struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE); - struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR); - struct ureg res0, res1; - GLuint mask0, mask1; - - if (count == nr_lights) { - if (separate) { - mask0 = WRITEMASK_XYZ; - mask1 = WRITEMASK_XYZ; - res0 = register_output( p, VERT_RESULT_COL0 ); - res1 = register_output( p, VERT_RESULT_COL1 ); - } - else { - mask0 = 0; - mask1 = WRITEMASK_XYZ; - res0 = _col0; - res1 = register_output( p, VERT_RESULT_COL0 ); - } - } - else { - mask0 = 0; - mask1 = 0; - res0 = _col0; - res1 = _col1; - } - - if (!is_undef(att)) { - /* light is attenuated by distance */ - emit_op1(p, OPCODE_LIT, lit, 0, dots); - emit_op2(p, OPCODE_MUL, lit, 0, lit, att); - emit_op3(p, OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0); - } - else if (!p->state->material_shininess_is_zero) { - /* there's a non-zero specular term */ - emit_op1(p, OPCODE_LIT, lit, 0, dots); - emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); - } - else { - /* no attenutation, no specular */ - emit_degenerate_lit(p, lit, dots); - emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); - } - - emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0); - emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1); - - release_temp(p, ambient); - release_temp(p, diffuse); - release_temp(p, specular); - } - - /* Back face lighting: - */ - if (twoside) { - struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT); - struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE); - struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR); - struct ureg res0, res1; - GLuint mask0, mask1; - - if (count == nr_lights) { - if (separate) { - mask0 = WRITEMASK_XYZ; - mask1 = WRITEMASK_XYZ; - res0 = register_output( p, VERT_RESULT_BFC0 ); - res1 = register_output( p, VERT_RESULT_BFC1 ); - } - else { - mask0 = 0; - mask1 = WRITEMASK_XYZ; - res0 = _bfc0; - res1 = register_output( p, VERT_RESULT_BFC0 ); - } - } - else { - res0 = _bfc0; - res1 = _bfc1; - mask0 = 0; - mask1 = 0; - } - - /* For the back face we need to negate the X and Y component - * dot products. dots.Z has the negated back-face specular - * exponent. We swizzle that into the W position. This - * negation makes the back-face specular term positive again. - */ - dots = negate(swizzle(dots,X,Y,W,Z)); - - if (!is_undef(att)) { - emit_op1(p, OPCODE_LIT, lit, 0, dots); - emit_op2(p, OPCODE_MUL, lit, 0, lit, att); - emit_op3(p, OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0); - } - else if (!p->state->material_shininess_is_zero) { - emit_op1(p, OPCODE_LIT, lit, 0, dots); - emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); /**/ - } - else { - emit_degenerate_lit(p, lit, dots); - emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); - } - - emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); - emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); - /* restore dots to its original state for subsequent lights - * by negating and swizzling again. - */ - dots = negate(swizzle(dots,X,Y,W,Z)); - - release_temp(p, ambient); - release_temp(p, diffuse); - release_temp(p, specular); - } - - release_temp(p, half); - release_temp(p, VPpli); - release_temp(p, att); - } - } - - release_temps( p ); -} - - -static void build_fog( struct tnl_program *p ) -{ - struct ureg fog = register_output(p, VERT_RESULT_FOGC); - struct ureg input; - - if (p->state->fog_source_is_depth) { - input = get_eye_position_z(p); - } - else { - input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); - } - - /* result.fog = {abs(f),0,0,1}; */ - emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); - emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p)); -} - - -static void build_reflect_texgen( struct tnl_program *p, - struct ureg dest, - GLuint writemask ) -{ - struct ureg normal = get_transformed_normal(p); - struct ureg eye_hat = get_eye_position_normalized(p); - struct ureg tmp = get_temp(p); - - /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); - /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); - /* (-2n.u)n + u */ - emit_op3(p, OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat); - - release_temp(p, tmp); -} - - -static void build_sphere_texgen( struct tnl_program *p, - struct ureg dest, - GLuint writemask ) -{ - struct ureg normal = get_transformed_normal(p); - struct ureg eye_hat = get_eye_position_normalized(p); - struct ureg tmp = get_temp(p); - struct ureg half = register_scalar_const(p, .5); - struct ureg r = get_temp(p); - struct ureg inv_m = get_temp(p); - struct ureg id = get_identity_param(p); - - /* Could share the above calculations, but it would be - * a fairly odd state for someone to set (both sphere and - * reflection active for different texture coordinate - * components. Of course - if two texture units enable - * reflect and/or sphere, things start to tilt in favour - * of seperating this out: - */ - - /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); - /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); - /* (-2n.u)n + u */ - emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); - /* r + 0,0,1 */ - emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); - /* rx^2 + ry^2 + (rz+1)^2 */ - emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); - /* 2/m */ - emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); - /* 1/m */ - emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); - /* r/m + 1/2 */ - emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); - - release_temp(p, tmp); - release_temp(p, r); - release_temp(p, inv_m); -} - - -static void build_texture_transform( struct tnl_program *p ) -{ - GLuint i, j; - - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - - if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) - continue; - - if (p->state->unit[i].coord_replace) - continue; - - if (p->state->unit[i].texgen_enabled || - p->state->unit[i].texmat_enabled) { - - GLuint texmat_enabled = p->state->unit[i].texmat_enabled; - struct ureg out = register_output(p, VERT_RESULT_TEX0 + i); - struct ureg out_texgen = undef; - - if (p->state->unit[i].texgen_enabled) { - GLuint copy_mask = 0; - GLuint sphere_mask = 0; - GLuint reflect_mask = 0; - GLuint normal_mask = 0; - GLuint modes[4]; - - if (texmat_enabled) - out_texgen = get_temp(p); - else - out_texgen = out; - - modes[0] = p->state->unit[i].texgen_mode0; - modes[1] = p->state->unit[i].texgen_mode1; - modes[2] = p->state->unit[i].texgen_mode2; - modes[3] = p->state->unit[i].texgen_mode3; - - for (j = 0; j < 4; j++) { - switch (modes[j]) { - case TXG_OBJ_LINEAR: { - struct ureg obj = register_input(p, VERT_ATTRIB_POS); - struct ureg plane = - register_param3(p, STATE_TEXGEN, i, - STATE_TEXGEN_OBJECT_S + j); - - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, - obj, plane ); - break; - } - case TXG_EYE_LINEAR: { - struct ureg eye = get_eye_position(p); - struct ureg plane = - register_param3(p, STATE_TEXGEN, i, - STATE_TEXGEN_EYE_S + j); - - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, - eye, plane ); - break; - } - case TXG_SPHERE_MAP: - sphere_mask |= WRITEMASK_X << j; - break; - case TXG_REFLECTION_MAP: - reflect_mask |= WRITEMASK_X << j; - break; - case TXG_NORMAL_MAP: - normal_mask |= WRITEMASK_X << j; - break; - case TXG_NONE: - copy_mask |= WRITEMASK_X << j; - } - } - - if (sphere_mask) { - build_sphere_texgen(p, out_texgen, sphere_mask); - } - - if (reflect_mask) { - build_reflect_texgen(p, out_texgen, reflect_mask); - } - - if (normal_mask) { - struct ureg normal = get_transformed_normal(p); - emit_op1(p, OPCODE_MOV, out_texgen, normal_mask, normal ); - } - - if (copy_mask) { - struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i); - emit_op1(p, OPCODE_MOV, out_texgen, copy_mask, in ); - } - } - - if (texmat_enabled) { - struct ureg texmat[4]; - struct ureg in = (!is_undef(out_texgen) ? - out_texgen : - register_input(p, VERT_ATTRIB_TEX0+i)); - if (p->mvp_with_dp4) { - register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, - 0, texmat ); - emit_matrix_transform_vec4( p, out, texmat, in ); - } - else { - register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, - STATE_MATRIX_TRANSPOSE, texmat ); - emit_transpose_matrix_transform_vec4( p, out, texmat, in ); - } - } - - release_temps(p); - } - else { - emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i); - } - } -} - - -/** - * Point size attenuation computation. - */ -static void build_atten_pointsize( struct tnl_program *p ) -{ - struct ureg eye = get_eye_position_z(p); - struct ureg state_size = register_param2(p, STATE_INTERNAL, STATE_POINT_SIZE_CLAMPED); - struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); - struct ureg out = register_output(p, VERT_RESULT_PSIZ); - struct ureg ut = get_temp(p); - - /* dist = |eyez| */ - emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z)); - /* p1 + dist * (p2 + dist * p3); */ - emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), - swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y)); - emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), - ut, swizzle1(state_attenuation, X)); - - /* 1 / sqrt(factor) */ - emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut ); - -#if 0 - /* out = pointSize / sqrt(factor) */ - emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size); -#else - /* this is a good place to clamp the point size since there's likely - * no hardware registers to clamp point size at rasterization time. - */ - emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size); - emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y)); - emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z)); -#endif - - release_temp(p, ut); -} - - -/** - * Pass-though per-vertex point size, from user's point size array. - */ -static void build_array_pointsize( struct tnl_program *p ) -{ - struct ureg in = register_input(p, VERT_ATTRIB_POINT_SIZE); - struct ureg out = register_output(p, VERT_RESULT_PSIZ); - emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, in); -} - - -static void build_tnl_program( struct tnl_program *p ) -{ - /* Emit the program, starting with modelviewproject: - */ - build_hpos(p); - - /* Lighting calculations: - */ - if (p->state->fragprog_inputs_read & (FRAG_BIT_COL0|FRAG_BIT_COL1)) { - if (p->state->light_global_enabled) - build_lighting(p); - else { - if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) - emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0); - - if (p->state->fragprog_inputs_read & FRAG_BIT_COL1) - emit_passthrough(p, VERT_ATTRIB_COLOR1, VERT_RESULT_COL1); - } - } - - if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC) - build_fog(p); - - if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY) - build_texture_transform(p); - - if (p->state->point_attenuated) - build_atten_pointsize(p); - else if (p->state->point_array) - build_array_pointsize(p); - - /* Finish up: - */ - emit_op1(p, OPCODE_END, undef, 0, undef); - - /* Disassemble: - */ - if (DISASSEM) { - printf ("\n"); - } -} - - -static void -create_new_program( const struct state_key *key, - struct gl_vertex_program *program, - GLboolean mvp_with_dp4, - GLuint max_temps) -{ - struct tnl_program p; - - memset(&p, 0, sizeof(p)); - p.state = key; - p.program = program; - p.eye_position = undef; - p.eye_position_z = undef; - p.eye_position_normalized = undef; - p.transformed_normal = undef; - p.identity = undef; - p.temp_in_use = 0; - p.mvp_with_dp4 = mvp_with_dp4; - - if (max_temps >= sizeof(int) * 8) - p.temp_reserved = 0; - else - p.temp_reserved = ~((1<Base.Instructions = _mesa_alloc_instructions(p.max_inst); - p.program->Base.String = NULL; - p.program->Base.NumInstructions = - p.program->Base.NumTemporaries = - p.program->Base.NumParameters = - p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0; - p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->Base.InputsRead = 0; - p.program->Base.OutputsWritten = 0; - - build_tnl_program( &p ); -} - - -/** - * Return a vertex program which implements the current fixed-function - * transform/lighting/texgen operations. - * XXX move this into core mesa (main/) - */ -struct gl_vertex_program * -_mesa_get_fixed_func_vertex_program(GLcontext *ctx) -{ - struct gl_vertex_program *prog; - struct state_key key; - - /* Grab all the relevent state and put it in a single structure: - */ - make_state_key(ctx, &key); - - /* Look for an already-prepared program for this state: - */ - prog = (struct gl_vertex_program *) - _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)); - - if (!prog) { - /* OK, we'll have to build a new one */ - if (0) - printf("Build new TNL program\n"); - - prog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); - if (!prog) - return NULL; - - create_new_program( &key, prog, - ctx->mvp_with_dp4, - ctx->Const.VertexProgram.MaxTemps ); - -#if 0 - if (ctx->Driver.ProgramStringNotify) - ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, - &prog->Base ); -#endif - _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, - &key, sizeof(key), &prog->Base); - } - - return prog; -} +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * \file ffvertex_prog.c + * + * Create a vertex program to execute the current fixed function T&L pipeline. + * \author Keith Whitwell + */ + + +#include "main/glheader.h" +#include "main/mtypes.h" +#include "main/macros.h" +#include "main/enums.h" +#include "main/ffvertex_prog.h" +#include "program/program.h" +#include "program/prog_cache.h" +#include "program/prog_instruction.h" +#include "program/prog_parameter.h" +#include "program/prog_print.h" +#include "program/prog_statevars.h" + + +/** Max of number of lights and texture coord units */ +#define NUM_UNITS MAX2(MAX_TEXTURE_COORD_UNITS, MAX_LIGHTS) + +struct state_key { + unsigned light_color_material_mask:12; + unsigned light_global_enabled:1; + unsigned light_local_viewer:1; + unsigned light_twoside:1; + unsigned material_shininess_is_zero:1; + unsigned need_eye_coords:1; + unsigned normalize:1; + unsigned rescale_normals:1; + + unsigned fog_source_is_depth:1; + unsigned separate_specular:1; + unsigned point_attenuated:1; + unsigned point_array:1; + unsigned texture_enabled_global:1; + unsigned fragprog_inputs_read:12; + + unsigned varying_vp_inputs; + + struct { + unsigned light_enabled:1; + unsigned light_eyepos3_is_zero:1; + unsigned light_spotcutoff_is_180:1; + unsigned light_attenuated:1; + unsigned texunit_really_enabled:1; + unsigned texmat_enabled:1; + unsigned coord_replace:1; + unsigned texgen_enabled:4; + unsigned texgen_mode0:4; + unsigned texgen_mode1:4; + unsigned texgen_mode2:4; + unsigned texgen_mode3:4; + } unit[NUM_UNITS]; +}; + + +#define TXG_NONE 0 +#define TXG_OBJ_LINEAR 1 +#define TXG_EYE_LINEAR 2 +#define TXG_SPHERE_MAP 3 +#define TXG_REFLECTION_MAP 4 +#define TXG_NORMAL_MAP 5 + +static GLuint translate_texgen( GLboolean enabled, GLenum mode ) +{ + if (!enabled) + return TXG_NONE; + + switch (mode) { + case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR; + case GL_EYE_LINEAR: return TXG_EYE_LINEAR; + case GL_SPHERE_MAP: return TXG_SPHERE_MAP; + case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP; + case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP; + default: return TXG_NONE; + } +} + + + +static GLboolean check_active_shininess( struct gl_context *ctx, + const struct state_key *key, + GLuint side ) +{ + GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side); + + if ((key->varying_vp_inputs & VERT_BIT_COLOR0) && + (key->light_color_material_mask & bit)) + return GL_TRUE; + + if (key->varying_vp_inputs & (bit << 16)) + return GL_TRUE; + + if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 0.0F) + return GL_TRUE; + + return GL_FALSE; +} + + +static void make_state_key( struct gl_context *ctx, struct state_key *key ) +{ + const struct gl_fragment_program *fp; + GLuint i; + + memset(key, 0, sizeof(struct state_key)); + fp = ctx->FragmentProgram._Current; + + /* This now relies on texenvprogram.c being active: + */ + assert(fp); + + key->need_eye_coords = ctx->_NeedEyeCoords; + + key->fragprog_inputs_read = fp->Base.InputsRead; + key->varying_vp_inputs = ctx->varying_vp_inputs; + + if (ctx->RenderMode == GL_FEEDBACK) { + /* make sure the vertprog emits color and tex0 */ + key->fragprog_inputs_read |= (FRAG_BIT_COL0 | FRAG_BIT_TEX0); + } + + key->separate_specular = (ctx->Light.Model.ColorControl == + GL_SEPARATE_SPECULAR_COLOR); + + if (ctx->Light.Enabled) { + key->light_global_enabled = 1; + + if (ctx->Light.Model.LocalViewer) + key->light_local_viewer = 1; + + if (ctx->Light.Model.TwoSide) + key->light_twoside = 1; + + if (ctx->Light.ColorMaterialEnabled) { + key->light_color_material_mask = ctx->Light.ColorMaterialBitmask; + } + + for (i = 0; i < MAX_LIGHTS; i++) { + struct gl_light *light = &ctx->Light.Light[i]; + + if (light->Enabled) { + key->unit[i].light_enabled = 1; + + if (light->EyePosition[3] == 0.0) + key->unit[i].light_eyepos3_is_zero = 1; + + if (light->SpotCutoff == 180.0) + key->unit[i].light_spotcutoff_is_180 = 1; + + if (light->ConstantAttenuation != 1.0 || + light->LinearAttenuation != 0.0 || + light->QuadraticAttenuation != 0.0) + key->unit[i].light_attenuated = 1; + } + } + + if (check_active_shininess(ctx, key, 0)) { + key->material_shininess_is_zero = 0; + } + else if (key->light_twoside && + check_active_shininess(ctx, key, 1)) { + key->material_shininess_is_zero = 0; + } + else { + key->material_shininess_is_zero = 1; + } + } + + if (ctx->Transform.Normalize) + key->normalize = 1; + + if (ctx->Transform.RescaleNormals) + key->rescale_normals = 1; + + if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) + key->fog_source_is_depth = 1; + + if (ctx->Point._Attenuated) + key->point_attenuated = 1; + +#if FEATURE_point_size_array + if (ctx->Array.ArrayObj->PointSize.Enabled) + key->point_array = 1; +#endif + + if (ctx->Texture._TexGenEnabled || + ctx->Texture._TexMatEnabled || + ctx->Texture._EnabledUnits) + key->texture_enabled_global = 1; + + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + + if (texUnit->_ReallyEnabled) + key->unit[i].texunit_really_enabled = 1; + + if (ctx->Point.PointSprite) + if (ctx->Point.CoordReplace[i]) + key->unit[i].coord_replace = 1; + + if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) + key->unit[i].texmat_enabled = 1; + + if (texUnit->TexGenEnabled) { + key->unit[i].texgen_enabled = 1; + + key->unit[i].texgen_mode0 = + translate_texgen( texUnit->TexGenEnabled & (1<<0), + texUnit->GenS.Mode ); + key->unit[i].texgen_mode1 = + translate_texgen( texUnit->TexGenEnabled & (1<<1), + texUnit->GenT.Mode ); + key->unit[i].texgen_mode2 = + translate_texgen( texUnit->TexGenEnabled & (1<<2), + texUnit->GenR.Mode ); + key->unit[i].texgen_mode3 = + translate_texgen( texUnit->TexGenEnabled & (1<<3), + texUnit->GenQ.Mode ); + } + } +} + + + +/* Very useful debugging tool - produces annotated listing of + * generated program with line/function references for each + * instruction back into this file: + */ +#define DISASSEM 0 + + +/* Use uregs to represent registers internally, translate to Mesa's + * expected formats on emit. + * + * NOTE: These are passed by value extensively in this file rather + * than as usual by pointer reference. If this disturbs you, try + * remembering they are just 32bits in size. + * + * GCC is smart enough to deal with these dword-sized structures in + * much the same way as if I had defined them as dwords and was using + * macros to access and set the fields. This is much nicer and easier + * to evolve. + */ +struct ureg { + GLuint file:4; + GLint idx:9; /* relative addressing may be negative */ + /* sizeof(idx) should == sizeof(prog_src_reg::Index) */ + GLuint negate:1; + GLuint swz:12; + GLuint pad:6; +}; + + +struct tnl_program { + const struct state_key *state; + struct gl_vertex_program *program; + GLint max_inst; /** number of instructions allocated for program */ + GLboolean mvp_with_dp4; + + GLuint temp_in_use; + GLuint temp_reserved; + + struct ureg eye_position; + struct ureg eye_position_z; + struct ureg eye_position_normalized; + struct ureg transformed_normal; + struct ureg identity; + + GLuint materials; + GLuint color_materials; +}; + + +static const struct ureg undef = { + PROGRAM_UNDEFINED, + 0, + 0, + 0, + 0 +}; + +/* Local shorthand: + */ +#define X SWIZZLE_X +#define Y SWIZZLE_Y +#define Z SWIZZLE_Z +#define W SWIZZLE_W + + +/* Construct a ureg: + */ +static struct ureg make_ureg(GLuint file, GLint idx) +{ + struct ureg reg; + reg.file = file; + reg.idx = idx; + reg.negate = 0; + reg.swz = SWIZZLE_NOOP; + reg.pad = 0; + return reg; +} + + + +static struct ureg negate( struct ureg reg ) +{ + reg.negate ^= 1; + return reg; +} + + +static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) +{ + reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), + GET_SWZ(reg.swz, y), + GET_SWZ(reg.swz, z), + GET_SWZ(reg.swz, w)); + return reg; +} + + +static struct ureg swizzle1( struct ureg reg, int x ) +{ + return swizzle(reg, x, x, x, x); +} + + +static struct ureg get_temp( struct tnl_program *p ) +{ + int bit = _mesa_ffs( ~p->temp_in_use ); + if (!bit) { + _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); + exit(1); + } + + if ((GLuint) bit > p->program->Base.NumTemporaries) + p->program->Base.NumTemporaries = bit; + + p->temp_in_use |= 1<<(bit-1); + return make_ureg(PROGRAM_TEMPORARY, bit-1); +} + + +static struct ureg reserve_temp( struct tnl_program *p ) +{ + struct ureg temp = get_temp( p ); + p->temp_reserved |= 1<temp_in_use &= ~(1<temp_in_use |= p->temp_reserved; /* can't release reserved temps */ + } +} + +static void release_temps( struct tnl_program *p ) +{ + p->temp_in_use = p->temp_reserved; +} + + +static struct ureg register_param5(struct tnl_program *p, + GLint s0, + GLint s1, + GLint s2, + GLint s3, + GLint s4) +{ + gl_state_index tokens[STATE_LENGTH]; + GLint idx; + tokens[0] = s0; + tokens[1] = s1; + tokens[2] = s2; + tokens[3] = s3; + tokens[4] = s4; + idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); + return make_ureg(PROGRAM_STATE_VAR, idx); +} + + +#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) +#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) +#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) +#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) + + + +/** + * \param input one of VERT_ATTRIB_x tokens. + */ +static struct ureg register_input( struct tnl_program *p, GLuint input ) +{ + assert(input < 32); + + if (p->state->varying_vp_inputs & (1<program->Base.InputsRead |= (1<program->Base.OutputsWritten |= BITFIELD64_BIT(output); + return make_ureg(PROGRAM_OUTPUT, output); +} + + +static struct ureg register_const4f( struct tnl_program *p, + GLfloat s0, + GLfloat s1, + GLfloat s2, + GLfloat s3) +{ + GLfloat values[4]; + GLint idx; + GLuint swizzle; + values[0] = s0; + values[1] = s1; + values[2] = s2; + values[3] = s3; + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, + &swizzle ); + ASSERT(swizzle == SWIZZLE_NOOP); + return make_ureg(PROGRAM_CONSTANT, idx); +} + +#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) +#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) +#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) +#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) + +static GLboolean is_undef( struct ureg reg ) +{ + return reg.file == PROGRAM_UNDEFINED; +} + + +static struct ureg get_identity_param( struct tnl_program *p ) +{ + if (is_undef(p->identity)) + p->identity = register_const4f(p, 0,0,0,1); + + return p->identity; +} + +static void register_matrix_param5( struct tnl_program *p, + GLint s0, /* modelview, projection, etc */ + GLint s1, /* texture matrix number */ + GLint s2, /* first row */ + GLint s3, /* last row */ + GLint s4, /* inverse, transpose, etc */ + struct ureg *matrix ) +{ + GLint i; + + /* This is a bit sad as the support is there to pull the whole + * matrix out in one go: + */ + for (i = 0; i <= s3 - s2; i++) + matrix[i] = register_param5( p, s0, s1, i, i, s4 ); +} + + +static void emit_arg( struct prog_src_register *src, + struct ureg reg ) +{ + src->File = reg.file; + src->Index = reg.idx; + src->Swizzle = reg.swz; + src->Negate = reg.negate ? NEGATE_XYZW : NEGATE_NONE; + src->Abs = 0; + src->RelAddr = 0; + /* Check that bitfield sizes aren't exceeded */ + ASSERT(src->Index == reg.idx); +} + + +static void emit_dst( struct prog_dst_register *dst, + struct ureg reg, GLuint mask ) +{ + dst->File = reg.file; + dst->Index = reg.idx; + /* allow zero as a shorthand for xyzw */ + dst->WriteMask = mask ? mask : WRITEMASK_XYZW; + dst->CondMask = COND_TR; /* always pass cond test */ + dst->CondSwizzle = SWIZZLE_NOOP; + dst->CondSrc = 0; + /* Check that bitfield sizes aren't exceeded */ + ASSERT(dst->Index == reg.idx); +} + + +static void debug_insn( struct prog_instruction *inst, const char *fn, + GLuint line ) +{ + if (DISASSEM) { + static const char *last_fn; + + if (fn != last_fn) { + last_fn = fn; + printf("%s:\n", fn); + } + + printf("%d:\t", line); + _mesa_print_instruction(inst); + } +} + + +static void emit_op3fn(struct tnl_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint mask, + struct ureg src0, + struct ureg src1, + struct ureg src2, + const char *fn, + GLuint line) +{ + GLuint nr; + struct prog_instruction *inst; + + assert((GLint) p->program->Base.NumInstructions <= p->max_inst); + + if (p->program->Base.NumInstructions == p->max_inst) { + /* need to extend the program's instruction array */ + struct prog_instruction *newInst; + + /* double the size */ + p->max_inst *= 2; + + newInst = _mesa_alloc_instructions(p->max_inst); + if (!newInst) { + _mesa_error(NULL, GL_OUT_OF_MEMORY, "vertex program build"); + return; + } + + _mesa_copy_instructions(newInst, + p->program->Base.Instructions, + p->program->Base.NumInstructions); + + _mesa_free_instructions(p->program->Base.Instructions, + p->program->Base.NumInstructions); + + p->program->Base.Instructions = newInst; + } + + nr = p->program->Base.NumInstructions++; + + inst = &p->program->Base.Instructions[nr]; + inst->Opcode = (enum prog_opcode) op; + inst->Data = 0; + + emit_arg( &inst->SrcReg[0], src0 ); + emit_arg( &inst->SrcReg[1], src1 ); + emit_arg( &inst->SrcReg[2], src2 ); + + emit_dst( &inst->DstReg, dest, mask ); + + debug_insn(inst, fn, line); +} + + +#define emit_op3(p, op, dst, mask, src0, src1, src2) \ + emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__) + +#define emit_op2(p, op, dst, mask, src0, src1) \ + emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__) + +#define emit_op1(p, op, dst, mask, src0) \ + emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__) + + +static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) +{ + if (reg.file == PROGRAM_TEMPORARY && + !(p->temp_reserved & (1<eye_position)) { + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg modelview[4]; + + p->eye_position = reserve_temp(p); + + if (p->mvp_with_dp4) { + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + 0, modelview ); + + emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); + } + else { + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, modelview ); + + emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); + } + } + + return p->eye_position; +} + + +static struct ureg get_eye_position_z( struct tnl_program *p ) +{ + if (!is_undef(p->eye_position)) + return swizzle1(p->eye_position, Z); + + if (is_undef(p->eye_position_z)) { + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg modelview[4]; + + p->eye_position_z = reserve_temp(p); + + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, + 0, modelview ); + + emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]); + } + + return p->eye_position_z; +} + + +static struct ureg get_eye_position_normalized( struct tnl_program *p ) +{ + if (is_undef(p->eye_position_normalized)) { + struct ureg eye = get_eye_position(p); + p->eye_position_normalized = reserve_temp(p); + emit_normalize_vec3(p, p->eye_position_normalized, eye); + } + + return p->eye_position_normalized; +} + + +static struct ureg get_transformed_normal( struct tnl_program *p ) +{ + if (is_undef(p->transformed_normal) && + !p->state->need_eye_coords && + !p->state->normalize && + !(p->state->need_eye_coords == p->state->rescale_normals)) + { + p->transformed_normal = register_input(p, VERT_ATTRIB_NORMAL ); + } + else if (is_undef(p->transformed_normal)) + { + struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); + struct ureg mvinv[3]; + struct ureg transformed_normal = reserve_temp(p); + + if (p->state->need_eye_coords) { + register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, + STATE_MATRIX_INVTRANS, mvinv ); + + /* Transform to eye space: + */ + emit_matrix_transform_vec3( p, transformed_normal, mvinv, normal ); + normal = transformed_normal; + } + + /* Normalize/Rescale: + */ + if (p->state->normalize) { + emit_normalize_vec3( p, transformed_normal, normal ); + normal = transformed_normal; + } + else if (p->state->need_eye_coords == p->state->rescale_normals) { + /* This is already adjusted for eye/non-eye rendering: + */ + struct ureg rescale = register_param2(p, STATE_INTERNAL, + STATE_NORMAL_SCALE); + + emit_op2( p, OPCODE_MUL, transformed_normal, 0, normal, rescale ); + normal = transformed_normal; + } + + assert(normal.file == PROGRAM_TEMPORARY); + p->transformed_normal = normal; + } + + return p->transformed_normal; +} + + +static void build_hpos( struct tnl_program *p ) +{ + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg hpos = register_output( p, VERT_RESULT_HPOS ); + struct ureg mvp[4]; + + if (p->mvp_with_dp4) { + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + 0, mvp ); + emit_matrix_transform_vec4( p, hpos, mvp, pos ); + } + else { + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + STATE_MATRIX_TRANSPOSE, mvp ); + emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); + } +} + + +static GLuint material_attrib( GLuint side, GLuint property ) +{ + return (property - STATE_AMBIENT) * 2 + side; +} + + +/** + * Get a bitmask of which material values vary on a per-vertex basis. + */ +static void set_material_flags( struct tnl_program *p ) +{ + p->color_materials = 0; + p->materials = 0; + + if (p->state->varying_vp_inputs & VERT_BIT_COLOR0) { + p->materials = + p->color_materials = p->state->light_color_material_mask; + } + + p->materials |= (p->state->varying_vp_inputs >> 16); +} + + +static struct ureg get_material( struct tnl_program *p, GLuint side, + GLuint property ) +{ + GLuint attrib = material_attrib(side, property); + + if (p->color_materials & (1<materials & (1<materials & SCENE_COLOR_BITS(side)) { + struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT); + struct ureg material_emission = get_material(p, side, STATE_EMISSION); + struct ureg material_ambient = get_material(p, side, STATE_AMBIENT); + struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE); + struct ureg tmp = make_temp(p, material_diffuse); + emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, + material_ambient, material_emission); + return tmp; + } + else + return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side ); +} + + +static struct ureg get_lightprod( struct tnl_program *p, GLuint light, + GLuint side, GLuint property ) +{ + GLuint attrib = material_attrib(side, property); + if (p->materials & (1<state->unit[i].light_spotcutoff_is_180) { + struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_SPOT_DIR_NORMALIZED, i); + struct ureg spot = get_temp(p); + struct ureg slt = get_temp(p); + + emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm); + emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot); + emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W)); + emit_op2(p, OPCODE_MUL, att, 0, slt, spot); + + release_temp(p, spot); + release_temp(p, slt); + } + + /* Calculate distance attenuation: + */ + if (p->state->unit[i].light_attenuated) { + /* 1/d,d,d,1/d */ + emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); + /* 1,d,d*d,1/d */ + emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); + /* 1/dist-atten */ + emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); + + if (!p->state->unit[i].light_spotcutoff_is_180) { + /* dist-atten */ + emit_op1(p, OPCODE_RCP, dist, 0, dist); + /* spot-atten * dist-atten */ + emit_op2(p, OPCODE_MUL, att, 0, dist, att); + } + else { + /* dist-atten */ + emit_op1(p, OPCODE_RCP, att, 0, dist); + } + } + + return att; +} + + +/** + * Compute: + * lit.y = MAX(0, dots.x) + * lit.z = SLT(0, dots.x) + */ +static void emit_degenerate_lit( struct tnl_program *p, + struct ureg lit, + struct ureg dots ) +{ + struct ureg id = get_identity_param(p); /* id = {0,0,0,1} */ + + /* Note that lit.x & lit.w will not be examined. Note also that + * dots.xyzw == dots.xxxx. + */ + + /* MAX lit, id, dots; + */ + emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots); + + /* result[2] = (in > 0 ? 1 : 0) + * SLT lit.z, id.z, dots; # lit.z = (0 < dots.z) ? 1 : 0 + */ + emit_op2(p, OPCODE_SLT, lit, WRITEMASK_Z, swizzle1(id,Z), dots); +} + + +/* Need to add some addtional parameters to allow lighting in object + * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye + * space lighting. + */ +static void build_lighting( struct tnl_program *p ) +{ + const GLboolean twoside = p->state->light_twoside; + const GLboolean separate = p->state->separate_specular; + GLuint nr_lights = 0, count = 0; + struct ureg normal = get_transformed_normal(p); + struct ureg lit = get_temp(p); + struct ureg dots = get_temp(p); + struct ureg _col0 = undef, _col1 = undef; + struct ureg _bfc0 = undef, _bfc1 = undef; + GLuint i; + + /* + * NOTE: + * dots.x = dot(normal, VPpli) + * dots.y = dot(normal, halfAngle) + * dots.z = back.shininess + * dots.w = front.shininess + */ + + for (i = 0; i < MAX_LIGHTS; i++) + if (p->state->unit[i].light_enabled) + nr_lights++; + + set_material_flags(p); + + { + if (!p->state->material_shininess_is_zero) { + struct ureg shininess = get_material(p, 0, STATE_SHININESS); + emit_op1(p, OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X)); + release_temp(p, shininess); + } + + _col0 = make_temp(p, get_scenecolor(p, 0)); + if (separate) + _col1 = make_temp(p, get_identity_param(p)); + else + _col1 = _col0; + } + + if (twoside) { + if (!p->state->material_shininess_is_zero) { + /* Note that we negate the back-face specular exponent here. + * The negation will be un-done later in the back-face code below. + */ + struct ureg shininess = get_material(p, 1, STATE_SHININESS); + emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, + negate(swizzle1(shininess,X))); + release_temp(p, shininess); + } + + _bfc0 = make_temp(p, get_scenecolor(p, 1)); + if (separate) + _bfc1 = make_temp(p, get_identity_param(p)); + else + _bfc1 = _bfc0; + } + + /* If no lights, still need to emit the scenecolor. + */ + { + struct ureg res0 = register_output( p, VERT_RESULT_COL0 ); + emit_op1(p, OPCODE_MOV, res0, 0, _col0); + } + + if (separate) { + struct ureg res1 = register_output( p, VERT_RESULT_COL1 ); + emit_op1(p, OPCODE_MOV, res1, 0, _col1); + } + + if (twoside) { + struct ureg res0 = register_output( p, VERT_RESULT_BFC0 ); + emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); + } + + if (twoside && separate) { + struct ureg res1 = register_output( p, VERT_RESULT_BFC1 ); + emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); + } + + if (nr_lights == 0) { + release_temps(p); + return; + } + + for (i = 0; i < MAX_LIGHTS; i++) { + if (p->state->unit[i].light_enabled) { + struct ureg half = undef; + struct ureg att = undef, VPpli = undef; + + count++; + + if (p->state->unit[i].light_eyepos3_is_zero) { + /* Can used precomputed constants in this case. + * Attenuation never applies to infinite lights. + */ + VPpli = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_POSITION_NORMALIZED, i); + + if (!p->state->material_shininess_is_zero) { + if (p->state->light_local_viewer) { + struct ureg eye_hat = get_eye_position_normalized(p); + half = get_temp(p); + emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); + emit_normalize_vec3(p, half, half); + } + else { + half = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_HALF_VECTOR, i); + } + } + } + else { + struct ureg Ppli = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_POSITION, i); + struct ureg V = get_eye_position(p); + struct ureg dist = get_temp(p); + + VPpli = get_temp(p); + + /* Calculate VPpli vector + */ + emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); + + /* Normalize VPpli. The dist value also used in + * attenuation below. + */ + emit_op2(p, OPCODE_DP3, dist, 0, VPpli, VPpli); + emit_op1(p, OPCODE_RSQ, dist, 0, dist); + emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist); + + /* Calculate attenuation: + */ + if (!p->state->unit[i].light_spotcutoff_is_180 || + p->state->unit[i].light_attenuated) { + att = calculate_light_attenuation(p, i, VPpli, dist); + } + + /* Calculate viewer direction, or use infinite viewer: + */ + if (!p->state->material_shininess_is_zero) { + half = get_temp(p); + + if (p->state->light_local_viewer) { + struct ureg eye_hat = get_eye_position_normalized(p); + emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); + } + else { + struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); + emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir); + } + + emit_normalize_vec3(p, half, half); + } + + release_temp(p, dist); + } + + /* Calculate dot products: + */ + if (p->state->material_shininess_is_zero) { + emit_op2(p, OPCODE_DP3, dots, 0, normal, VPpli); + } + else { + emit_op2(p, OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli); + emit_op2(p, OPCODE_DP3, dots, WRITEMASK_Y, normal, half); + } + + /* Front face lighting: + */ + { + struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT); + struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE); + struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR); + struct ureg res0, res1; + GLuint mask0, mask1; + + if (count == nr_lights) { + if (separate) { + mask0 = WRITEMASK_XYZ; + mask1 = WRITEMASK_XYZ; + res0 = register_output( p, VERT_RESULT_COL0 ); + res1 = register_output( p, VERT_RESULT_COL1 ); + } + else { + mask0 = 0; + mask1 = WRITEMASK_XYZ; + res0 = _col0; + res1 = register_output( p, VERT_RESULT_COL0 ); + } + } + else { + mask0 = 0; + mask1 = 0; + res0 = _col0; + res1 = _col1; + } + + if (!is_undef(att)) { + /* light is attenuated by distance */ + emit_op1(p, OPCODE_LIT, lit, 0, dots); + emit_op2(p, OPCODE_MUL, lit, 0, lit, att); + emit_op3(p, OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0); + } + else if (!p->state->material_shininess_is_zero) { + /* there's a non-zero specular term */ + emit_op1(p, OPCODE_LIT, lit, 0, dots); + emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); + } + else { + /* no attenutation, no specular */ + emit_degenerate_lit(p, lit, dots); + emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); + } + + emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0); + emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1); + + release_temp(p, ambient); + release_temp(p, diffuse); + release_temp(p, specular); + } + + /* Back face lighting: + */ + if (twoside) { + struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT); + struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE); + struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR); + struct ureg res0, res1; + GLuint mask0, mask1; + + if (count == nr_lights) { + if (separate) { + mask0 = WRITEMASK_XYZ; + mask1 = WRITEMASK_XYZ; + res0 = register_output( p, VERT_RESULT_BFC0 ); + res1 = register_output( p, VERT_RESULT_BFC1 ); + } + else { + mask0 = 0; + mask1 = WRITEMASK_XYZ; + res0 = _bfc0; + res1 = register_output( p, VERT_RESULT_BFC0 ); + } + } + else { + res0 = _bfc0; + res1 = _bfc1; + mask0 = 0; + mask1 = 0; + } + + /* For the back face we need to negate the X and Y component + * dot products. dots.Z has the negated back-face specular + * exponent. We swizzle that into the W position. This + * negation makes the back-face specular term positive again. + */ + dots = negate(swizzle(dots,X,Y,W,Z)); + + if (!is_undef(att)) { + emit_op1(p, OPCODE_LIT, lit, 0, dots); + emit_op2(p, OPCODE_MUL, lit, 0, lit, att); + emit_op3(p, OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0); + } + else if (!p->state->material_shininess_is_zero) { + emit_op1(p, OPCODE_LIT, lit, 0, dots); + emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); /**/ + } + else { + emit_degenerate_lit(p, lit, dots); + emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); + } + + emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); + emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); + /* restore dots to its original state for subsequent lights + * by negating and swizzling again. + */ + dots = negate(swizzle(dots,X,Y,W,Z)); + + release_temp(p, ambient); + release_temp(p, diffuse); + release_temp(p, specular); + } + + release_temp(p, half); + release_temp(p, VPpli); + release_temp(p, att); + } + } + + release_temps( p ); +} + + +static void build_fog( struct tnl_program *p ) +{ + struct ureg fog = register_output(p, VERT_RESULT_FOGC); + struct ureg input; + + if (p->state->fog_source_is_depth) { + input = get_eye_position_z(p); + } + else { + input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); + } + + /* result.fog = {abs(f),0,0,1}; */ + emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); + emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p)); +} + + +static void build_reflect_texgen( struct tnl_program *p, + struct ureg dest, + GLuint writemask ) +{ + struct ureg normal = get_transformed_normal(p); + struct ureg eye_hat = get_eye_position_normalized(p); + struct ureg tmp = get_temp(p); + + /* n.u */ + emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); + /* 2n.u */ + emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); + /* (-2n.u)n + u */ + emit_op3(p, OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat); + + release_temp(p, tmp); +} + + +static void build_sphere_texgen( struct tnl_program *p, + struct ureg dest, + GLuint writemask ) +{ + struct ureg normal = get_transformed_normal(p); + struct ureg eye_hat = get_eye_position_normalized(p); + struct ureg tmp = get_temp(p); + struct ureg half = register_scalar_const(p, .5); + struct ureg r = get_temp(p); + struct ureg inv_m = get_temp(p); + struct ureg id = get_identity_param(p); + + /* Could share the above calculations, but it would be + * a fairly odd state for someone to set (both sphere and + * reflection active for different texture coordinate + * components. Of course - if two texture units enable + * reflect and/or sphere, things start to tilt in favour + * of seperating this out: + */ + + /* n.u */ + emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); + /* 2n.u */ + emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); + /* (-2n.u)n + u */ + emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); + /* r + 0,0,1 */ + emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); + /* rx^2 + ry^2 + (rz+1)^2 */ + emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); + /* 2/m */ + emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); + /* 1/m */ + emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); + /* r/m + 1/2 */ + emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); + + release_temp(p, tmp); + release_temp(p, r); + release_temp(p, inv_m); +} + + +static void build_texture_transform( struct tnl_program *p ) +{ + GLuint i, j; + + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { + + if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) + continue; + + if (p->state->unit[i].coord_replace) + continue; + + if (p->state->unit[i].texgen_enabled || + p->state->unit[i].texmat_enabled) { + + GLuint texmat_enabled = p->state->unit[i].texmat_enabled; + struct ureg out = register_output(p, VERT_RESULT_TEX0 + i); + struct ureg out_texgen = undef; + + if (p->state->unit[i].texgen_enabled) { + GLuint copy_mask = 0; + GLuint sphere_mask = 0; + GLuint reflect_mask = 0; + GLuint normal_mask = 0; + GLuint modes[4]; + + if (texmat_enabled) + out_texgen = get_temp(p); + else + out_texgen = out; + + modes[0] = p->state->unit[i].texgen_mode0; + modes[1] = p->state->unit[i].texgen_mode1; + modes[2] = p->state->unit[i].texgen_mode2; + modes[3] = p->state->unit[i].texgen_mode3; + + for (j = 0; j < 4; j++) { + switch (modes[j]) { + case TXG_OBJ_LINEAR: { + struct ureg obj = register_input(p, VERT_ATTRIB_POS); + struct ureg plane = + register_param3(p, STATE_TEXGEN, i, + STATE_TEXGEN_OBJECT_S + j); + + emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, + obj, plane ); + break; + } + case TXG_EYE_LINEAR: { + struct ureg eye = get_eye_position(p); + struct ureg plane = + register_param3(p, STATE_TEXGEN, i, + STATE_TEXGEN_EYE_S + j); + + emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, + eye, plane ); + break; + } + case TXG_SPHERE_MAP: + sphere_mask |= WRITEMASK_X << j; + break; + case TXG_REFLECTION_MAP: + reflect_mask |= WRITEMASK_X << j; + break; + case TXG_NORMAL_MAP: + normal_mask |= WRITEMASK_X << j; + break; + case TXG_NONE: + copy_mask |= WRITEMASK_X << j; + } + } + + if (sphere_mask) { + build_sphere_texgen(p, out_texgen, sphere_mask); + } + + if (reflect_mask) { + build_reflect_texgen(p, out_texgen, reflect_mask); + } + + if (normal_mask) { + struct ureg normal = get_transformed_normal(p); + emit_op1(p, OPCODE_MOV, out_texgen, normal_mask, normal ); + } + + if (copy_mask) { + struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i); + emit_op1(p, OPCODE_MOV, out_texgen, copy_mask, in ); + } + } + + if (texmat_enabled) { + struct ureg texmat[4]; + struct ureg in = (!is_undef(out_texgen) ? + out_texgen : + register_input(p, VERT_ATTRIB_TEX0+i)); + if (p->mvp_with_dp4) { + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + 0, texmat ); + emit_matrix_transform_vec4( p, out, texmat, in ); + } + else { + register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, + STATE_MATRIX_TRANSPOSE, texmat ); + emit_transpose_matrix_transform_vec4( p, out, texmat, in ); + } + } + + release_temps(p); + } + else { + emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i); + } + } +} + + +/** + * Point size attenuation computation. + */ +static void build_atten_pointsize( struct tnl_program *p ) +{ + struct ureg eye = get_eye_position_z(p); + struct ureg state_size = register_param2(p, STATE_INTERNAL, STATE_POINT_SIZE_CLAMPED); + struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); + struct ureg out = register_output(p, VERT_RESULT_PSIZ); + struct ureg ut = get_temp(p); + + /* dist = |eyez| */ + emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z)); + /* p1 + dist * (p2 + dist * p3); */ + emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), + swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y)); + emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), + ut, swizzle1(state_attenuation, X)); + + /* 1 / sqrt(factor) */ + emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut ); + +#if 0 + /* out = pointSize / sqrt(factor) */ + emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size); +#else + /* this is a good place to clamp the point size since there's likely + * no hardware registers to clamp point size at rasterization time. + */ + emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size); + emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y)); + emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z)); +#endif + + release_temp(p, ut); +} + + +/** + * Pass-though per-vertex point size, from user's point size array. + */ +static void build_array_pointsize( struct tnl_program *p ) +{ + struct ureg in = register_input(p, VERT_ATTRIB_POINT_SIZE); + struct ureg out = register_output(p, VERT_RESULT_PSIZ); + emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, in); +} + + +static void build_tnl_program( struct tnl_program *p ) +{ + /* Emit the program, starting with modelviewproject: + */ + build_hpos(p); + + /* Lighting calculations: + */ + if (p->state->fragprog_inputs_read & (FRAG_BIT_COL0|FRAG_BIT_COL1)) { + if (p->state->light_global_enabled) + build_lighting(p); + else { + if (p->state->fragprog_inputs_read & FRAG_BIT_COL0) + emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0); + + if (p->state->fragprog_inputs_read & FRAG_BIT_COL1) + emit_passthrough(p, VERT_ATTRIB_COLOR1, VERT_RESULT_COL1); + } + } + + if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC) + build_fog(p); + + if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY) + build_texture_transform(p); + + if (p->state->point_attenuated) + build_atten_pointsize(p); + else if (p->state->point_array) + build_array_pointsize(p); + + /* Finish up: + */ + emit_op1(p, OPCODE_END, undef, 0, undef); + + /* Disassemble: + */ + if (DISASSEM) { + printf ("\n"); + } +} + + +static void +create_new_program( const struct state_key *key, + struct gl_vertex_program *program, + GLboolean mvp_with_dp4, + GLuint max_temps) +{ + struct tnl_program p; + + memset(&p, 0, sizeof(p)); + p.state = key; + p.program = program; + p.eye_position = undef; + p.eye_position_z = undef; + p.eye_position_normalized = undef; + p.transformed_normal = undef; + p.identity = undef; + p.temp_in_use = 0; + p.mvp_with_dp4 = mvp_with_dp4; + + if (max_temps >= sizeof(int) * 8) + p.temp_reserved = 0; + else + p.temp_reserved = ~((1<Base.Instructions = _mesa_alloc_instructions(p.max_inst); + p.program->Base.String = NULL; + p.program->Base.NumInstructions = + p.program->Base.NumTemporaries = + p.program->Base.NumParameters = + p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0; + p.program->Base.Parameters = _mesa_new_parameter_list(); + p.program->Base.InputsRead = 0; + p.program->Base.OutputsWritten = 0; + + build_tnl_program( &p ); +} + + +/** + * Return a vertex program which implements the current fixed-function + * transform/lighting/texgen operations. + * XXX move this into core mesa (main/) + */ +struct gl_vertex_program * +_mesa_get_fixed_func_vertex_program(struct gl_context *ctx) +{ + struct gl_vertex_program *prog; + struct state_key key; + + /* Grab all the relevent state and put it in a single structure: + */ + make_state_key(ctx, &key); + + /* Look for an already-prepared program for this state: + */ + prog = (struct gl_vertex_program *) + _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)); + + if (!prog) { + /* OK, we'll have to build a new one */ + if (0) + printf("Build new TNL program\n"); + + prog = (struct gl_vertex_program *) + ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + if (!prog) + return NULL; + + create_new_program( &key, prog, + ctx->mvp_with_dp4, + ctx->Const.VertexProgram.MaxTemps ); + +#if 0 + if (ctx->Driver.ProgramStringNotify) + ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, + &prog->Base ); +#endif + _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, + &key, sizeof(key), &prog->Base); + } + + return prog; +} diff --git a/mesalib/src/mesa/main/ffvertex_prog.h b/mesalib/src/mesa/main/ffvertex_prog.h index 38dc5fbb8..6d485bb2a 100644 --- a/mesalib/src/mesa/main/ffvertex_prog.h +++ b/mesalib/src/mesa/main/ffvertex_prog.h @@ -1,40 +1,40 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef FFVERTEX_PROG_H -#define FFVERTEX_PROG_H - - -#include "main/mtypes.h" - -struct gl_vertex_program * -_mesa_get_fixed_func_vertex_program(GLcontext *ctx); - - - -#endif /* FFVERTEX_PROG_H */ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef FFVERTEX_PROG_H +#define FFVERTEX_PROG_H + + +struct gl_context; + +struct gl_vertex_program * +_mesa_get_fixed_func_vertex_program(struct gl_context *ctx); + + + +#endif /* FFVERTEX_PROG_H */ diff --git a/mesalib/src/mesa/main/fog.c b/mesalib/src/mesa/main/fog.c index 9f26c012d..b4356c198 100644 --- a/mesalib/src/mesa/main/fog.c +++ b/mesalib/src/mesa/main/fog.c @@ -1,194 +1,194 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "fog.h" -#include "macros.h" -#include "mtypes.h" - - - -void GLAPIENTRY -_mesa_Fogf(GLenum pname, GLfloat param) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogi(GLenum pname, GLint param ) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogiv(GLenum pname, const GLint *params ) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - case GL_FOG_COORDINATE_SOURCE_EXT: - p[0] = (GLfloat) *params; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT( params[0] ); - p[1] = INT_TO_FLOAT( params[1] ); - p[2] = INT_TO_FLOAT( params[2] ); - p[3] = INT_TO_FLOAT( params[3] ); - break; - default: - /* Error will be caught later in _mesa_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - _mesa_Fogfv(pname, p); -} - - -#define UPDATE_FOG_SCALE(ctx) do {\ - if (ctx->Fog.End == ctx->Fog.Start)\ - ctx->Fog._Scale = 1.0f;\ - else\ - ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start);\ - } while(0) - - -void GLAPIENTRY -_mesa_Fogfv( GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum m; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_FOG_MODE: - m = (GLenum) (GLint) *params; - switch (m) { - case GL_LINEAR: - case GL_EXP: - case GL_EXP2: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - if (ctx->Fog.Mode == m) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Mode = m; - break; - case GL_FOG_DENSITY: - if (*params<0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFog" ); - return; - } - if (ctx->Fog.Density == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Density = *params; - break; - case GL_FOG_START: - if (ctx->Fog.Start == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Start = *params; - UPDATE_FOG_SCALE(ctx); - break; - case GL_FOG_END: - if (ctx->Fog.End == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.End = *params; - UPDATE_FOG_SCALE(ctx); - break; - case GL_FOG_INDEX: - if (ctx->Fog.Index == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Index = *params; - break; - case GL_FOG_COLOR: - if (TEST_EQ_4V(ctx->Fog.Color, params)) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F); - ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F); - ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F); - ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum) (GLint) *params; - if (!ctx->Extensions.EXT_fog_coord || - (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); - return; - } - if (ctx->Fog.FogCoordinateSource == p) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.FogCoordinateSource = p; - break; - } - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - - if (ctx->Driver.Fogfv) { - (*ctx->Driver.Fogfv)( ctx, pname, params ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_fog( GLcontext * ctx ) -{ - /* Fog group */ - ctx->Fog.Enabled = GL_FALSE; - ctx->Fog.Mode = GL_EXP; - ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); - ctx->Fog.Index = 0.0; - ctx->Fog.Density = 1.0; - ctx->Fog.Start = 0.0; - ctx->Fog.End = 1.0; - ctx->Fog.ColorSumEnabled = GL_FALSE; - ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; - ctx->Fog._Scale = 1.0f; -} +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "colormac.h" +#include "context.h" +#include "fog.h" +#include "macros.h" +#include "mtypes.h" + + + +void GLAPIENTRY +_mesa_Fogf(GLenum pname, GLfloat param) +{ + GLfloat fparam[4]; + fparam[0] = param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_Fogfv(pname, fparam); +} + + +void GLAPIENTRY +_mesa_Fogi(GLenum pname, GLint param ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_Fogfv(pname, fparam); +} + + +void GLAPIENTRY +_mesa_Fogiv(GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + case GL_FOG_COORDINATE_SOURCE_EXT: + p[0] = (GLfloat) *params; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + break; + default: + /* Error will be caught later in _mesa_Fogfv */ + ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); + } + _mesa_Fogfv(pname, p); +} + + +#define UPDATE_FOG_SCALE(ctx) do {\ + if (ctx->Fog.End == ctx->Fog.Start)\ + ctx->Fog._Scale = 1.0f;\ + else\ + ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start);\ + } while(0) + + +void GLAPIENTRY +_mesa_Fogfv( GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLenum m; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_FOG_MODE: + m = (GLenum) (GLint) *params; + switch (m) { + case GL_LINEAR: + case GL_EXP: + case GL_EXP2: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); + return; + } + if (ctx->Fog.Mode == m) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Mode = m; + break; + case GL_FOG_DENSITY: + if (*params<0.0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glFog" ); + return; + } + if (ctx->Fog.Density == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Density = *params; + break; + case GL_FOG_START: + if (ctx->Fog.Start == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Start = *params; + UPDATE_FOG_SCALE(ctx); + break; + case GL_FOG_END: + if (ctx->Fog.End == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.End = *params; + UPDATE_FOG_SCALE(ctx); + break; + case GL_FOG_INDEX: + if (ctx->Fog.Index == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Index = *params; + break; + case GL_FOG_COLOR: + if (TEST_EQ_4V(ctx->Fog.Color, params)) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F); + ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F); + ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F); + ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F); + break; + case GL_FOG_COORDINATE_SOURCE_EXT: { + GLenum p = (GLenum) (GLint) *params; + if (!ctx->Extensions.EXT_fog_coord || + (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); + return; + } + if (ctx->Fog.FogCoordinateSource == p) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.FogCoordinateSource = p; + break; + } + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); + return; + } + + if (ctx->Driver.Fogfv) { + (*ctx->Driver.Fogfv)( ctx, pname, params ); + } +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void _mesa_init_fog( struct gl_context * ctx ) +{ + /* Fog group */ + ctx->Fog.Enabled = GL_FALSE; + ctx->Fog.Mode = GL_EXP; + ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); + ctx->Fog.Index = 0.0; + ctx->Fog.Density = 1.0; + ctx->Fog.Start = 0.0; + ctx->Fog.End = 1.0; + ctx->Fog.ColorSumEnabled = GL_FALSE; + ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; + ctx->Fog._Scale = 1.0f; +} diff --git a/mesalib/src/mesa/main/fog.h b/mesalib/src/mesa/main/fog.h index a14d19cdb..72a0657af 100644 --- a/mesalib/src/mesa/main/fog.h +++ b/mesalib/src/mesa/main/fog.h @@ -1,66 +1,69 @@ -/** - * \file fog.h - * Fog operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FOG_H -#define FOG_H - - -#include "mtypes.h" - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_Fogf(GLenum pname, GLfloat param); - -extern void GLAPIENTRY -_mesa_Fogi(GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_Fogfv(GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_Fogiv(GLenum pname, const GLint *params ); - -extern void _mesa_init_fog( GLcontext * ctx ); - -#else - -/** No-op */ -#define _mesa_init_fog( c ) ((void)0) - -#endif - -#endif +/** + * \file fog.h + * Fog operations. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef FOG_H +#define FOG_H + + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + + +#if _HAVE_FULL_GL + +extern void GLAPIENTRY +_mesa_Fogf(GLenum pname, GLfloat param); + +extern void GLAPIENTRY +_mesa_Fogi(GLenum pname, GLint param ); + +extern void GLAPIENTRY +_mesa_Fogfv(GLenum pname, const GLfloat *params ); + +extern void GLAPIENTRY +_mesa_Fogiv(GLenum pname, const GLint *params ); + +extern void _mesa_init_fog( struct gl_context * ctx ); + +#else + +/** No-op */ +#define _mesa_init_fog( c ) ((void)0) + +#endif + +#endif diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 9db9f1c56..b7aecb396 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -1,1340 +1,1548 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "imports.h" -#include "formats.h" -#include "mfeatures.h" - - -/** - * Information about texture formats. - */ -struct gl_format_info -{ - gl_format Name; - - /** text name for debugging */ - const char *StrName; - - /** - * Base format is one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, - * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, - * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ - GLenum BaseFormat; - - /** - * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, - * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. - */ - GLenum DataType; - - GLubyte RedBits; - GLubyte GreenBits; - GLubyte BlueBits; - GLubyte AlphaBits; - GLubyte LuminanceBits; - GLubyte IntensityBits; - GLubyte IndexBits; - GLubyte DepthBits; - GLubyte StencilBits; - - /** - * To describe compressed formats. If not compressed, Width=Height=1. - */ - GLubyte BlockWidth, BlockHeight; - GLubyte BytesPerBlock; -}; - - -/** - * Info about each format. - * These must be in the same order as the MESA_FORMAT_* enums so that - * we can do lookups without searching. - */ -static struct gl_format_info format_info[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, /* Name */ - "MESA_FORMAT_NONE", /* StrName */ - GL_NONE, /* BaseFormat */ - GL_NONE, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 0, 0, 0 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888, /* Name */ - "MESA_FORMAT_RGBA8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888_REV, /* Name */ - "MESA_FORMAT_RGBA8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888, /* Name */ - "MESA_FORMAT_ARGB8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888_REV, /* Name */ - "MESA_FORMAT_ARGB8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888, /* Name */ - "MESA_FORMAT_XRGB8888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888_REV, /* Name */ - "MESA_FORMAT_XRGB8888_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB888, /* Name */ - "MESA_FORMAT_RGB888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_BGR888, /* Name */ - "MESA_FORMAT_BGR888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565, /* Name */ - "MESA_FORMAT_RGB565", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565_REV, /* Name */ - "MESA_FORMAT_RGB565_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444, /* Name */ - "MESA_FORMAT_ARGB4444", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444_REV, /* Name */ - "MESA_FORMAT_ARGB4444_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA5551, /* Name */ - "MESA_FORMAT_RGBA5551", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555, /* Name */ - "MESA_FORMAT_ARGB1555", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555_REV, /* Name */ - "MESA_FORMAT_ARGB1555_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88, /* Name */ - "MESA_FORMAT_AL88", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88_REV, /* Name */ - "MESA_FORMAT_AL88_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616, /* Name */ - "MESA_FORMAT_AL1616", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616_REV, /* Name */ - "MESA_FORMAT_AL1616_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB332, /* Name */ - "MESA_FORMAT_RGB332", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A8, /* Name */ - "MESA_FORMAT_A8", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L8, /* Name */ - "MESA_FORMAT_L8", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I8, /* Name */ - "MESA_FORMAT_I8", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_CI8, /* Name */ - "MESA_FORMAT_CI8", /* StrName */ - GL_COLOR_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR, /* Name */ - "MESA_FORMAT_YCBCR", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR_REV, /* Name */ - "MESA_FORMAT_YCBCR_REV", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z24_S8, /* Name */ - "MESA_FORMAT_Z24_S8", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8_Z24, /* Name */ - "MESA_FORMAT_S8_Z24", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z16, /* Name */ - "MESA_FORMAT_Z16", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_X8_Z24, /* Name */ - "MESA_FORMAT_X8_Z24", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z24_X8, /* Name */ - "MESA_FORMAT_Z24_X8", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z32, /* Name */ - "MESA_FORMAT_Z32", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8, /* Name */ - "MESA_FORMAT_S8", /* StrName */ - GL_STENCIL_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SRGB8, - "MESA_FORMAT_SRGB8", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_SRGBA8, - "MESA_FORMAT_SRGBA8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SARGB8, - "MESA_FORMAT_SARGB8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SL8, - "MESA_FORMAT_SL8", - GL_LUMINANCE, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SLA8, - "MESA_FORMAT_SLA8", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SRGB_DXT1, /* Name */ - "MESA_FORMAT_SRGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT1, - "MESA_FORMAT_SRGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT3, - "MESA_FORMAT_SRGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT5, - "MESA_FORMAT_SRGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - - { - MESA_FORMAT_RGB_FXT1, - "MESA_FORMAT_RGB_FXT1", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 0, /* approx Red/Green/BlueBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - { - MESA_FORMAT_RGBA_FXT1, - "MESA_FORMAT_RGBA_FXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - - { - MESA_FORMAT_RGB_DXT1, /* Name */ - "MESA_FORMAT_RGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT1, - "MESA_FORMAT_RGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT3, - "MESA_FORMAT_RGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT5, - "MESA_FORMAT_RGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_FLOAT32, - "MESA_FORMAT_RGBA_FLOAT32", - GL_RGBA, - GL_FLOAT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - "MESA_FORMAT_RGBA_FLOAT16", - GL_RGBA, - GL_FLOAT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_FLOAT32, - "MESA_FORMAT_RGB_FLOAT32", - GL_RGB, - GL_FLOAT, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_RGB_FLOAT16, - "MESA_FORMAT_RGB_FLOAT16", - GL_RGB, - GL_FLOAT, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - "MESA_FORMAT_ALPHA_FLOAT32", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - "MESA_FORMAT_ALPHA_FLOAT16", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - "MESA_FORMAT_LUMINANCE_FLOAT32", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 0, - 32, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - "MESA_FORMAT_LUMINANCE_FLOAT16", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 32, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - "MESA_FORMAT_INTENSITY_FLOAT32", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 32, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - "MESA_FORMAT_INTENSITY_FLOAT16", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - - /* unnormalized signed int formats */ - { - MESA_FORMAT_RGBA_INT8, - "MESA_FORMAT_RGBA_INT8", - GL_RGBA, - GL_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_INT16, - "MESA_FORMAT_RGBA_INT16", - GL_RGBA, - GL_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_INT32, - "MESA_FORMAT_RGBA_INT32", - GL_RGBA, - GL_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - /* unnormalized unsigned int formats */ - { - MESA_FORMAT_RGBA_UINT8, - "MESA_FORMAT_RGBA_UINT8", - GL_RGBA, - GL_UNSIGNED_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_UINT16, - "MESA_FORMAT_RGBA_UINT16", - GL_RGBA, - GL_UNSIGNED_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_UINT32, - "MESA_FORMAT_RGBA_UINT32", - GL_RGBA, - GL_UNSIGNED_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - - { - MESA_FORMAT_DUDV8, - "MESA_FORMAT_DUDV8", - GL_DUDV_ATI, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - - /* Signed 8 bits / channel */ - { - MESA_FORMAT_SIGNED_R8, /* Name */ - "MESA_FORMAT_SIGNED_R8", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_SIGNED_NORMALIZED, /* DataType */ - 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SIGNED_RG88, - "MESA_FORMAT_SIGNED_RG88", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RGBX8888, - "MESA_FORMAT_SIGNED_RGBX8888", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 /* 4 bpp, but no alpha */ - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - "MESA_FORMAT_SIGNED_RGBA8888", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - "MESA_FORMAT_SIGNED_RGBA8888_REV", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - - /* Signed 16 bits / channel */ - { - MESA_FORMAT_SIGNED_R_16, - "MESA_FORMAT_SIGNED_R_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RG_16, - "MESA_FORMAT_SIGNED_RG_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGB_16, - "MESA_FORMAT_SIGNED_RGB_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - "MESA_FORMAT_SIGNED_RGBA_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_16, - "MESA_FORMAT_RGBA_16", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - } -}; - - - -static const struct gl_format_info * -_mesa_get_format_info(gl_format format) -{ - const struct gl_format_info *info = &format_info[format]; - assert(info->Name == format); - return info; -} - - -/** Return string name of format (for debugging) */ -const char * -_mesa_get_format_name(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - return info->StrName; -} - - - -/** - * Return bytes needed to store a block of pixels in the given format. - * Normally, a block is 1x1 (a single pixel). But for compressed formats - * a block may be 4x4 or 8x4, etc. - */ -GLuint -_mesa_get_format_bytes(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - return info->BytesPerBlock; -} - - -/** - * Return bits per component for the given format. - * \param format one of MESA_FORMAT_x - * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. - */ -GLint -_mesa_get_format_bits(gl_format format, GLenum pname) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - switch (pname) { - case GL_RED_BITS: - case GL_TEXTURE_RED_SIZE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - return info->RedBits; - case GL_GREEN_BITS: - case GL_TEXTURE_GREEN_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - return info->GreenBits; - case GL_BLUE_BITS: - case GL_TEXTURE_BLUE_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - return info->BlueBits; - case GL_ALPHA_BITS: - case GL_TEXTURE_ALPHA_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - return info->AlphaBits; - case GL_TEXTURE_INTENSITY_SIZE: - return info->IntensityBits; - case GL_TEXTURE_LUMINANCE_SIZE: - return info->LuminanceBits; - case GL_INDEX_BITS: - case GL_TEXTURE_INDEX_SIZE_EXT: - return info->IndexBits; - case GL_DEPTH_BITS: - case GL_TEXTURE_DEPTH_SIZE_ARB: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - return info->DepthBits; - case GL_STENCIL_BITS: - case GL_TEXTURE_STENCIL_SIZE_EXT: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - return info->StencilBits; - default: - _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); - return 0; - } -} - - -/** - * Return the data type (or more specifically, the data representation) - * for the given format. - * The return value will be one of: - * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] - * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] - * GL_UNSIGNED_INT = an ordinary unsigned integer - * GL_FLOAT = an ordinary float - */ -GLenum -_mesa_get_format_datatype(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->DataType; -} - - -/** - * Return the basic format for the given type. The result will be - * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, - * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ -GLenum -_mesa_get_format_base_format(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BaseFormat; -} - - -/** - * Return the block size (in pixels) for the given format. Normally - * the block size is 1x1. But compressed formats will have block sizes - * of 4x4 or 8x4 pixels, etc. - * \param bw returns block width in pixels - * \param bh returns block height in pixels - */ -void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - *bw = info->BlockWidth; - *bh = info->BlockHeight; -} - - -/** Is the given format a compressed format? */ -GLboolean -_mesa_is_format_compressed(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BlockWidth > 1 || info->BlockHeight > 1; -} - - -/** - * Determine if the given format represents a packed depth/stencil buffer. - */ -GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - return info->BaseFormat == GL_DEPTH_STENCIL; -} - - -/** - * Return color encoding for given format. - * \return GL_LINEAR or GL_SRGB - */ -GLenum -_mesa_get_format_color_encoding(gl_format format) -{ - /* XXX this info should be encoded in gl_format_info */ - switch (format) { - case MESA_FORMAT_SRGB8: - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - case MESA_FORMAT_SL8: - case MESA_FORMAT_SLA8: - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: - return GL_SRGB; - default: - return GL_LINEAR; - } -} - - -/** - * Return number of bytes needed to store an image of the given size - * in the given format. - */ -GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format */ - const GLuint bw = info->BlockWidth, bh = info->BlockHeight; - const GLuint wblocks = (width + bw - 1) / bw; - const GLuint hblocks = (height + bh - 1) / bh; - const GLuint sz = wblocks * hblocks * info->BytesPerBlock; - return sz; - } - else { - /* non-compressed */ - const GLuint sz = width * height * depth * info->BytesPerBlock; - return sz; - } -} - - - -GLint -_mesa_format_row_stride(gl_format format, GLsizei width) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format */ - const GLuint bw = info->BlockWidth; - const GLuint wblocks = (width + bw - 1) / bw; - const GLint stride = wblocks * info->BytesPerBlock; - return stride; - } - else { - const GLint stride = width * info->BytesPerBlock; - return stride; - } -} - - - -/** - * Do sanity checking of the format info table. - */ -void -_mesa_test_formats(void) -{ - GLuint i; - - assert(Elements(format_info) == MESA_FORMAT_COUNT); - - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - const struct gl_format_info *info = _mesa_get_format_info(i); - assert(info); - - assert(info->Name == i); - - if (info->Name == MESA_FORMAT_NONE) - continue; - - if (info->BlockWidth == 1 && info->BlockHeight == 1) { - if (info->RedBits > 0) { - GLuint t = info->RedBits + info->GreenBits - + info->BlueBits + info->AlphaBits; - assert(t / 8 == info->BytesPerBlock); - (void) t; - } - } - - assert(info->DataType == GL_UNSIGNED_NORMALIZED || - info->DataType == GL_SIGNED_NORMALIZED || - info->DataType == GL_UNSIGNED_INT || - info->DataType == GL_FLOAT); - - if (info->BaseFormat == GL_RGB) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RGBA) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits > 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_LUMINANCE) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits > 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_INTENSITY) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits > 0); - } - - } -} - - - -/** - * Return datatype and number of components per texel for the given gl_format. - * Only used for mipmap generation code. - */ -void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps) -{ - switch (format) { - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_RGBA8888_REV: - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_ARGB8888_REV: - case MESA_FORMAT_XRGB8888: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB888: - case MESA_FORMAT_BGR888: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGB565: - case MESA_FORMAT_RGB565_REV: - *datatype = GL_UNSIGNED_SHORT_5_6_5; - *comps = 3; - return; - - case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_ARGB4444_REV: - *datatype = GL_UNSIGNED_SHORT_4_4_4_4; - *comps = 4; - return; - - case MESA_FORMAT_ARGB1555: - case MESA_FORMAT_ARGB1555_REV: - *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 4; - return; - - case MESA_FORMAT_AL88: - case MESA_FORMAT_AL88_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_AL1616: - case MESA_FORMAT_AL1616_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_RGB332: - *datatype = GL_UNSIGNED_BYTE_3_3_2; - *comps = 3; - return; - - case MESA_FORMAT_A8: - case MESA_FORMAT_L8: - case MESA_FORMAT_I8: - case MESA_FORMAT_CI8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - - case MESA_FORMAT_YCBCR: - case MESA_FORMAT_YCBCR_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_Z24_S8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_S8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_Z16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_X8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z24_X8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z32: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_DUDV8: - *datatype = GL_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_SIGNED_RGBA8888: - case MESA_FORMAT_SIGNED_RGBA8888_REV: - *datatype = GL_BYTE; - *comps = 4; - return; - - case MESA_FORMAT_SIGNED_R_16: - *datatype = GL_SHORT; - *comps = 1; - return; - case MESA_FORMAT_SIGNED_RG_16: - *datatype = GL_SHORT; - *comps = 2; - return; - case MESA_FORMAT_SIGNED_RGB_16: - *datatype = GL_SHORT; - *comps = 3; - return; - case MESA_FORMAT_SIGNED_RGBA_16: - *datatype = GL_SHORT; - *comps = 4; - return; - -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_SL8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - case MESA_FORMAT_SLA8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; -#endif - -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif - /* XXX generate error instead? */ - *datatype = GL_UNSIGNED_BYTE; - *comps = 0; - return; -#endif - - case MESA_FORMAT_RGBA_FLOAT32: - *datatype = GL_FLOAT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 4; - return; - case MESA_FORMAT_RGB_FLOAT32: - *datatype = GL_FLOAT; - *comps = 3; - return; - case MESA_FORMAT_RGB_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 3; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: - *datatype = GL_FLOAT; - *comps = 2; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 2; - return; - case MESA_FORMAT_ALPHA_FLOAT32: - case MESA_FORMAT_LUMINANCE_FLOAT32: - case MESA_FORMAT_INTENSITY_FLOAT32: - *datatype = GL_FLOAT; - *comps = 1; - return; - case MESA_FORMAT_ALPHA_FLOAT16: - case MESA_FORMAT_LUMINANCE_FLOAT16: - case MESA_FORMAT_INTENSITY_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 1; - return; - - case MESA_FORMAT_RGBA_INT8: - *datatype = GL_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT16: - *datatype = GL_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT32: - *datatype = GL_INT; - *comps = 4; - return; - - /** - * \name Non-normalized unsigned integer formats. - */ - case MESA_FORMAT_RGBA_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 4; - return; - - - default: - _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps"); - *datatype = 0; - *comps = 1; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "imports.h" +#include "formats.h" +#include "mfeatures.h" + + +/** + * Information about texture formats. + */ +struct gl_format_info +{ + gl_format Name; + + /** text name for debugging */ + const char *StrName; + + /** + * Base format is one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, + * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, + * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + */ + GLenum BaseFormat; + + /** + * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, + * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. + */ + GLenum DataType; + + GLubyte RedBits; + GLubyte GreenBits; + GLubyte BlueBits; + GLubyte AlphaBits; + GLubyte LuminanceBits; + GLubyte IntensityBits; + GLubyte IndexBits; + GLubyte DepthBits; + GLubyte StencilBits; + + /** + * To describe compressed formats. If not compressed, Width=Height=1. + */ + GLubyte BlockWidth, BlockHeight; + GLubyte BytesPerBlock; +}; + + +/** + * Info about each format. + * These must be in the same order as the MESA_FORMAT_* enums so that + * we can do lookups without searching. + */ +static struct gl_format_info format_info[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, /* Name */ + "MESA_FORMAT_NONE", /* StrName */ + GL_NONE, /* BaseFormat */ + GL_NONE, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 0, 0, 0 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888, /* Name */ + "MESA_FORMAT_RGBA8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888_REV, /* Name */ + "MESA_FORMAT_RGBA8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888, /* Name */ + "MESA_FORMAT_ARGB8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888_REV, /* Name */ + "MESA_FORMAT_ARGB8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888, /* Name */ + "MESA_FORMAT_XRGB8888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888_REV, /* Name */ + "MESA_FORMAT_XRGB8888_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB888, /* Name */ + "MESA_FORMAT_RGB888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_BGR888, /* Name */ + "MESA_FORMAT_BGR888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565, /* Name */ + "MESA_FORMAT_RGB565", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565_REV, /* Name */ + "MESA_FORMAT_RGB565_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444, /* Name */ + "MESA_FORMAT_ARGB4444", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444_REV, /* Name */ + "MESA_FORMAT_ARGB4444_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA5551, /* Name */ + "MESA_FORMAT_RGBA5551", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555, /* Name */ + "MESA_FORMAT_ARGB1555", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555_REV, /* Name */ + "MESA_FORMAT_ARGB1555_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL44, /* Name */ + "MESA_FORMAT_AL44", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ + 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88, /* Name */ + "MESA_FORMAT_AL88", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88_REV, /* Name */ + "MESA_FORMAT_AL88_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616, /* Name */ + "MESA_FORMAT_AL1616", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616_REV, /* Name */ + "MESA_FORMAT_AL1616_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB332, /* Name */ + "MESA_FORMAT_RGB332", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A8, /* Name */ + "MESA_FORMAT_A8", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A16, /* Name */ + "MESA_FORMAT_A16", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L8, /* Name */ + "MESA_FORMAT_L8", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L16, /* Name */ + "MESA_FORMAT_L16", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I8, /* Name */ + "MESA_FORMAT_I8", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I16, /* Name */ + "MESA_FORMAT_I16", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_CI8, /* Name */ + "MESA_FORMAT_CI8", /* StrName */ + GL_COLOR_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR, /* Name */ + "MESA_FORMAT_YCBCR", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR_REV, /* Name */ + "MESA_FORMAT_YCBCR_REV", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_R8, + "MESA_FORMAT_R8", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 8, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_RG88, + "MESA_FORMAT_RG88", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG88_REV, + "MESA_FORMAT_RG88_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_R16, + "MESA_FORMAT_R16", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG1616, + "MESA_FORMAT_RG1616", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RG1616_REV, + "MESA_FORMAT_RG1616_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ARGB2101010, + "MESA_FORMAT_ARGB2101010", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 10, 10, 10, 2, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_Z24_S8, /* Name */ + "MESA_FORMAT_Z24_S8", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8_Z24, /* Name */ + "MESA_FORMAT_S8_Z24", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z16, /* Name */ + "MESA_FORMAT_Z16", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_X8_Z24, /* Name */ + "MESA_FORMAT_X8_Z24", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z24_X8, /* Name */ + "MESA_FORMAT_Z24_X8", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z32, /* Name */ + "MESA_FORMAT_Z32", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8, /* Name */ + "MESA_FORMAT_S8", /* StrName */ + GL_STENCIL_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SRGB8, + "MESA_FORMAT_SRGB8", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 3 + }, + { + MESA_FORMAT_SRGBA8, + "MESA_FORMAT_SRGBA8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SARGB8, + "MESA_FORMAT_SARGB8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SL8, + "MESA_FORMAT_SL8", + GL_LUMINANCE, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SLA8, + "MESA_FORMAT_SLA8", + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SRGB_DXT1, /* Name */ + "MESA_FORMAT_SRGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT1, + "MESA_FORMAT_SRGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT3, + "MESA_FORMAT_SRGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT5, + "MESA_FORMAT_SRGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + + { + MESA_FORMAT_RGB_FXT1, + "MESA_FORMAT_RGB_FXT1", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 0, /* approx Red/Green/BlueBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + { + MESA_FORMAT_RGBA_FXT1, + "MESA_FORMAT_RGBA_FXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + + { + MESA_FORMAT_RGB_DXT1, /* Name */ + "MESA_FORMAT_RGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT1, + "MESA_FORMAT_RGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT3, + "MESA_FORMAT_RGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT5, + "MESA_FORMAT_RGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_FLOAT32, + "MESA_FORMAT_RGBA_FLOAT32", + GL_RGBA, + GL_FLOAT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + "MESA_FORMAT_RGBA_FLOAT16", + GL_RGBA, + GL_FLOAT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGB_FLOAT32, + "MESA_FORMAT_RGB_FLOAT32", + GL_RGB, + GL_FLOAT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 12 + }, + { + MESA_FORMAT_RGB_FLOAT16, + "MESA_FORMAT_RGB_FLOAT16", + GL_RGB, + GL_FLOAT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + "MESA_FORMAT_ALPHA_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + "MESA_FORMAT_ALPHA_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + "MESA_FORMAT_LUMINANCE_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 32, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + "MESA_FORMAT_LUMINANCE_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 32, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + "MESA_FORMAT_INTENSITY_FLOAT32", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 32, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + "MESA_FORMAT_INTENSITY_FLOAT16", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + }, + + /* unnormalized signed int formats */ + { + MESA_FORMAT_RGBA_INT8, + "MESA_FORMAT_RGBA_INT8", + GL_RGBA, + GL_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_INT16, + "MESA_FORMAT_RGBA_INT16", + GL_RGBA, + GL_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_INT32, + "MESA_FORMAT_RGBA_INT32", + GL_RGBA, + GL_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + /* unnormalized unsigned int formats */ + { + MESA_FORMAT_RGBA_UINT8, + "MESA_FORMAT_RGBA_UINT8", + GL_RGBA, + GL_UNSIGNED_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_UINT16, + "MESA_FORMAT_RGBA_UINT16", + GL_RGBA, + GL_UNSIGNED_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_UINT32, + "MESA_FORMAT_RGBA_UINT32", + GL_RGBA, + GL_UNSIGNED_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + + { + MESA_FORMAT_DUDV8, + "MESA_FORMAT_DUDV8", + GL_DUDV_ATI, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + + /* Signed 8 bits / channel */ + { + MESA_FORMAT_SIGNED_R8, /* Name */ + "MESA_FORMAT_SIGNED_R8", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_SIGNED_NORMALIZED, /* DataType */ + 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SIGNED_RG88, + "MESA_FORMAT_SIGNED_RG88", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + "MESA_FORMAT_SIGNED_RGBX8888", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 /* 4 bpp, but no alpha */ + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + "MESA_FORMAT_SIGNED_RGBA8888", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + "MESA_FORMAT_SIGNED_RGBA8888_REV", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + + /* Signed 16 bits / channel */ + { + MESA_FORMAT_SIGNED_R_16, + "MESA_FORMAT_SIGNED_R_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RG_16, + "MESA_FORMAT_SIGNED_RG_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + "MESA_FORMAT_SIGNED_RGB_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + "MESA_FORMAT_SIGNED_RGBA_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + } +}; + + + +static const struct gl_format_info * +_mesa_get_format_info(gl_format format) +{ + const struct gl_format_info *info = &format_info[format]; + assert(info->Name == format); + return info; +} + + +/** Return string name of format (for debugging) */ +const char * +_mesa_get_format_name(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->StrName; +} + + + +/** + * Return bytes needed to store a block of pixels in the given format. + * Normally, a block is 1x1 (a single pixel). But for compressed formats + * a block may be 4x4 or 8x4, etc. + */ +GLuint +_mesa_get_format_bytes(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + ASSERT(info->BytesPerBlock); + return info->BytesPerBlock; +} + + +/** + * Return bits per component for the given format. + * \param format one of MESA_FORMAT_x + * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. + */ +GLint +_mesa_get_format_bits(gl_format format, GLenum pname) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + switch (pname) { + case GL_RED_BITS: + case GL_TEXTURE_RED_SIZE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + return info->RedBits; + case GL_GREEN_BITS: + case GL_TEXTURE_GREEN_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + return info->GreenBits; + case GL_BLUE_BITS: + case GL_TEXTURE_BLUE_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + return info->BlueBits; + case GL_ALPHA_BITS: + case GL_TEXTURE_ALPHA_SIZE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + return info->AlphaBits; + case GL_TEXTURE_INTENSITY_SIZE: + return info->IntensityBits; + case GL_TEXTURE_LUMINANCE_SIZE: + return info->LuminanceBits; + case GL_INDEX_BITS: + case GL_TEXTURE_INDEX_SIZE_EXT: + return info->IndexBits; + case GL_DEPTH_BITS: + case GL_TEXTURE_DEPTH_SIZE_ARB: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + return info->DepthBits; + case GL_STENCIL_BITS: + case GL_TEXTURE_STENCIL_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + return info->StencilBits; + default: + _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); + return 0; + } +} + + +/** + * Return the data type (or more specifically, the data representation) + * for the given format. + * The return value will be one of: + * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] + * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] + * GL_UNSIGNED_INT = an ordinary unsigned integer + * GL_INT = an ordinary signed integer + * GL_FLOAT = an ordinary float + */ +GLenum +_mesa_get_format_datatype(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->DataType; +} + + +/** + * Return the basic format for the given type. The result will be + * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, + * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + */ +GLenum +_mesa_get_format_base_format(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BaseFormat; +} + + +/** + * Return the block size (in pixels) for the given format. Normally + * the block size is 1x1. But compressed formats will have block sizes + * of 4x4 or 8x4 pixels, etc. + * \param bw returns block width in pixels + * \param bh returns block height in pixels + */ +void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + *bw = info->BlockWidth; + *bh = info->BlockHeight; +} + + +/** Is the given format a compressed format? */ +GLboolean +_mesa_is_format_compressed(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BlockWidth > 1 || info->BlockHeight > 1; +} + + +/** + * Determine if the given format represents a packed depth/stencil buffer. + */ +GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + return info->BaseFormat == GL_DEPTH_STENCIL; +} + + +/** + * Is the given format a signed/unsigned integer color format? + */ +GLboolean +_mesa_is_format_integer_color(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && + info->BaseFormat != GL_DEPTH_COMPONENT && + info->BaseFormat != GL_DEPTH_STENCIL && + info->BaseFormat != GL_STENCIL_INDEX; +} + + +/** + * Return color encoding for given format. + * \return GL_LINEAR or GL_SRGB + */ +GLenum +_mesa_get_format_color_encoding(gl_format format) +{ + /* XXX this info should be encoded in gl_format_info */ + switch (format) { + case MESA_FORMAT_SRGB8: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: + return GL_SRGB; + default: + return GL_LINEAR; + } +} + + +/** + * Return number of bytes needed to store an image of the given size + * in the given format. + */ +GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const GLuint bw = info->BlockWidth, bh = info->BlockHeight; + const GLuint wblocks = (width + bw - 1) / bw; + const GLuint hblocks = (height + bh - 1) / bh; + const GLuint sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const GLuint sz = width * height * depth * info->BytesPerBlock; + return sz; + } +} + + +/** + * Same as _mesa_format_image_size() but returns a 64-bit value to + * accomodate very large textures. + */ +uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; + const uint64_t wblocks = (width + bw - 1) / bw; + const uint64_t hblocks = (height + bh - 1) / bh; + const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const uint64_t sz = ((uint64_t) width * + (uint64_t) height * + (uint64_t) depth * + info->BytesPerBlock); + return sz; + } +} + + + +GLint +_mesa_format_row_stride(gl_format format, GLsizei width) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format */ + const GLuint bw = info->BlockWidth; + const GLuint wblocks = (width + bw - 1) / bw; + const GLint stride = wblocks * info->BytesPerBlock; + return stride; + } + else { + const GLint stride = width * info->BytesPerBlock; + return stride; + } +} + + + +/** + * Do sanity checking of the format info table. + */ +void +_mesa_test_formats(void) +{ + GLuint i; + + assert(Elements(format_info) == MESA_FORMAT_COUNT); + + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + const struct gl_format_info *info = _mesa_get_format_info(i); + assert(info); + + assert(info->Name == i); + + if (info->Name == MESA_FORMAT_NONE) + continue; + + if (info->BlockWidth == 1 && info->BlockHeight == 1) { + if (info->RedBits > 0) { + GLuint t = info->RedBits + info->GreenBits + + info->BlueBits + info->AlphaBits; + assert(t / 8 == info->BytesPerBlock); + (void) t; + } + } + + assert(info->DataType == GL_UNSIGNED_NORMALIZED || + info->DataType == GL_SIGNED_NORMALIZED || + info->DataType == GL_UNSIGNED_INT || + info->DataType == GL_FLOAT); + + if (info->BaseFormat == GL_RGB) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RGBA) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits > 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RG) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RED) { + assert(info->RedBits > 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_LUMINANCE) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits > 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_INTENSITY) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits > 0); + } + + } +} + + + +/** + * Return datatype and number of components per texel for the given gl_format. + * Only used for mipmap generation code. + */ +void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps) +{ + switch (format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_XRGB8888_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGB888: + case MESA_FORMAT_BGR888: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + *datatype = GL_UNSIGNED_SHORT_5_6_5; + *comps = 3; + return; + + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + *datatype = GL_UNSIGNED_SHORT_4_4_4_4; + *comps = 4; + return; + + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; + *comps = 4; + return; + + case MESA_FORMAT_ARGB2101010: + *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; + *comps = 4; + return; + + case MESA_FORMAT_RGBA5551: + *datatype = GL_UNSIGNED_SHORT_5_5_5_1; + *comps = 4; + return; + + case MESA_FORMAT_AL44: /* XXX this isn't plain GL_UNSIGNED_BYTE */ + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RG88: + case MESA_FORMAT_RG88_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_AL1616: + case MESA_FORMAT_AL1616_REV: + case MESA_FORMAT_RG1616: + case MESA_FORMAT_RG1616_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_R16: + case MESA_FORMAT_A16: + case MESA_FORMAT_L16: + case MESA_FORMAT_I16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_RGB332: + *datatype = GL_UNSIGNED_BYTE_3_3_2; + *comps = 3; + return; + + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + case MESA_FORMAT_R8: + case MESA_FORMAT_S8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + + case MESA_FORMAT_YCBCR: + case MESA_FORMAT_YCBCR_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_Z24_S8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_S8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_Z16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_X8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z24_X8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z32: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_DUDV8: + *datatype = GL_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_SIGNED_R8: + *datatype = GL_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG88: + *datatype = GL_BYTE; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBX8888: + *datatype = GL_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_RGBA_16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_SIGNED_R_16: + *datatype = GL_SHORT; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG_16: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGB_16: + *datatype = GL_SHORT; + *comps = 3; + return; + case MESA_FORMAT_SIGNED_RGBA_16: + *datatype = GL_SHORT; + *comps = 4; + return; + +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_SL8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SLA8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; +#endif + +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_RGBA_DXT5: +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: +#endif +#endif + /* XXX generate error instead? */ + *datatype = GL_UNSIGNED_BYTE; + *comps = 0; + return; + + case MESA_FORMAT_RGBA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 4; + return; + case MESA_FORMAT_RGB_FLOAT32: + *datatype = GL_FLOAT; + *comps = 3; + return; + case MESA_FORMAT_RGB_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 3; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 2; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 2; + return; + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_INTENSITY_FLOAT32: + *datatype = GL_FLOAT; + *comps = 1; + return; + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 1; + return; + + case MESA_FORMAT_RGBA_INT8: + *datatype = GL_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT16: + *datatype = GL_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT32: + *datatype = GL_INT; + *comps = 4; + return; + + /** + * \name Non-normalized unsigned integer formats. + */ + case MESA_FORMAT_RGBA_UINT8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT32: + *datatype = GL_UNSIGNED_INT; + *comps = 4; + return; + + case MESA_FORMAT_COUNT: + assert(0); + return; + + case MESA_FORMAT_NONE: + /* For debug builds, warn if any formats are not handled */ +#ifdef DEBUG + default: +#endif + _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", + _mesa_get_format_name(format)); + *datatype = 0; + *comps = 1; + } +} diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index e9467f486..0d5e75526 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -1,213 +1,231 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - - -#ifndef FORMATS_H -#define FORMATS_H - - -#include - - - -/** - * Mesa texture/renderbuffer image formats. - */ -typedef enum -{ - MESA_FORMAT_NONE = 0, - - /** - * \name Basic hardware formats - */ - /*@{*/ - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ - MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ - MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ - MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ - MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ - MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ - MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ - MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ - MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ - MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ - MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ - MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ - MESA_FORMAT_RGB332, /* RRRG GGBB */ - MESA_FORMAT_A8, /* AAAA AAAA */ - MESA_FORMAT_L8, /* LLLL LLLL */ - MESA_FORMAT_I8, /* IIII IIII */ - MESA_FORMAT_CI8, /* CCCC CCCC */ - MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ - MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ - MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ - MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ - MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_S8, /* SSSS SSSS */ - /*@}*/ - - /** - * \name 8-bit/channel sRGB formats - */ - /*@{*/ - MESA_FORMAT_SRGB8, - MESA_FORMAT_SRGBA8, - MESA_FORMAT_SARGB8, - MESA_FORMAT_SL8, - MESA_FORMAT_SLA8, - MESA_FORMAT_SRGB_DXT1, - MESA_FORMAT_SRGBA_DXT1, - MESA_FORMAT_SRGBA_DXT3, - MESA_FORMAT_SRGBA_DXT5, - /*@}*/ - - /** - * \name Compressed texture formats. - */ - /*@{*/ - MESA_FORMAT_RGB_FXT1, - MESA_FORMAT_RGBA_FXT1, - MESA_FORMAT_RGB_DXT1, - MESA_FORMAT_RGBA_DXT1, - MESA_FORMAT_RGBA_DXT3, - MESA_FORMAT_RGBA_DXT5, - /*@}*/ - - /** - * \name Floating point texture formats. - */ - /*@{*/ - MESA_FORMAT_RGBA_FLOAT32, - MESA_FORMAT_RGBA_FLOAT16, - MESA_FORMAT_RGB_FLOAT32, - MESA_FORMAT_RGB_FLOAT16, - MESA_FORMAT_ALPHA_FLOAT32, - MESA_FORMAT_ALPHA_FLOAT16, - MESA_FORMAT_LUMINANCE_FLOAT32, - MESA_FORMAT_LUMINANCE_FLOAT16, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - MESA_FORMAT_INTENSITY_FLOAT32, - MESA_FORMAT_INTENSITY_FLOAT16, - /*@}*/ - - /** - * \name Non-normalized signed integer formats. - * XXX Note: these are just stand-ins for some better hardware - * formats TBD such as BGRA or ARGB. - */ - MESA_FORMAT_RGBA_INT8, - MESA_FORMAT_RGBA_INT16, - MESA_FORMAT_RGBA_INT32, - - /** - * \name Non-normalized unsigned integer formats. - */ - MESA_FORMAT_RGBA_UINT8, - MESA_FORMAT_RGBA_UINT16, - MESA_FORMAT_RGBA_UINT32, - - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - /** - * \name Signed fixed point texture formats. - */ - /*@{*/ - MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ - MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ - MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ - MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ - MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ - MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ - MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ - MESA_FORMAT_SIGNED_RGBA_16, /* ... */ - MESA_FORMAT_RGBA_16, /* ... */ - /*@}*/ - - MESA_FORMAT_COUNT -} gl_format; - - -extern const char * -_mesa_get_format_name(gl_format format); - -extern GLuint -_mesa_get_format_bytes(gl_format format); - -extern GLint -_mesa_get_format_bits(gl_format format, GLenum pname); - -extern GLenum -_mesa_get_format_datatype(gl_format format); - -extern GLenum -_mesa_get_format_base_format(gl_format format); - -extern void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); - -extern GLboolean -_mesa_is_format_compressed(gl_format format); - -extern GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format); - -extern GLenum -_mesa_get_format_color_encoding(gl_format format); - -extern GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern GLint -_mesa_format_row_stride(gl_format format, GLsizei width); - -extern void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps); - -extern void -_mesa_test_formats(void); - -#endif /* FORMATS_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + + +#ifndef FORMATS_H +#define FORMATS_H + + +#include + + + +/** + * Mesa texture/renderbuffer image formats. + */ +typedef enum +{ + MESA_FORMAT_NONE = 0, + + /** + * \name Basic hardware formats + */ + /*@{*/ + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ + MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ + MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ + MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ + MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ + MESA_FORMAT_AL44, /* AAAA LLLL */ + MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ + MESA_FORMAT_RGB332, /* RRRG GGBB */ + MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_I8, /* IIII IIII */ + MESA_FORMAT_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_CI8, /* CCCC CCCC */ + MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ + MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ + MESA_FORMAT_R8, /* RRRR RRRR */ + MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ + MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ + MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_S8, /* SSSS SSSS */ + /*@}*/ + + /** + * \name 8-bit/channel sRGB formats + */ + /*@{*/ + MESA_FORMAT_SRGB8, + MESA_FORMAT_SRGBA8, + MESA_FORMAT_SARGB8, + MESA_FORMAT_SL8, + MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, + MESA_FORMAT_SRGBA_DXT1, + MESA_FORMAT_SRGBA_DXT3, + MESA_FORMAT_SRGBA_DXT5, + /*@}*/ + + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + + /** + * \name Floating point texture formats. + */ + /*@{*/ + MESA_FORMAT_RGBA_FLOAT32, + MESA_FORMAT_RGBA_FLOAT16, + MESA_FORMAT_RGB_FLOAT32, + MESA_FORMAT_RGB_FLOAT16, + MESA_FORMAT_ALPHA_FLOAT32, + MESA_FORMAT_ALPHA_FLOAT16, + MESA_FORMAT_LUMINANCE_FLOAT32, + MESA_FORMAT_LUMINANCE_FLOAT16, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + MESA_FORMAT_INTENSITY_FLOAT32, + MESA_FORMAT_INTENSITY_FLOAT16, + /*@}*/ + + /** + * \name Non-normalized signed integer formats. + * XXX Note: these are just stand-ins for some better hardware + * formats TBD such as BGRA or ARGB. + */ + MESA_FORMAT_RGBA_INT8, + MESA_FORMAT_RGBA_INT16, + MESA_FORMAT_RGBA_INT32, + + /** + * \name Non-normalized unsigned integer formats. + */ + MESA_FORMAT_RGBA_UINT8, + MESA_FORMAT_RGBA_UINT16, + MESA_FORMAT_RGBA_UINT32, + + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + /** + * \name Signed fixed point texture formats. + */ + /*@{*/ + MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ + MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ + MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ + MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ + MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ + /*@}*/ + + MESA_FORMAT_COUNT +} gl_format; + + +extern const char * +_mesa_get_format_name(gl_format format); + +extern GLuint +_mesa_get_format_bytes(gl_format format); + +extern GLint +_mesa_get_format_bits(gl_format format, GLenum pname); + +extern GLenum +_mesa_get_format_datatype(gl_format format); + +extern GLenum +_mesa_get_format_base_format(gl_format format); + +extern void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); + +extern GLboolean +_mesa_is_format_compressed(gl_format format); + +extern GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format); + +extern GLboolean +_mesa_is_format_integer_color(gl_format format); + +extern GLenum +_mesa_get_format_color_encoding(gl_format format); + +extern GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern GLint +_mesa_format_row_stride(gl_format format, GLsizei width); + +extern void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps); + +extern void +_mesa_test_formats(void); + +#endif /* FORMATS_H */ diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index a98c09cfb..f8c0c6379 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -1,1063 +1,1084 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Functions for allocating/managing framebuffers and renderbuffers. - * Also, routines for reading/writing renderbuffer data as ubytes, - * ushorts, uints, etc. - */ - - -#include "glheader.h" -#include "imports.h" -#include "buffers.h" -#include "context.h" -#include "depthstencil.h" -#include "enums.h" -#include "formats.h" -#include "macros.h" -#include "mtypes.h" -#include "fbobject.h" -#include "framebuffer.h" -#include "renderbuffer.h" -#include "texobj.h" - - - -/** - * Compute/set the _DepthMax field for the given framebuffer. - * This value depends on the Z buffer resolution. - */ -static void -compute_depth_max(struct gl_framebuffer *fb) -{ - if (fb->Visual.depthBits == 0) { - /* Special case. Even if we don't have a depth buffer we need - * good values for DepthMax for Z vertex transformation purposes - * and for per-fragment fog computation. - */ - fb->_DepthMax = (1 << 16) - 1; - } - else if (fb->Visual.depthBits < 32) { - fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; - } - else { - /* Special case since shift values greater than or equal to the - * number of bits in the left hand expression's type are undefined. - */ - fb->_DepthMax = 0xffffffff; - } - fb->_DepthMaxF = (GLfloat) fb->_DepthMax; - - /* Minimum resolvable depth value, for polygon offset */ - fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; -} - -/** - * Create and initialize a gl_framebuffer object. - * This is intended for creating _window_system_ framebuffers, not generic - * framebuffer objects ala GL_EXT_framebuffer_object. - * - * \sa _mesa_new_framebuffer - */ -struct gl_framebuffer * -_mesa_create_framebuffer(const GLvisual *visual) -{ - struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); - assert(visual); - if (fb) { - _mesa_initialize_window_framebuffer(fb, visual); - } - return fb; -} - - -/** - * Allocate a new gl_framebuffer object. - * This is the default function for ctx->Driver.NewFramebuffer(). - * This is for allocating user-created framebuffers, not window-system - * framebuffers! - * \sa _mesa_create_framebuffer - */ -struct gl_framebuffer * -_mesa_new_framebuffer(GLcontext *ctx, GLuint name) -{ - struct gl_framebuffer *fb; - (void) ctx; - assert(name != 0); - fb = CALLOC_STRUCT(gl_framebuffer); - if (fb) { - _mesa_initialize_user_framebuffer(fb, name); - } - return fb; -} - - -/** - * Initialize a gl_framebuffer object. Typically used to initialize - * window system-created framebuffers, not user-created framebuffers. - * \sa _mesa_initialize_user_framebuffer - */ -void -_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const GLvisual *visual) -{ - assert(fb); - assert(visual); - - memset(fb, 0, sizeof(struct gl_framebuffer)); - - _glthread_INIT_MUTEX(fb->Mutex); - - fb->RefCount = 1; - - /* save the visual */ - fb->Visual = *visual; - - /* Init read/draw renderbuffer state */ - if (visual->doubleBufferMode) { - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_BACK; - fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; - fb->ColorReadBuffer = GL_BACK; - fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; - } - else { - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_FRONT; - fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; - fb->ColorReadBuffer = GL_FRONT; - fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; - } - - fb->Delete = _mesa_destroy_framebuffer; - fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; - - compute_depth_max(fb); -} - - -/** - * Initialize a user-created gl_framebuffer object. - * \sa _mesa_initialize_window_framebuffer - */ -void -_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name) -{ - assert(fb); - assert(name); - - memset(fb, 0, sizeof(struct gl_framebuffer)); - - fb->Name = name; - fb->RefCount = 1; - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; - fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; - fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; - fb->_ColorReadBufferIndex = BUFFER_COLOR0; - fb->Delete = _mesa_destroy_framebuffer; - _glthread_INIT_MUTEX(fb->Mutex); -} - - -/** - * Deallocate buffer and everything attached to it. - * Typically called via the gl_framebuffer->Delete() method. - */ -void -_mesa_destroy_framebuffer(struct gl_framebuffer *fb) -{ - if (fb) { - _mesa_free_framebuffer_data(fb); - free(fb); - } -} - - -/** - * Free all the data hanging off the given gl_framebuffer, but don't free - * the gl_framebuffer object itself. - */ -void -_mesa_free_framebuffer_data(struct gl_framebuffer *fb) -{ - GLuint i; - - assert(fb); - assert(fb->RefCount == 0); - - _glthread_DESTROY_MUTEX(fb->Mutex); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Renderbuffer) { - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); - } - if (att->Texture) { - _mesa_reference_texobj(&att->Texture, NULL); - } - ASSERT(!att->Renderbuffer); - ASSERT(!att->Texture); - att->Type = GL_NONE; - } - - /* unbind _Depth/_StencilBuffer to decr ref counts */ - _mesa_reference_renderbuffer(&fb->_DepthBuffer, NULL); - _mesa_reference_renderbuffer(&fb->_StencilBuffer, NULL); -} - - -/** - * Set *ptr to point to fb, with refcounting and locking. - */ -void -_mesa_reference_framebuffer(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb) -{ - assert(ptr); - if (*ptr == fb) { - /* no change */ - return; - } - - if (*ptr) { - /* unreference old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_framebuffer *oldFb = *ptr; - - _glthread_LOCK_MUTEX(oldFb->Mutex); - ASSERT(oldFb->RefCount > 0); - oldFb->RefCount--; - deleteFlag = (oldFb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldFb->Mutex); - - if (deleteFlag) - oldFb->Delete(oldFb); - - *ptr = NULL; - } - assert(!*ptr); - - if (fb) { - _glthread_LOCK_MUTEX(fb->Mutex); - fb->RefCount++; - _glthread_UNLOCK_MUTEX(fb->Mutex); - *ptr = fb; - } -} - - -/** - * Resize the given framebuffer's renderbuffers to the new width and height. - * This should only be used for window-system framebuffers, not - * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). - * This will typically be called via ctx->Driver.ResizeBuffers() or directly - * from a device driver. - * - * \note it's possible for ctx to be null since a window can be resized - * without a currently bound rendering context. - */ -void -_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height) -{ - GLuint i; - - /* XXX I think we could check if the size is not changing - * and return early. - */ - - /* For window system framebuffers, Name is zero */ - assert(fb->Name == 0); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) { - struct gl_renderbuffer *rb = att->Renderbuffer; - /* only resize if size is changing */ - if (rb->Width != width || rb->Height != height) { - if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - ASSERT(rb->Width == width); - ASSERT(rb->Height == height); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - /* no return */ - } - } - } - } - - if (fb->_DepthBuffer) { - struct gl_renderbuffer *rb = fb->_DepthBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - - if (fb->_StencilBuffer) { - struct gl_renderbuffer *rb = fb->_StencilBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - - fb->Width = width; - fb->Height = height; - - if (ctx) { - /* update scissor / window bounds */ - _mesa_update_draw_buffer_bounds(ctx); - /* Signal new buffer state so that swrast will update its clipping - * info (the CLIP_BIT flag). - */ - ctx->NewState |= _NEW_BUFFERS; - } -} - - - -/** - * XXX THIS IS OBSOLETE - drivers should take care of detecting window - * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). - * - * GL_MESA_resize_buffers extension. - * - * When this function is called, we'll ask the window system how large - * the current window is. If it's a new size, we'll call the driver's - * ResizeBuffers function. The driver will then resize its color buffers - * as needed, and maybe call the swrast's routine for reallocating - * swrast-managed depth/stencil/accum/etc buffers. - * \note This function should only be called through the GL API, not - * from device drivers (as was done in the past). - */ -void -_mesa_resizebuffers( GLcontext *ctx ) -{ - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glResizeBuffersMESA\n"); - - if (!ctx->Driver.GetBufferSize) { - return; - } - - if (ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - - assert(buffer->Name == 0); - - /* ask device driver for size of output buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - if (ctx->WinSysReadBuffer - && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysReadBuffer; - - assert(buffer->Name == 0); - - /* ask device driver for size of read buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - -/* - * XXX THIS IS OBSOLETE - */ -void GLAPIENTRY -_mesa_ResizeBuffersMESA( void ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Extensions.MESA_resize_buffers) - _mesa_resizebuffers( ctx ); -} - - - -/** - * Examine all the framebuffer's renderbuffers to update the Width/Height - * fields of the framebuffer. If we have renderbuffers with different - * sizes, set the framebuffer's width and height to the min size. - * Note: this is only intended for user-created framebuffers, not - * window-system framebuffes. - */ -static void -update_framebuffer_size(GLcontext *ctx, struct gl_framebuffer *fb) -{ - GLuint minWidth = ~0, minHeight = ~0; - GLuint i; - - /* user-created framebuffers only */ - assert(fb->Name); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - const struct gl_renderbuffer *rb = att->Renderbuffer; - if (rb) { - minWidth = MIN2(minWidth, rb->Width); - minHeight = MIN2(minHeight, rb->Height); - } - } - - if (minWidth != ~0) { - fb->Width = minWidth; - fb->Height = minHeight; - } - else { - fb->Width = 0; - fb->Height = 0; - } -} - - -/** - * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. - * These values are computed from the buffer's width and height and - * the scissor box, if it's enabled. - * \param ctx the GL context. - */ -void -_mesa_update_draw_buffer_bounds(GLcontext *ctx) -{ - struct gl_framebuffer *buffer = ctx->DrawBuffer; - - if (!buffer) - return; - - if (buffer->Name) { - /* user-created framebuffer size depends on the renderbuffers */ - update_framebuffer_size(ctx, buffer); - } - - buffer->_Xmin = 0; - buffer->_Ymin = 0; - buffer->_Xmax = buffer->Width; - buffer->_Ymax = buffer->Height; - - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > buffer->_Xmin) { - buffer->_Xmin = ctx->Scissor.X; - } - if (ctx->Scissor.Y > buffer->_Ymin) { - buffer->_Ymin = ctx->Scissor.Y; - } - if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) { - buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; - } - if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) { - buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; - } - /* finally, check for empty region */ - if (buffer->_Xmin > buffer->_Xmax) { - buffer->_Xmin = buffer->_Xmax; - } - if (buffer->_Ymin > buffer->_Ymax) { - buffer->_Ymin = buffer->_Ymax; - } - } - - ASSERT(buffer->_Xmin <= buffer->_Xmax); - ASSERT(buffer->_Ymin <= buffer->_Ymax); -} - - -/** - * The glGet queries of the framebuffer red/green/blue size, stencil size, - * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can - * change depending on the renderbuffer bindings. This function updates - * the given framebuffer's Visual from the current renderbuffer bindings. - * - * This may apply to user-created framebuffers or window system framebuffers. - * - * Also note: ctx->DrawBuffer->Visual.depthBits might not equal - * ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits. - * The former one is used to convert floating point depth values into - * integer Z values. - */ -void -_mesa_update_framebuffer_visual(struct gl_framebuffer *fb) -{ - GLuint i; - - memset(&fb->Visual, 0, sizeof(fb->Visual)); - fb->Visual.rgbMode = GL_TRUE; /* assume this */ - -#if 0 /* this _might_ be needed */ - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - /* leave visual fields zero'd */ - return; - } -#endif - - /* find first RGB renderbuffer */ - for (i = 0; i < BUFFER_COUNT; i++) { - if (fb->Attachment[i].Renderbuffer) { - const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); - const gl_format fmt = rb->Format; - - if (baseFormat == GL_RGBA || baseFormat == GL_RGB || - baseFormat == GL_ALPHA) { - fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); - fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); - fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); - fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); - fb->Visual.rgbBits = fb->Visual.redBits - + fb->Visual.greenBits + fb->Visual.blueBits; - fb->Visual.floatMode = GL_FALSE; - fb->Visual.samples = rb->NumSamples; - break; - } - } - } - - if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_DEPTH].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveDepthBuffer = GL_TRUE; - fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS); - } - - if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_STENCIL].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveStencilBuffer = GL_TRUE; - fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS); - } - - if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_ACCUM].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveAccumBuffer = GL_TRUE; - fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS); - fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); - fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); - fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); - } - - compute_depth_max(fb); -} - - -/** - * Update the framebuffer's _DepthBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a depth wrapper/adaptor. - * - * \param fb the framebuffer whose _DepthBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap - */ -void -_mesa_update_depth_buffer(GLcontext *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) -{ - struct gl_renderbuffer *depthRb; - - /* only one possiblity for now */ - ASSERT(attIndex == BUFFER_DEPTH); - - depthRb = fb->Attachment[attIndex].Renderbuffer; - - if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { - /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_DepthBuffer - || fb->_DepthBuffer->Wrapped != depthRb - || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper - = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); - _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); - ASSERT(fb->_DepthBuffer->Wrapped == depthRb); - } - } - else { - /* depthRb may be null */ - _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); - } -} - - -/** - * Update the framebuffer's _StencilBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a stencil wrapper/adaptor. - * - * \param fb the framebuffer whose _StencilBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap - */ -void -_mesa_update_stencil_buffer(GLcontext *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) -{ - struct gl_renderbuffer *stencilRb; - - ASSERT(attIndex == BUFFER_DEPTH || - attIndex == BUFFER_STENCIL); - - stencilRb = fb->Attachment[attIndex].Renderbuffer; - - if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { - /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_StencilBuffer - || fb->_StencilBuffer->Wrapped != stencilRb - || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper - = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb); - _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); - ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); - } - } - else { - /* stencilRb may be null */ - _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); - } -} - - -/* - * Example DrawBuffers scenarios: - * - * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to - * "gl_FragColor" or program writes to the "result.color" register: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Back - * - * - * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to - * gl_FragData[i] or program writes to result.color[i] registers: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front - * color[1] Aux0 - * color[3] Aux1 - * - * - * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to - * gl_FragColor, or fixed function: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Aux0, Aux1 - * - * - * In either case, the list of renderbuffers is stored in the - * framebuffer->_ColorDrawBuffers[] array and - * framebuffer->_NumColorDrawBuffers indicates the number of buffers. - * The renderer (like swrast) has to look at the current fragment shader - * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine - * how to map color outputs to renderbuffers. - * - * Note that these two calls are equivalent (for fixed function fragment - * shading anyway): - * a) glDrawBuffer(GL_FRONT_AND_BACK); (assuming non-stereo framebuffer) - * b) glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]); - */ - - - - -/** - * Update the (derived) list of color drawing renderbuffer pointers. - * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers - * writing colors. - */ -static void -update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) -{ - GLuint output; - - /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */ - fb->_ColorDrawBuffers[0] = NULL; - - for (output = 0; output < fb->_NumColorDrawBuffers; output++) { - GLint buf = fb->_ColorDrawBufferIndexes[output]; - if (buf >= 0) { - fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; - } - else { - fb->_ColorDrawBuffers[output] = NULL; - } - } -} - - -/** - * Update the (derived) color read renderbuffer pointer. - * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. - */ -static void -update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) -{ - (void) ctx; - if (fb->_ColorReadBufferIndex == -1 || - fb->DeletePending || - fb->Width == 0 || - fb->Height == 0) { - fb->_ColorReadBuffer = NULL; /* legal! */ - } - else { - ASSERT(fb->_ColorReadBufferIndex >= 0); - ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); - fb->_ColorReadBuffer - = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; - } -} - - -/** - * Update a gl_framebuffer's derived state. - * - * Specifically, update these framebuffer fields: - * _ColorDrawBuffers - * _NumColorDrawBuffers - * _ColorReadBuffer - * _DepthBuffer - * _StencilBuffer - * - * If the framebuffer is user-created, make sure it's complete. - * - * The following functions (at least) can effect framebuffer state: - * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, - * glRenderbufferStorageEXT. - */ -static void -update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) -{ - if (fb->Name == 0) { - /* This is a window-system framebuffer */ - /* Need to update the FB's GL_DRAW_BUFFER state to match the - * context state (GL_READ_BUFFER too). - */ - if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { - _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, - ctx->Color.DrawBuffer, NULL); - } - if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) { - - } - } - else { - /* This is a user-created framebuffer. - * Completeness only matters for user-created framebuffers. - */ - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { - _mesa_test_framebuffer_completeness(ctx, fb); - } - } - - /* Strictly speaking, we don't need to update the draw-state - * if this FB is bound as ctx->ReadBuffer (and conversely, the - * read-state if this FB is bound as ctx->DrawBuffer), but no - * harm. - */ - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); - - compute_depth_max(fb); -} - - -/** - * Update state related to the current draw/read framebuffers. - */ -void -_mesa_update_framebuffer(GLcontext *ctx) -{ - struct gl_framebuffer *drawFb; - struct gl_framebuffer *readFb; - - assert(ctx); - drawFb = ctx->DrawBuffer; - readFb = ctx->ReadBuffer; - - update_framebuffer(ctx, drawFb); - if (readFb != drawFb) - update_framebuffer(ctx, readFb); -} - - -/** - * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, - * glCopyTex[Sub]Image, etc) exists. - * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, - * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. - * \return GL_TRUE if buffer exists, GL_FALSE otherwise - */ -GLboolean -_mesa_source_buffer_exists(GLcontext *ctx, GLenum format) -{ - const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; - - /* If we don't know the framebuffer status, update it now */ - if (ctx->ReadBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - } - - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - return GL_FALSE; - } - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_COLOR_INDEX: - if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { - return GL_FALSE; - } - ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ - break; - case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_source_buffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; -} - - -/** - * As above, but for drawing operations. - * XXX could do some code merging w/ above function. - */ -GLboolean -_mesa_dest_buffer_exists(GLcontext *ctx, GLenum format) -{ - const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; - - /* If we don't know the framebuffer status, update it now */ - if (ctx->DrawBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - return GL_FALSE; - } - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_COLOR_INDEX: - /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ - /* Could assert that colorbuffer has RedBits > 0 */ - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ - break; - case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_dest_buffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. - */ -GLenum -_mesa_get_color_read_format(GLcontext *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_BGRA; - case MESA_FORMAT_RGB565: - return GL_BGR; - default: - return GL_RGBA; - } -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. - */ -GLenum -_mesa_get_color_read_type(GLcontext *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_UNSIGNED_BYTE; - case MESA_FORMAT_RGB565: - return GL_UNSIGNED_SHORT_5_6_5_REV; - default: - return GL_UNSIGNED_BYTE; - } -} - - -/** - * Print framebuffer info to stderr, for debugging. - */ -void -_mesa_print_framebuffer(const struct gl_framebuffer *fb) -{ - GLuint i; - - fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb); - fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height, - _mesa_lookup_enum_by_nr(fb->_Status)); - fprintf(stderr, " Attachments:\n"); - - for (i = 0; i < BUFFER_COUNT; i++) { - const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Type == GL_TEXTURE) { - const struct gl_texture_image *texImage; - fprintf(stderr, - " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n", - i, att->Texture->Name, att->TextureLevel, att->CubeMapFace, - att->Zoffset, att->Complete); - texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; - fprintf(stderr, " Size: %u x %u x %u Format %s\n", - texImage->Width, texImage->Height, texImage->Depth, - _mesa_get_format_name(texImage->TexFormat)); - } - else if (att->Type == GL_RENDERBUFFER) { - fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n", - i, att->Renderbuffer->Name, att->Complete); - fprintf(stderr, " Size: %u x %u Format %s\n", - att->Renderbuffer->Width, att->Renderbuffer->Height, - _mesa_get_format_name(att->Renderbuffer->Format)); - } - else { - fprintf(stderr, " %2d: none\n", i); - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.2 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * Functions for allocating/managing framebuffers and renderbuffers. + * Also, routines for reading/writing renderbuffer data as ubytes, + * ushorts, uints, etc. + */ + + +#include "glheader.h" +#include "imports.h" +#include "buffers.h" +#include "context.h" +#include "depthstencil.h" +#include "enums.h" +#include "formats.h" +#include "macros.h" +#include "mtypes.h" +#include "fbobject.h" +#include "framebuffer.h" +#include "renderbuffer.h" +#include "texobj.h" + + + +/** + * Compute/set the _DepthMax field for the given framebuffer. + * This value depends on the Z buffer resolution. + */ +static void +compute_depth_max(struct gl_framebuffer *fb) +{ + if (fb->Visual.depthBits == 0) { + /* Special case. Even if we don't have a depth buffer we need + * good values for DepthMax for Z vertex transformation purposes + * and for per-fragment fog computation. + */ + fb->_DepthMax = (1 << 16) - 1; + } + else if (fb->Visual.depthBits < 32) { + fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; + } + else { + /* Special case since shift values greater than or equal to the + * number of bits in the left hand expression's type are undefined. + */ + fb->_DepthMax = 0xffffffff; + } + fb->_DepthMaxF = (GLfloat) fb->_DepthMax; + + /* Minimum resolvable depth value, for polygon offset */ + fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; +} + +/** + * Create and initialize a gl_framebuffer object. + * This is intended for creating _window_system_ framebuffers, not generic + * framebuffer objects ala GL_EXT_framebuffer_object. + * + * \sa _mesa_new_framebuffer + */ +struct gl_framebuffer * +_mesa_create_framebuffer(const struct gl_config *visual) +{ + struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); + assert(visual); + if (fb) { + _mesa_initialize_window_framebuffer(fb, visual); + } + return fb; +} + + +/** + * Allocate a new gl_framebuffer object. + * This is the default function for ctx->Driver.NewFramebuffer(). + * This is for allocating user-created framebuffers, not window-system + * framebuffers! + * \sa _mesa_create_framebuffer + */ +struct gl_framebuffer * +_mesa_new_framebuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_framebuffer *fb; + (void) ctx; + assert(name != 0); + fb = CALLOC_STRUCT(gl_framebuffer); + if (fb) { + _mesa_initialize_user_framebuffer(fb, name); + } + return fb; +} + + +/** + * Initialize a gl_framebuffer object. Typically used to initialize + * window system-created framebuffers, not user-created framebuffers. + * \sa _mesa_initialize_user_framebuffer + */ +void +_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, + const struct gl_config *visual) +{ + assert(fb); + assert(visual); + + memset(fb, 0, sizeof(struct gl_framebuffer)); + + _glthread_INIT_MUTEX(fb->Mutex); + + fb->RefCount = 1; + + /* save the visual */ + fb->Visual = *visual; + + /* Init read/draw renderbuffer state */ + if (visual->doubleBufferMode) { + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_BACK; + fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; + fb->ColorReadBuffer = GL_BACK; + fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; + } + else { + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_FRONT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; + fb->ColorReadBuffer = GL_FRONT; + fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; + } + + fb->Delete = _mesa_destroy_framebuffer; + fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; + + compute_depth_max(fb); +} + + +/** + * Initialize a user-created gl_framebuffer object. + * \sa _mesa_initialize_window_framebuffer + */ +void +_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name) +{ + assert(fb); + assert(name); + + memset(fb, 0, sizeof(struct gl_framebuffer)); + + fb->Name = name; + fb->RefCount = 1; + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; + fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; + fb->_ColorReadBufferIndex = BUFFER_COLOR0; + fb->Delete = _mesa_destroy_framebuffer; + _glthread_INIT_MUTEX(fb->Mutex); +} + + +/** + * Deallocate buffer and everything attached to it. + * Typically called via the gl_framebuffer->Delete() method. + */ +void +_mesa_destroy_framebuffer(struct gl_framebuffer *fb) +{ + if (fb) { + _mesa_free_framebuffer_data(fb); + free(fb); + } +} + + +/** + * Free all the data hanging off the given gl_framebuffer, but don't free + * the gl_framebuffer object itself. + */ +void +_mesa_free_framebuffer_data(struct gl_framebuffer *fb) +{ + GLuint i; + + assert(fb); + assert(fb->RefCount == 0); + + _glthread_DESTROY_MUTEX(fb->Mutex); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Renderbuffer) { + _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); + } + if (att->Texture) { + _mesa_reference_texobj(&att->Texture, NULL); + } + ASSERT(!att->Renderbuffer); + ASSERT(!att->Texture); + att->Type = GL_NONE; + } + + /* unbind _Depth/_StencilBuffer to decr ref counts */ + _mesa_reference_renderbuffer(&fb->_DepthBuffer, NULL); + _mesa_reference_renderbuffer(&fb->_StencilBuffer, NULL); +} + + +/** + * Set *ptr to point to fb, with refcounting and locking. + */ +void +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb) +{ + assert(ptr); + if (*ptr == fb) { + /* no change */ + return; + } + + if (*ptr) { + /* unreference old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_framebuffer *oldFb = *ptr; + + _glthread_LOCK_MUTEX(oldFb->Mutex); + ASSERT(oldFb->RefCount > 0); + oldFb->RefCount--; + deleteFlag = (oldFb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldFb->Mutex); + + if (deleteFlag) + oldFb->Delete(oldFb); + + *ptr = NULL; + } + assert(!*ptr); + + if (fb) { + _glthread_LOCK_MUTEX(fb->Mutex); + fb->RefCount++; + _glthread_UNLOCK_MUTEX(fb->Mutex); + *ptr = fb; + } +} + + +/** + * Resize the given framebuffer's renderbuffers to the new width and height. + * This should only be used for window-system framebuffers, not + * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). + * This will typically be called via ctx->Driver.ResizeBuffers() or directly + * from a device driver. + * + * \note it's possible for ctx to be null since a window can be resized + * without a currently bound rendering context. + */ +void +_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height) +{ + GLuint i; + + /* XXX I think we could check if the size is not changing + * and return early. + */ + + /* For window system framebuffers, Name is zero */ + assert(fb->Name == 0); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) { + struct gl_renderbuffer *rb = att->Renderbuffer; + /* only resize if size is changing */ + if (rb->Width != width || rb->Height != height) { + if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + ASSERT(rb->Width == width); + ASSERT(rb->Height == height); + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + /* no return */ + } + } + } + } + + if (fb->_DepthBuffer) { + struct gl_renderbuffer *rb = fb->_DepthBuffer; + if (rb->Width != width || rb->Height != height) { + if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + } + } + } + + if (fb->_StencilBuffer) { + struct gl_renderbuffer *rb = fb->_StencilBuffer; + if (rb->Width != width || rb->Height != height) { + if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + } + } + } + + fb->Width = width; + fb->Height = height; + + if (ctx) { + /* update scissor / window bounds */ + _mesa_update_draw_buffer_bounds(ctx); + /* Signal new buffer state so that swrast will update its clipping + * info (the CLIP_BIT flag). + */ + ctx->NewState |= _NEW_BUFFERS; + } +} + + + +/** + * XXX THIS IS OBSOLETE - drivers should take care of detecting window + * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). + * + * GL_MESA_resize_buffers extension. + * + * When this function is called, we'll ask the window system how large + * the current window is. If it's a new size, we'll call the driver's + * ResizeBuffers function. The driver will then resize its color buffers + * as needed, and maybe call the swrast's routine for reallocating + * swrast-managed depth/stencil/accum/etc buffers. + * \note This function should only be called through the GL API, not + * from device drivers (as was done in the past). + */ +void +_mesa_resizebuffers( struct gl_context *ctx ) +{ + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glResizeBuffersMESA\n"); + + if (!ctx->Driver.GetBufferSize) { + return; + } + + if (ctx->WinSysDrawBuffer) { + GLuint newWidth, newHeight; + struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; + + assert(buffer->Name == 0); + + /* ask device driver for size of output buffer */ + ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); + + /* see if size of device driver's color buffer (window) has changed */ + if (buffer->Width != newWidth || buffer->Height != newHeight) { + if (ctx->Driver.ResizeBuffers) + ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); + } + } + + if (ctx->WinSysReadBuffer + && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { + GLuint newWidth, newHeight; + struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; + + assert(buffer->Name == 0); + + /* ask device driver for size of read buffer */ + ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); + + /* see if size of device driver's color buffer (window) has changed */ + if (buffer->Width != newWidth || buffer->Height != newHeight) { + if (ctx->Driver.ResizeBuffers) + ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); + } + } + + ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ +} + + +/* + * XXX THIS IS OBSOLETE + */ +void GLAPIENTRY +_mesa_ResizeBuffersMESA( void ) +{ + GET_CURRENT_CONTEXT(ctx); + + if (ctx->Extensions.MESA_resize_buffers) + _mesa_resizebuffers( ctx ); +} + + + +/** + * Examine all the framebuffer's renderbuffers to update the Width/Height + * fields of the framebuffer. If we have renderbuffers with different + * sizes, set the framebuffer's width and height to the min size. + * Note: this is only intended for user-created framebuffers, not + * window-system framebuffes. + */ +static void +update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint minWidth = ~0, minHeight = ~0; + GLuint i; + + /* user-created framebuffers only */ + assert(fb->Name); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + const struct gl_renderbuffer *rb = att->Renderbuffer; + if (rb) { + minWidth = MIN2(minWidth, rb->Width); + minHeight = MIN2(minHeight, rb->Height); + } + } + + if (minWidth != ~0) { + fb->Width = minWidth; + fb->Height = minHeight; + } + else { + fb->Width = 0; + fb->Height = 0; + } +} + + +/** + * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. + * These values are computed from the buffer's width and height and + * the scissor box, if it's enabled. + * \param ctx the GL context. + */ +void +_mesa_update_draw_buffer_bounds(struct gl_context *ctx) +{ + struct gl_framebuffer *buffer = ctx->DrawBuffer; + + if (!buffer) + return; + + if (buffer->Name) { + /* user-created framebuffer size depends on the renderbuffers */ + update_framebuffer_size(ctx, buffer); + } + + buffer->_Xmin = 0; + buffer->_Ymin = 0; + buffer->_Xmax = buffer->Width; + buffer->_Ymax = buffer->Height; + + if (ctx->Scissor.Enabled) { + if (ctx->Scissor.X > buffer->_Xmin) { + buffer->_Xmin = ctx->Scissor.X; + } + if (ctx->Scissor.Y > buffer->_Ymin) { + buffer->_Ymin = ctx->Scissor.Y; + } + if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) { + buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; + } + if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) { + buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; + } + /* finally, check for empty region */ + if (buffer->_Xmin > buffer->_Xmax) { + buffer->_Xmin = buffer->_Xmax; + } + if (buffer->_Ymin > buffer->_Ymax) { + buffer->_Ymin = buffer->_Ymax; + } + } + + ASSERT(buffer->_Xmin <= buffer->_Xmax); + ASSERT(buffer->_Ymin <= buffer->_Ymax); +} + + +/** + * The glGet queries of the framebuffer red/green/blue size, stencil size, + * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can + * change depending on the renderbuffer bindings. This function updates + * the given framebuffer's Visual from the current renderbuffer bindings. + * + * This may apply to user-created framebuffers or window system framebuffers. + * + * Also note: ctx->DrawBuffer->Visual.depthBits might not equal + * ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits. + * The former one is used to convert floating point depth values into + * integer Z values. + */ +void +_mesa_update_framebuffer_visual(struct gl_framebuffer *fb) +{ + GLuint i; + + memset(&fb->Visual, 0, sizeof(fb->Visual)); + fb->Visual.rgbMode = GL_TRUE; /* assume this */ + +#if 0 /* this _might_ be needed */ + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + /* leave visual fields zero'd */ + return; + } +#endif + + /* find first RGB renderbuffer */ + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer) { + const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); + const gl_format fmt = rb->Format; + + if (baseFormat == GL_RGBA || baseFormat == GL_RGB || + baseFormat == GL_ALPHA) { + fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); + fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); + fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); + fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); + fb->Visual.rgbBits = fb->Visual.redBits + + fb->Visual.greenBits + fb->Visual.blueBits; + fb->Visual.floatMode = GL_FALSE; + fb->Visual.samples = rb->NumSamples; + break; + } + } + } + + if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_DEPTH].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveDepthBuffer = GL_TRUE; + fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS); + } + + if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_STENCIL].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveStencilBuffer = GL_TRUE; + fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS); + } + + if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_ACCUM].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveAccumBuffer = GL_TRUE; + fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS); + fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); + fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); + fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); + } + + compute_depth_max(fb); +} + + +/** + * Update the framebuffer's _DepthBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a depth wrapper/adaptor. + * + * \param fb the framebuffer whose _DepthBuffer field to update + * \param attIndex indicates the renderbuffer to possibly wrap + */ +void +_mesa_update_depth_buffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLuint attIndex) +{ + struct gl_renderbuffer *depthRb; + + /* only one possiblity for now */ + ASSERT(attIndex == BUFFER_DEPTH); + + depthRb = fb->Attachment[attIndex].Renderbuffer; + + if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { + /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_DepthBuffer + || fb->_DepthBuffer->Wrapped != depthRb + || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper + = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); + _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); + ASSERT(fb->_DepthBuffer->Wrapped == depthRb); + } + } + else { + /* depthRb may be null */ + _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); + } +} + + +/** + * Update the framebuffer's _StencilBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a stencil wrapper/adaptor. + * + * \param fb the framebuffer whose _StencilBuffer field to update + * \param attIndex indicates the renderbuffer to possibly wrap + */ +void +_mesa_update_stencil_buffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLuint attIndex) +{ + struct gl_renderbuffer *stencilRb; + + ASSERT(attIndex == BUFFER_DEPTH || + attIndex == BUFFER_STENCIL); + + stencilRb = fb->Attachment[attIndex].Renderbuffer; + + if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { + /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_StencilBuffer + || fb->_StencilBuffer->Wrapped != stencilRb + || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper + = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb); + _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); + ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); + } + } + else { + /* stencilRb may be null */ + _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); + } +} + + +/* + * Example DrawBuffers scenarios: + * + * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to + * "gl_FragColor" or program writes to the "result.color" register: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front, Back + * + * + * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to + * gl_FragData[i] or program writes to result.color[i] registers: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front + * color[1] Aux0 + * color[3] Aux1 + * + * + * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to + * gl_FragColor, or fixed function: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front, Aux0, Aux1 + * + * + * In either case, the list of renderbuffers is stored in the + * framebuffer->_ColorDrawBuffers[] array and + * framebuffer->_NumColorDrawBuffers indicates the number of buffers. + * The renderer (like swrast) has to look at the current fragment shader + * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine + * how to map color outputs to renderbuffers. + * + * Note that these two calls are equivalent (for fixed function fragment + * shading anyway): + * a) glDrawBuffer(GL_FRONT_AND_BACK); (assuming non-stereo framebuffer) + * b) glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]); + */ + + + + +/** + * Update the (derived) list of color drawing renderbuffer pointers. + * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers + * writing colors. + */ +static void +update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint output; + + /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */ + fb->_ColorDrawBuffers[0] = NULL; + + for (output = 0; output < fb->_NumColorDrawBuffers; output++) { + GLint buf = fb->_ColorDrawBufferIndexes[output]; + if (buf >= 0) { + fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; + } + else { + fb->_ColorDrawBuffers[output] = NULL; + } + } +} + + +/** + * Update the (derived) color read renderbuffer pointer. + * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. + */ +static void +update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + (void) ctx; + if (fb->_ColorReadBufferIndex == -1 || + fb->DeletePending || + fb->Width == 0 || + fb->Height == 0) { + fb->_ColorReadBuffer = NULL; /* legal! */ + } + else { + ASSERT(fb->_ColorReadBufferIndex >= 0); + ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); + fb->_ColorReadBuffer + = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; + } +} + + +/** + * Update a gl_framebuffer's derived state. + * + * Specifically, update these framebuffer fields: + * _ColorDrawBuffers + * _NumColorDrawBuffers + * _ColorReadBuffer + * _DepthBuffer + * _StencilBuffer + * + * If the framebuffer is user-created, make sure it's complete. + * + * The following functions (at least) can effect framebuffer state: + * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, + * glRenderbufferStorageEXT. + */ +static void +update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Name == 0) { + /* This is a window-system framebuffer */ + /* Need to update the FB's GL_DRAW_BUFFER state to match the + * context state (GL_READ_BUFFER too). + */ + if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, + ctx->Color.DrawBuffer, NULL); + } + if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) { + + } + } + else { + /* This is a user-created framebuffer. + * Completeness only matters for user-created framebuffers. + */ + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { + _mesa_test_framebuffer_completeness(ctx, fb); + } + } + + /* Strictly speaking, we don't need to update the draw-state + * if this FB is bound as ctx->ReadBuffer (and conversely, the + * read-state if this FB is bound as ctx->DrawBuffer), but no + * harm. + */ + update_color_draw_buffers(ctx, fb); + update_color_read_buffer(ctx, fb); + _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); + _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + + compute_depth_max(fb); +} + + +/** + * Update state related to the current draw/read framebuffers. + */ +void +_mesa_update_framebuffer(struct gl_context *ctx) +{ + struct gl_framebuffer *drawFb; + struct gl_framebuffer *readFb; + + assert(ctx); + drawFb = ctx->DrawBuffer; + readFb = ctx->ReadBuffer; + + update_framebuffer(ctx, drawFb); + if (readFb != drawFb) + update_framebuffer(ctx, readFb); +} + + +/** + * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, + * glCopyTex[Sub]Image, etc) exists. + * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, + * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. + * \return GL_TRUE if buffer exists, GL_FALSE otherwise + */ +GLboolean +_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) +{ + const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; + + /* If we don't know the framebuffer status, update it now */ + if (ctx->ReadBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + } + + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return GL_FALSE; + } + + switch (format) { + case GL_COLOR: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RG: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_COLOR_INDEX: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { + return GL_FALSE; + } + ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); + break; + case GL_DEPTH: + case GL_DEPTH_COMPONENT: + if (!att[BUFFER_DEPTH].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ + break; + case GL_STENCIL: + case GL_STENCIL_INDEX: + if (!att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ + break; + case GL_DEPTH_STENCIL_EXT: + if (!att[BUFFER_DEPTH].Renderbuffer || + !att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /* + ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); + ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); + */ + break; + default: + _mesa_problem(ctx, + "Unexpected format 0x%x in _mesa_source_buffer_exists", + format); + return GL_FALSE; + } + + /* OK */ + return GL_TRUE; +} + + +/** + * As above, but for drawing operations. + * XXX could do some code merging w/ above function. + */ +GLboolean +_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) +{ + const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; + + /* If we don't know the framebuffer status, update it now */ + if (ctx->DrawBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); + } + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return GL_FALSE; + } + + switch (format) { + case GL_COLOR: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_COLOR_INDEX: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ + /* Could assert that colorbuffer has RedBits > 0 */ + break; + case GL_DEPTH: + case GL_DEPTH_COMPONENT: + if (!att[BUFFER_DEPTH].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ + break; + case GL_STENCIL: + case GL_STENCIL_INDEX: + if (!att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ + break; + case GL_DEPTH_STENCIL_EXT: + if (!att[BUFFER_DEPTH].Renderbuffer || + !att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /* + ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); + ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); + */ + break; + default: + _mesa_problem(ctx, + "Unexpected format 0x%x in _mesa_dest_buffer_exists", + format); + return GL_FALSE; + } + + /* OK */ + return GL_TRUE; +} + + +/** + * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. + */ +GLenum +_mesa_get_color_read_format(struct gl_context *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_BGRA; + case MESA_FORMAT_RGB565: + return GL_BGR; + default: + return GL_RGBA; + } +} + + +/** + * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. + */ +GLenum +_mesa_get_color_read_type(struct gl_context *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_UNSIGNED_BYTE; + case MESA_FORMAT_RGB565: + return GL_UNSIGNED_SHORT_5_6_5_REV; + default: + return GL_UNSIGNED_BYTE; + } +} + + +/** + * Print framebuffer info to stderr, for debugging. + */ +void +_mesa_print_framebuffer(const struct gl_framebuffer *fb) +{ + GLuint i; + + fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb); + fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height, + _mesa_lookup_enum_by_nr(fb->_Status)); + fprintf(stderr, " Attachments:\n"); + + for (i = 0; i < BUFFER_COUNT; i++) { + const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Type == GL_TEXTURE) { + const struct gl_texture_image *texImage; + fprintf(stderr, + " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n", + i, att->Texture->Name, att->TextureLevel, att->CubeMapFace, + att->Zoffset, att->Complete); + texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + fprintf(stderr, " Size: %u x %u x %u Format %s\n", + texImage->Width, texImage->Height, texImage->Depth, + _mesa_get_format_name(texImage->TexFormat)); + } + else if (att->Type == GL_RENDERBUFFER) { + fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n", + i, att->Renderbuffer->Name, att->Complete); + fprintf(stderr, " Size: %u x %u Format %s\n", + att->Renderbuffer->Width, att->Renderbuffer->Height, + _mesa_get_format_name(att->Renderbuffer->Format)); + } + else { + fprintf(stderr, " %2d: none\n", i); + } + } +} diff --git a/mesalib/src/mesa/main/framebuffer.h b/mesalib/src/mesa/main/framebuffer.h index 2e9844282..6b705146a 100644 --- a/mesalib/src/mesa/main/framebuffer.h +++ b/mesalib/src/mesa/main/framebuffer.h @@ -1,98 +1,101 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef FRAMEBUFFER_H -#define FRAMEBUFFER_H - -#include "mtypes.h" - -extern struct gl_framebuffer * -_mesa_create_framebuffer(const GLvisual *visual); - -extern struct gl_framebuffer * -_mesa_new_framebuffer(GLcontext *ctx, GLuint name); - -extern void -_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const GLvisual *visual); - -extern void -_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name); - -extern void -_mesa_destroy_framebuffer(struct gl_framebuffer *buffer); - -extern void -_mesa_free_framebuffer_data(struct gl_framebuffer *buffer); - -extern void -_mesa_reference_framebuffer(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb); - -extern void -_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height); - - -extern void -_mesa_resizebuffers( GLcontext *ctx ); - -extern void GLAPIENTRY -_mesa_ResizeBuffersMESA( void ); - - -extern void -_mesa_update_draw_buffer_bounds(GLcontext *ctx); - -extern void -_mesa_update_framebuffer_visual(struct gl_framebuffer *fb); - -extern void -_mesa_update_depth_buffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint attIndex); - -extern void -_mesa_update_stencil_buffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint attIndex); - -extern void -_mesa_update_framebuffer(GLcontext *ctx); - -extern GLboolean -_mesa_source_buffer_exists(GLcontext *ctx, GLenum format); - -extern GLboolean -_mesa_dest_buffer_exists(GLcontext *ctx, GLenum format); - -extern GLenum -_mesa_get_color_read_type(GLcontext *ctx); - -extern GLenum -_mesa_get_color_read_format(GLcontext *ctx); - -extern void -_mesa_print_framebuffer(const struct gl_framebuffer *fb); - -#endif /* FRAMEBUFFER_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef FRAMEBUFFER_H +#define FRAMEBUFFER_H + +#include "glheader.h" + +struct gl_config; +struct gl_context; + +extern struct gl_framebuffer * +_mesa_create_framebuffer(const struct gl_config *visual); + +extern struct gl_framebuffer * +_mesa_new_framebuffer(struct gl_context *ctx, GLuint name); + +extern void +_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, + const struct gl_config *visual); + +extern void +_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name); + +extern void +_mesa_destroy_framebuffer(struct gl_framebuffer *buffer); + +extern void +_mesa_free_framebuffer_data(struct gl_framebuffer *buffer); + +extern void +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb); + +extern void +_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height); + + +extern void +_mesa_resizebuffers( struct gl_context *ctx ); + +extern void GLAPIENTRY +_mesa_ResizeBuffersMESA( void ); + + +extern void +_mesa_update_draw_buffer_bounds(struct gl_context *ctx); + +extern void +_mesa_update_framebuffer_visual(struct gl_framebuffer *fb); + +extern void +_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint attIndex); + +extern void +_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint attIndex); + +extern void +_mesa_update_framebuffer(struct gl_context *ctx); + +extern GLboolean +_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format); + +extern GLboolean +_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format); + +extern GLenum +_mesa_get_color_read_type(struct gl_context *ctx); + +extern GLenum +_mesa_get_color_read_format(struct gl_context *ctx); + +extern void +_mesa_print_framebuffer(const struct gl_framebuffer *fb); + +#endif /* FRAMEBUFFER_H */ diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 2062134a3..cb6880a6f 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -1,2472 +1,2464 @@ -/* - * Copyright (C) 2010 Brian Paul All Rights Reserved. - * Copyright (C) 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Author: Kristian Høgsberg - */ - -#include "glheader.h" -#include "context.h" -#include "enable.h" -#include "enums.h" -#include "extensions.h" -#include "get.h" -#include "macros.h" -#include "mtypes.h" -#include "state.h" -#include "texcompress.h" -#include "framebuffer.h" - -/* This is a table driven implemetation of the glGet*v() functions. - * The basic idea is that most getters just look up an int somewhere - * in GLcontext and then convert it to a bool or float according to - * which of glGetIntegerv() glGetBooleanv() etc is being called. - * Instead of generating code to do this, we can just record the enum - * value and the offset into GLcontext in an array of structs. Then - * in glGet*(), we lookup the struct for the enum in question, and use - * the offset to get the int we need. - * - * Sometimes we need to look up a float, a boolean, a bit in a - * bitfield, a matrix or other types instead, so we need to track the - * type of the value in GLcontext. And sometimes the value isn't in - * GLcontext but in the drawbuffer, the array object, current texture - * unit, or maybe it's a computed value. So we need to also track - * where or how to find the value. Finally, we sometimes need to - * check that one of a number of extensions are enabled, the GL - * version or flush or call _mesa_update_state(). This is done by - * attaching optional extra information to the value description - * struct, it's sort of like an array of opcodes that describe extra - * checks or actions. - * - * Putting all this together we end up with struct value_desc below, - * and with a couple of macros to help, the table of struct value_desc - * is about as concise as the specification in the old python script. - */ - -#undef CONST - -#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) -#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ - ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ - (GLint) ((F) * 65536.0f) ) - -#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ - ((I) < SHRT_MIN) ? INT_MIN : \ - (GLint) ((I) * 65536) ) - -#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) - -#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) -#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) -#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) -#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) - -#define ENUM_TO_INT64(E) ( (GLint64) (E) ) -#define ENUM_TO_FIXED(E) (E) - -enum value_type { - TYPE_INVALID, - TYPE_API_MASK, - TYPE_INT, - TYPE_INT_2, - TYPE_INT_3, - TYPE_INT_4, - TYPE_INT_N, - TYPE_INT64, - TYPE_ENUM, - TYPE_ENUM_2, - TYPE_BOOLEAN, - TYPE_BIT_0, - TYPE_BIT_1, - TYPE_BIT_2, - TYPE_BIT_3, - TYPE_BIT_4, - TYPE_BIT_5, - TYPE_FLOAT, - TYPE_FLOAT_2, - TYPE_FLOAT_3, - TYPE_FLOAT_4, - TYPE_FLOATN, - TYPE_FLOATN_2, - TYPE_FLOATN_3, - TYPE_FLOATN_4, - TYPE_DOUBLEN, - TYPE_MATRIX, - TYPE_MATRIX_T, - TYPE_CONST -}; - -enum value_location { - LOC_BUFFER, - LOC_CONTEXT, - LOC_ARRAY, - LOC_TEXUNIT, - LOC_CUSTOM -}; - -enum value_extra { - EXTRA_END = 0x8000, - EXTRA_VERSION_30, - EXTRA_VERSION_31, - EXTRA_VERSION_32, - EXTRA_VERSION_ES2, - EXTRA_NEW_BUFFERS, - EXTRA_VALID_DRAW_BUFFER, - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_FLUSH_CURRENT, -}; - -#define NO_EXTRA NULL -#define NO_OFFSET 0 - -struct value_desc { - GLenum pname; - GLubyte location; /**< enum value_location */ - GLubyte type; /**< enum value_type */ - int offset; - const int *extra; -}; - -union value { - GLfloat value_float; - GLfloat value_float_4[4]; - GLmatrix *value_matrix; - GLint value_int; - GLint value_int_4[4]; - GLint64 value_int64; - GLenum value_enum; - - /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ - struct { - GLint n, ints[100]; - } value_int_n; - GLboolean value_bool; -}; - -#define BUFFER_FIELD(field, type) \ - LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) -#define CONTEXT_FIELD(field, type) \ - LOC_CONTEXT, type, offsetof(GLcontext, field) -#define ARRAY_FIELD(field, type) \ - LOC_ARRAY, type, offsetof(struct gl_array_object, field) -#define CONST(value) \ - LOC_CONTEXT, TYPE_CONST, value - -#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) -#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) - -#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) -#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) -#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) -#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) -#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) -#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) -#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) -#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) -#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) -#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) -#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) -#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) -#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) -#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) -#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) -#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) -#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) -#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) - -#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) -#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) -#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) - -#define EXT(f) \ - offsetof(struct gl_extensions, f) - -#define EXTRA_EXT(e) \ - static const int extra_##e[] = { \ - EXT(e), EXTRA_END \ - } - -#define EXTRA_EXT2(e1, e2) \ - static const int extra_##e1##_##e2[] = { \ - EXT(e1), EXT(e2), EXTRA_END \ - } - -/* The 'extra' mechanism is a way to specify extra checks (such as - * extensions or specific gl versions) or actions (flush current, new - * buffers) that we need to do before looking up an enum. We need to - * declare them all up front so we can refer to them in the value_desc - * structs below. */ - -static const int extra_new_buffers[] = { - EXTRA_NEW_BUFFERS, - EXTRA_END -}; - -static const int extra_valid_draw_buffer[] = { - EXTRA_VALID_DRAW_BUFFER, - EXTRA_END -}; - -static const int extra_valid_texture_unit[] = { - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_END -}; - -static const int extra_flush_current_valid_texture_unit[] = { - EXTRA_FLUSH_CURRENT, - EXTRA_VALID_TEXTURE_UNIT, - EXTRA_END -}; - -static const int extra_flush_current[] = { - EXTRA_FLUSH_CURRENT, - EXTRA_END -}; - -static const int extra_new_buffers_OES_read_format[] = { - EXTRA_NEW_BUFFERS, - EXT(OES_read_format), - EXTRA_END -}; - -static const int extra_EXT_secondary_color_flush_current[] = { - EXT(EXT_secondary_color), - EXTRA_FLUSH_CURRENT, - EXTRA_END -}; - -static const int extra_EXT_fog_coord_flush_current[] = { - EXT(EXT_fog_coord), - EXTRA_FLUSH_CURRENT, - EXTRA_END -}; - -EXTRA_EXT(ARB_multitexture); -EXTRA_EXT(ARB_texture_cube_map); -EXTRA_EXT(MESA_texture_array); -EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); -EXTRA_EXT(EXT_secondary_color); -EXTRA_EXT(EXT_fog_coord); -EXTRA_EXT(EXT_texture_lod_bias); -EXTRA_EXT(EXT_texture_filter_anisotropic); -EXTRA_EXT(IBM_rasterpos_clip); -EXTRA_EXT(NV_point_sprite); -EXTRA_EXT(SGIS_generate_mipmap); -EXTRA_EXT(NV_vertex_program); -EXTRA_EXT(NV_fragment_program); -EXTRA_EXT(NV_texture_rectangle); -EXTRA_EXT(EXT_stencil_two_side); -EXTRA_EXT(NV_light_max_exponent); -EXTRA_EXT(EXT_convolution); -EXTRA_EXT(EXT_histogram); -EXTRA_EXT(SGI_color_table); -EXTRA_EXT(SGI_texture_color_table); -EXTRA_EXT(EXT_depth_bounds_test); -EXTRA_EXT(ARB_depth_clamp); -EXTRA_EXT(ATI_fragment_shader); -EXTRA_EXT(EXT_framebuffer_blit); -EXTRA_EXT(ARB_shader_objects); -EXTRA_EXT(EXT_provoking_vertex); -EXTRA_EXT(ARB_fragment_shader); -EXTRA_EXT(ARB_fragment_program); -EXTRA_EXT(ARB_framebuffer_object); -EXTRA_EXT(EXT_framebuffer_object); -EXTRA_EXT(APPLE_vertex_array_object); -EXTRA_EXT(ARB_seamless_cube_map); -EXTRA_EXT(EXT_compiled_vertex_array); -EXTRA_EXT(ARB_sync); -EXTRA_EXT(ARB_vertex_shader); -EXTRA_EXT(EXT_transform_feedback); -EXTRA_EXT(ARB_transform_feedback2); -EXTRA_EXT(EXT_pixel_buffer_object); -EXTRA_EXT(ARB_vertex_program); -EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); -EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); -EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); -EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); -EXTRA_EXT(ARB_vertex_buffer_object); -EXTRA_EXT(ARB_geometry_shader4); - -static const int -extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { - EXT(ARB_vertex_program), - EXT(ARB_fragment_program), - EXT(NV_vertex_program), - EXTRA_END -}; - -static const int -extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { - EXT(NV_vertex_program), - EXT(ARB_vertex_program), - EXT(ARB_fragment_program), - EXT(NV_vertex_program), - EXTRA_END -}; - -static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; -static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; -static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; - -static const int -extra_ARB_vertex_program_version_es2[] = { - EXT(ARB_vertex_program), - EXTRA_VERSION_ES2, - EXTRA_END -}; - -#define API_OPENGL_BIT (1 << API_OPENGL) -#define API_OPENGLES_BIT (1 << API_OPENGLES) -#define API_OPENGLES2_BIT (1 << API_OPENGLES2) - -/* This is the big table describing all the enums we accept in - * glGet*v(). The table is partitioned into six parts: enums - * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared - * between OpenGL and GLES, enums exclusive to GLES, etc for the - * remaining combinations. When we add the enums to the hash table in - * _mesa_init_get_hash(), we only add the enums for the API we're - * instantiating and the different sections are guarded by #if - * FEATURE_GL etc to make sure we only compile in the enums we may - * need. */ - -static const struct value_desc values[] = { - /* Enums shared between OpenGL, GLES1 and GLES2 */ - { 0, 0, TYPE_API_MASK, - API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA}, - { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, - { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA }, - { GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, - { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, - { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA }, - { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA }, - { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA }, - { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA }, - { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA }, - { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA }, - { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA }, - { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA }, - { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA }, - { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA }, - { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers }, - { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA }, - { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA }, - { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, - { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, - { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxTextureLevels), NO_EXTRA }, - { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA }, - { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA }, - { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA }, - { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA }, - { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA }, - { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA }, - { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers }, - { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA }, - { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA }, - { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA }, - { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA }, - { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA }, - { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA }, - { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA }, - { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, - - /* GL_ARB_multitexture */ - { GL_ACTIVE_TEXTURE_ARB, - LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, - - /* Note that all the OES_* extensions require that the Mesa "struct - * gl_extensions" include a member with the name of the extension. - * That structure does not yet include OES extensions (and we're - * not sure whether it will). If it does, all the OES_* - * extensions below should mark the dependency. */ - - /* GL_ARB_texture_cube_map */ - { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, - TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, - { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxCubeTextureLevels), - extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ - - /* XXX: OES_blend_subtract */ - { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, - { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, - { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA), NO_EXTRA }, - { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA), NO_EXTRA }, - - /* GL_BLEND_EQUATION_RGB, which is what we're really after, is - * defined identically to GL_BLEND_EQUATION. */ - { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB), NO_EXTRA }, - { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA), NO_EXTRA }, - - /* GL_ARB_texture_compression */ - { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA }, - - /* GL_ARB_multisample */ - { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, - CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_VALUE_ARB, - CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA }, - { GL_SAMPLE_COVERAGE_INVERT_ARB, - CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA }, - { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA }, - { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA }, - - /* GL_SGIS_generate_mipmap */ - { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap), - extra_SGIS_generate_mipmap }, - - /* GL_ARB_vertex_buffer_object */ - { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - - /* GL_ARB_vertex_buffer_object */ - /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */ - { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_vertex_buffer_object }, - - /* GL_OES_read_format */ - { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0, - extra_new_buffers_OES_read_format }, - { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0, - extra_new_buffers_OES_read_format }, - - /* GL_EXT_framebuffer_object */ - { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name), - extra_EXT_framebuffer_object }, - { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, - extra_EXT_framebuffer_object }, - { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize), - extra_EXT_framebuffer_object }, - - /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's - * GLSL: */ - { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA }, - -#if FEATURE_GL || FEATURE_ES1 - /* Enums in OpenGL and GLES1 */ - { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA }, - { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA }, - { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA }, - { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA }, - { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA }, - { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA }, - { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA }, - { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA }, - { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA }, - { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA }, - { GL_LIGHT_MODEL_AMBIENT, - CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA }, - { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA }, - { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, - { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA }, - { GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, - { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA }, - { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA }, - { GL_CURRENT_COLOR, - CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), - extra_flush_current }, - { GL_CURRENT_NORMAL, - CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), - extra_flush_current }, - { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, - extra_flush_current_valid_texture_unit }, - { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA }, - { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA }, - { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA }, - { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA }, - { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA }, - { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA }, - { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA }, - { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA }, - { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA }, - { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA }, - { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA }, - { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA }, - { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA }, - { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA }, - { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA }, - { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ModelviewMatrixStack.Depth), NO_EXTRA }, - { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA }, - { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA }, - { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA }, - { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA }, - { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA }, - { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA }, - { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA }, - { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA }, - { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA }, - { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA }, - { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA }, - { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ProjectionMatrixStack.Depth), NO_EXTRA }, - { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA }, - { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA }, - { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit }, - { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0, - extra_valid_texture_unit }, - - { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA }, - { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA }, - { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA }, - { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA }, - { GL_NORMAL_ARRAY, ARRAY_ENUM(Normal.Enabled), NO_EXTRA }, - { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA }, - { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA }, - { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA }, - { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA }, - { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA }, - { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY, - LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_SIZE, - LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Size), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_TYPE, - LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Type), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_STRIDE, - LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Stride), NO_EXTRA }, - - /* GL_ARB_multitexture */ - { GL_MAX_TEXTURE_UNITS_ARB, - CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture }, - { GL_CLIENT_ACTIVE_TEXTURE_ARB, - LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, - - /* GL_ARB_texture_cube_map */ - { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - /* S, T, and R are always set at the same time */ - { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - - /* GL_ARB_multisample */ - { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA }, - { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA }, - - /* GL_ARB_vertex_buffer_object */ - { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA }, - { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA }, - { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, - - /* GL_OES_point_sprite */ - { GL_POINT_SPRITE_NV, - CONTEXT_BOOL(Point.PointSprite), - extra_NV_point_sprite_ARB_point_sprite }, - - /* GL_ARB_fragment_shader */ - { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), - extra_ARB_fragment_shader }, - - /* GL_ARB_vertex_shader */ - { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), - extra_ARB_vertex_shader }, - { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_vertex_shader }, - - /* GL_EXT_texture_lod_bias */ - { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias), - extra_EXT_texture_lod_bias }, - - /* GL_EXT_texture_filter_anisotropic */ - { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, - CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), - extra_EXT_texture_filter_anisotropic }, -#endif /* FEATURE_GL || FEATURE_ES1 */ - -#if FEATURE_ES1 - { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT }, - /* XXX: OES_matrix_get */ - { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES }, - { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES }, - { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES }, - - /* OES_point_size_array */ - { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) }, - { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) }, - { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) }, - { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 }, -#endif /* FEATURE_ES1 */ - -#if FEATURE_GL || FEATURE_ES2 - { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA }, - /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */ - { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA }, - { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */ - CONTEXT_INT(Const.MaxTextureCoordUnits), - extra_ARB_fragment_program_NV_fragment_program }, - - /* GL_ARB_draw_buffers */ - { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA }, - - { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4), NO_EXTRA }, - /* GL_ARB_fragment_program */ - { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */ - CONTEXT_INT(Const.MaxTextureImageUnits), - extra_ARB_fragment_program_NV_fragment_program }, - { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, - CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader }, - { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, - CONTEXT_INT(Const.MaxCombinedTextureImageUnits), - extra_ARB_vertex_shader }, - - /* GL_ARB_shader_objects - * Actually, this token isn't part of GL_ARB_shader_objects, but is - * close enough for now. */ - { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects }, - - /* OpenGL 2.0 */ - { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA }, - { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA }, - { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA }, - { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA }, - { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA }, - { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA }, - { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA }, - - { GL_MAX_VERTEX_ATTRIBS_ARB, - CONTEXT_INT(Const.VertexProgram.MaxAttribs), - extra_ARB_vertex_program_version_es2 }, - - /* OES_texture_3D */ - { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA }, - { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.Max3DTextureLevels), NO_EXTRA }, - - /* GL_ARB_fragment_program/OES_standard_derivatives */ - { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, - CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, -#endif /* FEATURE_GL || FEATURE_ES2 */ - -#if FEATURE_ES2 - /* Enums unique to OpenGL ES 2.0 */ - { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA }, - { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.FragmentProgram.MaxUniformComponents), NO_EXTRA }, - { GL_MAX_VARYING_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxVarying), NO_EXTRA }, - { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.VertexProgram.MaxUniformComponents), NO_EXTRA }, - { GL_SHADER_COMPILER, CONST(1), NO_EXTRA }, - /* OES_get_program_binary */ - { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, - { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, -#endif /* FEATURE_ES2 */ - -#if FEATURE_GL - /* Remaining enums are only in OpenGL */ - { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA }, - { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA }, - { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA }, - { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA }, - { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA }, - { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA }, - { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA }, - { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA }, - { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA }, - { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA }, - { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA }, - { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA }, - { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA }, - { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA }, - { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA }, - { GL_CURRENT_INDEX, - CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), - extra_flush_current }, - { GL_CURRENT_RASTER_COLOR, - CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA }, - { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA }, - { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA }, - { GL_CURRENT_RASTER_SECONDARY_COLOR, - CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA }, - { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, - extra_valid_texture_unit }, - { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA }, - { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA }, - { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA }, - { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA }, - { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, - { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, - { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA }, - { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA }, - { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA }, - { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA }, - { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA }, - { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers }, - { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA }, - { GL_INDEX_MODE, CONST(0) , NO_EXTRA}, - { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA }, - { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA }, - { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA }, - { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA }, - { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA }, - { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA }, - { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA }, - { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA }, - { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA }, - { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA }, - { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA }, - { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA }, - { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA }, - { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA }, - { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA }, - { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA }, - { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA }, - { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA }, - { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA }, - { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA }, - { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA }, - { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA }, - { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA }, - { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA }, - { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA }, - { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA }, - { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA }, - { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA }, - { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA }, - { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA }, - - { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA }, - { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA }, - { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA }, - { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA }, - { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA }, - { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA }, - { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA }, - { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA }, - { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA }, - { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA }, - { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA }, - { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA }, - { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA }, - { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA }, - { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA }, - { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA }, - { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA }, - { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA }, - { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA }, - { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA }, - { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA }, - { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA }, - { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA }, - { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, - { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, - { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA }, - { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA }, - { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA }, - { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA }, - { GL_RGBA_MODE, CONST(1), NO_EXTRA }, - { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA }, - { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA }, - - { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA }, - - { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, - { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, - { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, - { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, - - { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA }, - { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT, - TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, - { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT, - TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, - { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, - CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array }, - - { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3, - offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, - { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA }, - { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA }, - { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA }, - { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA }, - { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA }, - { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA }, - { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA }, - { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA }, - { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA }, - { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA }, - - /* Vertex arrays */ - { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA }, - { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA }, - { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA }, - { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, - - /* GL_ARB_texture_compression */ - { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA }, - - /* GL_EXT_compiled_vertex_array */ - { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst), - extra_EXT_compiled_vertex_array }, - { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount), - extra_EXT_compiled_vertex_array }, - - /* GL_ARB_transpose_matrix */ - { GL_TRANSPOSE_COLOR_MATRIX_ARB, CONTEXT_MATRIX_T(ColorMatrixStack.Top), NO_EXTRA }, - { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, - CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA }, - { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, - CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, - { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, - - /* GL_SGI_color_matrix (also in 1.2 imaging) */ - { GL_COLOR_MATRIX_SGI, CONTEXT_MATRIX(ColorMatrixStack.Top), NO_EXTRA }, - { GL_COLOR_MATRIX_STACK_DEPTH_SGI, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ColorMatrixStack.Depth), NO_EXTRA }, - { GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI, - CONST(MAX_COLOR_STACK_DEPTH), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_RED_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[0]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[1]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[2]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[3]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_RED_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[0]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[1]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[2]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[3]), NO_EXTRA }, - - /* GL_EXT_convolution (also in 1.2 imaging) */ - { GL_CONVOLUTION_1D_EXT, CONTEXT_BOOL(Pixel.Convolution1DEnabled), - extra_EXT_convolution }, - { GL_CONVOLUTION_2D_EXT, CONTEXT_BOOL(Pixel.Convolution2DEnabled), - extra_EXT_convolution }, - { GL_SEPARABLE_2D_EXT, CONTEXT_BOOL(Pixel.Separable2DEnabled), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[3]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[3]), - extra_EXT_convolution }, - - /* GL_EXT_histogram / GL_ARB_imaging */ - { GL_HISTOGRAM, CONTEXT_BOOL(Pixel.HistogramEnabled), - extra_EXT_histogram }, - { GL_MINMAX, CONTEXT_BOOL(Pixel.MinMaxEnabled), extra_EXT_histogram }, - - /* GL_SGI_color_table / GL_ARB_imaging */ - { GL_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]), - extra_SGI_color_table }, - { GL_POST_CONVOLUTION_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]), - extra_SGI_color_table }, - { GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]), - extra_SGI_color_table }, - - /* GL_SGI_texture_color_table */ - { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN, - offsetof(struct gl_texture_unit, ColorTableEnabled), - extra_SGI_texture_color_table }, - - /* GL_EXT_secondary_color */ - { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled), - extra_EXT_secondary_color_ARB_vertex_program }, - { GL_CURRENT_SECONDARY_COLOR_EXT, - CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), - extra_EXT_secondary_color_flush_current }, - { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled), - extra_EXT_secondary_color }, - { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type), - extra_EXT_secondary_color }, - { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride), - extra_EXT_secondary_color }, - { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size), - extra_EXT_secondary_color }, - - /* GL_EXT_fog_coord */ - { GL_CURRENT_FOG_COORDINATE_EXT, - CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), - extra_EXT_fog_coord_flush_current }, - { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride), - extra_EXT_fog_coord }, - { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource), - extra_EXT_fog_coord }, - - /* GL_IBM_rasterpos_clip */ - { GL_RASTER_POSITION_UNCLIPPED_IBM, - CONTEXT_BOOL(Transform.RasterPositionUnclipped), - extra_IBM_rasterpos_clip }, - - /* GL_NV_point_sprite */ - { GL_POINT_SPRITE_R_MODE_NV, - CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite }, - { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), - extra_NV_point_sprite_ARB_point_sprite }, - - /* GL_NV_vertex_program */ - { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]), - extra_NV_vertex_program }, - - /* GL_NV_fragment_program */ - { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled), - extra_NV_fragment_program }, - { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, - extra_NV_fragment_program }, - { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV, - CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS), - extra_NV_fragment_program }, - - /* GL_NV_texture_rectangle */ - { GL_TEXTURE_RECTANGLE_NV, - LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle }, - { GL_TEXTURE_BINDING_RECTANGLE_NV, - LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle }, - { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, - CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle }, - - /* GL_EXT_stencil_two_side */ - { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide), - extra_EXT_stencil_two_side }, - { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, - - /* GL_NV_light_max_exponent */ - { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess), - extra_NV_light_max_exponent }, - { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent), - extra_NV_light_max_exponent }, - - /* GL_ARB_vertex_buffer_object */ - { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA }, - { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA }, - { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA }, - { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA }, - - /* GL_EXT_pixel_buffer_object */ - { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, - extra_EXT_pixel_buffer_object }, - { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, - extra_EXT_pixel_buffer_object }, - - /* GL_ARB_vertex_program */ - { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */ - CONTEXT_BOOL(VertexProgram.Enabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/ - CONTEXT_BOOL(VertexProgram.PointSizeEnabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - CONTEXT_BOOL(VertexProgram.TwoSideEnabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - CONTEXT_INT(Const.MaxProgramMatrixStackDepth), - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */ - CONTEXT_INT(Const.MaxProgramMatrices), - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */ - LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - - { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ - LOC_CUSTOM, TYPE_MATRIX, 0, - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ - LOC_CUSTOM, TYPE_MATRIX, 0, - extra_ARB_vertex_program_ARB_fragment_program }, - - { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */ - CONTEXT_INT(Program.ErrorPos), - extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - - /* GL_ARB_fragment_program */ - { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled), - extra_ARB_fragment_program }, - - /* GL_EXT_depth_bounds_test */ - { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), - extra_EXT_depth_bounds_test }, - { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin), - extra_EXT_depth_bounds_test }, - - /* GL_ARB_depth_clamp*/ - { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp), - extra_ARB_depth_clamp }, - - /* GL_ARB_draw_buffers */ - { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, - { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]), - extra_valid_draw_buffer }, - { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]), - extra_valid_draw_buffer }, - { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]), - extra_valid_draw_buffer }, - - /* GL_ATI_fragment_shader */ - { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader }, - { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader }, - { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader }, - { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader }, - { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader }, - { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader }, - { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader }, - { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI, - CONST(3), extra_ATI_fragment_shader }, - - /* GL_EXT_framebuffer_object */ - { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments), - extra_EXT_framebuffer_object }, - - /* GL_EXT_framebuffer_blit - * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */ - { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, - extra_EXT_framebuffer_blit }, - - /* GL_EXT_provoking_vertex */ - { GL_PROVOKING_VERTEX_EXT, - CONTEXT_BOOL(Light.ProvokingVertex), extra_EXT_provoking_vertex }, - { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT, - CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention), - extra_EXT_provoking_vertex }, - - /* GL_ARB_framebuffer_object */ - { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples), - extra_ARB_framebuffer_object }, - - /* GL_APPLE_vertex_array_object */ - { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name), - extra_APPLE_vertex_array_object }, - - /* GL_ARB_seamless_cube_map */ - { GL_TEXTURE_CUBE_MAP_SEAMLESS, - CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map }, - - /* GL_ARB_sync */ - { GL_MAX_SERVER_WAIT_TIMEOUT, - CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync }, - - /* GL_EXT_transform_feedback */ - { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, - extra_EXT_transform_feedback }, - { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard), - extra_EXT_transform_feedback }, - { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, - CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), - extra_EXT_transform_feedback }, - { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, - CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs), - extra_EXT_transform_feedback }, - { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, - CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), - extra_EXT_transform_feedback }, - - /* GL_ARB_transform_feedback2 */ - { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0, - extra_ARB_transform_feedback2 }, - { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0, - extra_ARB_transform_feedback2 }, - { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_transform_feedback2 }, - - /* GL_ARB_geometry_shader4 */ - { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxGeometryTextureImageUnits), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxGeometryOutputVertices), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxGeometryTotalOutputComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxGeometryUniformComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxGeometryVaryingComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxVertexVaryingComponents), - extra_ARB_geometry_shader4 }, - - /* GL 3.0 */ - { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, - { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, - { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, - { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, - - /* GL 3.1 */ - { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart), - extra_version_31 }, - { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex), - extra_version_31 }, - - /* GL 3.2 */ - { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask), - extra_version_32 }, -#endif /* FEATURE_GL */ -}; - -/* All we need now is a way to look up the value struct from the enum. - * The code generated by gcc for the old generated big switch - * statement is a big, balanced, open coded if/else tree, essentially - * an unrolled binary search. It would be natural to sort the new - * enum table and use bsearch(), but we will use a read-only hash - * table instead. bsearch() has a nice guaranteed worst case - * performance, but we're also guaranteed to hit that worst case - * (log2(n) iterations) for about half the enums. Instead, using an - * open addressing hash table, we can find the enum on the first try - * for 80% of the enums, 1 collision for 10% and never more than 5 - * collisions for any enum (typical numbers). And the code is very - * simple, even though it feels a little magic. */ - -static unsigned short table[1024]; -static const int prime_factor = 89, prime_step = 281; - -#ifdef GET_DEBUG -static void -print_table_stats(void) -{ - int i, j, collisions[11], count, hash, mask; - const struct value_desc *d; - - count = 0; - mask = Elements(table) - 1; - memset(collisions, 0, sizeof collisions); - - for (i = 0; i < Elements(table); i++) { - if (!table[i]) - continue; - count++; - d = &values[table[i]]; - hash = (d->pname * prime_factor); - j = 0; - while (1) { - if (values[table[hash & mask]].pname == d->pname) - break; - hash += prime_step; - j++; - } - - if (j < 10) - collisions[j]++; - else - collisions[10]++; - } - - printf("number of enums: %d (total %d)\n", count, Elements(values)); - for (i = 0; i < Elements(collisions) - 1; i++) - if (collisions[i] > 0) - printf(" %d enums with %d %scollisions\n", - collisions[i], i, i == 10 ? "or more " : ""); -} -#endif - -/** - * Initialize the enum hash for a given API - * - * This is called from one_time_init() to insert the enum values that - * are valid for the API in question into the enum hash table. - * - * \param the current context, for determining the API in question - */ -void _mesa_init_get_hash(GLcontext *ctx) -{ - int i, hash, index, mask; - int api_mask = 0, api_bit; - - mask = Elements(table) - 1; - api_bit = 1 << ctx->API; - - for (i = 0; i < Elements(values); i++) { - if (values[i].type == TYPE_API_MASK) { - api_mask = values[i].offset; - continue; - } - if (!(api_mask & api_bit)) - continue; - - hash = (values[i].pname * prime_factor) & mask; - while (1) { - index = hash & mask; - if (!table[index]) { - table[index] = i; - break; - } - hash += prime_step; - } - } - -#ifdef GET_DEBUG - print_table_stats(); -#endif -} - -/** - * Handle irregular enums - * - * Some values don't conform to the "well-known type at context - * pointer + offset" pattern, so we have this function to catch all - * the corner cases. Typically, it's a computed value or a one-off - * pointer to a custom struct or something. - * - * In this case we can't return a pointer to the value, so we'll have - * to use the temporary variable 'v' declared back in the calling - * glGet*v() function to store the result. - * - * \param ctx the current context - * \param d the struct value_desc that describes the enum - * \param v pointer to the tmp declared in the calling glGet*v() function - */ -static void -find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v) -{ - struct gl_buffer_object *buffer_obj; - struct gl_client_array *array; - GLuint unit, *p; - - switch (d->pname) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_TEXTURE_RECTANGLE_NV: - v->value_bool = _mesa_IsEnabled(d->pname); - break; - - case GL_LINE_STIPPLE_PATTERN: - /* This is the only GLushort, special case it here by promoting - * to an int rather than introducing a new type. */ - v->value_int = ctx->Line.StipplePattern; - break; - - case GL_CURRENT_RASTER_TEXTURE_COORDS: - unit = ctx->Texture.CurrentUnit; - v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; - v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; - v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; - v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; - break; - - case GL_CURRENT_TEXTURE_COORDS: - unit = ctx->Texture.CurrentUnit; - v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; - v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; - v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; - v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; - break; - - case GL_COLOR_WRITEMASK: - v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; - v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; - v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; - v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; - break; - - case GL_EDGE_FLAG: - v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0; - break; - - case GL_READ_BUFFER: - v->value_enum = ctx->ReadBuffer->ColorReadBuffer; - break; - - case GL_MAP2_GRID_DOMAIN: - v->value_float_4[0] = ctx->Eval.MapGrid2u1; - v->value_float_4[1] = ctx->Eval.MapGrid2u2; - v->value_float_4[2] = ctx->Eval.MapGrid2v1; - v->value_float_4[3] = ctx->Eval.MapGrid2v2; - break; - - case GL_TEXTURE_STACK_DEPTH: - unit = ctx->Texture.CurrentUnit; - v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; - break; - case GL_TEXTURE_MATRIX: - unit = ctx->Texture.CurrentUnit; - v->value_matrix = ctx->TextureMatrixStack[unit].Top; - break; - - case GL_TEXTURE_COORD_ARRAY: - case GL_TEXTURE_COORD_ARRAY_SIZE: - case GL_TEXTURE_COORD_ARRAY_TYPE: - case GL_TEXTURE_COORD_ARRAY_STRIDE: - array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]; - v->value_int = *(GLuint *) ((char *) array + d->offset); - break; - - case GL_ACTIVE_TEXTURE_ARB: - v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; - break; - - case GL_MODELVIEW_STACK_DEPTH: - case GL_PROJECTION_STACK_DEPTH: - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; - break; - - case GL_MAX_TEXTURE_SIZE: - case GL_MAX_3D_TEXTURE_SIZE: - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - p = (GLuint *) ((char *) ctx + d->offset); - v->value_int = 1 << (*p - 1); - break; - - case GL_SCISSOR_BOX: - v->value_int_4[0] = ctx->Scissor.X; - v->value_int_4[1] = ctx->Scissor.Y; - v->value_int_4[2] = ctx->Scissor.Width; - v->value_int_4[3] = ctx->Scissor.Height; - break; - - case GL_LIST_INDEX: - v->value_int = - ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; - break; - case GL_LIST_MODE: - if (!ctx->CompileFlag) - v->value_enum = 0; - else if (ctx->ExecuteFlag) - v->value_enum = GL_COMPILE_AND_EXECUTE; - else - v->value_enum = GL_COMPILE; - break; - - case GL_VIEWPORT: - v->value_int_4[0] = ctx->Viewport.X; - v->value_int_4[1] = ctx->Viewport.Y; - v->value_int_4[2] = ctx->Viewport.Width; - v->value_int_4[3] = ctx->Viewport.Height; - break; - - case GL_ACTIVE_STENCIL_FACE_EXT: - v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; - break; - - case GL_STENCIL_FAIL: - v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_FUNC: - v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_PASS_DEPTH_PASS: - v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_REF: - v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_VALUE_MASK: - v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_WRITEMASK: - v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; - break; - - case GL_NUM_EXTENSIONS: - v->value_int = _mesa_get_extension_count(ctx); - break; - - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - v->value_int = _mesa_get_color_read_type(ctx); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - v->value_int = _mesa_get_color_read_format(ctx); - break; - - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - v->value_int = ctx->CurrentStack->Depth + 1; - break; - case GL_CURRENT_MATRIX_ARB: - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - v->value_matrix = ctx->CurrentStack->Top; - break; - - case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - v->value_int_n.n = - _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE); - ASSERT(v->value_int_n.n <= 100); - break; - - case GL_MAX_VARYING_FLOATS_ARB: - v->value_int = ctx->Const.MaxVarying * 4; - break; - - /* Various object names */ - - case GL_TEXTURE_BINDING_1D: - case GL_TEXTURE_BINDING_2D: - case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_BINDING_1D_ARRAY_EXT: - case GL_TEXTURE_BINDING_2D_ARRAY_EXT: - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - case GL_TEXTURE_BINDING_RECTANGLE_NV: - unit = ctx->Texture.CurrentUnit; - v->value_int = - ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; - break; - - /* GL_ARB_vertex_buffer_object */ - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - buffer_obj = (struct gl_buffer_object *) - ((char *) ctx->Array.ArrayObj + d->offset); - v->value_int = buffer_obj->Name; - break; - case GL_ARRAY_BUFFER_BINDING_ARB: - v->value_int = ctx->Array.ArrayBufferObj->Name; - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - v->value_int = - ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - v->value_int = ctx->Array.ElementArrayBufferObj->Name; - break; - - case GL_FRAGMENT_PROGRAM_BINDING_NV: - v->value_int = - ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - v->value_int = - ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0; - break; - case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - v->value_int = ctx->Pack.BufferObj->Name; - break; - case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - v->value_int = ctx->Unpack.BufferObj->Name; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: - v->value_int = ctx->TransformFeedback.CurrentObject->Paused; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: - v->value_int = ctx->TransformFeedback.CurrentObject->Active; - break; - case GL_TRANSFORM_FEEDBACK_BINDING: - v->value_int = ctx->TransformFeedback.CurrentObject->Name; - break; - case GL_CURRENT_PROGRAM: - v->value_int = - ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0; - break; - case GL_READ_FRAMEBUFFER_BINDING_EXT: - v->value_int = ctx->ReadBuffer->Name; - break; - case GL_RENDERBUFFER_BINDING_EXT: - v->value_int = - ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; - break; - case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: - v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name; - break; - } -} - -/** - * Check extra constraints on a struct value_desc descriptor - * - * If a struct value_desc has a non-NULL extra pointer, it means that - * there are a number of extra constraints to check or actions to - * perform. The extras is just an integer array where each integer - * encode different constraints or actions. - * - * \param ctx current context - * \param func name of calling glGet*v() function for error reporting - * \param d the struct value_desc that has the extra constraints - * - * \return GL_FALSE if one of the constraints was not satisfied, - * otherwise GL_TRUE. - */ -static GLboolean -check_extra(GLcontext *ctx, const char *func, const struct value_desc *d) -{ - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - int total, enabled; - const int *e; - - total = 0; - enabled = 0; - for (e = d->extra; *e != EXTRA_END; e++) - switch (*e) { - case EXTRA_VERSION_30: - if (version >= 30) { - total++; - enabled++; - } - break; - case EXTRA_VERSION_31: - if (version >= 31) { - total++; - enabled++; - } - break; - case EXTRA_VERSION_32: - if (version >= 32) { - total++; - enabled++; - } - break; - case EXTRA_VERSION_ES2: - if (ctx->API == API_OPENGLES2) { - total++; - enabled++; - } - break; - case EXTRA_NEW_BUFFERS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - break; - case EXTRA_FLUSH_CURRENT: - FLUSH_CURRENT(ctx, 0); - break; - case EXTRA_VALID_DRAW_BUFFER: - if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", - func, d->pname - GL_DRAW_BUFFER0_ARB); - return GL_FALSE; - } - break; - case EXTRA_VALID_TEXTURE_UNIT: - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", - func, ctx->Texture.CurrentUnit); - return GL_FALSE; - } - break; - case EXTRA_END: - break; - default: /* *e is a offset into the extension struct */ - total++; - if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) - enabled++; - break; - } - - if (total > 0 && enabled == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(d->pname)); - return GL_FALSE; - } - - return GL_TRUE; -} - -static const struct value_desc error_value = - { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; - -/** - * Find the struct value_desc corresponding to the enum 'pname'. - * - * We hash the enum value to get an index into the 'table' array, - * which holds the index in the 'values' array of struct value_desc. - * Once we've found the entry, we do the extra checks, if any, then - * look up the value and return a pointer to it. - * - * If the value has to be computed (for example, it's the result of a - * function call or we need to add 1 to it), we use the tmp 'v' to - * store the result. - * - * \param func name of glGet*v() func for error reporting - * \param pname the enum value we're looking up - * \param p is were we return the pointer to the value - * \param v a tmp union value variable in the calling glGet*v() function - * - * \return the struct value_desc corresponding to the enum or a struct - * value_desc of TYPE_INVALID if not found. This lets the calling - * glGet*v() function jump right into a switch statement and - * handle errors there instead of having to check for NULL. - */ -static const struct value_desc * -find_value(const char *func, GLenum pname, void **p, union value *v) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *unit; - int mask, hash; - const struct value_desc *d; - - mask = Elements(table) - 1; - hash = (pname * prime_factor); - while (1) { - d = &values[table[hash & mask]]; - if (likely(d->pname == pname)) - break; - - /* If the enum isn't valid, the hash walk ends with index 0, - * which is the API mask entry at the beginning of values[]. */ - if (d->type == TYPE_API_MASK) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(pname)); - return &error_value; - } - hash += prime_step; - } - - if (unlikely(d->extra && !check_extra(ctx, func, d))) - return &error_value; - - switch (d->location) { - case LOC_BUFFER: - *p = ((char *) ctx->DrawBuffer + d->offset); - return d; - case LOC_CONTEXT: - *p = ((char *) ctx + d->offset); - return d; - case LOC_ARRAY: - *p = ((char *) ctx->Array.ArrayObj + d->offset); - return d; - case LOC_TEXUNIT: - unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - *p = ((char *) unit + d->offset); - return d; - case LOC_CUSTOM: - find_custom_value(ctx, d, v); - *p = v; - return d; - default: - assert(0); - break; - } - - /* silence warning */ - return &error_value; -} - -static const int transpose[] = { - 0, 4, 8, 12, - 1, 5, 9, 13, - 2, 6, 10, 14, - 3, 7, 11, 15 -}; - -void GLAPIENTRY -_mesa_GetBooleanv(GLenum pname, GLboolean *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetBooleanv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = INT_TO_BOOLEAN(d->offset); - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); - break; - - case TYPE_BOOLEAN: - params[0] = ((GLboolean*) p)[0]; - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_BOOLEAN(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - -void GLAPIENTRY -_mesa_GetFloatv(GLenum pname, GLfloat *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetFloatv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = (GLfloat) d->offset; - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = ((GLfloat *) p)[3]; - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = ((GLfloat *) p)[2]; - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = ((GLfloat *) p)[1]; - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = ((GLfloat *) p)[0]; - break; - - case TYPE_DOUBLEN: - params[0] = ((GLdouble *) p)[0]; - break; - - case TYPE_INT_4: - params[3] = (GLfloat) (((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = (GLfloat) (((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = (GLfloat) (((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = (GLfloat) (((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[i]; - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[transpose[i]]; - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); - break; - } -} - -void GLAPIENTRY -_mesa_GetIntegerv(GLenum pname, GLint *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetIntegerv", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = d->offset; - break; - - case TYPE_FLOAT_4: - params[3] = IROUND(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - params[2] = IROUND(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - params[1] = IROUND(((GLfloat *) p)[1]); - case TYPE_FLOAT: - params[0] = IROUND(((GLfloat *) p)[0]); - break; - - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); - case TYPE_FLOATN: - params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = ((GLint *) p)[3]; - case TYPE_INT_3: - params[2] = ((GLint *) p)[2]; - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = ((GLint *) p)[1]; - case TYPE_INT: - case TYPE_ENUM: - params[0] = ((GLint *) p)[0]; - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = v.value_int_n.ints[i]; - break; - - case TYPE_INT64: - params[0] = INT64_TO_INT(((GLint64 *) p)[0]); - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - -#if FEATURE_ARB_sync -void GLAPIENTRY -_mesa_GetInteger64v(GLenum pname, GLint64 *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetInteger64v", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = d->offset; - break; - - case TYPE_FLOAT_4: - params[3] = IROUND64(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - params[2] = IROUND64(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - params[1] = IROUND64(((GLfloat *) p)[1]); - case TYPE_FLOAT: - params[0] = IROUND64(((GLfloat *) p)[0]); - break; - - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]); - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]); - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]); - case TYPE_FLOATN: - params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = ((GLint *) p)[3]; - case TYPE_INT_3: - params[2] = ((GLint *) p)[2]; - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = ((GLint *) p)[1]; - case TYPE_INT: - case TYPE_ENUM: - params[0] = ((GLint *) p)[0]; - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = ((GLboolean*) p)[0]; - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT64(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} -#endif /* FEATURE_ARB_sync */ - -void GLAPIENTRY -_mesa_GetDoublev(GLenum pname, GLdouble *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetDoublev", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = d->offset; - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = ((GLfloat *) p)[3]; - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = ((GLfloat *) p)[2]; - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = ((GLfloat *) p)[1]; - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = ((GLfloat *) p)[0]; - break; - - case TYPE_DOUBLEN: - params[0] = ((GLdouble *) p)[0]; - break; - - case TYPE_INT_4: - params[3] = ((GLint *) p)[3]; - case TYPE_INT_3: - params[2] = ((GLint *) p)[2]; - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = ((GLint *) p)[1]; - case TYPE_INT: - case TYPE_ENUM: - params[0] = ((GLint *) p)[0]; - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = v.value_int_n.ints[i]; - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = *(GLboolean*) p; - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[i]; - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = m->m[transpose[i]]; - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = (*(GLbitfield *) p >> shift) & 1; - break; - } -} - -static enum value_type -find_value_indexed(const char *func, GLenum pname, int index, union value *v) -{ - GET_CURRENT_CONTEXT(ctx); - - switch (pname) { - - case GL_BLEND: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.EXT_draw_buffers2) - goto invalid_enum; - v->value_int = (ctx->Color.BlendEnabled >> index) & 1; - return TYPE_INT; - - case GL_COLOR_WRITEMASK: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.EXT_draw_buffers2) - goto invalid_enum; - v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; - v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; - v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; - v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; - return TYPE_INT_4; - - case GL_TRANSFORM_FEEDBACK_BUFFER_START: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) - goto invalid_value; - if (!ctx->Extensions.EXT_transform_feedback) - goto invalid_enum; - v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; - return TYPE_INT64; - - case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) - goto invalid_value; - if (!ctx->Extensions.EXT_transform_feedback) - goto invalid_enum; - v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index]; - return TYPE_INT64; - - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) - goto invalid_value; - if (!ctx->Extensions.EXT_transform_feedback) - goto invalid_enum; - v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name; - return TYPE_INT; - } - - invalid_enum: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(pname)); - return TYPE_INVALID; - invalid_value: - _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, - _mesa_lookup_enum_by_nr(pname)); - return TYPE_INVALID; -} - -void GLAPIENTRY -_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) -{ - union value v; - - switch (find_value_indexed("glGetBooleanIndexedv", pname, index, &v)) { - case TYPE_INT: - params[0] = INT_TO_BOOLEAN(v.value_int); - break; - case TYPE_INT_4: - params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); - params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); - params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); - params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); - break; - case TYPE_INT64: - params[0] = INT64_TO_BOOLEAN(v.value_int); - break; - default: - assert(0); - } -} - -void GLAPIENTRY -_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) -{ - union value v; - - switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { - case TYPE_INT: - params[0] = v.value_int; - break; - case TYPE_INT_4: - params[0] = v.value_int_4[0]; - params[1] = v.value_int_4[1]; - params[2] = v.value_int_4[2]; - params[3] = v.value_int_4[3]; - break; - case TYPE_INT64: - params[0] = INT64_TO_INT(v.value_int); - break; - default: - assert(0); - } -} - -#if FEATURE_ARB_sync -void GLAPIENTRY -_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) -{ - union value v; - - switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { - case TYPE_INT: - params[0] = v.value_int; - break; - case TYPE_INT_4: - params[0] = v.value_int_4[0]; - params[1] = v.value_int_4[1]; - params[2] = v.value_int_4[2]; - params[3] = v.value_int_4[3]; - break; - case TYPE_INT64: - params[0] = v.value_int; - break; - default: - assert(0); - } -} -#endif /* FEATURE_ARB_sync */ - -#if FEATURE_ES1 -void GLAPIENTRY -_mesa_GetFixedv(GLenum pname, GLfixed *params) -{ - const struct value_desc *d; - union value v; - GLmatrix *m; - int shift, i; - void *p; - - d = find_value("glGetDoublev", pname, &p, &v); - switch (d->type) { - case TYPE_INVALID: - break; - case TYPE_CONST: - params[0] = INT_TO_FIXED(d->offset); - break; - - case TYPE_FLOAT_4: - case TYPE_FLOATN_4: - params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); - case TYPE_FLOAT_3: - case TYPE_FLOATN_3: - params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); - case TYPE_FLOAT_2: - case TYPE_FLOATN_2: - params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); - case TYPE_FLOAT: - case TYPE_FLOATN: - params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); - break; - - case TYPE_DOUBLEN: - params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); - break; - - case TYPE_INT_4: - params[3] = INT_TO_FIXED(((GLint *) p)[3]); - case TYPE_INT_3: - params[2] = INT_TO_FIXED(((GLint *) p)[2]); - case TYPE_INT_2: - case TYPE_ENUM_2: - params[1] = INT_TO_FIXED(((GLint *) p)[1]); - case TYPE_INT: - case TYPE_ENUM: - params[0] = INT_TO_FIXED(((GLint *) p)[0]); - break; - - case TYPE_INT_N: - for (i = 0; i < v.value_int_n.n; i++) - params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); - break; - - case TYPE_INT64: - params[0] = ((GLint64 *) p)[0]; - break; - - case TYPE_BOOLEAN: - params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); - break; - - case TYPE_MATRIX: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_FIXED(m->m[i]); - break; - - case TYPE_MATRIX_T: - m = *(GLmatrix **) p; - for (i = 0; i < 16; i++) - params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); - break; - - case TYPE_BIT_0: - case TYPE_BIT_1: - case TYPE_BIT_2: - case TYPE_BIT_3: - case TYPE_BIT_4: - case TYPE_BIT_5: - shift = d->type - TYPE_BIT_0; - params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); - break; - } -} -#endif +/* + * Copyright (C) 2010 Brian Paul All Rights Reserved. + * Copyright (C) 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Author: Kristian Høgsberg + */ + +#include "glheader.h" +#include "context.h" +#include "enable.h" +#include "enums.h" +#include "extensions.h" +#include "get.h" +#include "macros.h" +#include "mtypes.h" +#include "state.h" +#include "texcompress.h" +#include "framebuffer.h" + +/* This is a table driven implemetation of the glGet*v() functions. + * The basic idea is that most getters just look up an int somewhere + * in struct gl_context and then convert it to a bool or float according to + * which of glGetIntegerv() glGetBooleanv() etc is being called. + * Instead of generating code to do this, we can just record the enum + * value and the offset into struct gl_context in an array of structs. Then + * in glGet*(), we lookup the struct for the enum in question, and use + * the offset to get the int we need. + * + * Sometimes we need to look up a float, a boolean, a bit in a + * bitfield, a matrix or other types instead, so we need to track the + * type of the value in struct gl_context. And sometimes the value isn't in + * struct gl_context but in the drawbuffer, the array object, current texture + * unit, or maybe it's a computed value. So we need to also track + * where or how to find the value. Finally, we sometimes need to + * check that one of a number of extensions are enabled, the GL + * version or flush or call _mesa_update_state(). This is done by + * attaching optional extra information to the value description + * struct, it's sort of like an array of opcodes that describe extra + * checks or actions. + * + * Putting all this together we end up with struct value_desc below, + * and with a couple of macros to help, the table of struct value_desc + * is about as concise as the specification in the old python script. + */ + +#undef CONST + +#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) +#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ + ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ + (GLint) ((F) * 65536.0f) ) + +#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) +#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ + ((I) < SHRT_MIN) ? INT_MIN : \ + (GLint) ((I) * 65536) ) + +#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) +#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) + +#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) +#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) +#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) +#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) + +#define ENUM_TO_INT64(E) ( (GLint64) (E) ) +#define ENUM_TO_FIXED(E) (E) + +enum value_type { + TYPE_INVALID, + TYPE_API_MASK, + TYPE_INT, + TYPE_INT_2, + TYPE_INT_3, + TYPE_INT_4, + TYPE_INT_N, + TYPE_INT64, + TYPE_ENUM, + TYPE_ENUM_2, + TYPE_BOOLEAN, + TYPE_BIT_0, + TYPE_BIT_1, + TYPE_BIT_2, + TYPE_BIT_3, + TYPE_BIT_4, + TYPE_BIT_5, + TYPE_FLOAT, + TYPE_FLOAT_2, + TYPE_FLOAT_3, + TYPE_FLOAT_4, + TYPE_FLOATN, + TYPE_FLOATN_2, + TYPE_FLOATN_3, + TYPE_FLOATN_4, + TYPE_DOUBLEN, + TYPE_MATRIX, + TYPE_MATRIX_T, + TYPE_CONST +}; + +enum value_location { + LOC_BUFFER, + LOC_CONTEXT, + LOC_ARRAY, + LOC_TEXUNIT, + LOC_CUSTOM +}; + +enum value_extra { + EXTRA_END = 0x8000, + EXTRA_VERSION_30, + EXTRA_VERSION_31, + EXTRA_VERSION_32, + EXTRA_VERSION_ES2, + EXTRA_NEW_BUFFERS, + EXTRA_VALID_DRAW_BUFFER, + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_FLUSH_CURRENT, +}; + +#define NO_EXTRA NULL +#define NO_OFFSET 0 + +struct value_desc { + GLenum pname; + GLubyte location; /**< enum value_location */ + GLubyte type; /**< enum value_type */ + int offset; + const int *extra; +}; + +union value { + GLfloat value_float; + GLfloat value_float_4[4]; + GLmatrix *value_matrix; + GLint value_int; + GLint value_int_4[4]; + GLint64 value_int64; + GLenum value_enum; + + /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ + struct { + GLint n, ints[100]; + } value_int_n; + GLboolean value_bool; +}; + +#define BUFFER_FIELD(field, type) \ + LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) +#define CONTEXT_FIELD(field, type) \ + LOC_CONTEXT, type, offsetof(struct gl_context, field) +#define ARRAY_FIELD(field, type) \ + LOC_ARRAY, type, offsetof(struct gl_array_object, field) +#define CONST(value) \ + LOC_CONTEXT, TYPE_CONST, value + +#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) +#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) +#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) + +#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) +#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) +#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) +#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) +#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) +#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) +#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) +#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) +#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) +#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) +#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) +#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) +#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) +#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) +#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) +#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) +#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) +#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) + +#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) +#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) +#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) + +#define EXT(f) \ + offsetof(struct gl_extensions, f) + +#define EXTRA_EXT(e) \ + static const int extra_##e[] = { \ + EXT(e), EXTRA_END \ + } + +#define EXTRA_EXT2(e1, e2) \ + static const int extra_##e1##_##e2[] = { \ + EXT(e1), EXT(e2), EXTRA_END \ + } + +/* The 'extra' mechanism is a way to specify extra checks (such as + * extensions or specific gl versions) or actions (flush current, new + * buffers) that we need to do before looking up an enum. We need to + * declare them all up front so we can refer to them in the value_desc + * structs below. */ + +static const int extra_new_buffers[] = { + EXTRA_NEW_BUFFERS, + EXTRA_END +}; + +static const int extra_valid_draw_buffer[] = { + EXTRA_VALID_DRAW_BUFFER, + EXTRA_END +}; + +static const int extra_valid_texture_unit[] = { + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_END +}; + +static const int extra_flush_current_valid_texture_unit[] = { + EXTRA_FLUSH_CURRENT, + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_END +}; + +static const int extra_flush_current[] = { + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +static const int extra_new_buffers_OES_read_format[] = { + EXTRA_NEW_BUFFERS, + EXT(OES_read_format), + EXTRA_END +}; + +static const int extra_EXT_secondary_color_flush_current[] = { + EXT(EXT_secondary_color), + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +static const int extra_EXT_fog_coord_flush_current[] = { + EXT(EXT_fog_coord), + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +static const int extra_EXT_texture_integer[] = { + EXT(EXT_texture_integer), + EXTRA_END +}; + +static const int extra_EXT_gpu_shader4[] = { + EXT(EXT_gpu_shader4), + EXTRA_END +}; + + +EXTRA_EXT(ARB_multitexture); +EXTRA_EXT(ARB_texture_cube_map); +EXTRA_EXT(MESA_texture_array); +EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); +EXTRA_EXT(EXT_secondary_color); +EXTRA_EXT(EXT_fog_coord); +EXTRA_EXT(EXT_texture_lod_bias); +EXTRA_EXT(EXT_texture_filter_anisotropic); +EXTRA_EXT(IBM_rasterpos_clip); +EXTRA_EXT(NV_point_sprite); +EXTRA_EXT(SGIS_generate_mipmap); +EXTRA_EXT(NV_vertex_program); +EXTRA_EXT(NV_fragment_program); +EXTRA_EXT(NV_texture_rectangle); +EXTRA_EXT(EXT_stencil_two_side); +EXTRA_EXT(NV_light_max_exponent); +EXTRA_EXT(SGI_texture_color_table); +EXTRA_EXT(EXT_depth_bounds_test); +EXTRA_EXT(ARB_depth_clamp); +EXTRA_EXT(ATI_fragment_shader); +EXTRA_EXT(EXT_framebuffer_blit); +EXTRA_EXT(ARB_shader_objects); +EXTRA_EXT(EXT_provoking_vertex); +EXTRA_EXT(ARB_fragment_shader); +EXTRA_EXT(ARB_fragment_program); +EXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample); +EXTRA_EXT(EXT_framebuffer_object); +EXTRA_EXT(APPLE_vertex_array_object); +EXTRA_EXT(ARB_seamless_cube_map); +EXTRA_EXT(EXT_compiled_vertex_array); +EXTRA_EXT(ARB_sync); +EXTRA_EXT(ARB_vertex_shader); +EXTRA_EXT(EXT_transform_feedback); +EXTRA_EXT(ARB_transform_feedback2); +EXTRA_EXT(EXT_pixel_buffer_object); +EXTRA_EXT(ARB_vertex_program); +EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); +EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); +EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); +EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); +EXTRA_EXT(ARB_vertex_buffer_object); +EXTRA_EXT(ARB_geometry_shader4); +EXTRA_EXT(ARB_copy_buffer); + +static const int +extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { + EXT(ARB_vertex_program), + EXT(ARB_fragment_program), + EXT(NV_vertex_program), + EXTRA_END +}; + +static const int +extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { + EXT(NV_vertex_program), + EXT(ARB_vertex_program), + EXT(ARB_fragment_program), + EXT(NV_vertex_program), + EXTRA_END +}; + +static const int +extra_NV_primitive_restart[] = { + EXT(NV_primitive_restart), + EXTRA_END +}; + +static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; +static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; +static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; + +static const int +extra_ARB_vertex_program_version_es2[] = { + EXT(ARB_vertex_program), + EXTRA_VERSION_ES2, + EXTRA_END +}; + +#define API_OPENGL_BIT (1 << API_OPENGL) +#define API_OPENGLES_BIT (1 << API_OPENGLES) +#define API_OPENGLES2_BIT (1 << API_OPENGLES2) + +/* This is the big table describing all the enums we accept in + * glGet*v(). The table is partitioned into six parts: enums + * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared + * between OpenGL and GLES, enums exclusive to GLES, etc for the + * remaining combinations. When we add the enums to the hash table in + * _mesa_init_get_hash(), we only add the enums for the API we're + * instantiating and the different sections are guarded by #if + * FEATURE_GL etc to make sure we only compile in the enums we may + * need. */ + +static const struct value_desc values[] = { + /* Enums shared between OpenGL, GLES1 and GLES2 */ + { 0, 0, TYPE_API_MASK, + API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA}, + { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, + { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA }, + { GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, + { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, + { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, + { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA }, + { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA }, + { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA }, + { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA }, + { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA }, + { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA }, + { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA }, + { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA }, + { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA }, + { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA }, + { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers }, + { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA }, + { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA }, + { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, + { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, + { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA }, + { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA }, + { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA }, + { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA }, + { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA }, + { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA }, + { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA }, + { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers }, + { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, + { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA }, + { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA }, + { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA }, + { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA }, + { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, + { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, + { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA }, + { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA }, + { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA }, + { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, + + /* GL_ARB_multitexture */ + { GL_ACTIVE_TEXTURE_ARB, + LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, + + /* Note that all the OES_* extensions require that the Mesa "struct + * gl_extensions" include a member with the name of the extension. + * That structure does not yet include OES extensions (and we're + * not sure whether it will). If it does, all the OES_* + * extensions below should mark the dependency. */ + + /* GL_ARB_texture_cube_map */ + { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, + TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, + { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_context, Const.MaxCubeTextureLevels), + extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ + + /* XXX: OES_blend_subtract */ + { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, + { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, + { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA), NO_EXTRA }, + { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA), NO_EXTRA }, + + /* GL_BLEND_EQUATION_RGB, which is what we're really after, is + * defined identically to GL_BLEND_EQUATION. */ + { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB), NO_EXTRA }, + { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA), NO_EXTRA }, + + /* GL_ARB_texture_compression */ + { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA }, + + /* GL_ARB_multisample */ + { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, + CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA }, + { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA }, + { GL_SAMPLE_COVERAGE_VALUE_ARB, + CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA }, + { GL_SAMPLE_COVERAGE_INVERT_ARB, + CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA }, + { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA }, + { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA }, + + /* GL_SGIS_generate_mipmap */ + { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap), + extra_SGIS_generate_mipmap }, + + /* GL_ARB_vertex_buffer_object */ + { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + + /* GL_ARB_vertex_buffer_object */ + /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */ + { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_buffer_object }, + + /* GL_ARB_copy_buffer */ + { GL_COPY_READ_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer }, + { GL_COPY_WRITE_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer }, + + /* GL_OES_read_format */ + { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0, + extra_new_buffers_OES_read_format }, + { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0, + extra_new_buffers_OES_read_format }, + + /* GL_EXT_framebuffer_object */ + { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name), + extra_EXT_framebuffer_object }, + { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_framebuffer_object }, + { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize), + extra_EXT_framebuffer_object }, + + /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's + * GLSL: */ + { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA }, + +#if FEATURE_GL || FEATURE_ES1 + /* Enums in OpenGL and GLES1 */ + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA }, + { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA }, + { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA }, + { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA }, + { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA }, + { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA }, + { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA }, + { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA }, + { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA }, + { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA }, + { GL_LIGHT_MODEL_AMBIENT, + CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA }, + { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA }, + { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, + { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA }, + { GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, + { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA }, + { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA }, + { GL_CURRENT_COLOR, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), + extra_flush_current }, + { GL_CURRENT_NORMAL, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), + extra_flush_current }, + { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, + extra_flush_current_valid_texture_unit }, + { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA }, + { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA }, + { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA }, + { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA }, + { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA }, + { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA }, + { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA }, + { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA }, + { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA }, + { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA }, + { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA }, + { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA }, + { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA }, + { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA }, + { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA }, + { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA }, + { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA }, + { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA }, + { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA }, + { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA }, + { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA }, + { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA }, + { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA }, + { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA }, + { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA }, + { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA }, + { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA }, + { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA }, + { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA }, + { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA }, + { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA }, + { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA }, + { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, + { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit }, + { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0, + extra_valid_texture_unit }, + + { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA }, + { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA }, + { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA }, + { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA }, + { GL_NORMAL_ARRAY, ARRAY_ENUM(Normal.Enabled), NO_EXTRA }, + { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA }, + { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA }, + { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA }, + { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA }, + { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA }, + { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_SIZE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Size), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_TYPE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Type), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_STRIDE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Stride), NO_EXTRA }, + + /* GL_ARB_multitexture */ + { GL_MAX_TEXTURE_UNITS_ARB, + CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture }, + { GL_CLIENT_ACTIVE_TEXTURE_ARB, + LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, + + /* GL_ARB_texture_cube_map */ + { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, + /* S, T, and R are always set at the same time */ + { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0, + offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, + + /* GL_ARB_multisample */ + { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA }, + { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA }, + + /* GL_ARB_vertex_buffer_object */ + { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA }, + { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA }, + { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, + + /* GL_OES_point_sprite */ + { GL_POINT_SPRITE_NV, + CONTEXT_BOOL(Point.PointSprite), + extra_NV_point_sprite_ARB_point_sprite }, + + /* GL_ARB_fragment_shader */ + { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), + extra_ARB_fragment_shader }, + + /* GL_ARB_vertex_shader */ + { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), + extra_ARB_vertex_shader }, + { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_shader }, + + /* GL_EXT_texture_lod_bias */ + { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias), + extra_EXT_texture_lod_bias }, + + /* GL_EXT_texture_filter_anisotropic */ + { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, + CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), + extra_EXT_texture_filter_anisotropic }, +#endif /* FEATURE_GL || FEATURE_ES1 */ + +#if FEATURE_ES1 + { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT }, + /* XXX: OES_matrix_get */ + { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES }, + { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES }, + { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES }, + + /* OES_point_size_array */ + { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) }, + { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) }, + { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) }, + { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 }, +#endif /* FEATURE_ES1 */ + +#if FEATURE_GL || FEATURE_ES2 + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA }, + /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */ + { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA }, + { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */ + CONTEXT_INT(Const.MaxTextureCoordUnits), + extra_ARB_fragment_program_NV_fragment_program }, + + /* GL_ARB_draw_buffers */ + { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA }, + + { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4), NO_EXTRA }, + /* GL_ARB_fragment_program */ + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */ + CONTEXT_INT(Const.MaxTextureImageUnits), + extra_ARB_fragment_program_NV_fragment_program }, + { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader }, + { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.MaxCombinedTextureImageUnits), + extra_ARB_vertex_shader }, + + /* GL_ARB_shader_objects + * Actually, this token isn't part of GL_ARB_shader_objects, but is + * close enough for now. */ + { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects }, + + /* OpenGL 2.0 */ + { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA }, + { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA }, + { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA }, + { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA }, + { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA }, + { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA }, + { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA }, + + { GL_MAX_VERTEX_ATTRIBS_ARB, + CONTEXT_INT(Const.VertexProgram.MaxAttribs), + extra_ARB_vertex_program_version_es2 }, + + /* OES_texture_3D */ + { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA }, + { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA }, + + /* GL_ARB_fragment_program/OES_standard_derivatives */ + { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, + CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, +#endif /* FEATURE_GL || FEATURE_ES2 */ + +#if FEATURE_ES2 + /* Enums unique to OpenGL ES 2.0 */ + { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA }, + { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), NO_EXTRA }, + { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + { GL_SHADER_COMPILER, CONST(1), NO_EXTRA }, + /* OES_get_program_binary */ + { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, + { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, +#endif /* FEATURE_ES2 */ + +#if FEATURE_GL + /* Remaining enums are only in OpenGL */ + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA }, + { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA }, + { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA }, + { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA }, + { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA }, + { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA }, + { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA }, + { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA }, + { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA }, + { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA }, + { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA }, + { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA }, + { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA }, + { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA }, + { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA }, + { GL_CURRENT_INDEX, + CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), + extra_flush_current }, + { GL_CURRENT_RASTER_COLOR, + CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA }, + { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA }, + { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA }, + { GL_CURRENT_RASTER_SECONDARY_COLOR, + CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA }, + { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, + extra_valid_texture_unit }, + { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA }, + { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA }, + { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA }, + { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA }, + { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, + { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, + { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA }, + { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA }, + { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA }, + { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA }, + { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA }, + { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers }, + { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA }, + { GL_INDEX_MODE, CONST(0) , NO_EXTRA}, + { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA }, + { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA }, + { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA }, + { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA }, + { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA }, + { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA }, + { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA }, + { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA }, + { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA }, + { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, + { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA }, + { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA }, + { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA }, + { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA }, + { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA }, + { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA }, + { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA }, + { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA }, + { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA }, + { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA }, + { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA }, + { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA }, + { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA }, + { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA }, + { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA }, + { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA }, + { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA }, + { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA }, + { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA }, + { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA }, + { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA }, + { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA }, + { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA }, + { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA }, + { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA }, + { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA }, + { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA }, + { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA }, + + { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA }, + { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA }, + { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA }, + { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA }, + { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA }, + { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA }, + { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA }, + { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA }, + { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA }, + { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA }, + { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA }, + { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA }, + { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA }, + { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA }, + { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA }, + { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA }, + { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA }, + { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA }, + { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA }, + { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA }, + { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA }, + { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA }, + { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA }, + { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA }, + { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA }, + { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA }, + { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA }, + { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, + { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, + { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA }, + { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA }, + { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA }, + { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA }, + { GL_RGBA_MODE, CONST(1), NO_EXTRA }, + { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA }, + { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA }, + + { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA }, + + { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, + { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, + { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, + { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, + + { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA }, + { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT, + TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, + { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT, + TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, + { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, + CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array }, + + { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0, + offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, + { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1, + offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, + { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2, + offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, + { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3, + offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, + { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA }, + { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA }, + { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA }, + { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA }, + { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA }, + { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA }, + { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA }, + { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA }, + { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA }, + { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA }, + + /* Vertex arrays */ + { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA }, + { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA }, + { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA }, + { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA }, + { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA }, + { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, + + /* GL_ARB_texture_compression */ + { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA }, + + /* GL_EXT_compiled_vertex_array */ + { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst), + extra_EXT_compiled_vertex_array }, + { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount), + extra_EXT_compiled_vertex_array }, + + /* GL_ARB_transpose_matrix */ + { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, + CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA }, + { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, + CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, + { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, + + /* GL_SGI_texture_color_table */ + { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN, + offsetof(struct gl_texture_unit, ColorTableEnabled), + extra_SGI_texture_color_table }, + + /* GL_EXT_secondary_color */ + { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled), + extra_EXT_secondary_color_ARB_vertex_program }, + { GL_CURRENT_SECONDARY_COLOR_EXT, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), + extra_EXT_secondary_color_flush_current }, + { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size), + extra_EXT_secondary_color }, + + /* GL_EXT_fog_coord */ + { GL_CURRENT_FOG_COORDINATE_EXT, + CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), + extra_EXT_fog_coord_flush_current }, + { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource), + extra_EXT_fog_coord }, + + /* GL_IBM_rasterpos_clip */ + { GL_RASTER_POSITION_UNCLIPPED_IBM, + CONTEXT_BOOL(Transform.RasterPositionUnclipped), + extra_IBM_rasterpos_clip }, + + /* GL_NV_point_sprite */ + { GL_POINT_SPRITE_R_MODE_NV, + CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite }, + { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), + extra_NV_point_sprite_ARB_point_sprite }, + + /* GL_NV_vertex_program */ + { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]), + extra_NV_vertex_program }, + + /* GL_NV_fragment_program */ + { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled), + extra_NV_fragment_program }, + { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, + extra_NV_fragment_program }, + { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV, + CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS), + extra_NV_fragment_program }, + + /* GL_NV_texture_rectangle */ + { GL_TEXTURE_RECTANGLE_NV, + LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle }, + { GL_TEXTURE_BINDING_RECTANGLE_NV, + LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle }, + { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, + CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle }, + + /* GL_EXT_stencil_two_side */ + { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide), + extra_EXT_stencil_two_side }, + { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, + + /* GL_NV_light_max_exponent */ + { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess), + extra_NV_light_max_exponent }, + { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent), + extra_NV_light_max_exponent }, + + /* GL_NV_primitive_restart */ + { GL_PRIMITIVE_RESTART_NV, CONTEXT_BOOL(Array.PrimitiveRestart), + extra_NV_primitive_restart }, + { GL_PRIMITIVE_RESTART_INDEX_NV, CONTEXT_INT(Array.RestartIndex), + extra_NV_primitive_restart }, + + /* GL_ARB_vertex_buffer_object */ + { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA }, + { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA }, + { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA }, + { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA }, + + /* GL_EXT_pixel_buffer_object */ + { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_pixel_buffer_object }, + { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_pixel_buffer_object }, + + /* GL_ARB_vertex_program */ + { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */ + CONTEXT_BOOL(VertexProgram.Enabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/ + CONTEXT_BOOL(VertexProgram.PointSizeEnabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + CONTEXT_BOOL(VertexProgram.TwoSideEnabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ + CONTEXT_INT(Const.MaxProgramMatrixStackDepth), + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */ + CONTEXT_INT(Const.MaxProgramMatrices), + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */ + LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + + { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ + LOC_CUSTOM, TYPE_MATRIX, 0, + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ + LOC_CUSTOM, TYPE_MATRIX, 0, + extra_ARB_vertex_program_ARB_fragment_program }, + + { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */ + CONTEXT_INT(Program.ErrorPos), + extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + + /* GL_ARB_fragment_program */ + { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled), + extra_ARB_fragment_program }, + + /* GL_EXT_depth_bounds_test */ + { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), + extra_EXT_depth_bounds_test }, + { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin), + extra_EXT_depth_bounds_test }, + + /* GL_ARB_depth_clamp*/ + { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp), + extra_ARB_depth_clamp }, + + /* GL_ARB_draw_buffers */ + { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, + { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER4_ARB, BUFFER_ENUM(ColorDrawBuffer[4]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER5_ARB, BUFFER_ENUM(ColorDrawBuffer[5]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER6_ARB, BUFFER_ENUM(ColorDrawBuffer[6]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER7_ARB, BUFFER_ENUM(ColorDrawBuffer[7]), + extra_valid_draw_buffer }, + + /* GL_ATI_fragment_shader */ + { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader }, + { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader }, + { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader }, + { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader }, + { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader }, + { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader }, + { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader }, + { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI, + CONST(3), extra_ATI_fragment_shader }, + + /* GL_EXT_framebuffer_object */ + { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments), + extra_EXT_framebuffer_object }, + + /* GL_EXT_framebuffer_blit + * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */ + { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_framebuffer_blit }, + + /* GL_EXT_provoking_vertex */ + { GL_PROVOKING_VERTEX_EXT, + CONTEXT_BOOL(Light.ProvokingVertex), extra_EXT_provoking_vertex }, + { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT, + CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention), + extra_EXT_provoking_vertex }, + + /* GL_ARB_framebuffer_object */ + { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples), + extra_ARB_framebuffer_object_EXT_framebuffer_multisample }, + + /* GL_APPLE_vertex_array_object */ + { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name), + extra_APPLE_vertex_array_object }, + + /* GL_ARB_seamless_cube_map */ + { GL_TEXTURE_CUBE_MAP_SEAMLESS, + CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map }, + + /* GL_ARB_sync */ + { GL_MAX_SERVER_WAIT_TIMEOUT, + CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync }, + + /* GL_EXT_texture_integer */ + { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor), + extra_EXT_texture_integer }, + + /* GL_EXT_transform_feedback */ + { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_transform_feedback }, + { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, + CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, + CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, + CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), + extra_EXT_transform_feedback }, + + /* GL_ARB_transform_feedback2 */ + { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0, + extra_ARB_transform_feedback2 }, + { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0, + extra_ARB_transform_feedback2 }, + { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_transform_feedback2 }, + + /* GL_ARB_geometry_shader4 */ + { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryTextureImageUnits), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryOutputVertices), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryTotalOutputComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryUniformComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryVaryingComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxVertexVaryingComponents), + extra_ARB_geometry_shader4 }, + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + { GL_MIN_PROGRAM_TEXEL_OFFSET, + CONTEXT_INT(Const.MinProgramTexelOffset), + extra_EXT_gpu_shader4 }, + { GL_MAX_PROGRAM_TEXEL_OFFSET, + CONTEXT_INT(Const.MaxProgramTexelOffset), + extra_EXT_gpu_shader4 }, + + /* GL 3.0 */ + { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, + { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, + { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, + { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, + + /* GL 3.1 */ + /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV + * vs. GL_PRIMITIVE_RESTART! + */ + { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart), + extra_version_31 }, + { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex), + extra_version_31 }, + + + /* GL 3.2 */ + { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask), + extra_version_32 }, +#endif /* FEATURE_GL */ +}; + +/* All we need now is a way to look up the value struct from the enum. + * The code generated by gcc for the old generated big switch + * statement is a big, balanced, open coded if/else tree, essentially + * an unrolled binary search. It would be natural to sort the new + * enum table and use bsearch(), but we will use a read-only hash + * table instead. bsearch() has a nice guaranteed worst case + * performance, but we're also guaranteed to hit that worst case + * (log2(n) iterations) for about half the enums. Instead, using an + * open addressing hash table, we can find the enum on the first try + * for 80% of the enums, 1 collision for 10% and never more than 5 + * collisions for any enum (typical numbers). And the code is very + * simple, even though it feels a little magic. */ + +static unsigned short table[1024]; +static const int prime_factor = 89, prime_step = 281; + +#ifdef GET_DEBUG +static void +print_table_stats(void) +{ + int i, j, collisions[11], count, hash, mask; + const struct value_desc *d; + + count = 0; + mask = Elements(table) - 1; + memset(collisions, 0, sizeof collisions); + + for (i = 0; i < Elements(table); i++) { + if (!table[i]) + continue; + count++; + d = &values[table[i]]; + hash = (d->pname * prime_factor); + j = 0; + while (1) { + if (values[table[hash & mask]].pname == d->pname) + break; + hash += prime_step; + j++; + } + + if (j < 10) + collisions[j]++; + else + collisions[10]++; + } + + printf("number of enums: %d (total %d)\n", count, Elements(values)); + for (i = 0; i < Elements(collisions) - 1; i++) + if (collisions[i] > 0) + printf(" %d enums with %d %scollisions\n", + collisions[i], i, i == 10 ? "or more " : ""); +} +#endif + +/** + * Initialize the enum hash for a given API + * + * This is called from one_time_init() to insert the enum values that + * are valid for the API in question into the enum hash table. + * + * \param the current context, for determining the API in question + */ +void _mesa_init_get_hash(struct gl_context *ctx) +{ + int i, hash, index, mask; + int api_mask = 0, api_bit; + + mask = Elements(table) - 1; + api_bit = 1 << ctx->API; + + for (i = 0; i < Elements(values); i++) { + if (values[i].type == TYPE_API_MASK) { + api_mask = values[i].offset; + continue; + } + if (!(api_mask & api_bit)) + continue; + + hash = (values[i].pname * prime_factor) & mask; + while (1) { + index = hash & mask; + if (!table[index]) { + table[index] = i; + break; + } + hash += prime_step; + } + } + +#ifdef GET_DEBUG + print_table_stats(); +#endif +} + +/** + * Handle irregular enums + * + * Some values don't conform to the "well-known type at context + * pointer + offset" pattern, so we have this function to catch all + * the corner cases. Typically, it's a computed value or a one-off + * pointer to a custom struct or something. + * + * In this case we can't return a pointer to the value, so we'll have + * to use the temporary variable 'v' declared back in the calling + * glGet*v() function to store the result. + * + * \param ctx the current context + * \param d the struct value_desc that describes the enum + * \param v pointer to the tmp declared in the calling glGet*v() function + */ +static void +find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) +{ + struct gl_buffer_object *buffer_obj; + struct gl_client_array *array; + GLuint unit, *p; + + switch (d->pname) { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_RECTANGLE_NV: + v->value_bool = _mesa_IsEnabled(d->pname); + break; + + case GL_LINE_STIPPLE_PATTERN: + /* This is the only GLushort, special case it here by promoting + * to an int rather than introducing a new type. */ + v->value_int = ctx->Line.StipplePattern; + break; + + case GL_CURRENT_RASTER_TEXTURE_COORDS: + unit = ctx->Texture.CurrentUnit; + v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; + v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; + v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; + v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; + break; + + case GL_CURRENT_TEXTURE_COORDS: + unit = ctx->Texture.CurrentUnit; + v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; + v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; + v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; + v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; + break; + + case GL_COLOR_WRITEMASK: + v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; + v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; + v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; + v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; + break; + + case GL_EDGE_FLAG: + v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0; + break; + + case GL_READ_BUFFER: + v->value_enum = ctx->ReadBuffer->ColorReadBuffer; + break; + + case GL_MAP2_GRID_DOMAIN: + v->value_float_4[0] = ctx->Eval.MapGrid2u1; + v->value_float_4[1] = ctx->Eval.MapGrid2u2; + v->value_float_4[2] = ctx->Eval.MapGrid2v1; + v->value_float_4[3] = ctx->Eval.MapGrid2v2; + break; + + case GL_TEXTURE_STACK_DEPTH: + unit = ctx->Texture.CurrentUnit; + v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; + break; + case GL_TEXTURE_MATRIX: + unit = ctx->Texture.CurrentUnit; + v->value_matrix = ctx->TextureMatrixStack[unit].Top; + break; + + case GL_TEXTURE_COORD_ARRAY: + case GL_TEXTURE_COORD_ARRAY_SIZE: + case GL_TEXTURE_COORD_ARRAY_TYPE: + case GL_TEXTURE_COORD_ARRAY_STRIDE: + array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]; + v->value_int = *(GLuint *) ((char *) array + d->offset); + break; + + case GL_ACTIVE_TEXTURE_ARB: + v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; + break; + case GL_CLIENT_ACTIVE_TEXTURE_ARB: + v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; + break; + + case GL_MODELVIEW_STACK_DEPTH: + case GL_PROJECTION_STACK_DEPTH: + v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; + break; + + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_3D_TEXTURE_SIZE: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + p = (GLuint *) ((char *) ctx + d->offset); + v->value_int = 1 << (*p - 1); + break; + + case GL_SCISSOR_BOX: + v->value_int_4[0] = ctx->Scissor.X; + v->value_int_4[1] = ctx->Scissor.Y; + v->value_int_4[2] = ctx->Scissor.Width; + v->value_int_4[3] = ctx->Scissor.Height; + break; + + case GL_LIST_INDEX: + v->value_int = + ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; + break; + case GL_LIST_MODE: + if (!ctx->CompileFlag) + v->value_enum = 0; + else if (ctx->ExecuteFlag) + v->value_enum = GL_COMPILE_AND_EXECUTE; + else + v->value_enum = GL_COMPILE; + break; + + case GL_VIEWPORT: + v->value_int_4[0] = ctx->Viewport.X; + v->value_int_4[1] = ctx->Viewport.Y; + v->value_int_4[2] = ctx->Viewport.Width; + v->value_int_4[3] = ctx->Viewport.Height; + break; + + case GL_ACTIVE_STENCIL_FACE_EXT: + v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; + break; + + case GL_STENCIL_FAIL: + v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_FUNC: + v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_PASS_DEPTH_PASS: + v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_REF: + v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_VALUE_MASK: + v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_WRITEMASK: + v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; + break; + + case GL_NUM_EXTENSIONS: + v->value_int = _mesa_get_extension_count(ctx); + break; + + case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: + v->value_int = _mesa_get_color_read_type(ctx); + break; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: + v->value_int = _mesa_get_color_read_format(ctx); + break; + + case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: + v->value_int = ctx->CurrentStack->Depth + 1; + break; + case GL_CURRENT_MATRIX_ARB: + case GL_TRANSPOSE_CURRENT_MATRIX_ARB: + v->value_matrix = ctx->CurrentStack->Top; + break; + + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + v->value_int_n.n = + _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE); + ASSERT(v->value_int_n.n <= 100); + break; + + case GL_MAX_VARYING_FLOATS_ARB: + v->value_int = ctx->Const.MaxVarying * 4; + break; + + /* Various object names */ + + case GL_TEXTURE_BINDING_1D: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_3D: + case GL_TEXTURE_BINDING_1D_ARRAY_EXT: + case GL_TEXTURE_BINDING_2D_ARRAY_EXT: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + unit = ctx->Texture.CurrentUnit; + v->value_int = + ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; + break; + + /* GL_ARB_vertex_buffer_object */ + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + buffer_obj = (struct gl_buffer_object *) + ((char *) ctx->Array.ArrayObj + d->offset); + v->value_int = buffer_obj->Name; + break; + case GL_ARRAY_BUFFER_BINDING_ARB: + v->value_int = ctx->Array.ArrayBufferObj->Name; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + v->value_int = + ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + v->value_int = ctx->Array.ElementArrayBufferObj->Name; + break; + + /* ARB_copy_buffer */ + case GL_COPY_READ_BUFFER: + v->value_int = ctx->CopyReadBuffer->Name; + break; + case GL_COPY_WRITE_BUFFER: + v->value_int = ctx->CopyWriteBuffer->Name; + break; + + case GL_FRAGMENT_PROGRAM_BINDING_NV: + v->value_int = + ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; + break; + case GL_VERTEX_PROGRAM_BINDING_NV: + v->value_int = + ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0; + break; + case GL_PIXEL_PACK_BUFFER_BINDING_EXT: + v->value_int = ctx->Pack.BufferObj->Name; + break; + case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: + v->value_int = ctx->Unpack.BufferObj->Name; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: + v->value_int = ctx->TransformFeedback.CurrentObject->Paused; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: + v->value_int = ctx->TransformFeedback.CurrentObject->Active; + break; + case GL_TRANSFORM_FEEDBACK_BINDING: + v->value_int = ctx->TransformFeedback.CurrentObject->Name; + break; + case GL_CURRENT_PROGRAM: + v->value_int = + ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; + break; + case GL_READ_FRAMEBUFFER_BINDING_EXT: + v->value_int = ctx->ReadBuffer->Name; + break; + case GL_RENDERBUFFER_BINDING_EXT: + v->value_int = + ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; + break; + case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: + v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name; + break; + + case GL_MAX_VERTEX_UNIFORM_VECTORS: + v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4; + break; + + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4; + break; + } +} + +/** + * Check extra constraints on a struct value_desc descriptor + * + * If a struct value_desc has a non-NULL extra pointer, it means that + * there are a number of extra constraints to check or actions to + * perform. The extras is just an integer array where each integer + * encode different constraints or actions. + * + * \param ctx current context + * \param func name of calling glGet*v() function for error reporting + * \param d the struct value_desc that has the extra constraints + * + * \return GL_FALSE if one of the constraints was not satisfied, + * otherwise GL_TRUE. + */ +static GLboolean +check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) +{ + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; + int total, enabled; + const int *e; + + total = 0; + enabled = 0; + for (e = d->extra; *e != EXTRA_END; e++) + switch (*e) { + case EXTRA_VERSION_30: + if (version >= 30) { + total++; + enabled++; + } + break; + case EXTRA_VERSION_31: + if (version >= 31) { + total++; + enabled++; + } + break; + case EXTRA_VERSION_32: + if (version >= 32) { + total++; + enabled++; + } + break; + case EXTRA_VERSION_ES2: + if (ctx->API == API_OPENGLES2) { + total++; + enabled++; + } + break; + case EXTRA_NEW_BUFFERS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); + break; + case EXTRA_FLUSH_CURRENT: + FLUSH_CURRENT(ctx, 0); + break; + case EXTRA_VALID_DRAW_BUFFER: + if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", + func, d->pname - GL_DRAW_BUFFER0_ARB); + return GL_FALSE; + } + break; + case EXTRA_VALID_TEXTURE_UNIT: + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", + func, ctx->Texture.CurrentUnit); + return GL_FALSE; + } + break; + case EXTRA_END: + break; + default: /* *e is a offset into the extension struct */ + total++; + if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) + enabled++; + break; + } + + if (total > 0 && enabled == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(d->pname)); + return GL_FALSE; + } + + return GL_TRUE; +} + +static const struct value_desc error_value = + { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; + +/** + * Find the struct value_desc corresponding to the enum 'pname'. + * + * We hash the enum value to get an index into the 'table' array, + * which holds the index in the 'values' array of struct value_desc. + * Once we've found the entry, we do the extra checks, if any, then + * look up the value and return a pointer to it. + * + * If the value has to be computed (for example, it's the result of a + * function call or we need to add 1 to it), we use the tmp 'v' to + * store the result. + * + * \param func name of glGet*v() func for error reporting + * \param pname the enum value we're looking up + * \param p is were we return the pointer to the value + * \param v a tmp union value variable in the calling glGet*v() function + * + * \return the struct value_desc corresponding to the enum or a struct + * value_desc of TYPE_INVALID if not found. This lets the calling + * glGet*v() function jump right into a switch statement and + * handle errors there instead of having to check for NULL. + */ +static const struct value_desc * +find_value(const char *func, GLenum pname, void **p, union value *v) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *unit; + int mask, hash; + const struct value_desc *d; + + mask = Elements(table) - 1; + hash = (pname * prime_factor); + while (1) { + d = &values[table[hash & mask]]; + + /* If the enum isn't valid, the hash walk ends with index 0, + * which is the API mask entry at the beginning of values[]. */ + if (unlikely(d->type == TYPE_API_MASK)) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return &error_value; + } + + if (likely(d->pname == pname)) + break; + + hash += prime_step; + } + + if (unlikely(d->extra && !check_extra(ctx, func, d))) + return &error_value; + + switch (d->location) { + case LOC_BUFFER: + *p = ((char *) ctx->DrawBuffer + d->offset); + return d; + case LOC_CONTEXT: + *p = ((char *) ctx + d->offset); + return d; + case LOC_ARRAY: + *p = ((char *) ctx->Array.ArrayObj + d->offset); + return d; + case LOC_TEXUNIT: + unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + *p = ((char *) unit + d->offset); + return d; + case LOC_CUSTOM: + find_custom_value(ctx, d, v); + *p = v; + return d; + default: + assert(0); + break; + } + + /* silence warning */ + return &error_value; +} + +static const int transpose[] = { + 0, 4, 8, 12, + 1, 5, 9, 13, + 2, 6, 10, 14, + 3, 7, 11, 15 +}; + +void GLAPIENTRY +_mesa_GetBooleanv(GLenum pname, GLboolean *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetBooleanv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = INT_TO_BOOLEAN(d->offset); + break; + + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); + break; + + case TYPE_BOOLEAN: + params[0] = ((GLboolean*) p)[0]; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_BOOLEAN(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } +} + +void GLAPIENTRY +_mesa_GetFloatv(GLenum pname, GLfloat *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetFloatv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = (GLfloat) d->offset; + break; + + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = ((GLfloat *) p)[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = ((GLfloat *) p)[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = ((GLfloat *) p)[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = ((GLfloat *) p)[0]; + break; + + case TYPE_DOUBLEN: + params[0] = ((GLdouble *) p)[0]; + break; + + case TYPE_INT_4: + params[3] = (GLfloat) (((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = (GLfloat) (((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = (GLfloat) (((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = (GLfloat) (((GLint *) p)[0]); + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[i]; + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[transpose[i]]; + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); + break; + } +} + +void GLAPIENTRY +_mesa_GetIntegerv(GLenum pname, GLint *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetIntegerv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; + + case TYPE_FLOAT_4: + params[3] = IROUND(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + params[2] = IROUND(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + params[1] = IROUND(((GLfloat *) p)[1]); + case TYPE_FLOAT: + params[0] = IROUND(((GLfloat *) p)[0]); + break; + + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); + case TYPE_FLOATN: + params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = v.value_int_n.ints[i]; + break; + + case TYPE_INT64: + params[0] = INT64_TO_INT(((GLint64 *) p)[0]); + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } +} + +#if FEATURE_ARB_sync +void GLAPIENTRY +_mesa_GetInteger64v(GLenum pname, GLint64 *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetInteger64v", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; + + case TYPE_FLOAT_4: + params[3] = IROUND64(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + params[2] = IROUND64(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + params[1] = IROUND64(((GLfloat *) p)[1]); + case TYPE_FLOAT: + params[0] = IROUND64(((GLfloat *) p)[0]); + break; + + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]); + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]); + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]); + case TYPE_FLOATN: + params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = ((GLboolean*) p)[0]; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT64(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } +} +#endif /* FEATURE_ARB_sync */ + +void GLAPIENTRY +_mesa_GetDoublev(GLenum pname, GLdouble *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetDoublev", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; + + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = ((GLfloat *) p)[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = ((GLfloat *) p)[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = ((GLfloat *) p)[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = ((GLfloat *) p)[0]; + break; + + case TYPE_DOUBLEN: + params[0] = ((GLdouble *) p)[0]; + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = v.value_int_n.ints[i]; + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = *(GLboolean*) p; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[i]; + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[transpose[i]]; + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } +} + +static enum value_type +find_value_indexed(const char *func, GLenum pname, int index, union value *v) +{ + GET_CURRENT_CONTEXT(ctx); + + switch (pname) { + + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.EXT_draw_buffers2) + goto invalid_enum; + v->value_int = (ctx->Color.BlendEnabled >> index) & 1; + return TYPE_INT; + + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.EXT_draw_buffers2) + goto invalid_enum; + v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; + v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; + v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; + v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; + return TYPE_INT_4; + + case GL_TRANSFORM_FEEDBACK_BUFFER_START: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; + return TYPE_INT64; + + case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index]; + return TYPE_INT64; + + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name; + return TYPE_INT; + } + + invalid_enum: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return TYPE_INVALID; + invalid_value: + _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return TYPE_INVALID; +} + +void GLAPIENTRY +_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) +{ + union value v; + + switch (find_value_indexed("glGetBooleanIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = INT_TO_BOOLEAN(v.value_int); + break; + case TYPE_INT_4: + params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); + params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); + params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); + params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); + break; + case TYPE_INT64: + params[0] = INT64_TO_BOOLEAN(v.value_int); + break; + default: + assert(0); + } +} + +void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) +{ + union value v; + + switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = v.value_int; + break; + case TYPE_INT_4: + params[0] = v.value_int_4[0]; + params[1] = v.value_int_4[1]; + params[2] = v.value_int_4[2]; + params[3] = v.value_int_4[3]; + break; + case TYPE_INT64: + params[0] = INT64_TO_INT(v.value_int); + break; + default: + assert(0); + } +} + +#if FEATURE_ARB_sync +void GLAPIENTRY +_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) +{ + union value v; + + switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = v.value_int; + break; + case TYPE_INT_4: + params[0] = v.value_int_4[0]; + params[1] = v.value_int_4[1]; + params[2] = v.value_int_4[2]; + params[3] = v.value_int_4[3]; + break; + case TYPE_INT64: + params[0] = v.value_int; + break; + default: + assert(0); + } +} +#endif /* FEATURE_ARB_sync */ + +#if FEATURE_ES1 +void GLAPIENTRY +_mesa_GetFixedv(GLenum pname, GLfixed *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetDoublev", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = INT_TO_FIXED(d->offset); + break; + + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = INT_TO_FIXED(((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = INT_TO_FIXED(((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = INT_TO_FIXED(((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = INT_TO_FIXED(((GLint *) p)[0]); + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_FIXED(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); + break; + } +} +#endif diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c index 3910047fb..103a4942a 100644 --- a/mesalib/src/mesa/main/getstring.c +++ b/mesalib/src/mesa/main/getstring.c @@ -1,251 +1,251 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#include "glheader.h" -#include "context.h" -#include "get.h" -#include "enums.h" -#include "extensions.h" - - -/** - * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. - */ -static const GLubyte * -shading_language_version(GLcontext *ctx) -{ - switch (ctx->API) { - case API_OPENGL: - if (!ctx->Extensions.ARB_shader_objects) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetString"); - return (const GLubyte *) 0; - } - - switch (ctx->Const.GLSLVersion) { - case 110: - return (const GLubyte *) "1.10"; - case 120: - return (const GLubyte *) "1.20"; - case 130: - return (const GLubyte *) "1.30"; - default: - _mesa_problem(ctx, - "Invalid GLSL version in shading_language_version()"); - return (const GLubyte *) 0; - } - break; - - case API_OPENGLES2: - return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"; - - case API_OPENGLES: - /* fall-through */ - - default: - _mesa_problem(ctx, "Unexpected API value in shading_language_version()"); - return (const GLubyte *) 0; - } -} - - -/** - * Query string-valued state. The return value should _not_ be freed by - * the caller. - * - * \param name the state variable to query. - * - * \sa glGetString(). - * - * Tries to get the string from dd_function_table::GetString, otherwise returns - * the hardcoded strings. - */ -const GLubyte * GLAPIENTRY -_mesa_GetString( GLenum name ) -{ - GET_CURRENT_CONTEXT(ctx); - static const char *vendor = "Brian Paul"; - static const char *renderer = "Mesa"; - - if (!ctx) - return NULL; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - /* this is a required driver function */ - assert(ctx->Driver.GetString); - { - /* Give the driver the chance to handle this query */ - const GLubyte *str = (*ctx->Driver.GetString)(ctx, name); - if (str) - return str; - } - - switch (name) { - case GL_VENDOR: - return (const GLubyte *) vendor; - case GL_RENDERER: - return (const GLubyte *) renderer; - case GL_VERSION: - return (const GLubyte *) ctx->VersionString; - case GL_EXTENSIONS: - return (const GLubyte *) ctx->Extensions.String; -#if FEATURE_ARB_shading_language_100 || FEATURE_ES2 - case GL_SHADING_LANGUAGE_VERSION: - return shading_language_version(ctx); -#endif -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ - FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_PROGRAM_ERROR_STRING_NV: - if (ctx->Extensions.NV_fragment_program || - ctx->Extensions.ARB_fragment_program || - ctx->Extensions.NV_vertex_program || - ctx->Extensions.ARB_vertex_program) { - return (const GLubyte *) ctx->Program.ErrorString; - } - /* FALL-THROUGH */ -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); - return (const GLubyte *) 0; - } -} - - -/** - * GL3 - */ -const GLubyte * GLAPIENTRY -_mesa_GetStringi(GLenum name, GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!ctx) - return NULL; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); - - switch (name) { - case GL_EXTENSIONS: - if (index >= _mesa_get_extension_count(ctx)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index); - return (const GLubyte *) 0; - } - return _mesa_get_enabled_extension(ctx, index); - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); - return (const GLubyte *) 0; - } -} - - - -/** - * Return pointer-valued state, such as a vertex array pointer. - * - * \param pname names state to be queried - * \param params returns the pointer value - * - * \sa glGetPointerv(). - * - * Tries to get the specified pointer via dd_function_table::GetPointerv, - * otherwise gets the specified pointer from the current context. - */ -void GLAPIENTRY -_mesa_GetPointerv( GLenum pname, GLvoid **params ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint clientUnit = ctx->Array.ActiveTexture; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!params) - return; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); - - switch (pname) { - case GL_VERTEX_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr; - break; - case GL_NORMAL_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr; - break; - case GL_COLOR_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr; - break; - case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: - *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr; - break; - case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: - *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr; - break; - case GL_INDEX_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr; - break; - case GL_TEXTURE_COORD_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr; - break; - case GL_EDGE_FLAG_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr; - break; - case GL_FEEDBACK_BUFFER_POINTER: - *params = ctx->Feedback.Buffer; - break; - case GL_SELECTION_BUFFER_POINTER: - *params = ctx->Select.Buffer; - break; -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_POINTER_OES: - *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr; - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); - return; - } -} - - -/** - * Returns the current GL error code, or GL_NO_ERROR. - * \return current error code - * - * Returns __GLcontextRec::ErrorValue. - */ -GLenum GLAPIENTRY -_mesa_GetError( void ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum e = ctx->ErrorValue; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); - - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - ctx->ErrorDebugCount = 0; - return e; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#include "glheader.h" +#include "context.h" +#include "get.h" +#include "enums.h" +#include "extensions.h" + + +/** + * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. + */ +static const GLubyte * +shading_language_version(struct gl_context *ctx) +{ + switch (ctx->API) { + case API_OPENGL: + if (!ctx->Extensions.ARB_shader_objects) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetString"); + return (const GLubyte *) 0; + } + + switch (ctx->Const.GLSLVersion) { + case 110: + return (const GLubyte *) "1.10"; + case 120: + return (const GLubyte *) "1.20"; + case 130: + return (const GLubyte *) "1.30"; + default: + _mesa_problem(ctx, + "Invalid GLSL version in shading_language_version()"); + return (const GLubyte *) 0; + } + break; + + case API_OPENGLES2: + return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"; + + case API_OPENGLES: + /* fall-through */ + + default: + _mesa_problem(ctx, "Unexpected API value in shading_language_version()"); + return (const GLubyte *) 0; + } +} + + +/** + * Query string-valued state. The return value should _not_ be freed by + * the caller. + * + * \param name the state variable to query. + * + * \sa glGetString(). + * + * Tries to get the string from dd_function_table::GetString, otherwise returns + * the hardcoded strings. + */ +const GLubyte * GLAPIENTRY +_mesa_GetString( GLenum name ) +{ + GET_CURRENT_CONTEXT(ctx); + static const char *vendor = "Brian Paul"; + static const char *renderer = "Mesa"; + + if (!ctx) + return NULL; + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); + + /* this is a required driver function */ + assert(ctx->Driver.GetString); + { + /* Give the driver the chance to handle this query */ + const GLubyte *str = (*ctx->Driver.GetString)(ctx, name); + if (str) + return str; + } + + switch (name) { + case GL_VENDOR: + return (const GLubyte *) vendor; + case GL_RENDERER: + return (const GLubyte *) renderer; + case GL_VERSION: + return (const GLubyte *) ctx->VersionString; + case GL_EXTENSIONS: + return (const GLubyte *) ctx->Extensions.String; +#if FEATURE_ARB_shading_language_100 || FEATURE_ES2 + case GL_SHADING_LANGUAGE_VERSION: + return shading_language_version(ctx); +#endif +#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ + FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + case GL_PROGRAM_ERROR_STRING_NV: + if (ctx->Extensions.NV_fragment_program || + ctx->Extensions.ARB_fragment_program || + ctx->Extensions.NV_vertex_program || + ctx->Extensions.ARB_vertex_program) { + return (const GLubyte *) ctx->Program.ErrorString; + } + /* FALL-THROUGH */ +#endif + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); + return (const GLubyte *) 0; + } +} + + +/** + * GL3 + */ +const GLubyte * GLAPIENTRY +_mesa_GetStringi(GLenum name, GLuint index) +{ + GET_CURRENT_CONTEXT(ctx); + + if (!ctx) + return NULL; + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); + + switch (name) { + case GL_EXTENSIONS: + if (index >= _mesa_get_extension_count(ctx)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index); + return (const GLubyte *) 0; + } + return _mesa_get_enabled_extension(ctx, index); + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); + return (const GLubyte *) 0; + } +} + + + +/** + * Return pointer-valued state, such as a vertex array pointer. + * + * \param pname names state to be queried + * \param params returns the pointer value + * + * \sa glGetPointerv(). + * + * Tries to get the specified pointer via dd_function_table::GetPointerv, + * otherwise gets the specified pointer from the current context. + */ +void GLAPIENTRY +_mesa_GetPointerv( GLenum pname, GLvoid **params ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint clientUnit = ctx->Array.ActiveTexture; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!params) + return; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); + + switch (pname) { + case GL_VERTEX_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr; + break; + case GL_NORMAL_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr; + break; + case GL_COLOR_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr; + break; + case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: + *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr; + break; + case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: + *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr; + break; + case GL_INDEX_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr; + break; + case GL_TEXTURE_COORD_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr; + break; + case GL_EDGE_FLAG_ARRAY_POINTER: + *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr; + break; + case GL_FEEDBACK_BUFFER_POINTER: + *params = ctx->Feedback.Buffer; + break; + case GL_SELECTION_BUFFER_POINTER: + *params = ctx->Select.Buffer; + break; +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_POINTER_OES: + *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr; + break; +#endif + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); + return; + } +} + + +/** + * Returns the current GL error code, or GL_NO_ERROR. + * \return current error code + * + * Returns __struct gl_contextRec::ErrorValue. + */ +GLenum GLAPIENTRY +_mesa_GetError( void ) +{ + GET_CURRENT_CONTEXT(ctx); + GLenum e = ctx->ErrorValue; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); + + ctx->ErrorValue = (GLenum) GL_NO_ERROR; + ctx->ErrorDebugCount = 0; + return e; +} diff --git a/mesalib/src/mesa/main/glapidispatch.h b/mesalib/src/mesa/main/glapidispatch.h new file mode 100644 index 000000000..140ea831c --- /dev/null +++ b/mesalib/src/mesa/main/glapidispatch.h @@ -0,0 +1,4548 @@ +/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */ + +/* + * (C) Copyright IBM Corporation 2005 + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if !defined( _GLAPI_DISPATCH_H_ ) +# define _GLAPI_DISPATCH_H_ + + +/* this file should not be included directly in mesa */ + +/** + * \file glapidispatch.h + * Macros for handling GL dispatch tables. + * + * For each known GL function, there are 3 macros in this file. The first + * macro is named CALL_FuncName and is used to call that GL function using + * the specified dispatch table. The other 2 macros, called GET_FuncName + * can SET_FuncName, are used to get and set the dispatch pointer for the + * named function in the specified dispatch table. + */ + +#define CALL_by_offset(disp, cast, offset, parameters) \ + (*(cast (GET_by_offset(disp, offset)))) parameters +#define GET_by_offset(disp, offset) \ + (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL +#define SET_by_offset(disp, offset, fn) \ + do { \ + if ( (offset) < 0 ) { \ + /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\n", */ \ + /* __func__, __LINE__, disp, offset, # fn); */ \ + /* abort(); */ \ + } \ + else { \ + ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \ + } \ + } while(0) + +/* total number of offsets below */ +#define _gloffset_COUNT 881 + +#define _gloffset_NewList 0 +#define _gloffset_EndList 1 +#define _gloffset_CallList 2 +#define _gloffset_CallLists 3 +#define _gloffset_DeleteLists 4 +#define _gloffset_GenLists 5 +#define _gloffset_ListBase 6 +#define _gloffset_Begin 7 +#define _gloffset_Bitmap 8 +#define _gloffset_Color3b 9 +#define _gloffset_Color3bv 10 +#define _gloffset_Color3d 11 +#define _gloffset_Color3dv 12 +#define _gloffset_Color3f 13 +#define _gloffset_Color3fv 14 +#define _gloffset_Color3i 15 +#define _gloffset_Color3iv 16 +#define _gloffset_Color3s 17 +#define _gloffset_Color3sv 18 +#define _gloffset_Color3ub 19 +#define _gloffset_Color3ubv 20 +#define _gloffset_Color3ui 21 +#define _gloffset_Color3uiv 22 +#define _gloffset_Color3us 23 +#define _gloffset_Color3usv 24 +#define _gloffset_Color4b 25 +#define _gloffset_Color4bv 26 +#define _gloffset_Color4d 27 +#define _gloffset_Color4dv 28 +#define _gloffset_Color4f 29 +#define _gloffset_Color4fv 30 +#define _gloffset_Color4i 31 +#define _gloffset_Color4iv 32 +#define _gloffset_Color4s 33 +#define _gloffset_Color4sv 34 +#define _gloffset_Color4ub 35 +#define _gloffset_Color4ubv 36 +#define _gloffset_Color4ui 37 +#define _gloffset_Color4uiv 38 +#define _gloffset_Color4us 39 +#define _gloffset_Color4usv 40 +#define _gloffset_EdgeFlag 41 +#define _gloffset_EdgeFlagv 42 +#define _gloffset_End 43 +#define _gloffset_Indexd 44 +#define _gloffset_Indexdv 45 +#define _gloffset_Indexf 46 +#define _gloffset_Indexfv 47 +#define _gloffset_Indexi 48 +#define _gloffset_Indexiv 49 +#define _gloffset_Indexs 50 +#define _gloffset_Indexsv 51 +#define _gloffset_Normal3b 52 +#define _gloffset_Normal3bv 53 +#define _gloffset_Normal3d 54 +#define _gloffset_Normal3dv 55 +#define _gloffset_Normal3f 56 +#define _gloffset_Normal3fv 57 +#define _gloffset_Normal3i 58 +#define _gloffset_Normal3iv 59 +#define _gloffset_Normal3s 60 +#define _gloffset_Normal3sv 61 +#define _gloffset_RasterPos2d 62 +#define _gloffset_RasterPos2dv 63 +#define _gloffset_RasterPos2f 64 +#define _gloffset_RasterPos2fv 65 +#define _gloffset_RasterPos2i 66 +#define _gloffset_RasterPos2iv 67 +#define _gloffset_RasterPos2s 68 +#define _gloffset_RasterPos2sv 69 +#define _gloffset_RasterPos3d 70 +#define _gloffset_RasterPos3dv 71 +#define _gloffset_RasterPos3f 72 +#define _gloffset_RasterPos3fv 73 +#define _gloffset_RasterPos3i 74 +#define _gloffset_RasterPos3iv 75 +#define _gloffset_RasterPos3s 76 +#define _gloffset_RasterPos3sv 77 +#define _gloffset_RasterPos4d 78 +#define _gloffset_RasterPos4dv 79 +#define _gloffset_RasterPos4f 80 +#define _gloffset_RasterPos4fv 81 +#define _gloffset_RasterPos4i 82 +#define _gloffset_RasterPos4iv 83 +#define _gloffset_RasterPos4s 84 +#define _gloffset_RasterPos4sv 85 +#define _gloffset_Rectd 86 +#define _gloffset_Rectdv 87 +#define _gloffset_Rectf 88 +#define _gloffset_Rectfv 89 +#define _gloffset_Recti 90 +#define _gloffset_Rectiv 91 +#define _gloffset_Rects 92 +#define _gloffset_Rectsv 93 +#define _gloffset_TexCoord1d 94 +#define _gloffset_TexCoord1dv 95 +#define _gloffset_TexCoord1f 96 +#define _gloffset_TexCoord1fv 97 +#define _gloffset_TexCoord1i 98 +#define _gloffset_TexCoord1iv 99 +#define _gloffset_TexCoord1s 100 +#define _gloffset_TexCoord1sv 101 +#define _gloffset_TexCoord2d 102 +#define _gloffset_TexCoord2dv 103 +#define _gloffset_TexCoord2f 104 +#define _gloffset_TexCoord2fv 105 +#define _gloffset_TexCoord2i 106 +#define _gloffset_TexCoord2iv 107 +#define _gloffset_TexCoord2s 108 +#define _gloffset_TexCoord2sv 109 +#define _gloffset_TexCoord3d 110 +#define _gloffset_TexCoord3dv 111 +#define _gloffset_TexCoord3f 112 +#define _gloffset_TexCoord3fv 113 +#define _gloffset_TexCoord3i 114 +#define _gloffset_TexCoord3iv 115 +#define _gloffset_TexCoord3s 116 +#define _gloffset_TexCoord3sv 117 +#define _gloffset_TexCoord4d 118 +#define _gloffset_TexCoord4dv 119 +#define _gloffset_TexCoord4f 120 +#define _gloffset_TexCoord4fv 121 +#define _gloffset_TexCoord4i 122 +#define _gloffset_TexCoord4iv 123 +#define _gloffset_TexCoord4s 124 +#define _gloffset_TexCoord4sv 125 +#define _gloffset_Vertex2d 126 +#define _gloffset_Vertex2dv 127 +#define _gloffset_Vertex2f 128 +#define _gloffset_Vertex2fv 129 +#define _gloffset_Vertex2i 130 +#define _gloffset_Vertex2iv 131 +#define _gloffset_Vertex2s 132 +#define _gloffset_Vertex2sv 133 +#define _gloffset_Vertex3d 134 +#define _gloffset_Vertex3dv 135 +#define _gloffset_Vertex3f 136 +#define _gloffset_Vertex3fv 137 +#define _gloffset_Vertex3i 138 +#define _gloffset_Vertex3iv 139 +#define _gloffset_Vertex3s 140 +#define _gloffset_Vertex3sv 141 +#define _gloffset_Vertex4d 142 +#define _gloffset_Vertex4dv 143 +#define _gloffset_Vertex4f 144 +#define _gloffset_Vertex4fv 145 +#define _gloffset_Vertex4i 146 +#define _gloffset_Vertex4iv 147 +#define _gloffset_Vertex4s 148 +#define _gloffset_Vertex4sv 149 +#define _gloffset_ClipPlane 150 +#define _gloffset_ColorMaterial 151 +#define _gloffset_CullFace 152 +#define _gloffset_Fogf 153 +#define _gloffset_Fogfv 154 +#define _gloffset_Fogi 155 +#define _gloffset_Fogiv 156 +#define _gloffset_FrontFace 157 +#define _gloffset_Hint 158 +#define _gloffset_Lightf 159 +#define _gloffset_Lightfv 160 +#define _gloffset_Lighti 161 +#define _gloffset_Lightiv 162 +#define _gloffset_LightModelf 163 +#define _gloffset_LightModelfv 164 +#define _gloffset_LightModeli 165 +#define _gloffset_LightModeliv 166 +#define _gloffset_LineStipple 167 +#define _gloffset_LineWidth 168 +#define _gloffset_Materialf 169 +#define _gloffset_Materialfv 170 +#define _gloffset_Materiali 171 +#define _gloffset_Materialiv 172 +#define _gloffset_PointSize 173 +#define _gloffset_PolygonMode 174 +#define _gloffset_PolygonStipple 175 +#define _gloffset_Scissor 176 +#define _gloffset_ShadeModel 177 +#define _gloffset_TexParameterf 178 +#define _gloffset_TexParameterfv 179 +#define _gloffset_TexParameteri 180 +#define _gloffset_TexParameteriv 181 +#define _gloffset_TexImage1D 182 +#define _gloffset_TexImage2D 183 +#define _gloffset_TexEnvf 184 +#define _gloffset_TexEnvfv 185 +#define _gloffset_TexEnvi 186 +#define _gloffset_TexEnviv 187 +#define _gloffset_TexGend 188 +#define _gloffset_TexGendv 189 +#define _gloffset_TexGenf 190 +#define _gloffset_TexGenfv 191 +#define _gloffset_TexGeni 192 +#define _gloffset_TexGeniv 193 +#define _gloffset_FeedbackBuffer 194 +#define _gloffset_SelectBuffer 195 +#define _gloffset_RenderMode 196 +#define _gloffset_InitNames 197 +#define _gloffset_LoadName 198 +#define _gloffset_PassThrough 199 +#define _gloffset_PopName 200 +#define _gloffset_PushName 201 +#define _gloffset_DrawBuffer 202 +#define _gloffset_Clear 203 +#define _gloffset_ClearAccum 204 +#define _gloffset_ClearIndex 205 +#define _gloffset_ClearColor 206 +#define _gloffset_ClearStencil 207 +#define _gloffset_ClearDepth 208 +#define _gloffset_StencilMask 209 +#define _gloffset_ColorMask 210 +#define _gloffset_DepthMask 211 +#define _gloffset_IndexMask 212 +#define _gloffset_Accum 213 +#define _gloffset_Disable 214 +#define _gloffset_Enable 215 +#define _gloffset_Finish 216 +#define _gloffset_Flush 217 +#define _gloffset_PopAttrib 218 +#define _gloffset_PushAttrib 219 +#define _gloffset_Map1d 220 +#define _gloffset_Map1f 221 +#define _gloffset_Map2d 222 +#define _gloffset_Map2f 223 +#define _gloffset_MapGrid1d 224 +#define _gloffset_MapGrid1f 225 +#define _gloffset_MapGrid2d 226 +#define _gloffset_MapGrid2f 227 +#define _gloffset_EvalCoord1d 228 +#define _gloffset_EvalCoord1dv 229 +#define _gloffset_EvalCoord1f 230 +#define _gloffset_EvalCoord1fv 231 +#define _gloffset_EvalCoord2d 232 +#define _gloffset_EvalCoord2dv 233 +#define _gloffset_EvalCoord2f 234 +#define _gloffset_EvalCoord2fv 235 +#define _gloffset_EvalMesh1 236 +#define _gloffset_EvalPoint1 237 +#define _gloffset_EvalMesh2 238 +#define _gloffset_EvalPoint2 239 +#define _gloffset_AlphaFunc 240 +#define _gloffset_BlendFunc 241 +#define _gloffset_LogicOp 242 +#define _gloffset_StencilFunc 243 +#define _gloffset_StencilOp 244 +#define _gloffset_DepthFunc 245 +#define _gloffset_PixelZoom 246 +#define _gloffset_PixelTransferf 247 +#define _gloffset_PixelTransferi 248 +#define _gloffset_PixelStoref 249 +#define _gloffset_PixelStorei 250 +#define _gloffset_PixelMapfv 251 +#define _gloffset_PixelMapuiv 252 +#define _gloffset_PixelMapusv 253 +#define _gloffset_ReadBuffer 254 +#define _gloffset_CopyPixels 255 +#define _gloffset_ReadPixels 256 +#define _gloffset_DrawPixels 257 +#define _gloffset_GetBooleanv 258 +#define _gloffset_GetClipPlane 259 +#define _gloffset_GetDoublev 260 +#define _gloffset_GetError 261 +#define _gloffset_GetFloatv 262 +#define _gloffset_GetIntegerv 263 +#define _gloffset_GetLightfv 264 +#define _gloffset_GetLightiv 265 +#define _gloffset_GetMapdv 266 +#define _gloffset_GetMapfv 267 +#define _gloffset_GetMapiv 268 +#define _gloffset_GetMaterialfv 269 +#define _gloffset_GetMaterialiv 270 +#define _gloffset_GetPixelMapfv 271 +#define _gloffset_GetPixelMapuiv 272 +#define _gloffset_GetPixelMapusv 273 +#define _gloffset_GetPolygonStipple 274 +#define _gloffset_GetString 275 +#define _gloffset_GetTexEnvfv 276 +#define _gloffset_GetTexEnviv 277 +#define _gloffset_GetTexGendv 278 +#define _gloffset_GetTexGenfv 279 +#define _gloffset_GetTexGeniv 280 +#define _gloffset_GetTexImage 281 +#define _gloffset_GetTexParameterfv 282 +#define _gloffset_GetTexParameteriv 283 +#define _gloffset_GetTexLevelParameterfv 284 +#define _gloffset_GetTexLevelParameteriv 285 +#define _gloffset_IsEnabled 286 +#define _gloffset_IsList 287 +#define _gloffset_DepthRange 288 +#define _gloffset_Frustum 289 +#define _gloffset_LoadIdentity 290 +#define _gloffset_LoadMatrixf 291 +#define _gloffset_LoadMatrixd 292 +#define _gloffset_MatrixMode 293 +#define _gloffset_MultMatrixf 294 +#define _gloffset_MultMatrixd 295 +#define _gloffset_Ortho 296 +#define _gloffset_PopMatrix 297 +#define _gloffset_PushMatrix 298 +#define _gloffset_Rotated 299 +#define _gloffset_Rotatef 300 +#define _gloffset_Scaled 301 +#define _gloffset_Scalef 302 +#define _gloffset_Translated 303 +#define _gloffset_Translatef 304 +#define _gloffset_Viewport 305 +#define _gloffset_ArrayElement 306 +#define _gloffset_BindTexture 307 +#define _gloffset_ColorPointer 308 +#define _gloffset_DisableClientState 309 +#define _gloffset_DrawArrays 310 +#define _gloffset_DrawElements 311 +#define _gloffset_EdgeFlagPointer 312 +#define _gloffset_EnableClientState 313 +#define _gloffset_IndexPointer 314 +#define _gloffset_Indexub 315 +#define _gloffset_Indexubv 316 +#define _gloffset_InterleavedArrays 317 +#define _gloffset_NormalPointer 318 +#define _gloffset_PolygonOffset 319 +#define _gloffset_TexCoordPointer 320 +#define _gloffset_VertexPointer 321 +#define _gloffset_AreTexturesResident 322 +#define _gloffset_CopyTexImage1D 323 +#define _gloffset_CopyTexImage2D 324 +#define _gloffset_CopyTexSubImage1D 325 +#define _gloffset_CopyTexSubImage2D 326 +#define _gloffset_DeleteTextures 327 +#define _gloffset_GenTextures 328 +#define _gloffset_GetPointerv 329 +#define _gloffset_IsTexture 330 +#define _gloffset_PrioritizeTextures 331 +#define _gloffset_TexSubImage1D 332 +#define _gloffset_TexSubImage2D 333 +#define _gloffset_PopClientAttrib 334 +#define _gloffset_PushClientAttrib 335 +#define _gloffset_BlendColor 336 +#define _gloffset_BlendEquation 337 +#define _gloffset_DrawRangeElements 338 +#define _gloffset_ColorTable 339 +#define _gloffset_ColorTableParameterfv 340 +#define _gloffset_ColorTableParameteriv 341 +#define _gloffset_CopyColorTable 342 +#define _gloffset_GetColorTable 343 +#define _gloffset_GetColorTableParameterfv 344 +#define _gloffset_GetColorTableParameteriv 345 +#define _gloffset_ColorSubTable 346 +#define _gloffset_CopyColorSubTable 347 +#define _gloffset_ConvolutionFilter1D 348 +#define _gloffset_ConvolutionFilter2D 349 +#define _gloffset_ConvolutionParameterf 350 +#define _gloffset_ConvolutionParameterfv 351 +#define _gloffset_ConvolutionParameteri 352 +#define _gloffset_ConvolutionParameteriv 353 +#define _gloffset_CopyConvolutionFilter1D 354 +#define _gloffset_CopyConvolutionFilter2D 355 +#define _gloffset_GetConvolutionFilter 356 +#define _gloffset_GetConvolutionParameterfv 357 +#define _gloffset_GetConvolutionParameteriv 358 +#define _gloffset_GetSeparableFilter 359 +#define _gloffset_SeparableFilter2D 360 +#define _gloffset_GetHistogram 361 +#define _gloffset_GetHistogramParameterfv 362 +#define _gloffset_GetHistogramParameteriv 363 +#define _gloffset_GetMinmax 364 +#define _gloffset_GetMinmaxParameterfv 365 +#define _gloffset_GetMinmaxParameteriv 366 +#define _gloffset_Histogram 367 +#define _gloffset_Minmax 368 +#define _gloffset_ResetHistogram 369 +#define _gloffset_ResetMinmax 370 +#define _gloffset_TexImage3D 371 +#define _gloffset_TexSubImage3D 372 +#define _gloffset_CopyTexSubImage3D 373 +#define _gloffset_ActiveTextureARB 374 +#define _gloffset_ClientActiveTextureARB 375 +#define _gloffset_MultiTexCoord1dARB 376 +#define _gloffset_MultiTexCoord1dvARB 377 +#define _gloffset_MultiTexCoord1fARB 378 +#define _gloffset_MultiTexCoord1fvARB 379 +#define _gloffset_MultiTexCoord1iARB 380 +#define _gloffset_MultiTexCoord1ivARB 381 +#define _gloffset_MultiTexCoord1sARB 382 +#define _gloffset_MultiTexCoord1svARB 383 +#define _gloffset_MultiTexCoord2dARB 384 +#define _gloffset_MultiTexCoord2dvARB 385 +#define _gloffset_MultiTexCoord2fARB 386 +#define _gloffset_MultiTexCoord2fvARB 387 +#define _gloffset_MultiTexCoord2iARB 388 +#define _gloffset_MultiTexCoord2ivARB 389 +#define _gloffset_MultiTexCoord2sARB 390 +#define _gloffset_MultiTexCoord2svARB 391 +#define _gloffset_MultiTexCoord3dARB 392 +#define _gloffset_MultiTexCoord3dvARB 393 +#define _gloffset_MultiTexCoord3fARB 394 +#define _gloffset_MultiTexCoord3fvARB 395 +#define _gloffset_MultiTexCoord3iARB 396 +#define _gloffset_MultiTexCoord3ivARB 397 +#define _gloffset_MultiTexCoord3sARB 398 +#define _gloffset_MultiTexCoord3svARB 399 +#define _gloffset_MultiTexCoord4dARB 400 +#define _gloffset_MultiTexCoord4dvARB 401 +#define _gloffset_MultiTexCoord4fARB 402 +#define _gloffset_MultiTexCoord4fvARB 403 +#define _gloffset_MultiTexCoord4iARB 404 +#define _gloffset_MultiTexCoord4ivARB 405 +#define _gloffset_MultiTexCoord4sARB 406 +#define _gloffset_MultiTexCoord4svARB 407 + +#if !defined(_GLAPI_USE_REMAP_TABLE) + +#define _gloffset_AttachShader 408 +#define _gloffset_CreateProgram 409 +#define _gloffset_CreateShader 410 +#define _gloffset_DeleteProgram 411 +#define _gloffset_DeleteShader 412 +#define _gloffset_DetachShader 413 +#define _gloffset_GetAttachedShaders 414 +#define _gloffset_GetProgramInfoLog 415 +#define _gloffset_GetProgramiv 416 +#define _gloffset_GetShaderInfoLog 417 +#define _gloffset_GetShaderiv 418 +#define _gloffset_IsProgram 419 +#define _gloffset_IsShader 420 +#define _gloffset_StencilFuncSeparate 421 +#define _gloffset_StencilMaskSeparate 422 +#define _gloffset_StencilOpSeparate 423 +#define _gloffset_UniformMatrix2x3fv 424 +#define _gloffset_UniformMatrix2x4fv 425 +#define _gloffset_UniformMatrix3x2fv 426 +#define _gloffset_UniformMatrix3x4fv 427 +#define _gloffset_UniformMatrix4x2fv 428 +#define _gloffset_UniformMatrix4x3fv 429 +#define _gloffset_ClampColor 430 +#define _gloffset_ClearBufferfi 431 +#define _gloffset_ClearBufferfv 432 +#define _gloffset_ClearBufferiv 433 +#define _gloffset_ClearBufferuiv 434 +#define _gloffset_GetStringi 435 +#define _gloffset_TexBuffer 436 +#define _gloffset_FramebufferTexture 437 +#define _gloffset_GetBufferParameteri64v 438 +#define _gloffset_GetInteger64i_v 439 +#define _gloffset_VertexAttribDivisor 440 +#define _gloffset_LoadTransposeMatrixdARB 441 +#define _gloffset_LoadTransposeMatrixfARB 442 +#define _gloffset_MultTransposeMatrixdARB 443 +#define _gloffset_MultTransposeMatrixfARB 444 +#define _gloffset_SampleCoverageARB 445 +#define _gloffset_CompressedTexImage1DARB 446 +#define _gloffset_CompressedTexImage2DARB 447 +#define _gloffset_CompressedTexImage3DARB 448 +#define _gloffset_CompressedTexSubImage1DARB 449 +#define _gloffset_CompressedTexSubImage2DARB 450 +#define _gloffset_CompressedTexSubImage3DARB 451 +#define _gloffset_GetCompressedTexImageARB 452 +#define _gloffset_DisableVertexAttribArrayARB 453 +#define _gloffset_EnableVertexAttribArrayARB 454 +#define _gloffset_GetProgramEnvParameterdvARB 455 +#define _gloffset_GetProgramEnvParameterfvARB 456 +#define _gloffset_GetProgramLocalParameterdvARB 457 +#define _gloffset_GetProgramLocalParameterfvARB 458 +#define _gloffset_GetProgramStringARB 459 +#define _gloffset_GetProgramivARB 460 +#define _gloffset_GetVertexAttribdvARB 461 +#define _gloffset_GetVertexAttribfvARB 462 +#define _gloffset_GetVertexAttribivARB 463 +#define _gloffset_ProgramEnvParameter4dARB 464 +#define _gloffset_ProgramEnvParameter4dvARB 465 +#define _gloffset_ProgramEnvParameter4fARB 466 +#define _gloffset_ProgramEnvParameter4fvARB 467 +#define _gloffset_ProgramLocalParameter4dARB 468 +#define _gloffset_ProgramLocalParameter4dvARB 469 +#define _gloffset_ProgramLocalParameter4fARB 470 +#define _gloffset_ProgramLocalParameter4fvARB 471 +#define _gloffset_ProgramStringARB 472 +#define _gloffset_VertexAttrib1dARB 473 +#define _gloffset_VertexAttrib1dvARB 474 +#define _gloffset_VertexAttrib1fARB 475 +#define _gloffset_VertexAttrib1fvARB 476 +#define _gloffset_VertexAttrib1sARB 477 +#define _gloffset_VertexAttrib1svARB 478 +#define _gloffset_VertexAttrib2dARB 479 +#define _gloffset_VertexAttrib2dvARB 480 +#define _gloffset_VertexAttrib2fARB 481 +#define _gloffset_VertexAttrib2fvARB 482 +#define _gloffset_VertexAttrib2sARB 483 +#define _gloffset_VertexAttrib2svARB 484 +#define _gloffset_VertexAttrib3dARB 485 +#define _gloffset_VertexAttrib3dvARB 486 +#define _gloffset_VertexAttrib3fARB 487 +#define _gloffset_VertexAttrib3fvARB 488 +#define _gloffset_VertexAttrib3sARB 489 +#define _gloffset_VertexAttrib3svARB 490 +#define _gloffset_VertexAttrib4NbvARB 491 +#define _gloffset_VertexAttrib4NivARB 492 +#define _gloffset_VertexAttrib4NsvARB 493 +#define _gloffset_VertexAttrib4NubARB 494 +#define _gloffset_VertexAttrib4NubvARB 495 +#define _gloffset_VertexAttrib4NuivARB 496 +#define _gloffset_VertexAttrib4NusvARB 497 +#define _gloffset_VertexAttrib4bvARB 498 +#define _gloffset_VertexAttrib4dARB 499 +#define _gloffset_VertexAttrib4dvARB 500 +#define _gloffset_VertexAttrib4fARB 501 +#define _gloffset_VertexAttrib4fvARB 502 +#define _gloffset_VertexAttrib4ivARB 503 +#define _gloffset_VertexAttrib4sARB 504 +#define _gloffset_VertexAttrib4svARB 505 +#define _gloffset_VertexAttrib4ubvARB 506 +#define _gloffset_VertexAttrib4uivARB 507 +#define _gloffset_VertexAttrib4usvARB 508 +#define _gloffset_VertexAttribPointerARB 509 +#define _gloffset_BindBufferARB 510 +#define _gloffset_BufferDataARB 511 +#define _gloffset_BufferSubDataARB 512 +#define _gloffset_DeleteBuffersARB 513 +#define _gloffset_GenBuffersARB 514 +#define _gloffset_GetBufferParameterivARB 515 +#define _gloffset_GetBufferPointervARB 516 +#define _gloffset_GetBufferSubDataARB 517 +#define _gloffset_IsBufferARB 518 +#define _gloffset_MapBufferARB 519 +#define _gloffset_UnmapBufferARB 520 +#define _gloffset_BeginQueryARB 521 +#define _gloffset_DeleteQueriesARB 522 +#define _gloffset_EndQueryARB 523 +#define _gloffset_GenQueriesARB 524 +#define _gloffset_GetQueryObjectivARB 525 +#define _gloffset_GetQueryObjectuivARB 526 +#define _gloffset_GetQueryivARB 527 +#define _gloffset_IsQueryARB 528 +#define _gloffset_AttachObjectARB 529 +#define _gloffset_CompileShaderARB 530 +#define _gloffset_CreateProgramObjectARB 531 +#define _gloffset_CreateShaderObjectARB 532 +#define _gloffset_DeleteObjectARB 533 +#define _gloffset_DetachObjectARB 534 +#define _gloffset_GetActiveUniformARB 535 +#define _gloffset_GetAttachedObjectsARB 536 +#define _gloffset_GetHandleARB 537 +#define _gloffset_GetInfoLogARB 538 +#define _gloffset_GetObjectParameterfvARB 539 +#define _gloffset_GetObjectParameterivARB 540 +#define _gloffset_GetShaderSourceARB 541 +#define _gloffset_GetUniformLocationARB 542 +#define _gloffset_GetUniformfvARB 543 +#define _gloffset_GetUniformivARB 544 +#define _gloffset_LinkProgramARB 545 +#define _gloffset_ShaderSourceARB 546 +#define _gloffset_Uniform1fARB 547 +#define _gloffset_Uniform1fvARB 548 +#define _gloffset_Uniform1iARB 549 +#define _gloffset_Uniform1ivARB 550 +#define _gloffset_Uniform2fARB 551 +#define _gloffset_Uniform2fvARB 552 +#define _gloffset_Uniform2iARB 553 +#define _gloffset_Uniform2ivARB 554 +#define _gloffset_Uniform3fARB 555 +#define _gloffset_Uniform3fvARB 556 +#define _gloffset_Uniform3iARB 557 +#define _gloffset_Uniform3ivARB 558 +#define _gloffset_Uniform4fARB 559 +#define _gloffset_Uniform4fvARB 560 +#define _gloffset_Uniform4iARB 561 +#define _gloffset_Uniform4ivARB 562 +#define _gloffset_UniformMatrix2fvARB 563 +#define _gloffset_UniformMatrix3fvARB 564 +#define _gloffset_UniformMatrix4fvARB 565 +#define _gloffset_UseProgramObjectARB 566 +#define _gloffset_ValidateProgramARB 567 +#define _gloffset_BindAttribLocationARB 568 +#define _gloffset_GetActiveAttribARB 569 +#define _gloffset_GetAttribLocationARB 570 +#define _gloffset_DrawBuffersARB 571 +#define _gloffset_DrawArraysInstancedARB 572 +#define _gloffset_DrawElementsInstancedARB 573 +#define _gloffset_RenderbufferStorageMultisample 574 +#define _gloffset_FramebufferTextureARB 575 +#define _gloffset_FramebufferTextureFaceARB 576 +#define _gloffset_ProgramParameteriARB 577 +#define _gloffset_FlushMappedBufferRange 578 +#define _gloffset_MapBufferRange 579 +#define _gloffset_BindVertexArray 580 +#define _gloffset_GenVertexArrays 581 +#define _gloffset_CopyBufferSubData 582 +#define _gloffset_ClientWaitSync 583 +#define _gloffset_DeleteSync 584 +#define _gloffset_FenceSync 585 +#define _gloffset_GetInteger64v 586 +#define _gloffset_GetSynciv 587 +#define _gloffset_IsSync 588 +#define _gloffset_WaitSync 589 +#define _gloffset_DrawElementsBaseVertex 590 +#define _gloffset_DrawRangeElementsBaseVertex 591 +#define _gloffset_MultiDrawElementsBaseVertex 592 +#define _gloffset_BindTransformFeedback 593 +#define _gloffset_DeleteTransformFeedbacks 594 +#define _gloffset_DrawTransformFeedback 595 +#define _gloffset_GenTransformFeedbacks 596 +#define _gloffset_IsTransformFeedback 597 +#define _gloffset_PauseTransformFeedback 598 +#define _gloffset_ResumeTransformFeedback 599 +#define _gloffset_PolygonOffsetEXT 600 +#define _gloffset_GetPixelTexGenParameterfvSGIS 601 +#define _gloffset_GetPixelTexGenParameterivSGIS 602 +#define _gloffset_PixelTexGenParameterfSGIS 603 +#define _gloffset_PixelTexGenParameterfvSGIS 604 +#define _gloffset_PixelTexGenParameteriSGIS 605 +#define _gloffset_PixelTexGenParameterivSGIS 606 +#define _gloffset_SampleMaskSGIS 607 +#define _gloffset_SamplePatternSGIS 608 +#define _gloffset_ColorPointerEXT 609 +#define _gloffset_EdgeFlagPointerEXT 610 +#define _gloffset_IndexPointerEXT 611 +#define _gloffset_NormalPointerEXT 612 +#define _gloffset_TexCoordPointerEXT 613 +#define _gloffset_VertexPointerEXT 614 +#define _gloffset_PointParameterfEXT 615 +#define _gloffset_PointParameterfvEXT 616 +#define _gloffset_LockArraysEXT 617 +#define _gloffset_UnlockArraysEXT 618 +#define _gloffset_SecondaryColor3bEXT 619 +#define _gloffset_SecondaryColor3bvEXT 620 +#define _gloffset_SecondaryColor3dEXT 621 +#define _gloffset_SecondaryColor3dvEXT 622 +#define _gloffset_SecondaryColor3fEXT 623 +#define _gloffset_SecondaryColor3fvEXT 624 +#define _gloffset_SecondaryColor3iEXT 625 +#define _gloffset_SecondaryColor3ivEXT 626 +#define _gloffset_SecondaryColor3sEXT 627 +#define _gloffset_SecondaryColor3svEXT 628 +#define _gloffset_SecondaryColor3ubEXT 629 +#define _gloffset_SecondaryColor3ubvEXT 630 +#define _gloffset_SecondaryColor3uiEXT 631 +#define _gloffset_SecondaryColor3uivEXT 632 +#define _gloffset_SecondaryColor3usEXT 633 +#define _gloffset_SecondaryColor3usvEXT 634 +#define _gloffset_SecondaryColorPointerEXT 635 +#define _gloffset_MultiDrawArraysEXT 636 +#define _gloffset_MultiDrawElementsEXT 637 +#define _gloffset_FogCoordPointerEXT 638 +#define _gloffset_FogCoorddEXT 639 +#define _gloffset_FogCoorddvEXT 640 +#define _gloffset_FogCoordfEXT 641 +#define _gloffset_FogCoordfvEXT 642 +#define _gloffset_PixelTexGenSGIX 643 +#define _gloffset_BlendFuncSeparateEXT 644 +#define _gloffset_FlushVertexArrayRangeNV 645 +#define _gloffset_VertexArrayRangeNV 646 +#define _gloffset_CombinerInputNV 647 +#define _gloffset_CombinerOutputNV 648 +#define _gloffset_CombinerParameterfNV 649 +#define _gloffset_CombinerParameterfvNV 650 +#define _gloffset_CombinerParameteriNV 651 +#define _gloffset_CombinerParameterivNV 652 +#define _gloffset_FinalCombinerInputNV 653 +#define _gloffset_GetCombinerInputParameterfvNV 654 +#define _gloffset_GetCombinerInputParameterivNV 655 +#define _gloffset_GetCombinerOutputParameterfvNV 656 +#define _gloffset_GetCombinerOutputParameterivNV 657 +#define _gloffset_GetFinalCombinerInputParameterfvNV 658 +#define _gloffset_GetFinalCombinerInputParameterivNV 659 +#define _gloffset_ResizeBuffersMESA 660 +#define _gloffset_WindowPos2dMESA 661 +#define _gloffset_WindowPos2dvMESA 662 +#define _gloffset_WindowPos2fMESA 663 +#define _gloffset_WindowPos2fvMESA 664 +#define _gloffset_WindowPos2iMESA 665 +#define _gloffset_WindowPos2ivMESA 666 +#define _gloffset_WindowPos2sMESA 667 +#define _gloffset_WindowPos2svMESA 668 +#define _gloffset_WindowPos3dMESA 669 +#define _gloffset_WindowPos3dvMESA 670 +#define _gloffset_WindowPos3fMESA 671 +#define _gloffset_WindowPos3fvMESA 672 +#define _gloffset_WindowPos3iMESA 673 +#define _gloffset_WindowPos3ivMESA 674 +#define _gloffset_WindowPos3sMESA 675 +#define _gloffset_WindowPos3svMESA 676 +#define _gloffset_WindowPos4dMESA 677 +#define _gloffset_WindowPos4dvMESA 678 +#define _gloffset_WindowPos4fMESA 679 +#define _gloffset_WindowPos4fvMESA 680 +#define _gloffset_WindowPos4iMESA 681 +#define _gloffset_WindowPos4ivMESA 682 +#define _gloffset_WindowPos4sMESA 683 +#define _gloffset_WindowPos4svMESA 684 +#define _gloffset_MultiModeDrawArraysIBM 685 +#define _gloffset_MultiModeDrawElementsIBM 686 +#define _gloffset_DeleteFencesNV 687 +#define _gloffset_FinishFenceNV 688 +#define _gloffset_GenFencesNV 689 +#define _gloffset_GetFenceivNV 690 +#define _gloffset_IsFenceNV 691 +#define _gloffset_SetFenceNV 692 +#define _gloffset_TestFenceNV 693 +#define _gloffset_AreProgramsResidentNV 694 +#define _gloffset_BindProgramNV 695 +#define _gloffset_DeleteProgramsNV 696 +#define _gloffset_ExecuteProgramNV 697 +#define _gloffset_GenProgramsNV 698 +#define _gloffset_GetProgramParameterdvNV 699 +#define _gloffset_GetProgramParameterfvNV 700 +#define _gloffset_GetProgramStringNV 701 +#define _gloffset_GetProgramivNV 702 +#define _gloffset_GetTrackMatrixivNV 703 +#define _gloffset_GetVertexAttribPointervNV 704 +#define _gloffset_GetVertexAttribdvNV 705 +#define _gloffset_GetVertexAttribfvNV 706 +#define _gloffset_GetVertexAttribivNV 707 +#define _gloffset_IsProgramNV 708 +#define _gloffset_LoadProgramNV 709 +#define _gloffset_ProgramParameters4dvNV 710 +#define _gloffset_ProgramParameters4fvNV 711 +#define _gloffset_RequestResidentProgramsNV 712 +#define _gloffset_TrackMatrixNV 713 +#define _gloffset_VertexAttrib1dNV 714 +#define _gloffset_VertexAttrib1dvNV 715 +#define _gloffset_VertexAttrib1fNV 716 +#define _gloffset_VertexAttrib1fvNV 717 +#define _gloffset_VertexAttrib1sNV 718 +#define _gloffset_VertexAttrib1svNV 719 +#define _gloffset_VertexAttrib2dNV 720 +#define _gloffset_VertexAttrib2dvNV 721 +#define _gloffset_VertexAttrib2fNV 722 +#define _gloffset_VertexAttrib2fvNV 723 +#define _gloffset_VertexAttrib2sNV 724 +#define _gloffset_VertexAttrib2svNV 725 +#define _gloffset_VertexAttrib3dNV 726 +#define _gloffset_VertexAttrib3dvNV 727 +#define _gloffset_VertexAttrib3fNV 728 +#define _gloffset_VertexAttrib3fvNV 729 +#define _gloffset_VertexAttrib3sNV 730 +#define _gloffset_VertexAttrib3svNV 731 +#define _gloffset_VertexAttrib4dNV 732 +#define _gloffset_VertexAttrib4dvNV 733 +#define _gloffset_VertexAttrib4fNV 734 +#define _gloffset_VertexAttrib4fvNV 735 +#define _gloffset_VertexAttrib4sNV 736 +#define _gloffset_VertexAttrib4svNV 737 +#define _gloffset_VertexAttrib4ubNV 738 +#define _gloffset_VertexAttrib4ubvNV 739 +#define _gloffset_VertexAttribPointerNV 740 +#define _gloffset_VertexAttribs1dvNV 741 +#define _gloffset_VertexAttribs1fvNV 742 +#define _gloffset_VertexAttribs1svNV 743 +#define _gloffset_VertexAttribs2dvNV 744 +#define _gloffset_VertexAttribs2fvNV 745 +#define _gloffset_VertexAttribs2svNV 746 +#define _gloffset_VertexAttribs3dvNV 747 +#define _gloffset_VertexAttribs3fvNV 748 +#define _gloffset_VertexAttribs3svNV 749 +#define _gloffset_VertexAttribs4dvNV 750 +#define _gloffset_VertexAttribs4fvNV 751 +#define _gloffset_VertexAttribs4svNV 752 +#define _gloffset_VertexAttribs4ubvNV 753 +#define _gloffset_GetTexBumpParameterfvATI 754 +#define _gloffset_GetTexBumpParameterivATI 755 +#define _gloffset_TexBumpParameterfvATI 756 +#define _gloffset_TexBumpParameterivATI 757 +#define _gloffset_AlphaFragmentOp1ATI 758 +#define _gloffset_AlphaFragmentOp2ATI 759 +#define _gloffset_AlphaFragmentOp3ATI 760 +#define _gloffset_BeginFragmentShaderATI 761 +#define _gloffset_BindFragmentShaderATI 762 +#define _gloffset_ColorFragmentOp1ATI 763 +#define _gloffset_ColorFragmentOp2ATI 764 +#define _gloffset_ColorFragmentOp3ATI 765 +#define _gloffset_DeleteFragmentShaderATI 766 +#define _gloffset_EndFragmentShaderATI 767 +#define _gloffset_GenFragmentShadersATI 768 +#define _gloffset_PassTexCoordATI 769 +#define _gloffset_SampleMapATI 770 +#define _gloffset_SetFragmentShaderConstantATI 771 +#define _gloffset_PointParameteriNV 772 +#define _gloffset_PointParameterivNV 773 +#define _gloffset_ActiveStencilFaceEXT 774 +#define _gloffset_BindVertexArrayAPPLE 775 +#define _gloffset_DeleteVertexArraysAPPLE 776 +#define _gloffset_GenVertexArraysAPPLE 777 +#define _gloffset_IsVertexArrayAPPLE 778 +#define _gloffset_GetProgramNamedParameterdvNV 779 +#define _gloffset_GetProgramNamedParameterfvNV 780 +#define _gloffset_ProgramNamedParameter4dNV 781 +#define _gloffset_ProgramNamedParameter4dvNV 782 +#define _gloffset_ProgramNamedParameter4fNV 783 +#define _gloffset_ProgramNamedParameter4fvNV 784 +#define _gloffset_PrimitiveRestartIndexNV 785 +#define _gloffset_PrimitiveRestartNV 786 +#define _gloffset_DepthBoundsEXT 787 +#define _gloffset_BlendEquationSeparateEXT 788 +#define _gloffset_BindFramebufferEXT 789 +#define _gloffset_BindRenderbufferEXT 790 +#define _gloffset_CheckFramebufferStatusEXT 791 +#define _gloffset_DeleteFramebuffersEXT 792 +#define _gloffset_DeleteRenderbuffersEXT 793 +#define _gloffset_FramebufferRenderbufferEXT 794 +#define _gloffset_FramebufferTexture1DEXT 795 +#define _gloffset_FramebufferTexture2DEXT 796 +#define _gloffset_FramebufferTexture3DEXT 797 +#define _gloffset_GenFramebuffersEXT 798 +#define _gloffset_GenRenderbuffersEXT 799 +#define _gloffset_GenerateMipmapEXT 800 +#define _gloffset_GetFramebufferAttachmentParameterivEXT 801 +#define _gloffset_GetRenderbufferParameterivEXT 802 +#define _gloffset_IsFramebufferEXT 803 +#define _gloffset_IsRenderbufferEXT 804 +#define _gloffset_RenderbufferStorageEXT 805 +#define _gloffset_BlitFramebufferEXT 806 +#define _gloffset_BufferParameteriAPPLE 807 +#define _gloffset_FlushMappedBufferRangeAPPLE 808 +#define _gloffset_BindFragDataLocationEXT 809 +#define _gloffset_GetFragDataLocationEXT 810 +#define _gloffset_GetUniformuivEXT 811 +#define _gloffset_GetVertexAttribIivEXT 812 +#define _gloffset_GetVertexAttribIuivEXT 813 +#define _gloffset_Uniform1uiEXT 814 +#define _gloffset_Uniform1uivEXT 815 +#define _gloffset_Uniform2uiEXT 816 +#define _gloffset_Uniform2uivEXT 817 +#define _gloffset_Uniform3uiEXT 818 +#define _gloffset_Uniform3uivEXT 819 +#define _gloffset_Uniform4uiEXT 820 +#define _gloffset_Uniform4uivEXT 821 +#define _gloffset_VertexAttribI1iEXT 822 +#define _gloffset_VertexAttribI1ivEXT 823 +#define _gloffset_VertexAttribI1uiEXT 824 +#define _gloffset_VertexAttribI1uivEXT 825 +#define _gloffset_VertexAttribI2iEXT 826 +#define _gloffset_VertexAttribI2ivEXT 827 +#define _gloffset_VertexAttribI2uiEXT 828 +#define _gloffset_VertexAttribI2uivEXT 829 +#define _gloffset_VertexAttribI3iEXT 830 +#define _gloffset_VertexAttribI3ivEXT 831 +#define _gloffset_VertexAttribI3uiEXT 832 +#define _gloffset_VertexAttribI3uivEXT 833 +#define _gloffset_VertexAttribI4bvEXT 834 +#define _gloffset_VertexAttribI4iEXT 835 +#define _gloffset_VertexAttribI4ivEXT 836 +#define _gloffset_VertexAttribI4svEXT 837 +#define _gloffset_VertexAttribI4ubvEXT 838 +#define _gloffset_VertexAttribI4uiEXT 839 +#define _gloffset_VertexAttribI4uivEXT 840 +#define _gloffset_VertexAttribI4usvEXT 841 +#define _gloffset_VertexAttribIPointerEXT 842 +#define _gloffset_FramebufferTextureLayerEXT 843 +#define _gloffset_ColorMaskIndexedEXT 844 +#define _gloffset_DisableIndexedEXT 845 +#define _gloffset_EnableIndexedEXT 846 +#define _gloffset_GetBooleanIndexedvEXT 847 +#define _gloffset_GetIntegerIndexedvEXT 848 +#define _gloffset_IsEnabledIndexedEXT 849 +#define _gloffset_ClearColorIiEXT 850 +#define _gloffset_ClearColorIuiEXT 851 +#define _gloffset_GetTexParameterIivEXT 852 +#define _gloffset_GetTexParameterIuivEXT 853 +#define _gloffset_TexParameterIivEXT 854 +#define _gloffset_TexParameterIuivEXT 855 +#define _gloffset_BeginConditionalRenderNV 856 +#define _gloffset_EndConditionalRenderNV 857 +#define _gloffset_BeginTransformFeedbackEXT 858 +#define _gloffset_BindBufferBaseEXT 859 +#define _gloffset_BindBufferOffsetEXT 860 +#define _gloffset_BindBufferRangeEXT 861 +#define _gloffset_EndTransformFeedbackEXT 862 +#define _gloffset_GetTransformFeedbackVaryingEXT 863 +#define _gloffset_TransformFeedbackVaryingsEXT 864 +#define _gloffset_ProvokingVertexEXT 865 +#define _gloffset_GetTexParameterPointervAPPLE 866 +#define _gloffset_TextureRangeAPPLE 867 +#define _gloffset_GetObjectParameterivAPPLE 868 +#define _gloffset_ObjectPurgeableAPPLE 869 +#define _gloffset_ObjectUnpurgeableAPPLE 870 +#define _gloffset_ActiveProgramEXT 871 +#define _gloffset_CreateShaderProgramEXT 872 +#define _gloffset_UseShaderProgramEXT 873 +#define _gloffset_StencilFuncSeparateATI 874 +#define _gloffset_ProgramEnvParameters4fvEXT 875 +#define _gloffset_ProgramLocalParameters4fvEXT 876 +#define _gloffset_GetQueryObjecti64vEXT 877 +#define _gloffset_GetQueryObjectui64vEXT 878 +#define _gloffset_EGLImageTargetRenderbufferStorageOES 879 +#define _gloffset_EGLImageTargetTexture2DOES 880 + +#else /* !_GLAPI_USE_REMAP_TABLE */ + +#define driDispatchRemapTable_size 473 +extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; + +#define AttachShader_remap_index 0 +#define CreateProgram_remap_index 1 +#define CreateShader_remap_index 2 +#define DeleteProgram_remap_index 3 +#define DeleteShader_remap_index 4 +#define DetachShader_remap_index 5 +#define GetAttachedShaders_remap_index 6 +#define GetProgramInfoLog_remap_index 7 +#define GetProgramiv_remap_index 8 +#define GetShaderInfoLog_remap_index 9 +#define GetShaderiv_remap_index 10 +#define IsProgram_remap_index 11 +#define IsShader_remap_index 12 +#define StencilFuncSeparate_remap_index 13 +#define StencilMaskSeparate_remap_index 14 +#define StencilOpSeparate_remap_index 15 +#define UniformMatrix2x3fv_remap_index 16 +#define UniformMatrix2x4fv_remap_index 17 +#define UniformMatrix3x2fv_remap_index 18 +#define UniformMatrix3x4fv_remap_index 19 +#define UniformMatrix4x2fv_remap_index 20 +#define UniformMatrix4x3fv_remap_index 21 +#define ClampColor_remap_index 22 +#define ClearBufferfi_remap_index 23 +#define ClearBufferfv_remap_index 24 +#define ClearBufferiv_remap_index 25 +#define ClearBufferuiv_remap_index 26 +#define GetStringi_remap_index 27 +#define TexBuffer_remap_index 28 +#define FramebufferTexture_remap_index 29 +#define GetBufferParameteri64v_remap_index 30 +#define GetInteger64i_v_remap_index 31 +#define VertexAttribDivisor_remap_index 32 +#define LoadTransposeMatrixdARB_remap_index 33 +#define LoadTransposeMatrixfARB_remap_index 34 +#define MultTransposeMatrixdARB_remap_index 35 +#define MultTransposeMatrixfARB_remap_index 36 +#define SampleCoverageARB_remap_index 37 +#define CompressedTexImage1DARB_remap_index 38 +#define CompressedTexImage2DARB_remap_index 39 +#define CompressedTexImage3DARB_remap_index 40 +#define CompressedTexSubImage1DARB_remap_index 41 +#define CompressedTexSubImage2DARB_remap_index 42 +#define CompressedTexSubImage3DARB_remap_index 43 +#define GetCompressedTexImageARB_remap_index 44 +#define DisableVertexAttribArrayARB_remap_index 45 +#define EnableVertexAttribArrayARB_remap_index 46 +#define GetProgramEnvParameterdvARB_remap_index 47 +#define GetProgramEnvParameterfvARB_remap_index 48 +#define GetProgramLocalParameterdvARB_remap_index 49 +#define GetProgramLocalParameterfvARB_remap_index 50 +#define GetProgramStringARB_remap_index 51 +#define GetProgramivARB_remap_index 52 +#define GetVertexAttribdvARB_remap_index 53 +#define GetVertexAttribfvARB_remap_index 54 +#define GetVertexAttribivARB_remap_index 55 +#define ProgramEnvParameter4dARB_remap_index 56 +#define ProgramEnvParameter4dvARB_remap_index 57 +#define ProgramEnvParameter4fARB_remap_index 58 +#define ProgramEnvParameter4fvARB_remap_index 59 +#define ProgramLocalParameter4dARB_remap_index 60 +#define ProgramLocalParameter4dvARB_remap_index 61 +#define ProgramLocalParameter4fARB_remap_index 62 +#define ProgramLocalParameter4fvARB_remap_index 63 +#define ProgramStringARB_remap_index 64 +#define VertexAttrib1dARB_remap_index 65 +#define VertexAttrib1dvARB_remap_index 66 +#define VertexAttrib1fARB_remap_index 67 +#define VertexAttrib1fvARB_remap_index 68 +#define VertexAttrib1sARB_remap_index 69 +#define VertexAttrib1svARB_remap_index 70 +#define VertexAttrib2dARB_remap_index 71 +#define VertexAttrib2dvARB_remap_index 72 +#define VertexAttrib2fARB_remap_index 73 +#define VertexAttrib2fvARB_remap_index 74 +#define VertexAttrib2sARB_remap_index 75 +#define VertexAttrib2svARB_remap_index 76 +#define VertexAttrib3dARB_remap_index 77 +#define VertexAttrib3dvARB_remap_index 78 +#define VertexAttrib3fARB_remap_index 79 +#define VertexAttrib3fvARB_remap_index 80 +#define VertexAttrib3sARB_remap_index 81 +#define VertexAttrib3svARB_remap_index 82 +#define VertexAttrib4NbvARB_remap_index 83 +#define VertexAttrib4NivARB_remap_index 84 +#define VertexAttrib4NsvARB_remap_index 85 +#define VertexAttrib4NubARB_remap_index 86 +#define VertexAttrib4NubvARB_remap_index 87 +#define VertexAttrib4NuivARB_remap_index 88 +#define VertexAttrib4NusvARB_remap_index 89 +#define VertexAttrib4bvARB_remap_index 90 +#define VertexAttrib4dARB_remap_index 91 +#define VertexAttrib4dvARB_remap_index 92 +#define VertexAttrib4fARB_remap_index 93 +#define VertexAttrib4fvARB_remap_index 94 +#define VertexAttrib4ivARB_remap_index 95 +#define VertexAttrib4sARB_remap_index 96 +#define VertexAttrib4svARB_remap_index 97 +#define VertexAttrib4ubvARB_remap_index 98 +#define VertexAttrib4uivARB_remap_index 99 +#define VertexAttrib4usvARB_remap_index 100 +#define VertexAttribPointerARB_remap_index 101 +#define BindBufferARB_remap_index 102 +#define BufferDataARB_remap_index 103 +#define BufferSubDataARB_remap_index 104 +#define DeleteBuffersARB_remap_index 105 +#define GenBuffersARB_remap_index 106 +#define GetBufferParameterivARB_remap_index 107 +#define GetBufferPointervARB_remap_index 108 +#define GetBufferSubDataARB_remap_index 109 +#define IsBufferARB_remap_index 110 +#define MapBufferARB_remap_index 111 +#define UnmapBufferARB_remap_index 112 +#define BeginQueryARB_remap_index 113 +#define DeleteQueriesARB_remap_index 114 +#define EndQueryARB_remap_index 115 +#define GenQueriesARB_remap_index 116 +#define GetQueryObjectivARB_remap_index 117 +#define GetQueryObjectuivARB_remap_index 118 +#define GetQueryivARB_remap_index 119 +#define IsQueryARB_remap_index 120 +#define AttachObjectARB_remap_index 121 +#define CompileShaderARB_remap_index 122 +#define CreateProgramObjectARB_remap_index 123 +#define CreateShaderObjectARB_remap_index 124 +#define DeleteObjectARB_remap_index 125 +#define DetachObjectARB_remap_index 126 +#define GetActiveUniformARB_remap_index 127 +#define GetAttachedObjectsARB_remap_index 128 +#define GetHandleARB_remap_index 129 +#define GetInfoLogARB_remap_index 130 +#define GetObjectParameterfvARB_remap_index 131 +#define GetObjectParameterivARB_remap_index 132 +#define GetShaderSourceARB_remap_index 133 +#define GetUniformLocationARB_remap_index 134 +#define GetUniformfvARB_remap_index 135 +#define GetUniformivARB_remap_index 136 +#define LinkProgramARB_remap_index 137 +#define ShaderSourceARB_remap_index 138 +#define Uniform1fARB_remap_index 139 +#define Uniform1fvARB_remap_index 140 +#define Uniform1iARB_remap_index 141 +#define Uniform1ivARB_remap_index 142 +#define Uniform2fARB_remap_index 143 +#define Uniform2fvARB_remap_index 144 +#define Uniform2iARB_remap_index 145 +#define Uniform2ivARB_remap_index 146 +#define Uniform3fARB_remap_index 147 +#define Uniform3fvARB_remap_index 148 +#define Uniform3iARB_remap_index 149 +#define Uniform3ivARB_remap_index 150 +#define Uniform4fARB_remap_index 151 +#define Uniform4fvARB_remap_index 152 +#define Uniform4iARB_remap_index 153 +#define Uniform4ivARB_remap_index 154 +#define UniformMatrix2fvARB_remap_index 155 +#define UniformMatrix3fvARB_remap_index 156 +#define UniformMatrix4fvARB_remap_index 157 +#define UseProgramObjectARB_remap_index 158 +#define ValidateProgramARB_remap_index 159 +#define BindAttribLocationARB_remap_index 160 +#define GetActiveAttribARB_remap_index 161 +#define GetAttribLocationARB_remap_index 162 +#define DrawBuffersARB_remap_index 163 +#define DrawArraysInstancedARB_remap_index 164 +#define DrawElementsInstancedARB_remap_index 165 +#define RenderbufferStorageMultisample_remap_index 166 +#define FramebufferTextureARB_remap_index 167 +#define FramebufferTextureFaceARB_remap_index 168 +#define ProgramParameteriARB_remap_index 169 +#define FlushMappedBufferRange_remap_index 170 +#define MapBufferRange_remap_index 171 +#define BindVertexArray_remap_index 172 +#define GenVertexArrays_remap_index 173 +#define CopyBufferSubData_remap_index 174 +#define ClientWaitSync_remap_index 175 +#define DeleteSync_remap_index 176 +#define FenceSync_remap_index 177 +#define GetInteger64v_remap_index 178 +#define GetSynciv_remap_index 179 +#define IsSync_remap_index 180 +#define WaitSync_remap_index 181 +#define DrawElementsBaseVertex_remap_index 182 +#define DrawRangeElementsBaseVertex_remap_index 183 +#define MultiDrawElementsBaseVertex_remap_index 184 +#define BindTransformFeedback_remap_index 185 +#define DeleteTransformFeedbacks_remap_index 186 +#define DrawTransformFeedback_remap_index 187 +#define GenTransformFeedbacks_remap_index 188 +#define IsTransformFeedback_remap_index 189 +#define PauseTransformFeedback_remap_index 190 +#define ResumeTransformFeedback_remap_index 191 +#define PolygonOffsetEXT_remap_index 192 +#define GetPixelTexGenParameterfvSGIS_remap_index 193 +#define GetPixelTexGenParameterivSGIS_remap_index 194 +#define PixelTexGenParameterfSGIS_remap_index 195 +#define PixelTexGenParameterfvSGIS_remap_index 196 +#define PixelTexGenParameteriSGIS_remap_index 197 +#define PixelTexGenParameterivSGIS_remap_index 198 +#define SampleMaskSGIS_remap_index 199 +#define SamplePatternSGIS_remap_index 200 +#define ColorPointerEXT_remap_index 201 +#define EdgeFlagPointerEXT_remap_index 202 +#define IndexPointerEXT_remap_index 203 +#define NormalPointerEXT_remap_index 204 +#define TexCoordPointerEXT_remap_index 205 +#define VertexPointerEXT_remap_index 206 +#define PointParameterfEXT_remap_index 207 +#define PointParameterfvEXT_remap_index 208 +#define LockArraysEXT_remap_index 209 +#define UnlockArraysEXT_remap_index 210 +#define SecondaryColor3bEXT_remap_index 211 +#define SecondaryColor3bvEXT_remap_index 212 +#define SecondaryColor3dEXT_remap_index 213 +#define SecondaryColor3dvEXT_remap_index 214 +#define SecondaryColor3fEXT_remap_index 215 +#define SecondaryColor3fvEXT_remap_index 216 +#define SecondaryColor3iEXT_remap_index 217 +#define SecondaryColor3ivEXT_remap_index 218 +#define SecondaryColor3sEXT_remap_index 219 +#define SecondaryColor3svEXT_remap_index 220 +#define SecondaryColor3ubEXT_remap_index 221 +#define SecondaryColor3ubvEXT_remap_index 222 +#define SecondaryColor3uiEXT_remap_index 223 +#define SecondaryColor3uivEXT_remap_index 224 +#define SecondaryColor3usEXT_remap_index 225 +#define SecondaryColor3usvEXT_remap_index 226 +#define SecondaryColorPointerEXT_remap_index 227 +#define MultiDrawArraysEXT_remap_index 228 +#define MultiDrawElementsEXT_remap_index 229 +#define FogCoordPointerEXT_remap_index 230 +#define FogCoorddEXT_remap_index 231 +#define FogCoorddvEXT_remap_index 232 +#define FogCoordfEXT_remap_index 233 +#define FogCoordfvEXT_remap_index 234 +#define PixelTexGenSGIX_remap_index 235 +#define BlendFuncSeparateEXT_remap_index 236 +#define FlushVertexArrayRangeNV_remap_index 237 +#define VertexArrayRangeNV_remap_index 238 +#define CombinerInputNV_remap_index 239 +#define CombinerOutputNV_remap_index 240 +#define CombinerParameterfNV_remap_index 241 +#define CombinerParameterfvNV_remap_index 242 +#define CombinerParameteriNV_remap_index 243 +#define CombinerParameterivNV_remap_index 244 +#define FinalCombinerInputNV_remap_index 245 +#define GetCombinerInputParameterfvNV_remap_index 246 +#define GetCombinerInputParameterivNV_remap_index 247 +#define GetCombinerOutputParameterfvNV_remap_index 248 +#define GetCombinerOutputParameterivNV_remap_index 249 +#define GetFinalCombinerInputParameterfvNV_remap_index 250 +#define GetFinalCombinerInputParameterivNV_remap_index 251 +#define ResizeBuffersMESA_remap_index 252 +#define WindowPos2dMESA_remap_index 253 +#define WindowPos2dvMESA_remap_index 254 +#define WindowPos2fMESA_remap_index 255 +#define WindowPos2fvMESA_remap_index 256 +#define WindowPos2iMESA_remap_index 257 +#define WindowPos2ivMESA_remap_index 258 +#define WindowPos2sMESA_remap_index 259 +#define WindowPos2svMESA_remap_index 260 +#define WindowPos3dMESA_remap_index 261 +#define WindowPos3dvMESA_remap_index 262 +#define WindowPos3fMESA_remap_index 263 +#define WindowPos3fvMESA_remap_index 264 +#define WindowPos3iMESA_remap_index 265 +#define WindowPos3ivMESA_remap_index 266 +#define WindowPos3sMESA_remap_index 267 +#define WindowPos3svMESA_remap_index 268 +#define WindowPos4dMESA_remap_index 269 +#define WindowPos4dvMESA_remap_index 270 +#define WindowPos4fMESA_remap_index 271 +#define WindowPos4fvMESA_remap_index 272 +#define WindowPos4iMESA_remap_index 273 +#define WindowPos4ivMESA_remap_index 274 +#define WindowPos4sMESA_remap_index 275 +#define WindowPos4svMESA_remap_index 276 +#define MultiModeDrawArraysIBM_remap_index 277 +#define MultiModeDrawElementsIBM_remap_index 278 +#define DeleteFencesNV_remap_index 279 +#define FinishFenceNV_remap_index 280 +#define GenFencesNV_remap_index 281 +#define GetFenceivNV_remap_index 282 +#define IsFenceNV_remap_index 283 +#define SetFenceNV_remap_index 284 +#define TestFenceNV_remap_index 285 +#define AreProgramsResidentNV_remap_index 286 +#define BindProgramNV_remap_index 287 +#define DeleteProgramsNV_remap_index 288 +#define ExecuteProgramNV_remap_index 289 +#define GenProgramsNV_remap_index 290 +#define GetProgramParameterdvNV_remap_index 291 +#define GetProgramParameterfvNV_remap_index 292 +#define GetProgramStringNV_remap_index 293 +#define GetProgramivNV_remap_index 294 +#define GetTrackMatrixivNV_remap_index 295 +#define GetVertexAttribPointervNV_remap_index 296 +#define GetVertexAttribdvNV_remap_index 297 +#define GetVertexAttribfvNV_remap_index 298 +#define GetVertexAttribivNV_remap_index 299 +#define IsProgramNV_remap_index 300 +#define LoadProgramNV_remap_index 301 +#define ProgramParameters4dvNV_remap_index 302 +#define ProgramParameters4fvNV_remap_index 303 +#define RequestResidentProgramsNV_remap_index 304 +#define TrackMatrixNV_remap_index 305 +#define VertexAttrib1dNV_remap_index 306 +#define VertexAttrib1dvNV_remap_index 307 +#define VertexAttrib1fNV_remap_index 308 +#define VertexAttrib1fvNV_remap_index 309 +#define VertexAttrib1sNV_remap_index 310 +#define VertexAttrib1svNV_remap_index 311 +#define VertexAttrib2dNV_remap_index 312 +#define VertexAttrib2dvNV_remap_index 313 +#define VertexAttrib2fNV_remap_index 314 +#define VertexAttrib2fvNV_remap_index 315 +#define VertexAttrib2sNV_remap_index 316 +#define VertexAttrib2svNV_remap_index 317 +#define VertexAttrib3dNV_remap_index 318 +#define VertexAttrib3dvNV_remap_index 319 +#define VertexAttrib3fNV_remap_index 320 +#define VertexAttrib3fvNV_remap_index 321 +#define VertexAttrib3sNV_remap_index 322 +#define VertexAttrib3svNV_remap_index 323 +#define VertexAttrib4dNV_remap_index 324 +#define VertexAttrib4dvNV_remap_index 325 +#define VertexAttrib4fNV_remap_index 326 +#define VertexAttrib4fvNV_remap_index 327 +#define VertexAttrib4sNV_remap_index 328 +#define VertexAttrib4svNV_remap_index 329 +#define VertexAttrib4ubNV_remap_index 330 +#define VertexAttrib4ubvNV_remap_index 331 +#define VertexAttribPointerNV_remap_index 332 +#define VertexAttribs1dvNV_remap_index 333 +#define VertexAttribs1fvNV_remap_index 334 +#define VertexAttribs1svNV_remap_index 335 +#define VertexAttribs2dvNV_remap_index 336 +#define VertexAttribs2fvNV_remap_index 337 +#define VertexAttribs2svNV_remap_index 338 +#define VertexAttribs3dvNV_remap_index 339 +#define VertexAttribs3fvNV_remap_index 340 +#define VertexAttribs3svNV_remap_index 341 +#define VertexAttribs4dvNV_remap_index 342 +#define VertexAttribs4fvNV_remap_index 343 +#define VertexAttribs4svNV_remap_index 344 +#define VertexAttribs4ubvNV_remap_index 345 +#define GetTexBumpParameterfvATI_remap_index 346 +#define GetTexBumpParameterivATI_remap_index 347 +#define TexBumpParameterfvATI_remap_index 348 +#define TexBumpParameterivATI_remap_index 349 +#define AlphaFragmentOp1ATI_remap_index 350 +#define AlphaFragmentOp2ATI_remap_index 351 +#define AlphaFragmentOp3ATI_remap_index 352 +#define BeginFragmentShaderATI_remap_index 353 +#define BindFragmentShaderATI_remap_index 354 +#define ColorFragmentOp1ATI_remap_index 355 +#define ColorFragmentOp2ATI_remap_index 356 +#define ColorFragmentOp3ATI_remap_index 357 +#define DeleteFragmentShaderATI_remap_index 358 +#define EndFragmentShaderATI_remap_index 359 +#define GenFragmentShadersATI_remap_index 360 +#define PassTexCoordATI_remap_index 361 +#define SampleMapATI_remap_index 362 +#define SetFragmentShaderConstantATI_remap_index 363 +#define PointParameteriNV_remap_index 364 +#define PointParameterivNV_remap_index 365 +#define ActiveStencilFaceEXT_remap_index 366 +#define BindVertexArrayAPPLE_remap_index 367 +#define DeleteVertexArraysAPPLE_remap_index 368 +#define GenVertexArraysAPPLE_remap_index 369 +#define IsVertexArrayAPPLE_remap_index 370 +#define GetProgramNamedParameterdvNV_remap_index 371 +#define GetProgramNamedParameterfvNV_remap_index 372 +#define ProgramNamedParameter4dNV_remap_index 373 +#define ProgramNamedParameter4dvNV_remap_index 374 +#define ProgramNamedParameter4fNV_remap_index 375 +#define ProgramNamedParameter4fvNV_remap_index 376 +#define PrimitiveRestartIndexNV_remap_index 377 +#define PrimitiveRestartNV_remap_index 378 +#define DepthBoundsEXT_remap_index 379 +#define BlendEquationSeparateEXT_remap_index 380 +#define BindFramebufferEXT_remap_index 381 +#define BindRenderbufferEXT_remap_index 382 +#define CheckFramebufferStatusEXT_remap_index 383 +#define DeleteFramebuffersEXT_remap_index 384 +#define DeleteRenderbuffersEXT_remap_index 385 +#define FramebufferRenderbufferEXT_remap_index 386 +#define FramebufferTexture1DEXT_remap_index 387 +#define FramebufferTexture2DEXT_remap_index 388 +#define FramebufferTexture3DEXT_remap_index 389 +#define GenFramebuffersEXT_remap_index 390 +#define GenRenderbuffersEXT_remap_index 391 +#define GenerateMipmapEXT_remap_index 392 +#define GetFramebufferAttachmentParameterivEXT_remap_index 393 +#define GetRenderbufferParameterivEXT_remap_index 394 +#define IsFramebufferEXT_remap_index 395 +#define IsRenderbufferEXT_remap_index 396 +#define RenderbufferStorageEXT_remap_index 397 +#define BlitFramebufferEXT_remap_index 398 +#define BufferParameteriAPPLE_remap_index 399 +#define FlushMappedBufferRangeAPPLE_remap_index 400 +#define BindFragDataLocationEXT_remap_index 401 +#define GetFragDataLocationEXT_remap_index 402 +#define GetUniformuivEXT_remap_index 403 +#define GetVertexAttribIivEXT_remap_index 404 +#define GetVertexAttribIuivEXT_remap_index 405 +#define Uniform1uiEXT_remap_index 406 +#define Uniform1uivEXT_remap_index 407 +#define Uniform2uiEXT_remap_index 408 +#define Uniform2uivEXT_remap_index 409 +#define Uniform3uiEXT_remap_index 410 +#define Uniform3uivEXT_remap_index 411 +#define Uniform4uiEXT_remap_index 412 +#define Uniform4uivEXT_remap_index 413 +#define VertexAttribI1iEXT_remap_index 414 +#define VertexAttribI1ivEXT_remap_index 415 +#define VertexAttribI1uiEXT_remap_index 416 +#define VertexAttribI1uivEXT_remap_index 417 +#define VertexAttribI2iEXT_remap_index 418 +#define VertexAttribI2ivEXT_remap_index 419 +#define VertexAttribI2uiEXT_remap_index 420 +#define VertexAttribI2uivEXT_remap_index 421 +#define VertexAttribI3iEXT_remap_index 422 +#define VertexAttribI3ivEXT_remap_index 423 +#define VertexAttribI3uiEXT_remap_index 424 +#define VertexAttribI3uivEXT_remap_index 425 +#define VertexAttribI4bvEXT_remap_index 426 +#define VertexAttribI4iEXT_remap_index 427 +#define VertexAttribI4ivEXT_remap_index 428 +#define VertexAttribI4svEXT_remap_index 429 +#define VertexAttribI4ubvEXT_remap_index 430 +#define VertexAttribI4uiEXT_remap_index 431 +#define VertexAttribI4uivEXT_remap_index 432 +#define VertexAttribI4usvEXT_remap_index 433 +#define VertexAttribIPointerEXT_remap_index 434 +#define FramebufferTextureLayerEXT_remap_index 435 +#define ColorMaskIndexedEXT_remap_index 436 +#define DisableIndexedEXT_remap_index 437 +#define EnableIndexedEXT_remap_index 438 +#define GetBooleanIndexedvEXT_remap_index 439 +#define GetIntegerIndexedvEXT_remap_index 440 +#define IsEnabledIndexedEXT_remap_index 441 +#define ClearColorIiEXT_remap_index 442 +#define ClearColorIuiEXT_remap_index 443 +#define GetTexParameterIivEXT_remap_index 444 +#define GetTexParameterIuivEXT_remap_index 445 +#define TexParameterIivEXT_remap_index 446 +#define TexParameterIuivEXT_remap_index 447 +#define BeginConditionalRenderNV_remap_index 448 +#define EndConditionalRenderNV_remap_index 449 +#define BeginTransformFeedbackEXT_remap_index 450 +#define BindBufferBaseEXT_remap_index 451 +#define BindBufferOffsetEXT_remap_index 452 +#define BindBufferRangeEXT_remap_index 453 +#define EndTransformFeedbackEXT_remap_index 454 +#define GetTransformFeedbackVaryingEXT_remap_index 455 +#define TransformFeedbackVaryingsEXT_remap_index 456 +#define ProvokingVertexEXT_remap_index 457 +#define GetTexParameterPointervAPPLE_remap_index 458 +#define TextureRangeAPPLE_remap_index 459 +#define GetObjectParameterivAPPLE_remap_index 460 +#define ObjectPurgeableAPPLE_remap_index 461 +#define ObjectUnpurgeableAPPLE_remap_index 462 +#define ActiveProgramEXT_remap_index 463 +#define CreateShaderProgramEXT_remap_index 464 +#define UseShaderProgramEXT_remap_index 465 +#define StencilFuncSeparateATI_remap_index 466 +#define ProgramEnvParameters4fvEXT_remap_index 467 +#define ProgramLocalParameters4fvEXT_remap_index 468 +#define GetQueryObjecti64vEXT_remap_index 469 +#define GetQueryObjectui64vEXT_remap_index 470 +#define EGLImageTargetRenderbufferStorageOES_remap_index 471 +#define EGLImageTargetTexture2DOES_remap_index 472 + +#define _gloffset_AttachShader driDispatchRemapTable[AttachShader_remap_index] +#define _gloffset_CreateProgram driDispatchRemapTable[CreateProgram_remap_index] +#define _gloffset_CreateShader driDispatchRemapTable[CreateShader_remap_index] +#define _gloffset_DeleteProgram driDispatchRemapTable[DeleteProgram_remap_index] +#define _gloffset_DeleteShader driDispatchRemapTable[DeleteShader_remap_index] +#define _gloffset_DetachShader driDispatchRemapTable[DetachShader_remap_index] +#define _gloffset_GetAttachedShaders driDispatchRemapTable[GetAttachedShaders_remap_index] +#define _gloffset_GetProgramInfoLog driDispatchRemapTable[GetProgramInfoLog_remap_index] +#define _gloffset_GetProgramiv driDispatchRemapTable[GetProgramiv_remap_index] +#define _gloffset_GetShaderInfoLog driDispatchRemapTable[GetShaderInfoLog_remap_index] +#define _gloffset_GetShaderiv driDispatchRemapTable[GetShaderiv_remap_index] +#define _gloffset_IsProgram driDispatchRemapTable[IsProgram_remap_index] +#define _gloffset_IsShader driDispatchRemapTable[IsShader_remap_index] +#define _gloffset_StencilFuncSeparate driDispatchRemapTable[StencilFuncSeparate_remap_index] +#define _gloffset_StencilMaskSeparate driDispatchRemapTable[StencilMaskSeparate_remap_index] +#define _gloffset_StencilOpSeparate driDispatchRemapTable[StencilOpSeparate_remap_index] +#define _gloffset_UniformMatrix2x3fv driDispatchRemapTable[UniformMatrix2x3fv_remap_index] +#define _gloffset_UniformMatrix2x4fv driDispatchRemapTable[UniformMatrix2x4fv_remap_index] +#define _gloffset_UniformMatrix3x2fv driDispatchRemapTable[UniformMatrix3x2fv_remap_index] +#define _gloffset_UniformMatrix3x4fv driDispatchRemapTable[UniformMatrix3x4fv_remap_index] +#define _gloffset_UniformMatrix4x2fv driDispatchRemapTable[UniformMatrix4x2fv_remap_index] +#define _gloffset_UniformMatrix4x3fv driDispatchRemapTable[UniformMatrix4x3fv_remap_index] +#define _gloffset_ClampColor driDispatchRemapTable[ClampColor_remap_index] +#define _gloffset_ClearBufferfi driDispatchRemapTable[ClearBufferfi_remap_index] +#define _gloffset_ClearBufferfv driDispatchRemapTable[ClearBufferfv_remap_index] +#define _gloffset_ClearBufferiv driDispatchRemapTable[ClearBufferiv_remap_index] +#define _gloffset_ClearBufferuiv driDispatchRemapTable[ClearBufferuiv_remap_index] +#define _gloffset_GetStringi driDispatchRemapTable[GetStringi_remap_index] +#define _gloffset_TexBuffer driDispatchRemapTable[TexBuffer_remap_index] +#define _gloffset_FramebufferTexture driDispatchRemapTable[FramebufferTexture_remap_index] +#define _gloffset_GetBufferParameteri64v driDispatchRemapTable[GetBufferParameteri64v_remap_index] +#define _gloffset_GetInteger64i_v driDispatchRemapTable[GetInteger64i_v_remap_index] +#define _gloffset_VertexAttribDivisor driDispatchRemapTable[VertexAttribDivisor_remap_index] +#define _gloffset_LoadTransposeMatrixdARB driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index] +#define _gloffset_LoadTransposeMatrixfARB driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index] +#define _gloffset_MultTransposeMatrixdARB driDispatchRemapTable[MultTransposeMatrixdARB_remap_index] +#define _gloffset_MultTransposeMatrixfARB driDispatchRemapTable[MultTransposeMatrixfARB_remap_index] +#define _gloffset_SampleCoverageARB driDispatchRemapTable[SampleCoverageARB_remap_index] +#define _gloffset_CompressedTexImage1DARB driDispatchRemapTable[CompressedTexImage1DARB_remap_index] +#define _gloffset_CompressedTexImage2DARB driDispatchRemapTable[CompressedTexImage2DARB_remap_index] +#define _gloffset_CompressedTexImage3DARB driDispatchRemapTable[CompressedTexImage3DARB_remap_index] +#define _gloffset_CompressedTexSubImage1DARB driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index] +#define _gloffset_CompressedTexSubImage2DARB driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index] +#define _gloffset_CompressedTexSubImage3DARB driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index] +#define _gloffset_GetCompressedTexImageARB driDispatchRemapTable[GetCompressedTexImageARB_remap_index] +#define _gloffset_DisableVertexAttribArrayARB driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index] +#define _gloffset_EnableVertexAttribArrayARB driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index] +#define _gloffset_GetProgramEnvParameterdvARB driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index] +#define _gloffset_GetProgramEnvParameterfvARB driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index] +#define _gloffset_GetProgramLocalParameterdvARB driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index] +#define _gloffset_GetProgramLocalParameterfvARB driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index] +#define _gloffset_GetProgramStringARB driDispatchRemapTable[GetProgramStringARB_remap_index] +#define _gloffset_GetProgramivARB driDispatchRemapTable[GetProgramivARB_remap_index] +#define _gloffset_GetVertexAttribdvARB driDispatchRemapTable[GetVertexAttribdvARB_remap_index] +#define _gloffset_GetVertexAttribfvARB driDispatchRemapTable[GetVertexAttribfvARB_remap_index] +#define _gloffset_GetVertexAttribivARB driDispatchRemapTable[GetVertexAttribivARB_remap_index] +#define _gloffset_ProgramEnvParameter4dARB driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index] +#define _gloffset_ProgramEnvParameter4dvARB driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index] +#define _gloffset_ProgramEnvParameter4fARB driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index] +#define _gloffset_ProgramEnvParameter4fvARB driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index] +#define _gloffset_ProgramLocalParameter4dARB driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index] +#define _gloffset_ProgramLocalParameter4dvARB driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index] +#define _gloffset_ProgramLocalParameter4fARB driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index] +#define _gloffset_ProgramLocalParameter4fvARB driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index] +#define _gloffset_ProgramStringARB driDispatchRemapTable[ProgramStringARB_remap_index] +#define _gloffset_VertexAttrib1dARB driDispatchRemapTable[VertexAttrib1dARB_remap_index] +#define _gloffset_VertexAttrib1dvARB driDispatchRemapTable[VertexAttrib1dvARB_remap_index] +#define _gloffset_VertexAttrib1fARB driDispatchRemapTable[VertexAttrib1fARB_remap_index] +#define _gloffset_VertexAttrib1fvARB driDispatchRemapTable[VertexAttrib1fvARB_remap_index] +#define _gloffset_VertexAttrib1sARB driDispatchRemapTable[VertexAttrib1sARB_remap_index] +#define _gloffset_VertexAttrib1svARB driDispatchRemapTable[VertexAttrib1svARB_remap_index] +#define _gloffset_VertexAttrib2dARB driDispatchRemapTable[VertexAttrib2dARB_remap_index] +#define _gloffset_VertexAttrib2dvARB driDispatchRemapTable[VertexAttrib2dvARB_remap_index] +#define _gloffset_VertexAttrib2fARB driDispatchRemapTable[VertexAttrib2fARB_remap_index] +#define _gloffset_VertexAttrib2fvARB driDispatchRemapTable[VertexAttrib2fvARB_remap_index] +#define _gloffset_VertexAttrib2sARB driDispatchRemapTable[VertexAttrib2sARB_remap_index] +#define _gloffset_VertexAttrib2svARB driDispatchRemapTable[VertexAttrib2svARB_remap_index] +#define _gloffset_VertexAttrib3dARB driDispatchRemapTable[VertexAttrib3dARB_remap_index] +#define _gloffset_VertexAttrib3dvARB driDispatchRemapTable[VertexAttrib3dvARB_remap_index] +#define _gloffset_VertexAttrib3fARB driDispatchRemapTable[VertexAttrib3fARB_remap_index] +#define _gloffset_VertexAttrib3fvARB driDispatchRemapTable[VertexAttrib3fvARB_remap_index] +#define _gloffset_VertexAttrib3sARB driDispatchRemapTable[VertexAttrib3sARB_remap_index] +#define _gloffset_VertexAttrib3svARB driDispatchRemapTable[VertexAttrib3svARB_remap_index] +#define _gloffset_VertexAttrib4NbvARB driDispatchRemapTable[VertexAttrib4NbvARB_remap_index] +#define _gloffset_VertexAttrib4NivARB driDispatchRemapTable[VertexAttrib4NivARB_remap_index] +#define _gloffset_VertexAttrib4NsvARB driDispatchRemapTable[VertexAttrib4NsvARB_remap_index] +#define _gloffset_VertexAttrib4NubARB driDispatchRemapTable[VertexAttrib4NubARB_remap_index] +#define _gloffset_VertexAttrib4NubvARB driDispatchRemapTable[VertexAttrib4NubvARB_remap_index] +#define _gloffset_VertexAttrib4NuivARB driDispatchRemapTable[VertexAttrib4NuivARB_remap_index] +#define _gloffset_VertexAttrib4NusvARB driDispatchRemapTable[VertexAttrib4NusvARB_remap_index] +#define _gloffset_VertexAttrib4bvARB driDispatchRemapTable[VertexAttrib4bvARB_remap_index] +#define _gloffset_VertexAttrib4dARB driDispatchRemapTable[VertexAttrib4dARB_remap_index] +#define _gloffset_VertexAttrib4dvARB driDispatchRemapTable[VertexAttrib4dvARB_remap_index] +#define _gloffset_VertexAttrib4fARB driDispatchRemapTable[VertexAttrib4fARB_remap_index] +#define _gloffset_VertexAttrib4fvARB driDispatchRemapTable[VertexAttrib4fvARB_remap_index] +#define _gloffset_VertexAttrib4ivARB driDispatchRemapTable[VertexAttrib4ivARB_remap_index] +#define _gloffset_VertexAttrib4sARB driDispatchRemapTable[VertexAttrib4sARB_remap_index] +#define _gloffset_VertexAttrib4svARB driDispatchRemapTable[VertexAttrib4svARB_remap_index] +#define _gloffset_VertexAttrib4ubvARB driDispatchRemapTable[VertexAttrib4ubvARB_remap_index] +#define _gloffset_VertexAttrib4uivARB driDispatchRemapTable[VertexAttrib4uivARB_remap_index] +#define _gloffset_VertexAttrib4usvARB driDispatchRemapTable[VertexAttrib4usvARB_remap_index] +#define _gloffset_VertexAttribPointerARB driDispatchRemapTable[VertexAttribPointerARB_remap_index] +#define _gloffset_BindBufferARB driDispatchRemapTable[BindBufferARB_remap_index] +#define _gloffset_BufferDataARB driDispatchRemapTable[BufferDataARB_remap_index] +#define _gloffset_BufferSubDataARB driDispatchRemapTable[BufferSubDataARB_remap_index] +#define _gloffset_DeleteBuffersARB driDispatchRemapTable[DeleteBuffersARB_remap_index] +#define _gloffset_GenBuffersARB driDispatchRemapTable[GenBuffersARB_remap_index] +#define _gloffset_GetBufferParameterivARB driDispatchRemapTable[GetBufferParameterivARB_remap_index] +#define _gloffset_GetBufferPointervARB driDispatchRemapTable[GetBufferPointervARB_remap_index] +#define _gloffset_GetBufferSubDataARB driDispatchRemapTable[GetBufferSubDataARB_remap_index] +#define _gloffset_IsBufferARB driDispatchRemapTable[IsBufferARB_remap_index] +#define _gloffset_MapBufferARB driDispatchRemapTable[MapBufferARB_remap_index] +#define _gloffset_UnmapBufferARB driDispatchRemapTable[UnmapBufferARB_remap_index] +#define _gloffset_BeginQueryARB driDispatchRemapTable[BeginQueryARB_remap_index] +#define _gloffset_DeleteQueriesARB driDispatchRemapTable[DeleteQueriesARB_remap_index] +#define _gloffset_EndQueryARB driDispatchRemapTable[EndQueryARB_remap_index] +#define _gloffset_GenQueriesARB driDispatchRemapTable[GenQueriesARB_remap_index] +#define _gloffset_GetQueryObjectivARB driDispatchRemapTable[GetQueryObjectivARB_remap_index] +#define _gloffset_GetQueryObjectuivARB driDispatchRemapTable[GetQueryObjectuivARB_remap_index] +#define _gloffset_GetQueryivARB driDispatchRemapTable[GetQueryivARB_remap_index] +#define _gloffset_IsQueryARB driDispatchRemapTable[IsQueryARB_remap_index] +#define _gloffset_AttachObjectARB driDispatchRemapTable[AttachObjectARB_remap_index] +#define _gloffset_CompileShaderARB driDispatchRemapTable[CompileShaderARB_remap_index] +#define _gloffset_CreateProgramObjectARB driDispatchRemapTable[CreateProgramObjectARB_remap_index] +#define _gloffset_CreateShaderObjectARB driDispatchRemapTable[CreateShaderObjectARB_remap_index] +#define _gloffset_DeleteObjectARB driDispatchRemapTable[DeleteObjectARB_remap_index] +#define _gloffset_DetachObjectARB driDispatchRemapTable[DetachObjectARB_remap_index] +#define _gloffset_GetActiveUniformARB driDispatchRemapTable[GetActiveUniformARB_remap_index] +#define _gloffset_GetAttachedObjectsARB driDispatchRemapTable[GetAttachedObjectsARB_remap_index] +#define _gloffset_GetHandleARB driDispatchRemapTable[GetHandleARB_remap_index] +#define _gloffset_GetInfoLogARB driDispatchRemapTable[GetInfoLogARB_remap_index] +#define _gloffset_GetObjectParameterfvARB driDispatchRemapTable[GetObjectParameterfvARB_remap_index] +#define _gloffset_GetObjectParameterivARB driDispatchRemapTable[GetObjectParameterivARB_remap_index] +#define _gloffset_GetShaderSourceARB driDispatchRemapTable[GetShaderSourceARB_remap_index] +#define _gloffset_GetUniformLocationARB driDispatchRemapTable[GetUniformLocationARB_remap_index] +#define _gloffset_GetUniformfvARB driDispatchRemapTable[GetUniformfvARB_remap_index] +#define _gloffset_GetUniformivARB driDispatchRemapTable[GetUniformivARB_remap_index] +#define _gloffset_LinkProgramARB driDispatchRemapTable[LinkProgramARB_remap_index] +#define _gloffset_ShaderSourceARB driDispatchRemapTable[ShaderSourceARB_remap_index] +#define _gloffset_Uniform1fARB driDispatchRemapTable[Uniform1fARB_remap_index] +#define _gloffset_Uniform1fvARB driDispatchRemapTable[Uniform1fvARB_remap_index] +#define _gloffset_Uniform1iARB driDispatchRemapTable[Uniform1iARB_remap_index] +#define _gloffset_Uniform1ivARB driDispatchRemapTable[Uniform1ivARB_remap_index] +#define _gloffset_Uniform2fARB driDispatchRemapTable[Uniform2fARB_remap_index] +#define _gloffset_Uniform2fvARB driDispatchRemapTable[Uniform2fvARB_remap_index] +#define _gloffset_Uniform2iARB driDispatchRemapTable[Uniform2iARB_remap_index] +#define _gloffset_Uniform2ivARB driDispatchRemapTable[Uniform2ivARB_remap_index] +#define _gloffset_Uniform3fARB driDispatchRemapTable[Uniform3fARB_remap_index] +#define _gloffset_Uniform3fvARB driDispatchRemapTable[Uniform3fvARB_remap_index] +#define _gloffset_Uniform3iARB driDispatchRemapTable[Uniform3iARB_remap_index] +#define _gloffset_Uniform3ivARB driDispatchRemapTable[Uniform3ivARB_remap_index] +#define _gloffset_Uniform4fARB driDispatchRemapTable[Uniform4fARB_remap_index] +#define _gloffset_Uniform4fvARB driDispatchRemapTable[Uniform4fvARB_remap_index] +#define _gloffset_Uniform4iARB driDispatchRemapTable[Uniform4iARB_remap_index] +#define _gloffset_Uniform4ivARB driDispatchRemapTable[Uniform4ivARB_remap_index] +#define _gloffset_UniformMatrix2fvARB driDispatchRemapTable[UniformMatrix2fvARB_remap_index] +#define _gloffset_UniformMatrix3fvARB driDispatchRemapTable[UniformMatrix3fvARB_remap_index] +#define _gloffset_UniformMatrix4fvARB driDispatchRemapTable[UniformMatrix4fvARB_remap_index] +#define _gloffset_UseProgramObjectARB driDispatchRemapTable[UseProgramObjectARB_remap_index] +#define _gloffset_ValidateProgramARB driDispatchRemapTable[ValidateProgramARB_remap_index] +#define _gloffset_BindAttribLocationARB driDispatchRemapTable[BindAttribLocationARB_remap_index] +#define _gloffset_GetActiveAttribARB driDispatchRemapTable[GetActiveAttribARB_remap_index] +#define _gloffset_GetAttribLocationARB driDispatchRemapTable[GetAttribLocationARB_remap_index] +#define _gloffset_DrawBuffersARB driDispatchRemapTable[DrawBuffersARB_remap_index] +#define _gloffset_DrawArraysInstancedARB driDispatchRemapTable[DrawArraysInstancedARB_remap_index] +#define _gloffset_DrawElementsInstancedARB driDispatchRemapTable[DrawElementsInstancedARB_remap_index] +#define _gloffset_RenderbufferStorageMultisample driDispatchRemapTable[RenderbufferStorageMultisample_remap_index] +#define _gloffset_FramebufferTextureARB driDispatchRemapTable[FramebufferTextureARB_remap_index] +#define _gloffset_FramebufferTextureFaceARB driDispatchRemapTable[FramebufferTextureFaceARB_remap_index] +#define _gloffset_ProgramParameteriARB driDispatchRemapTable[ProgramParameteriARB_remap_index] +#define _gloffset_FlushMappedBufferRange driDispatchRemapTable[FlushMappedBufferRange_remap_index] +#define _gloffset_MapBufferRange driDispatchRemapTable[MapBufferRange_remap_index] +#define _gloffset_BindVertexArray driDispatchRemapTable[BindVertexArray_remap_index] +#define _gloffset_GenVertexArrays driDispatchRemapTable[GenVertexArrays_remap_index] +#define _gloffset_CopyBufferSubData driDispatchRemapTable[CopyBufferSubData_remap_index] +#define _gloffset_ClientWaitSync driDispatchRemapTable[ClientWaitSync_remap_index] +#define _gloffset_DeleteSync driDispatchRemapTable[DeleteSync_remap_index] +#define _gloffset_FenceSync driDispatchRemapTable[FenceSync_remap_index] +#define _gloffset_GetInteger64v driDispatchRemapTable[GetInteger64v_remap_index] +#define _gloffset_GetSynciv driDispatchRemapTable[GetSynciv_remap_index] +#define _gloffset_IsSync driDispatchRemapTable[IsSync_remap_index] +#define _gloffset_WaitSync driDispatchRemapTable[WaitSync_remap_index] +#define _gloffset_DrawElementsBaseVertex driDispatchRemapTable[DrawElementsBaseVertex_remap_index] +#define _gloffset_DrawRangeElementsBaseVertex driDispatchRemapTable[DrawRangeElementsBaseVertex_remap_index] +#define _gloffset_MultiDrawElementsBaseVertex driDispatchRemapTable[MultiDrawElementsBaseVertex_remap_index] +#define _gloffset_BindTransformFeedback driDispatchRemapTable[BindTransformFeedback_remap_index] +#define _gloffset_DeleteTransformFeedbacks driDispatchRemapTable[DeleteTransformFeedbacks_remap_index] +#define _gloffset_DrawTransformFeedback driDispatchRemapTable[DrawTransformFeedback_remap_index] +#define _gloffset_GenTransformFeedbacks driDispatchRemapTable[GenTransformFeedbacks_remap_index] +#define _gloffset_IsTransformFeedback driDispatchRemapTable[IsTransformFeedback_remap_index] +#define _gloffset_PauseTransformFeedback driDispatchRemapTable[PauseTransformFeedback_remap_index] +#define _gloffset_ResumeTransformFeedback driDispatchRemapTable[ResumeTransformFeedback_remap_index] +#define _gloffset_PolygonOffsetEXT driDispatchRemapTable[PolygonOffsetEXT_remap_index] +#define _gloffset_GetPixelTexGenParameterfvSGIS driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index] +#define _gloffset_GetPixelTexGenParameterivSGIS driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index] +#define _gloffset_PixelTexGenParameterfSGIS driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index] +#define _gloffset_PixelTexGenParameterfvSGIS driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index] +#define _gloffset_PixelTexGenParameteriSGIS driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index] +#define _gloffset_PixelTexGenParameterivSGIS driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index] +#define _gloffset_SampleMaskSGIS driDispatchRemapTable[SampleMaskSGIS_remap_index] +#define _gloffset_SamplePatternSGIS driDispatchRemapTable[SamplePatternSGIS_remap_index] +#define _gloffset_ColorPointerEXT driDispatchRemapTable[ColorPointerEXT_remap_index] +#define _gloffset_EdgeFlagPointerEXT driDispatchRemapTable[EdgeFlagPointerEXT_remap_index] +#define _gloffset_IndexPointerEXT driDispatchRemapTable[IndexPointerEXT_remap_index] +#define _gloffset_NormalPointerEXT driDispatchRemapTable[NormalPointerEXT_remap_index] +#define _gloffset_TexCoordPointerEXT driDispatchRemapTable[TexCoordPointerEXT_remap_index] +#define _gloffset_VertexPointerEXT driDispatchRemapTable[VertexPointerEXT_remap_index] +#define _gloffset_PointParameterfEXT driDispatchRemapTable[PointParameterfEXT_remap_index] +#define _gloffset_PointParameterfvEXT driDispatchRemapTable[PointParameterfvEXT_remap_index] +#define _gloffset_LockArraysEXT driDispatchRemapTable[LockArraysEXT_remap_index] +#define _gloffset_UnlockArraysEXT driDispatchRemapTable[UnlockArraysEXT_remap_index] +#define _gloffset_SecondaryColor3bEXT driDispatchRemapTable[SecondaryColor3bEXT_remap_index] +#define _gloffset_SecondaryColor3bvEXT driDispatchRemapTable[SecondaryColor3bvEXT_remap_index] +#define _gloffset_SecondaryColor3dEXT driDispatchRemapTable[SecondaryColor3dEXT_remap_index] +#define _gloffset_SecondaryColor3dvEXT driDispatchRemapTable[SecondaryColor3dvEXT_remap_index] +#define _gloffset_SecondaryColor3fEXT driDispatchRemapTable[SecondaryColor3fEXT_remap_index] +#define _gloffset_SecondaryColor3fvEXT driDispatchRemapTable[SecondaryColor3fvEXT_remap_index] +#define _gloffset_SecondaryColor3iEXT driDispatchRemapTable[SecondaryColor3iEXT_remap_index] +#define _gloffset_SecondaryColor3ivEXT driDispatchRemapTable[SecondaryColor3ivEXT_remap_index] +#define _gloffset_SecondaryColor3sEXT driDispatchRemapTable[SecondaryColor3sEXT_remap_index] +#define _gloffset_SecondaryColor3svEXT driDispatchRemapTable[SecondaryColor3svEXT_remap_index] +#define _gloffset_SecondaryColor3ubEXT driDispatchRemapTable[SecondaryColor3ubEXT_remap_index] +#define _gloffset_SecondaryColor3ubvEXT driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index] +#define _gloffset_SecondaryColor3uiEXT driDispatchRemapTable[SecondaryColor3uiEXT_remap_index] +#define _gloffset_SecondaryColor3uivEXT driDispatchRemapTable[SecondaryColor3uivEXT_remap_index] +#define _gloffset_SecondaryColor3usEXT driDispatchRemapTable[SecondaryColor3usEXT_remap_index] +#define _gloffset_SecondaryColor3usvEXT driDispatchRemapTable[SecondaryColor3usvEXT_remap_index] +#define _gloffset_SecondaryColorPointerEXT driDispatchRemapTable[SecondaryColorPointerEXT_remap_index] +#define _gloffset_MultiDrawArraysEXT driDispatchRemapTable[MultiDrawArraysEXT_remap_index] +#define _gloffset_MultiDrawElementsEXT driDispatchRemapTable[MultiDrawElementsEXT_remap_index] +#define _gloffset_FogCoordPointerEXT driDispatchRemapTable[FogCoordPointerEXT_remap_index] +#define _gloffset_FogCoorddEXT driDispatchRemapTable[FogCoorddEXT_remap_index] +#define _gloffset_FogCoorddvEXT driDispatchRemapTable[FogCoorddvEXT_remap_index] +#define _gloffset_FogCoordfEXT driDispatchRemapTable[FogCoordfEXT_remap_index] +#define _gloffset_FogCoordfvEXT driDispatchRemapTable[FogCoordfvEXT_remap_index] +#define _gloffset_PixelTexGenSGIX driDispatchRemapTable[PixelTexGenSGIX_remap_index] +#define _gloffset_BlendFuncSeparateEXT driDispatchRemapTable[BlendFuncSeparateEXT_remap_index] +#define _gloffset_FlushVertexArrayRangeNV driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index] +#define _gloffset_VertexArrayRangeNV driDispatchRemapTable[VertexArrayRangeNV_remap_index] +#define _gloffset_CombinerInputNV driDispatchRemapTable[CombinerInputNV_remap_index] +#define _gloffset_CombinerOutputNV driDispatchRemapTable[CombinerOutputNV_remap_index] +#define _gloffset_CombinerParameterfNV driDispatchRemapTable[CombinerParameterfNV_remap_index] +#define _gloffset_CombinerParameterfvNV driDispatchRemapTable[CombinerParameterfvNV_remap_index] +#define _gloffset_CombinerParameteriNV driDispatchRemapTable[CombinerParameteriNV_remap_index] +#define _gloffset_CombinerParameterivNV driDispatchRemapTable[CombinerParameterivNV_remap_index] +#define _gloffset_FinalCombinerInputNV driDispatchRemapTable[FinalCombinerInputNV_remap_index] +#define _gloffset_GetCombinerInputParameterfvNV driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index] +#define _gloffset_GetCombinerInputParameterivNV driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index] +#define _gloffset_GetCombinerOutputParameterfvNV driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index] +#define _gloffset_GetCombinerOutputParameterivNV driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index] +#define _gloffset_GetFinalCombinerInputParameterfvNV driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index] +#define _gloffset_GetFinalCombinerInputParameterivNV driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index] +#define _gloffset_ResizeBuffersMESA driDispatchRemapTable[ResizeBuffersMESA_remap_index] +#define _gloffset_WindowPos2dMESA driDispatchRemapTable[WindowPos2dMESA_remap_index] +#define _gloffset_WindowPos2dvMESA driDispatchRemapTable[WindowPos2dvMESA_remap_index] +#define _gloffset_WindowPos2fMESA driDispatchRemapTable[WindowPos2fMESA_remap_index] +#define _gloffset_WindowPos2fvMESA driDispatchRemapTable[WindowPos2fvMESA_remap_index] +#define _gloffset_WindowPos2iMESA driDispatchRemapTable[WindowPos2iMESA_remap_index] +#define _gloffset_WindowPos2ivMESA driDispatchRemapTable[WindowPos2ivMESA_remap_index] +#define _gloffset_WindowPos2sMESA driDispatchRemapTable[WindowPos2sMESA_remap_index] +#define _gloffset_WindowPos2svMESA driDispatchRemapTable[WindowPos2svMESA_remap_index] +#define _gloffset_WindowPos3dMESA driDispatchRemapTable[WindowPos3dMESA_remap_index] +#define _gloffset_WindowPos3dvMESA driDispatchRemapTable[WindowPos3dvMESA_remap_index] +#define _gloffset_WindowPos3fMESA driDispatchRemapTable[WindowPos3fMESA_remap_index] +#define _gloffset_WindowPos3fvMESA driDispatchRemapTable[WindowPos3fvMESA_remap_index] +#define _gloffset_WindowPos3iMESA driDispatchRemapTable[WindowPos3iMESA_remap_index] +#define _gloffset_WindowPos3ivMESA driDispatchRemapTable[WindowPos3ivMESA_remap_index] +#define _gloffset_WindowPos3sMESA driDispatchRemapTable[WindowPos3sMESA_remap_index] +#define _gloffset_WindowPos3svMESA driDispatchRemapTable[WindowPos3svMESA_remap_index] +#define _gloffset_WindowPos4dMESA driDispatchRemapTable[WindowPos4dMESA_remap_index] +#define _gloffset_WindowPos4dvMESA driDispatchRemapTable[WindowPos4dvMESA_remap_index] +#define _gloffset_WindowPos4fMESA driDispatchRemapTable[WindowPos4fMESA_remap_index] +#define _gloffset_WindowPos4fvMESA driDispatchRemapTable[WindowPos4fvMESA_remap_index] +#define _gloffset_WindowPos4iMESA driDispatchRemapTable[WindowPos4iMESA_remap_index] +#define _gloffset_WindowPos4ivMESA driDispatchRemapTable[WindowPos4ivMESA_remap_index] +#define _gloffset_WindowPos4sMESA driDispatchRemapTable[WindowPos4sMESA_remap_index] +#define _gloffset_WindowPos4svMESA driDispatchRemapTable[WindowPos4svMESA_remap_index] +#define _gloffset_MultiModeDrawArraysIBM driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index] +#define _gloffset_MultiModeDrawElementsIBM driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index] +#define _gloffset_DeleteFencesNV driDispatchRemapTable[DeleteFencesNV_remap_index] +#define _gloffset_FinishFenceNV driDispatchRemapTable[FinishFenceNV_remap_index] +#define _gloffset_GenFencesNV driDispatchRemapTable[GenFencesNV_remap_index] +#define _gloffset_GetFenceivNV driDispatchRemapTable[GetFenceivNV_remap_index] +#define _gloffset_IsFenceNV driDispatchRemapTable[IsFenceNV_remap_index] +#define _gloffset_SetFenceNV driDispatchRemapTable[SetFenceNV_remap_index] +#define _gloffset_TestFenceNV driDispatchRemapTable[TestFenceNV_remap_index] +#define _gloffset_AreProgramsResidentNV driDispatchRemapTable[AreProgramsResidentNV_remap_index] +#define _gloffset_BindProgramNV driDispatchRemapTable[BindProgramNV_remap_index] +#define _gloffset_DeleteProgramsNV driDispatchRemapTable[DeleteProgramsNV_remap_index] +#define _gloffset_ExecuteProgramNV driDispatchRemapTable[ExecuteProgramNV_remap_index] +#define _gloffset_GenProgramsNV driDispatchRemapTable[GenProgramsNV_remap_index] +#define _gloffset_GetProgramParameterdvNV driDispatchRemapTable[GetProgramParameterdvNV_remap_index] +#define _gloffset_GetProgramParameterfvNV driDispatchRemapTable[GetProgramParameterfvNV_remap_index] +#define _gloffset_GetProgramStringNV driDispatchRemapTable[GetProgramStringNV_remap_index] +#define _gloffset_GetProgramivNV driDispatchRemapTable[GetProgramivNV_remap_index] +#define _gloffset_GetTrackMatrixivNV driDispatchRemapTable[GetTrackMatrixivNV_remap_index] +#define _gloffset_GetVertexAttribPointervNV driDispatchRemapTable[GetVertexAttribPointervNV_remap_index] +#define _gloffset_GetVertexAttribdvNV driDispatchRemapTable[GetVertexAttribdvNV_remap_index] +#define _gloffset_GetVertexAttribfvNV driDispatchRemapTable[GetVertexAttribfvNV_remap_index] +#define _gloffset_GetVertexAttribivNV driDispatchRemapTable[GetVertexAttribivNV_remap_index] +#define _gloffset_IsProgramNV driDispatchRemapTable[IsProgramNV_remap_index] +#define _gloffset_LoadProgramNV driDispatchRemapTable[LoadProgramNV_remap_index] +#define _gloffset_ProgramParameters4dvNV driDispatchRemapTable[ProgramParameters4dvNV_remap_index] +#define _gloffset_ProgramParameters4fvNV driDispatchRemapTable[ProgramParameters4fvNV_remap_index] +#define _gloffset_RequestResidentProgramsNV driDispatchRemapTable[RequestResidentProgramsNV_remap_index] +#define _gloffset_TrackMatrixNV driDispatchRemapTable[TrackMatrixNV_remap_index] +#define _gloffset_VertexAttrib1dNV driDispatchRemapTable[VertexAttrib1dNV_remap_index] +#define _gloffset_VertexAttrib1dvNV driDispatchRemapTable[VertexAttrib1dvNV_remap_index] +#define _gloffset_VertexAttrib1fNV driDispatchRemapTable[VertexAttrib1fNV_remap_index] +#define _gloffset_VertexAttrib1fvNV driDispatchRemapTable[VertexAttrib1fvNV_remap_index] +#define _gloffset_VertexAttrib1sNV driDispatchRemapTable[VertexAttrib1sNV_remap_index] +#define _gloffset_VertexAttrib1svNV driDispatchRemapTable[VertexAttrib1svNV_remap_index] +#define _gloffset_VertexAttrib2dNV driDispatchRemapTable[VertexAttrib2dNV_remap_index] +#define _gloffset_VertexAttrib2dvNV driDispatchRemapTable[VertexAttrib2dvNV_remap_index] +#define _gloffset_VertexAttrib2fNV driDispatchRemapTable[VertexAttrib2fNV_remap_index] +#define _gloffset_VertexAttrib2fvNV driDispatchRemapTable[VertexAttrib2fvNV_remap_index] +#define _gloffset_VertexAttrib2sNV driDispatchRemapTable[VertexAttrib2sNV_remap_index] +#define _gloffset_VertexAttrib2svNV driDispatchRemapTable[VertexAttrib2svNV_remap_index] +#define _gloffset_VertexAttrib3dNV driDispatchRemapTable[VertexAttrib3dNV_remap_index] +#define _gloffset_VertexAttrib3dvNV driDispatchRemapTable[VertexAttrib3dvNV_remap_index] +#define _gloffset_VertexAttrib3fNV driDispatchRemapTable[VertexAttrib3fNV_remap_index] +#define _gloffset_VertexAttrib3fvNV driDispatchRemapTable[VertexAttrib3fvNV_remap_index] +#define _gloffset_VertexAttrib3sNV driDispatchRemapTable[VertexAttrib3sNV_remap_index] +#define _gloffset_VertexAttrib3svNV driDispatchRemapTable[VertexAttrib3svNV_remap_index] +#define _gloffset_VertexAttrib4dNV driDispatchRemapTable[VertexAttrib4dNV_remap_index] +#define _gloffset_VertexAttrib4dvNV driDispatchRemapTable[VertexAttrib4dvNV_remap_index] +#define _gloffset_VertexAttrib4fNV driDispatchRemapTable[VertexAttrib4fNV_remap_index] +#define _gloffset_VertexAttrib4fvNV driDispatchRemapTable[VertexAttrib4fvNV_remap_index] +#define _gloffset_VertexAttrib4sNV driDispatchRemapTable[VertexAttrib4sNV_remap_index] +#define _gloffset_VertexAttrib4svNV driDispatchRemapTable[VertexAttrib4svNV_remap_index] +#define _gloffset_VertexAttrib4ubNV driDispatchRemapTable[VertexAttrib4ubNV_remap_index] +#define _gloffset_VertexAttrib4ubvNV driDispatchRemapTable[VertexAttrib4ubvNV_remap_index] +#define _gloffset_VertexAttribPointerNV driDispatchRemapTable[VertexAttribPointerNV_remap_index] +#define _gloffset_VertexAttribs1dvNV driDispatchRemapTable[VertexAttribs1dvNV_remap_index] +#define _gloffset_VertexAttribs1fvNV driDispatchRemapTable[VertexAttribs1fvNV_remap_index] +#define _gloffset_VertexAttribs1svNV driDispatchRemapTable[VertexAttribs1svNV_remap_index] +#define _gloffset_VertexAttribs2dvNV driDispatchRemapTable[VertexAttribs2dvNV_remap_index] +#define _gloffset_VertexAttribs2fvNV driDispatchRemapTable[VertexAttribs2fvNV_remap_index] +#define _gloffset_VertexAttribs2svNV driDispatchRemapTable[VertexAttribs2svNV_remap_index] +#define _gloffset_VertexAttribs3dvNV driDispatchRemapTable[VertexAttribs3dvNV_remap_index] +#define _gloffset_VertexAttribs3fvNV driDispatchRemapTable[VertexAttribs3fvNV_remap_index] +#define _gloffset_VertexAttribs3svNV driDispatchRemapTable[VertexAttribs3svNV_remap_index] +#define _gloffset_VertexAttribs4dvNV driDispatchRemapTable[VertexAttribs4dvNV_remap_index] +#define _gloffset_VertexAttribs4fvNV driDispatchRemapTable[VertexAttribs4fvNV_remap_index] +#define _gloffset_VertexAttribs4svNV driDispatchRemapTable[VertexAttribs4svNV_remap_index] +#define _gloffset_VertexAttribs4ubvNV driDispatchRemapTable[VertexAttribs4ubvNV_remap_index] +#define _gloffset_GetTexBumpParameterfvATI driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index] +#define _gloffset_GetTexBumpParameterivATI driDispatchRemapTable[GetTexBumpParameterivATI_remap_index] +#define _gloffset_TexBumpParameterfvATI driDispatchRemapTable[TexBumpParameterfvATI_remap_index] +#define _gloffset_TexBumpParameterivATI driDispatchRemapTable[TexBumpParameterivATI_remap_index] +#define _gloffset_AlphaFragmentOp1ATI driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index] +#define _gloffset_AlphaFragmentOp2ATI driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index] +#define _gloffset_AlphaFragmentOp3ATI driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index] +#define _gloffset_BeginFragmentShaderATI driDispatchRemapTable[BeginFragmentShaderATI_remap_index] +#define _gloffset_BindFragmentShaderATI driDispatchRemapTable[BindFragmentShaderATI_remap_index] +#define _gloffset_ColorFragmentOp1ATI driDispatchRemapTable[ColorFragmentOp1ATI_remap_index] +#define _gloffset_ColorFragmentOp2ATI driDispatchRemapTable[ColorFragmentOp2ATI_remap_index] +#define _gloffset_ColorFragmentOp3ATI driDispatchRemapTable[ColorFragmentOp3ATI_remap_index] +#define _gloffset_DeleteFragmentShaderATI driDispatchRemapTable[DeleteFragmentShaderATI_remap_index] +#define _gloffset_EndFragmentShaderATI driDispatchRemapTable[EndFragmentShaderATI_remap_index] +#define _gloffset_GenFragmentShadersATI driDispatchRemapTable[GenFragmentShadersATI_remap_index] +#define _gloffset_PassTexCoordATI driDispatchRemapTable[PassTexCoordATI_remap_index] +#define _gloffset_SampleMapATI driDispatchRemapTable[SampleMapATI_remap_index] +#define _gloffset_SetFragmentShaderConstantATI driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index] +#define _gloffset_PointParameteriNV driDispatchRemapTable[PointParameteriNV_remap_index] +#define _gloffset_PointParameterivNV driDispatchRemapTable[PointParameterivNV_remap_index] +#define _gloffset_ActiveStencilFaceEXT driDispatchRemapTable[ActiveStencilFaceEXT_remap_index] +#define _gloffset_BindVertexArrayAPPLE driDispatchRemapTable[BindVertexArrayAPPLE_remap_index] +#define _gloffset_DeleteVertexArraysAPPLE driDispatchRemapTable[DeleteVertexArraysAPPLE_remap_index] +#define _gloffset_GenVertexArraysAPPLE driDispatchRemapTable[GenVertexArraysAPPLE_remap_index] +#define _gloffset_IsVertexArrayAPPLE driDispatchRemapTable[IsVertexArrayAPPLE_remap_index] +#define _gloffset_GetProgramNamedParameterdvNV driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index] +#define _gloffset_GetProgramNamedParameterfvNV driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index] +#define _gloffset_ProgramNamedParameter4dNV driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index] +#define _gloffset_ProgramNamedParameter4dvNV driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index] +#define _gloffset_ProgramNamedParameter4fNV driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index] +#define _gloffset_ProgramNamedParameter4fvNV driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index] +#define _gloffset_PrimitiveRestartIndexNV driDispatchRemapTable[PrimitiveRestartIndexNV_remap_index] +#define _gloffset_PrimitiveRestartNV driDispatchRemapTable[PrimitiveRestartNV_remap_index] +#define _gloffset_DepthBoundsEXT driDispatchRemapTable[DepthBoundsEXT_remap_index] +#define _gloffset_BlendEquationSeparateEXT driDispatchRemapTable[BlendEquationSeparateEXT_remap_index] +#define _gloffset_BindFramebufferEXT driDispatchRemapTable[BindFramebufferEXT_remap_index] +#define _gloffset_BindRenderbufferEXT driDispatchRemapTable[BindRenderbufferEXT_remap_index] +#define _gloffset_CheckFramebufferStatusEXT driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index] +#define _gloffset_DeleteFramebuffersEXT driDispatchRemapTable[DeleteFramebuffersEXT_remap_index] +#define _gloffset_DeleteRenderbuffersEXT driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index] +#define _gloffset_FramebufferRenderbufferEXT driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index] +#define _gloffset_FramebufferTexture1DEXT driDispatchRemapTable[FramebufferTexture1DEXT_remap_index] +#define _gloffset_FramebufferTexture2DEXT driDispatchRemapTable[FramebufferTexture2DEXT_remap_index] +#define _gloffset_FramebufferTexture3DEXT driDispatchRemapTable[FramebufferTexture3DEXT_remap_index] +#define _gloffset_GenFramebuffersEXT driDispatchRemapTable[GenFramebuffersEXT_remap_index] +#define _gloffset_GenRenderbuffersEXT driDispatchRemapTable[GenRenderbuffersEXT_remap_index] +#define _gloffset_GenerateMipmapEXT driDispatchRemapTable[GenerateMipmapEXT_remap_index] +#define _gloffset_GetFramebufferAttachmentParameterivEXT driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index] +#define _gloffset_GetRenderbufferParameterivEXT driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index] +#define _gloffset_IsFramebufferEXT driDispatchRemapTable[IsFramebufferEXT_remap_index] +#define _gloffset_IsRenderbufferEXT driDispatchRemapTable[IsRenderbufferEXT_remap_index] +#define _gloffset_RenderbufferStorageEXT driDispatchRemapTable[RenderbufferStorageEXT_remap_index] +#define _gloffset_BlitFramebufferEXT driDispatchRemapTable[BlitFramebufferEXT_remap_index] +#define _gloffset_BufferParameteriAPPLE driDispatchRemapTable[BufferParameteriAPPLE_remap_index] +#define _gloffset_FlushMappedBufferRangeAPPLE driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index] +#define _gloffset_BindFragDataLocationEXT driDispatchRemapTable[BindFragDataLocationEXT_remap_index] +#define _gloffset_GetFragDataLocationEXT driDispatchRemapTable[GetFragDataLocationEXT_remap_index] +#define _gloffset_GetUniformuivEXT driDispatchRemapTable[GetUniformuivEXT_remap_index] +#define _gloffset_GetVertexAttribIivEXT driDispatchRemapTable[GetVertexAttribIivEXT_remap_index] +#define _gloffset_GetVertexAttribIuivEXT driDispatchRemapTable[GetVertexAttribIuivEXT_remap_index] +#define _gloffset_Uniform1uiEXT driDispatchRemapTable[Uniform1uiEXT_remap_index] +#define _gloffset_Uniform1uivEXT driDispatchRemapTable[Uniform1uivEXT_remap_index] +#define _gloffset_Uniform2uiEXT driDispatchRemapTable[Uniform2uiEXT_remap_index] +#define _gloffset_Uniform2uivEXT driDispatchRemapTable[Uniform2uivEXT_remap_index] +#define _gloffset_Uniform3uiEXT driDispatchRemapTable[Uniform3uiEXT_remap_index] +#define _gloffset_Uniform3uivEXT driDispatchRemapTable[Uniform3uivEXT_remap_index] +#define _gloffset_Uniform4uiEXT driDispatchRemapTable[Uniform4uiEXT_remap_index] +#define _gloffset_Uniform4uivEXT driDispatchRemapTable[Uniform4uivEXT_remap_index] +#define _gloffset_VertexAttribI1iEXT driDispatchRemapTable[VertexAttribI1iEXT_remap_index] +#define _gloffset_VertexAttribI1ivEXT driDispatchRemapTable[VertexAttribI1ivEXT_remap_index] +#define _gloffset_VertexAttribI1uiEXT driDispatchRemapTable[VertexAttribI1uiEXT_remap_index] +#define _gloffset_VertexAttribI1uivEXT driDispatchRemapTable[VertexAttribI1uivEXT_remap_index] +#define _gloffset_VertexAttribI2iEXT driDispatchRemapTable[VertexAttribI2iEXT_remap_index] +#define _gloffset_VertexAttribI2ivEXT driDispatchRemapTable[VertexAttribI2ivEXT_remap_index] +#define _gloffset_VertexAttribI2uiEXT driDispatchRemapTable[VertexAttribI2uiEXT_remap_index] +#define _gloffset_VertexAttribI2uivEXT driDispatchRemapTable[VertexAttribI2uivEXT_remap_index] +#define _gloffset_VertexAttribI3iEXT driDispatchRemapTable[VertexAttribI3iEXT_remap_index] +#define _gloffset_VertexAttribI3ivEXT driDispatchRemapTable[VertexAttribI3ivEXT_remap_index] +#define _gloffset_VertexAttribI3uiEXT driDispatchRemapTable[VertexAttribI3uiEXT_remap_index] +#define _gloffset_VertexAttribI3uivEXT driDispatchRemapTable[VertexAttribI3uivEXT_remap_index] +#define _gloffset_VertexAttribI4bvEXT driDispatchRemapTable[VertexAttribI4bvEXT_remap_index] +#define _gloffset_VertexAttribI4iEXT driDispatchRemapTable[VertexAttribI4iEXT_remap_index] +#define _gloffset_VertexAttribI4ivEXT driDispatchRemapTable[VertexAttribI4ivEXT_remap_index] +#define _gloffset_VertexAttribI4svEXT driDispatchRemapTable[VertexAttribI4svEXT_remap_index] +#define _gloffset_VertexAttribI4ubvEXT driDispatchRemapTable[VertexAttribI4ubvEXT_remap_index] +#define _gloffset_VertexAttribI4uiEXT driDispatchRemapTable[VertexAttribI4uiEXT_remap_index] +#define _gloffset_VertexAttribI4uivEXT driDispatchRemapTable[VertexAttribI4uivEXT_remap_index] +#define _gloffset_VertexAttribI4usvEXT driDispatchRemapTable[VertexAttribI4usvEXT_remap_index] +#define _gloffset_VertexAttribIPointerEXT driDispatchRemapTable[VertexAttribIPointerEXT_remap_index] +#define _gloffset_FramebufferTextureLayerEXT driDispatchRemapTable[FramebufferTextureLayerEXT_remap_index] +#define _gloffset_ColorMaskIndexedEXT driDispatchRemapTable[ColorMaskIndexedEXT_remap_index] +#define _gloffset_DisableIndexedEXT driDispatchRemapTable[DisableIndexedEXT_remap_index] +#define _gloffset_EnableIndexedEXT driDispatchRemapTable[EnableIndexedEXT_remap_index] +#define _gloffset_GetBooleanIndexedvEXT driDispatchRemapTable[GetBooleanIndexedvEXT_remap_index] +#define _gloffset_GetIntegerIndexedvEXT driDispatchRemapTable[GetIntegerIndexedvEXT_remap_index] +#define _gloffset_IsEnabledIndexedEXT driDispatchRemapTable[IsEnabledIndexedEXT_remap_index] +#define _gloffset_ClearColorIiEXT driDispatchRemapTable[ClearColorIiEXT_remap_index] +#define _gloffset_ClearColorIuiEXT driDispatchRemapTable[ClearColorIuiEXT_remap_index] +#define _gloffset_GetTexParameterIivEXT driDispatchRemapTable[GetTexParameterIivEXT_remap_index] +#define _gloffset_GetTexParameterIuivEXT driDispatchRemapTable[GetTexParameterIuivEXT_remap_index] +#define _gloffset_TexParameterIivEXT driDispatchRemapTable[TexParameterIivEXT_remap_index] +#define _gloffset_TexParameterIuivEXT driDispatchRemapTable[TexParameterIuivEXT_remap_index] +#define _gloffset_BeginConditionalRenderNV driDispatchRemapTable[BeginConditionalRenderNV_remap_index] +#define _gloffset_EndConditionalRenderNV driDispatchRemapTable[EndConditionalRenderNV_remap_index] +#define _gloffset_BeginTransformFeedbackEXT driDispatchRemapTable[BeginTransformFeedbackEXT_remap_index] +#define _gloffset_BindBufferBaseEXT driDispatchRemapTable[BindBufferBaseEXT_remap_index] +#define _gloffset_BindBufferOffsetEXT driDispatchRemapTable[BindBufferOffsetEXT_remap_index] +#define _gloffset_BindBufferRangeEXT driDispatchRemapTable[BindBufferRangeEXT_remap_index] +#define _gloffset_EndTransformFeedbackEXT driDispatchRemapTable[EndTransformFeedbackEXT_remap_index] +#define _gloffset_GetTransformFeedbackVaryingEXT driDispatchRemapTable[GetTransformFeedbackVaryingEXT_remap_index] +#define _gloffset_TransformFeedbackVaryingsEXT driDispatchRemapTable[TransformFeedbackVaryingsEXT_remap_index] +#define _gloffset_ProvokingVertexEXT driDispatchRemapTable[ProvokingVertexEXT_remap_index] +#define _gloffset_GetTexParameterPointervAPPLE driDispatchRemapTable[GetTexParameterPointervAPPLE_remap_index] +#define _gloffset_TextureRangeAPPLE driDispatchRemapTable[TextureRangeAPPLE_remap_index] +#define _gloffset_GetObjectParameterivAPPLE driDispatchRemapTable[GetObjectParameterivAPPLE_remap_index] +#define _gloffset_ObjectPurgeableAPPLE driDispatchRemapTable[ObjectPurgeableAPPLE_remap_index] +#define _gloffset_ObjectUnpurgeableAPPLE driDispatchRemapTable[ObjectUnpurgeableAPPLE_remap_index] +#define _gloffset_ActiveProgramEXT driDispatchRemapTable[ActiveProgramEXT_remap_index] +#define _gloffset_CreateShaderProgramEXT driDispatchRemapTable[CreateShaderProgramEXT_remap_index] +#define _gloffset_UseShaderProgramEXT driDispatchRemapTable[UseShaderProgramEXT_remap_index] +#define _gloffset_StencilFuncSeparateATI driDispatchRemapTable[StencilFuncSeparateATI_remap_index] +#define _gloffset_ProgramEnvParameters4fvEXT driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index] +#define _gloffset_ProgramLocalParameters4fvEXT driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index] +#define _gloffset_GetQueryObjecti64vEXT driDispatchRemapTable[GetQueryObjecti64vEXT_remap_index] +#define _gloffset_GetQueryObjectui64vEXT driDispatchRemapTable[GetQueryObjectui64vEXT_remap_index] +#define _gloffset_EGLImageTargetRenderbufferStorageOES driDispatchRemapTable[EGLImageTargetRenderbufferStorageOES_remap_index] +#define _gloffset_EGLImageTargetTexture2DOES driDispatchRemapTable[EGLImageTargetTexture2DOES_remap_index] + +#endif /* _GLAPI_USE_REMAP_TABLE */ + +#define CALL_NewList(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), _gloffset_NewList, parameters) +#define GET_NewList(disp) GET_by_offset(disp, _gloffset_NewList) +#define SET_NewList(disp, fn) SET_by_offset(disp, _gloffset_NewList, fn) +#define CALL_EndList(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_EndList, parameters) +#define GET_EndList(disp) GET_by_offset(disp, _gloffset_EndList) +#define SET_EndList(disp, fn) SET_by_offset(disp, _gloffset_EndList, fn) +#define CALL_CallList(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_CallList, parameters) +#define GET_CallList(disp) GET_by_offset(disp, _gloffset_CallList) +#define SET_CallList(disp, fn) SET_by_offset(disp, _gloffset_CallList, fn) +#define CALL_CallLists(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLenum, const GLvoid *)), _gloffset_CallLists, parameters) +#define GET_CallLists(disp) GET_by_offset(disp, _gloffset_CallLists) +#define SET_CallLists(disp, fn) SET_by_offset(disp, _gloffset_CallLists, fn) +#define CALL_DeleteLists(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei)), _gloffset_DeleteLists, parameters) +#define GET_DeleteLists(disp) GET_by_offset(disp, _gloffset_DeleteLists) +#define SET_DeleteLists(disp, fn) SET_by_offset(disp, _gloffset_DeleteLists, fn) +#define CALL_GenLists(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLsizei)), _gloffset_GenLists, parameters) +#define GET_GenLists(disp) GET_by_offset(disp, _gloffset_GenLists) +#define SET_GenLists(disp, fn) SET_by_offset(disp, _gloffset_GenLists, fn) +#define CALL_ListBase(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_ListBase, parameters) +#define GET_ListBase(disp) GET_by_offset(disp, _gloffset_ListBase) +#define SET_ListBase(disp, fn) SET_by_offset(disp, _gloffset_ListBase, fn) +#define CALL_Begin(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_Begin, parameters) +#define GET_Begin(disp) GET_by_offset(disp, _gloffset_Begin) +#define SET_Begin(disp, fn) SET_by_offset(disp, _gloffset_Begin, fn) +#define CALL_Bitmap(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *)), _gloffset_Bitmap, parameters) +#define GET_Bitmap(disp) GET_by_offset(disp, _gloffset_Bitmap) +#define SET_Bitmap(disp, fn) SET_by_offset(disp, _gloffset_Bitmap, fn) +#define CALL_Color3b(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), _gloffset_Color3b, parameters) +#define GET_Color3b(disp) GET_by_offset(disp, _gloffset_Color3b) +#define SET_Color3b(disp, fn) SET_by_offset(disp, _gloffset_Color3b, fn) +#define CALL_Color3bv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), _gloffset_Color3bv, parameters) +#define GET_Color3bv(disp) GET_by_offset(disp, _gloffset_Color3bv) +#define SET_Color3bv(disp, fn) SET_by_offset(disp, _gloffset_Color3bv, fn) +#define CALL_Color3d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_Color3d, parameters) +#define GET_Color3d(disp) GET_by_offset(disp, _gloffset_Color3d) +#define SET_Color3d(disp, fn) SET_by_offset(disp, _gloffset_Color3d, fn) +#define CALL_Color3dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Color3dv, parameters) +#define GET_Color3dv(disp) GET_by_offset(disp, _gloffset_Color3dv) +#define SET_Color3dv(disp, fn) SET_by_offset(disp, _gloffset_Color3dv, fn) +#define CALL_Color3f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_Color3f, parameters) +#define GET_Color3f(disp) GET_by_offset(disp, _gloffset_Color3f) +#define SET_Color3f(disp, fn) SET_by_offset(disp, _gloffset_Color3f, fn) +#define CALL_Color3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Color3fv, parameters) +#define GET_Color3fv(disp) GET_by_offset(disp, _gloffset_Color3fv) +#define SET_Color3fv(disp, fn) SET_by_offset(disp, _gloffset_Color3fv, fn) +#define CALL_Color3i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_Color3i, parameters) +#define GET_Color3i(disp) GET_by_offset(disp, _gloffset_Color3i) +#define SET_Color3i(disp, fn) SET_by_offset(disp, _gloffset_Color3i, fn) +#define CALL_Color3iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Color3iv, parameters) +#define GET_Color3iv(disp) GET_by_offset(disp, _gloffset_Color3iv) +#define SET_Color3iv(disp, fn) SET_by_offset(disp, _gloffset_Color3iv, fn) +#define CALL_Color3s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_Color3s, parameters) +#define GET_Color3s(disp) GET_by_offset(disp, _gloffset_Color3s) +#define SET_Color3s(disp, fn) SET_by_offset(disp, _gloffset_Color3s, fn) +#define CALL_Color3sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Color3sv, parameters) +#define GET_Color3sv(disp) GET_by_offset(disp, _gloffset_Color3sv) +#define SET_Color3sv(disp, fn) SET_by_offset(disp, _gloffset_Color3sv, fn) +#define CALL_Color3ub(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte)), _gloffset_Color3ub, parameters) +#define GET_Color3ub(disp) GET_by_offset(disp, _gloffset_Color3ub) +#define SET_Color3ub(disp, fn) SET_by_offset(disp, _gloffset_Color3ub, fn) +#define CALL_Color3ubv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), _gloffset_Color3ubv, parameters) +#define GET_Color3ubv(disp) GET_by_offset(disp, _gloffset_Color3ubv) +#define SET_Color3ubv(disp, fn) SET_by_offset(disp, _gloffset_Color3ubv, fn) +#define CALL_Color3ui(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), _gloffset_Color3ui, parameters) +#define GET_Color3ui(disp) GET_by_offset(disp, _gloffset_Color3ui) +#define SET_Color3ui(disp, fn) SET_by_offset(disp, _gloffset_Color3ui, fn) +#define CALL_Color3uiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), _gloffset_Color3uiv, parameters) +#define GET_Color3uiv(disp) GET_by_offset(disp, _gloffset_Color3uiv) +#define SET_Color3uiv(disp, fn) SET_by_offset(disp, _gloffset_Color3uiv, fn) +#define CALL_Color3us(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort)), _gloffset_Color3us, parameters) +#define GET_Color3us(disp) GET_by_offset(disp, _gloffset_Color3us) +#define SET_Color3us(disp, fn) SET_by_offset(disp, _gloffset_Color3us, fn) +#define CALL_Color3usv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), _gloffset_Color3usv, parameters) +#define GET_Color3usv(disp) GET_by_offset(disp, _gloffset_Color3usv) +#define SET_Color3usv(disp, fn) SET_by_offset(disp, _gloffset_Color3usv, fn) +#define CALL_Color4b(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte, GLbyte)), _gloffset_Color4b, parameters) +#define GET_Color4b(disp) GET_by_offset(disp, _gloffset_Color4b) +#define SET_Color4b(disp, fn) SET_by_offset(disp, _gloffset_Color4b, fn) +#define CALL_Color4bv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), _gloffset_Color4bv, parameters) +#define GET_Color4bv(disp) GET_by_offset(disp, _gloffset_Color4bv) +#define SET_Color4bv(disp, fn) SET_by_offset(disp, _gloffset_Color4bv, fn) +#define CALL_Color4d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Color4d, parameters) +#define GET_Color4d(disp) GET_by_offset(disp, _gloffset_Color4d) +#define SET_Color4d(disp, fn) SET_by_offset(disp, _gloffset_Color4d, fn) +#define CALL_Color4dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Color4dv, parameters) +#define GET_Color4dv(disp) GET_by_offset(disp, _gloffset_Color4dv) +#define SET_Color4dv(disp, fn) SET_by_offset(disp, _gloffset_Color4dv, fn) +#define CALL_Color4f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_Color4f, parameters) +#define GET_Color4f(disp) GET_by_offset(disp, _gloffset_Color4f) +#define SET_Color4f(disp, fn) SET_by_offset(disp, _gloffset_Color4f, fn) +#define CALL_Color4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Color4fv, parameters) +#define GET_Color4fv(disp) GET_by_offset(disp, _gloffset_Color4fv) +#define SET_Color4fv(disp, fn) SET_by_offset(disp, _gloffset_Color4fv, fn) +#define CALL_Color4i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_Color4i, parameters) +#define GET_Color4i(disp) GET_by_offset(disp, _gloffset_Color4i) +#define SET_Color4i(disp, fn) SET_by_offset(disp, _gloffset_Color4i, fn) +#define CALL_Color4iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Color4iv, parameters) +#define GET_Color4iv(disp) GET_by_offset(disp, _gloffset_Color4iv) +#define SET_Color4iv(disp, fn) SET_by_offset(disp, _gloffset_Color4iv, fn) +#define CALL_Color4s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_Color4s, parameters) +#define GET_Color4s(disp) GET_by_offset(disp, _gloffset_Color4s) +#define SET_Color4s(disp, fn) SET_by_offset(disp, _gloffset_Color4s, fn) +#define CALL_Color4sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Color4sv, parameters) +#define GET_Color4sv(disp) GET_by_offset(disp, _gloffset_Color4sv) +#define SET_Color4sv(disp, fn) SET_by_offset(disp, _gloffset_Color4sv, fn) +#define CALL_Color4ub(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte, GLubyte)), _gloffset_Color4ub, parameters) +#define GET_Color4ub(disp) GET_by_offset(disp, _gloffset_Color4ub) +#define SET_Color4ub(disp, fn) SET_by_offset(disp, _gloffset_Color4ub, fn) +#define CALL_Color4ubv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), _gloffset_Color4ubv, parameters) +#define GET_Color4ubv(disp) GET_by_offset(disp, _gloffset_Color4ubv) +#define SET_Color4ubv(disp, fn) SET_by_offset(disp, _gloffset_Color4ubv, fn) +#define CALL_Color4ui(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint, GLuint)), _gloffset_Color4ui, parameters) +#define GET_Color4ui(disp) GET_by_offset(disp, _gloffset_Color4ui) +#define SET_Color4ui(disp, fn) SET_by_offset(disp, _gloffset_Color4ui, fn) +#define CALL_Color4uiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), _gloffset_Color4uiv, parameters) +#define GET_Color4uiv(disp) GET_by_offset(disp, _gloffset_Color4uiv) +#define SET_Color4uiv(disp, fn) SET_by_offset(disp, _gloffset_Color4uiv, fn) +#define CALL_Color4us(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort, GLushort)), _gloffset_Color4us, parameters) +#define GET_Color4us(disp) GET_by_offset(disp, _gloffset_Color4us) +#define SET_Color4us(disp, fn) SET_by_offset(disp, _gloffset_Color4us, fn) +#define CALL_Color4usv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), _gloffset_Color4usv, parameters) +#define GET_Color4usv(disp) GET_by_offset(disp, _gloffset_Color4usv) +#define SET_Color4usv(disp, fn) SET_by_offset(disp, _gloffset_Color4usv, fn) +#define CALL_EdgeFlag(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLboolean)), _gloffset_EdgeFlag, parameters) +#define GET_EdgeFlag(disp) GET_by_offset(disp, _gloffset_EdgeFlag) +#define SET_EdgeFlag(disp, fn) SET_by_offset(disp, _gloffset_EdgeFlag, fn) +#define CALL_EdgeFlagv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLboolean *)), _gloffset_EdgeFlagv, parameters) +#define GET_EdgeFlagv(disp) GET_by_offset(disp, _gloffset_EdgeFlagv) +#define SET_EdgeFlagv(disp, fn) SET_by_offset(disp, _gloffset_EdgeFlagv, fn) +#define CALL_End(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_End, parameters) +#define GET_End(disp) GET_by_offset(disp, _gloffset_End) +#define SET_End(disp, fn) SET_by_offset(disp, _gloffset_End, fn) +#define CALL_Indexd(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), _gloffset_Indexd, parameters) +#define GET_Indexd(disp) GET_by_offset(disp, _gloffset_Indexd) +#define SET_Indexd(disp, fn) SET_by_offset(disp, _gloffset_Indexd, fn) +#define CALL_Indexdv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Indexdv, parameters) +#define GET_Indexdv(disp) GET_by_offset(disp, _gloffset_Indexdv) +#define SET_Indexdv(disp, fn) SET_by_offset(disp, _gloffset_Indexdv, fn) +#define CALL_Indexf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_Indexf, parameters) +#define GET_Indexf(disp) GET_by_offset(disp, _gloffset_Indexf) +#define SET_Indexf(disp, fn) SET_by_offset(disp, _gloffset_Indexf, fn) +#define CALL_Indexfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Indexfv, parameters) +#define GET_Indexfv(disp) GET_by_offset(disp, _gloffset_Indexfv) +#define SET_Indexfv(disp, fn) SET_by_offset(disp, _gloffset_Indexfv, fn) +#define CALL_Indexi(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), _gloffset_Indexi, parameters) +#define GET_Indexi(disp) GET_by_offset(disp, _gloffset_Indexi) +#define SET_Indexi(disp, fn) SET_by_offset(disp, _gloffset_Indexi, fn) +#define CALL_Indexiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Indexiv, parameters) +#define GET_Indexiv(disp) GET_by_offset(disp, _gloffset_Indexiv) +#define SET_Indexiv(disp, fn) SET_by_offset(disp, _gloffset_Indexiv, fn) +#define CALL_Indexs(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort)), _gloffset_Indexs, parameters) +#define GET_Indexs(disp) GET_by_offset(disp, _gloffset_Indexs) +#define SET_Indexs(disp, fn) SET_by_offset(disp, _gloffset_Indexs, fn) +#define CALL_Indexsv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Indexsv, parameters) +#define GET_Indexsv(disp) GET_by_offset(disp, _gloffset_Indexsv) +#define SET_Indexsv(disp, fn) SET_by_offset(disp, _gloffset_Indexsv, fn) +#define CALL_Normal3b(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), _gloffset_Normal3b, parameters) +#define GET_Normal3b(disp) GET_by_offset(disp, _gloffset_Normal3b) +#define SET_Normal3b(disp, fn) SET_by_offset(disp, _gloffset_Normal3b, fn) +#define CALL_Normal3bv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), _gloffset_Normal3bv, parameters) +#define GET_Normal3bv(disp) GET_by_offset(disp, _gloffset_Normal3bv) +#define SET_Normal3bv(disp, fn) SET_by_offset(disp, _gloffset_Normal3bv, fn) +#define CALL_Normal3d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_Normal3d, parameters) +#define GET_Normal3d(disp) GET_by_offset(disp, _gloffset_Normal3d) +#define SET_Normal3d(disp, fn) SET_by_offset(disp, _gloffset_Normal3d, fn) +#define CALL_Normal3dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Normal3dv, parameters) +#define GET_Normal3dv(disp) GET_by_offset(disp, _gloffset_Normal3dv) +#define SET_Normal3dv(disp, fn) SET_by_offset(disp, _gloffset_Normal3dv, fn) +#define CALL_Normal3f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_Normal3f, parameters) +#define GET_Normal3f(disp) GET_by_offset(disp, _gloffset_Normal3f) +#define SET_Normal3f(disp, fn) SET_by_offset(disp, _gloffset_Normal3f, fn) +#define CALL_Normal3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Normal3fv, parameters) +#define GET_Normal3fv(disp) GET_by_offset(disp, _gloffset_Normal3fv) +#define SET_Normal3fv(disp, fn) SET_by_offset(disp, _gloffset_Normal3fv, fn) +#define CALL_Normal3i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_Normal3i, parameters) +#define GET_Normal3i(disp) GET_by_offset(disp, _gloffset_Normal3i) +#define SET_Normal3i(disp, fn) SET_by_offset(disp, _gloffset_Normal3i, fn) +#define CALL_Normal3iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Normal3iv, parameters) +#define GET_Normal3iv(disp) GET_by_offset(disp, _gloffset_Normal3iv) +#define SET_Normal3iv(disp, fn) SET_by_offset(disp, _gloffset_Normal3iv, fn) +#define CALL_Normal3s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_Normal3s, parameters) +#define GET_Normal3s(disp) GET_by_offset(disp, _gloffset_Normal3s) +#define SET_Normal3s(disp, fn) SET_by_offset(disp, _gloffset_Normal3s, fn) +#define CALL_Normal3sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Normal3sv, parameters) +#define GET_Normal3sv(disp) GET_by_offset(disp, _gloffset_Normal3sv) +#define SET_Normal3sv(disp, fn) SET_by_offset(disp, _gloffset_Normal3sv, fn) +#define CALL_RasterPos2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), _gloffset_RasterPos2d, parameters) +#define GET_RasterPos2d(disp) GET_by_offset(disp, _gloffset_RasterPos2d) +#define SET_RasterPos2d(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2d, fn) +#define CALL_RasterPos2dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_RasterPos2dv, parameters) +#define GET_RasterPos2dv(disp) GET_by_offset(disp, _gloffset_RasterPos2dv) +#define SET_RasterPos2dv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2dv, fn) +#define CALL_RasterPos2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_RasterPos2f, parameters) +#define GET_RasterPos2f(disp) GET_by_offset(disp, _gloffset_RasterPos2f) +#define SET_RasterPos2f(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2f, fn) +#define CALL_RasterPos2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_RasterPos2fv, parameters) +#define GET_RasterPos2fv(disp) GET_by_offset(disp, _gloffset_RasterPos2fv) +#define SET_RasterPos2fv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2fv, fn) +#define CALL_RasterPos2i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_RasterPos2i, parameters) +#define GET_RasterPos2i(disp) GET_by_offset(disp, _gloffset_RasterPos2i) +#define SET_RasterPos2i(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2i, fn) +#define CALL_RasterPos2iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_RasterPos2iv, parameters) +#define GET_RasterPos2iv(disp) GET_by_offset(disp, _gloffset_RasterPos2iv) +#define SET_RasterPos2iv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2iv, fn) +#define CALL_RasterPos2s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), _gloffset_RasterPos2s, parameters) +#define GET_RasterPos2s(disp) GET_by_offset(disp, _gloffset_RasterPos2s) +#define SET_RasterPos2s(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2s, fn) +#define CALL_RasterPos2sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_RasterPos2sv, parameters) +#define GET_RasterPos2sv(disp) GET_by_offset(disp, _gloffset_RasterPos2sv) +#define SET_RasterPos2sv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos2sv, fn) +#define CALL_RasterPos3d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_RasterPos3d, parameters) +#define GET_RasterPos3d(disp) GET_by_offset(disp, _gloffset_RasterPos3d) +#define SET_RasterPos3d(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3d, fn) +#define CALL_RasterPos3dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_RasterPos3dv, parameters) +#define GET_RasterPos3dv(disp) GET_by_offset(disp, _gloffset_RasterPos3dv) +#define SET_RasterPos3dv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3dv, fn) +#define CALL_RasterPos3f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_RasterPos3f, parameters) +#define GET_RasterPos3f(disp) GET_by_offset(disp, _gloffset_RasterPos3f) +#define SET_RasterPos3f(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3f, fn) +#define CALL_RasterPos3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_RasterPos3fv, parameters) +#define GET_RasterPos3fv(disp) GET_by_offset(disp, _gloffset_RasterPos3fv) +#define SET_RasterPos3fv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3fv, fn) +#define CALL_RasterPos3i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_RasterPos3i, parameters) +#define GET_RasterPos3i(disp) GET_by_offset(disp, _gloffset_RasterPos3i) +#define SET_RasterPos3i(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3i, fn) +#define CALL_RasterPos3iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_RasterPos3iv, parameters) +#define GET_RasterPos3iv(disp) GET_by_offset(disp, _gloffset_RasterPos3iv) +#define SET_RasterPos3iv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3iv, fn) +#define CALL_RasterPos3s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_RasterPos3s, parameters) +#define GET_RasterPos3s(disp) GET_by_offset(disp, _gloffset_RasterPos3s) +#define SET_RasterPos3s(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3s, fn) +#define CALL_RasterPos3sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_RasterPos3sv, parameters) +#define GET_RasterPos3sv(disp) GET_by_offset(disp, _gloffset_RasterPos3sv) +#define SET_RasterPos3sv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos3sv, fn) +#define CALL_RasterPos4d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_RasterPos4d, parameters) +#define GET_RasterPos4d(disp) GET_by_offset(disp, _gloffset_RasterPos4d) +#define SET_RasterPos4d(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4d, fn) +#define CALL_RasterPos4dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_RasterPos4dv, parameters) +#define GET_RasterPos4dv(disp) GET_by_offset(disp, _gloffset_RasterPos4dv) +#define SET_RasterPos4dv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4dv, fn) +#define CALL_RasterPos4f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_RasterPos4f, parameters) +#define GET_RasterPos4f(disp) GET_by_offset(disp, _gloffset_RasterPos4f) +#define SET_RasterPos4f(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4f, fn) +#define CALL_RasterPos4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_RasterPos4fv, parameters) +#define GET_RasterPos4fv(disp) GET_by_offset(disp, _gloffset_RasterPos4fv) +#define SET_RasterPos4fv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4fv, fn) +#define CALL_RasterPos4i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_RasterPos4i, parameters) +#define GET_RasterPos4i(disp) GET_by_offset(disp, _gloffset_RasterPos4i) +#define SET_RasterPos4i(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4i, fn) +#define CALL_RasterPos4iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_RasterPos4iv, parameters) +#define GET_RasterPos4iv(disp) GET_by_offset(disp, _gloffset_RasterPos4iv) +#define SET_RasterPos4iv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4iv, fn) +#define CALL_RasterPos4s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_RasterPos4s, parameters) +#define GET_RasterPos4s(disp) GET_by_offset(disp, _gloffset_RasterPos4s) +#define SET_RasterPos4s(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4s, fn) +#define CALL_RasterPos4sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_RasterPos4sv, parameters) +#define GET_RasterPos4sv(disp) GET_by_offset(disp, _gloffset_RasterPos4sv) +#define SET_RasterPos4sv(disp, fn) SET_by_offset(disp, _gloffset_RasterPos4sv, fn) +#define CALL_Rectd(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Rectd, parameters) +#define GET_Rectd(disp) GET_by_offset(disp, _gloffset_Rectd) +#define SET_Rectd(disp, fn) SET_by_offset(disp, _gloffset_Rectd, fn) +#define CALL_Rectdv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *, const GLdouble *)), _gloffset_Rectdv, parameters) +#define GET_Rectdv(disp) GET_by_offset(disp, _gloffset_Rectdv) +#define SET_Rectdv(disp, fn) SET_by_offset(disp, _gloffset_Rectdv, fn) +#define CALL_Rectf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_Rectf, parameters) +#define GET_Rectf(disp) GET_by_offset(disp, _gloffset_Rectf) +#define SET_Rectf(disp, fn) SET_by_offset(disp, _gloffset_Rectf, fn) +#define CALL_Rectfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *, const GLfloat *)), _gloffset_Rectfv, parameters) +#define GET_Rectfv(disp) GET_by_offset(disp, _gloffset_Rectfv) +#define SET_Rectfv(disp, fn) SET_by_offset(disp, _gloffset_Rectfv, fn) +#define CALL_Recti(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_Recti, parameters) +#define GET_Recti(disp) GET_by_offset(disp, _gloffset_Recti) +#define SET_Recti(disp, fn) SET_by_offset(disp, _gloffset_Recti, fn) +#define CALL_Rectiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *, const GLint *)), _gloffset_Rectiv, parameters) +#define GET_Rectiv(disp) GET_by_offset(disp, _gloffset_Rectiv) +#define SET_Rectiv(disp, fn) SET_by_offset(disp, _gloffset_Rectiv, fn) +#define CALL_Rects(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_Rects, parameters) +#define GET_Rects(disp) GET_by_offset(disp, _gloffset_Rects) +#define SET_Rects(disp, fn) SET_by_offset(disp, _gloffset_Rects, fn) +#define CALL_Rectsv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *, const GLshort *)), _gloffset_Rectsv, parameters) +#define GET_Rectsv(disp) GET_by_offset(disp, _gloffset_Rectsv) +#define SET_Rectsv(disp, fn) SET_by_offset(disp, _gloffset_Rectsv, fn) +#define CALL_TexCoord1d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), _gloffset_TexCoord1d, parameters) +#define GET_TexCoord1d(disp) GET_by_offset(disp, _gloffset_TexCoord1d) +#define SET_TexCoord1d(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1d, fn) +#define CALL_TexCoord1dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_TexCoord1dv, parameters) +#define GET_TexCoord1dv(disp) GET_by_offset(disp, _gloffset_TexCoord1dv) +#define SET_TexCoord1dv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1dv, fn) +#define CALL_TexCoord1f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_TexCoord1f, parameters) +#define GET_TexCoord1f(disp) GET_by_offset(disp, _gloffset_TexCoord1f) +#define SET_TexCoord1f(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1f, fn) +#define CALL_TexCoord1fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_TexCoord1fv, parameters) +#define GET_TexCoord1fv(disp) GET_by_offset(disp, _gloffset_TexCoord1fv) +#define SET_TexCoord1fv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1fv, fn) +#define CALL_TexCoord1i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), _gloffset_TexCoord1i, parameters) +#define GET_TexCoord1i(disp) GET_by_offset(disp, _gloffset_TexCoord1i) +#define SET_TexCoord1i(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1i, fn) +#define CALL_TexCoord1iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_TexCoord1iv, parameters) +#define GET_TexCoord1iv(disp) GET_by_offset(disp, _gloffset_TexCoord1iv) +#define SET_TexCoord1iv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1iv, fn) +#define CALL_TexCoord1s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort)), _gloffset_TexCoord1s, parameters) +#define GET_TexCoord1s(disp) GET_by_offset(disp, _gloffset_TexCoord1s) +#define SET_TexCoord1s(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1s, fn) +#define CALL_TexCoord1sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_TexCoord1sv, parameters) +#define GET_TexCoord1sv(disp) GET_by_offset(disp, _gloffset_TexCoord1sv) +#define SET_TexCoord1sv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord1sv, fn) +#define CALL_TexCoord2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), _gloffset_TexCoord2d, parameters) +#define GET_TexCoord2d(disp) GET_by_offset(disp, _gloffset_TexCoord2d) +#define SET_TexCoord2d(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2d, fn) +#define CALL_TexCoord2dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_TexCoord2dv, parameters) +#define GET_TexCoord2dv(disp) GET_by_offset(disp, _gloffset_TexCoord2dv) +#define SET_TexCoord2dv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2dv, fn) +#define CALL_TexCoord2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_TexCoord2f, parameters) +#define GET_TexCoord2f(disp) GET_by_offset(disp, _gloffset_TexCoord2f) +#define SET_TexCoord2f(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2f, fn) +#define CALL_TexCoord2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_TexCoord2fv, parameters) +#define GET_TexCoord2fv(disp) GET_by_offset(disp, _gloffset_TexCoord2fv) +#define SET_TexCoord2fv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2fv, fn) +#define CALL_TexCoord2i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_TexCoord2i, parameters) +#define GET_TexCoord2i(disp) GET_by_offset(disp, _gloffset_TexCoord2i) +#define SET_TexCoord2i(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2i, fn) +#define CALL_TexCoord2iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_TexCoord2iv, parameters) +#define GET_TexCoord2iv(disp) GET_by_offset(disp, _gloffset_TexCoord2iv) +#define SET_TexCoord2iv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2iv, fn) +#define CALL_TexCoord2s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), _gloffset_TexCoord2s, parameters) +#define GET_TexCoord2s(disp) GET_by_offset(disp, _gloffset_TexCoord2s) +#define SET_TexCoord2s(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2s, fn) +#define CALL_TexCoord2sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_TexCoord2sv, parameters) +#define GET_TexCoord2sv(disp) GET_by_offset(disp, _gloffset_TexCoord2sv) +#define SET_TexCoord2sv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord2sv, fn) +#define CALL_TexCoord3d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_TexCoord3d, parameters) +#define GET_TexCoord3d(disp) GET_by_offset(disp, _gloffset_TexCoord3d) +#define SET_TexCoord3d(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3d, fn) +#define CALL_TexCoord3dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_TexCoord3dv, parameters) +#define GET_TexCoord3dv(disp) GET_by_offset(disp, _gloffset_TexCoord3dv) +#define SET_TexCoord3dv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3dv, fn) +#define CALL_TexCoord3f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_TexCoord3f, parameters) +#define GET_TexCoord3f(disp) GET_by_offset(disp, _gloffset_TexCoord3f) +#define SET_TexCoord3f(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3f, fn) +#define CALL_TexCoord3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_TexCoord3fv, parameters) +#define GET_TexCoord3fv(disp) GET_by_offset(disp, _gloffset_TexCoord3fv) +#define SET_TexCoord3fv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3fv, fn) +#define CALL_TexCoord3i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_TexCoord3i, parameters) +#define GET_TexCoord3i(disp) GET_by_offset(disp, _gloffset_TexCoord3i) +#define SET_TexCoord3i(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3i, fn) +#define CALL_TexCoord3iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_TexCoord3iv, parameters) +#define GET_TexCoord3iv(disp) GET_by_offset(disp, _gloffset_TexCoord3iv) +#define SET_TexCoord3iv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3iv, fn) +#define CALL_TexCoord3s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_TexCoord3s, parameters) +#define GET_TexCoord3s(disp) GET_by_offset(disp, _gloffset_TexCoord3s) +#define SET_TexCoord3s(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3s, fn) +#define CALL_TexCoord3sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_TexCoord3sv, parameters) +#define GET_TexCoord3sv(disp) GET_by_offset(disp, _gloffset_TexCoord3sv) +#define SET_TexCoord3sv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord3sv, fn) +#define CALL_TexCoord4d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_TexCoord4d, parameters) +#define GET_TexCoord4d(disp) GET_by_offset(disp, _gloffset_TexCoord4d) +#define SET_TexCoord4d(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4d, fn) +#define CALL_TexCoord4dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_TexCoord4dv, parameters) +#define GET_TexCoord4dv(disp) GET_by_offset(disp, _gloffset_TexCoord4dv) +#define SET_TexCoord4dv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4dv, fn) +#define CALL_TexCoord4f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_TexCoord4f, parameters) +#define GET_TexCoord4f(disp) GET_by_offset(disp, _gloffset_TexCoord4f) +#define SET_TexCoord4f(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4f, fn) +#define CALL_TexCoord4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_TexCoord4fv, parameters) +#define GET_TexCoord4fv(disp) GET_by_offset(disp, _gloffset_TexCoord4fv) +#define SET_TexCoord4fv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4fv, fn) +#define CALL_TexCoord4i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_TexCoord4i, parameters) +#define GET_TexCoord4i(disp) GET_by_offset(disp, _gloffset_TexCoord4i) +#define SET_TexCoord4i(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4i, fn) +#define CALL_TexCoord4iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_TexCoord4iv, parameters) +#define GET_TexCoord4iv(disp) GET_by_offset(disp, _gloffset_TexCoord4iv) +#define SET_TexCoord4iv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4iv, fn) +#define CALL_TexCoord4s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_TexCoord4s, parameters) +#define GET_TexCoord4s(disp) GET_by_offset(disp, _gloffset_TexCoord4s) +#define SET_TexCoord4s(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4s, fn) +#define CALL_TexCoord4sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_TexCoord4sv, parameters) +#define GET_TexCoord4sv(disp) GET_by_offset(disp, _gloffset_TexCoord4sv) +#define SET_TexCoord4sv(disp, fn) SET_by_offset(disp, _gloffset_TexCoord4sv, fn) +#define CALL_Vertex2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), _gloffset_Vertex2d, parameters) +#define GET_Vertex2d(disp) GET_by_offset(disp, _gloffset_Vertex2d) +#define SET_Vertex2d(disp, fn) SET_by_offset(disp, _gloffset_Vertex2d, fn) +#define CALL_Vertex2dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Vertex2dv, parameters) +#define GET_Vertex2dv(disp) GET_by_offset(disp, _gloffset_Vertex2dv) +#define SET_Vertex2dv(disp, fn) SET_by_offset(disp, _gloffset_Vertex2dv, fn) +#define CALL_Vertex2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_Vertex2f, parameters) +#define GET_Vertex2f(disp) GET_by_offset(disp, _gloffset_Vertex2f) +#define SET_Vertex2f(disp, fn) SET_by_offset(disp, _gloffset_Vertex2f, fn) +#define CALL_Vertex2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Vertex2fv, parameters) +#define GET_Vertex2fv(disp) GET_by_offset(disp, _gloffset_Vertex2fv) +#define SET_Vertex2fv(disp, fn) SET_by_offset(disp, _gloffset_Vertex2fv, fn) +#define CALL_Vertex2i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_Vertex2i, parameters) +#define GET_Vertex2i(disp) GET_by_offset(disp, _gloffset_Vertex2i) +#define SET_Vertex2i(disp, fn) SET_by_offset(disp, _gloffset_Vertex2i, fn) +#define CALL_Vertex2iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Vertex2iv, parameters) +#define GET_Vertex2iv(disp) GET_by_offset(disp, _gloffset_Vertex2iv) +#define SET_Vertex2iv(disp, fn) SET_by_offset(disp, _gloffset_Vertex2iv, fn) +#define CALL_Vertex2s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), _gloffset_Vertex2s, parameters) +#define GET_Vertex2s(disp) GET_by_offset(disp, _gloffset_Vertex2s) +#define SET_Vertex2s(disp, fn) SET_by_offset(disp, _gloffset_Vertex2s, fn) +#define CALL_Vertex2sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Vertex2sv, parameters) +#define GET_Vertex2sv(disp) GET_by_offset(disp, _gloffset_Vertex2sv) +#define SET_Vertex2sv(disp, fn) SET_by_offset(disp, _gloffset_Vertex2sv, fn) +#define CALL_Vertex3d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_Vertex3d, parameters) +#define GET_Vertex3d(disp) GET_by_offset(disp, _gloffset_Vertex3d) +#define SET_Vertex3d(disp, fn) SET_by_offset(disp, _gloffset_Vertex3d, fn) +#define CALL_Vertex3dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Vertex3dv, parameters) +#define GET_Vertex3dv(disp) GET_by_offset(disp, _gloffset_Vertex3dv) +#define SET_Vertex3dv(disp, fn) SET_by_offset(disp, _gloffset_Vertex3dv, fn) +#define CALL_Vertex3f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_Vertex3f, parameters) +#define GET_Vertex3f(disp) GET_by_offset(disp, _gloffset_Vertex3f) +#define SET_Vertex3f(disp, fn) SET_by_offset(disp, _gloffset_Vertex3f, fn) +#define CALL_Vertex3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Vertex3fv, parameters) +#define GET_Vertex3fv(disp) GET_by_offset(disp, _gloffset_Vertex3fv) +#define SET_Vertex3fv(disp, fn) SET_by_offset(disp, _gloffset_Vertex3fv, fn) +#define CALL_Vertex3i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_Vertex3i, parameters) +#define GET_Vertex3i(disp) GET_by_offset(disp, _gloffset_Vertex3i) +#define SET_Vertex3i(disp, fn) SET_by_offset(disp, _gloffset_Vertex3i, fn) +#define CALL_Vertex3iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Vertex3iv, parameters) +#define GET_Vertex3iv(disp) GET_by_offset(disp, _gloffset_Vertex3iv) +#define SET_Vertex3iv(disp, fn) SET_by_offset(disp, _gloffset_Vertex3iv, fn) +#define CALL_Vertex3s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_Vertex3s, parameters) +#define GET_Vertex3s(disp) GET_by_offset(disp, _gloffset_Vertex3s) +#define SET_Vertex3s(disp, fn) SET_by_offset(disp, _gloffset_Vertex3s, fn) +#define CALL_Vertex3sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Vertex3sv, parameters) +#define GET_Vertex3sv(disp) GET_by_offset(disp, _gloffset_Vertex3sv) +#define SET_Vertex3sv(disp, fn) SET_by_offset(disp, _gloffset_Vertex3sv, fn) +#define CALL_Vertex4d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Vertex4d, parameters) +#define GET_Vertex4d(disp) GET_by_offset(disp, _gloffset_Vertex4d) +#define SET_Vertex4d(disp, fn) SET_by_offset(disp, _gloffset_Vertex4d, fn) +#define CALL_Vertex4dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_Vertex4dv, parameters) +#define GET_Vertex4dv(disp) GET_by_offset(disp, _gloffset_Vertex4dv) +#define SET_Vertex4dv(disp, fn) SET_by_offset(disp, _gloffset_Vertex4dv, fn) +#define CALL_Vertex4f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_Vertex4f, parameters) +#define GET_Vertex4f(disp) GET_by_offset(disp, _gloffset_Vertex4f) +#define SET_Vertex4f(disp, fn) SET_by_offset(disp, _gloffset_Vertex4f, fn) +#define CALL_Vertex4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_Vertex4fv, parameters) +#define GET_Vertex4fv(disp) GET_by_offset(disp, _gloffset_Vertex4fv) +#define SET_Vertex4fv(disp, fn) SET_by_offset(disp, _gloffset_Vertex4fv, fn) +#define CALL_Vertex4i(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_Vertex4i, parameters) +#define GET_Vertex4i(disp) GET_by_offset(disp, _gloffset_Vertex4i) +#define SET_Vertex4i(disp, fn) SET_by_offset(disp, _gloffset_Vertex4i, fn) +#define CALL_Vertex4iv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_Vertex4iv, parameters) +#define GET_Vertex4iv(disp) GET_by_offset(disp, _gloffset_Vertex4iv) +#define SET_Vertex4iv(disp, fn) SET_by_offset(disp, _gloffset_Vertex4iv, fn) +#define CALL_Vertex4s(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_Vertex4s, parameters) +#define GET_Vertex4s(disp) GET_by_offset(disp, _gloffset_Vertex4s) +#define SET_Vertex4s(disp, fn) SET_by_offset(disp, _gloffset_Vertex4s, fn) +#define CALL_Vertex4sv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_Vertex4sv, parameters) +#define GET_Vertex4sv(disp) GET_by_offset(disp, _gloffset_Vertex4sv) +#define SET_Vertex4sv(disp, fn) SET_by_offset(disp, _gloffset_Vertex4sv, fn) +#define CALL_ClipPlane(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLdouble *)), _gloffset_ClipPlane, parameters) +#define GET_ClipPlane(disp) GET_by_offset(disp, _gloffset_ClipPlane) +#define SET_ClipPlane(disp, fn) SET_by_offset(disp, _gloffset_ClipPlane, fn) +#define CALL_ColorMaterial(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_ColorMaterial, parameters) +#define GET_ColorMaterial(disp) GET_by_offset(disp, _gloffset_ColorMaterial) +#define SET_ColorMaterial(disp, fn) SET_by_offset(disp, _gloffset_ColorMaterial, fn) +#define CALL_CullFace(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_CullFace, parameters) +#define GET_CullFace(disp) GET_by_offset(disp, _gloffset_CullFace) +#define SET_CullFace(disp, fn) SET_by_offset(disp, _gloffset_CullFace, fn) +#define CALL_Fogf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_Fogf, parameters) +#define GET_Fogf(disp) GET_by_offset(disp, _gloffset_Fogf) +#define SET_Fogf(disp, fn) SET_by_offset(disp, _gloffset_Fogf, fn) +#define CALL_Fogfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_Fogfv, parameters) +#define GET_Fogfv(disp) GET_by_offset(disp, _gloffset_Fogfv) +#define SET_Fogfv(disp, fn) SET_by_offset(disp, _gloffset_Fogfv, fn) +#define CALL_Fogi(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_Fogi, parameters) +#define GET_Fogi(disp) GET_by_offset(disp, _gloffset_Fogi) +#define SET_Fogi(disp, fn) SET_by_offset(disp, _gloffset_Fogi, fn) +#define CALL_Fogiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_Fogiv, parameters) +#define GET_Fogiv(disp) GET_by_offset(disp, _gloffset_Fogiv) +#define SET_Fogiv(disp, fn) SET_by_offset(disp, _gloffset_Fogiv, fn) +#define CALL_FrontFace(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_FrontFace, parameters) +#define GET_FrontFace(disp) GET_by_offset(disp, _gloffset_FrontFace) +#define SET_FrontFace(disp, fn) SET_by_offset(disp, _gloffset_FrontFace, fn) +#define CALL_Hint(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_Hint, parameters) +#define GET_Hint(disp) GET_by_offset(disp, _gloffset_Hint) +#define SET_Hint(disp, fn) SET_by_offset(disp, _gloffset_Hint, fn) +#define CALL_Lightf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_Lightf, parameters) +#define GET_Lightf(disp) GET_by_offset(disp, _gloffset_Lightf) +#define SET_Lightf(disp, fn) SET_by_offset(disp, _gloffset_Lightf, fn) +#define CALL_Lightfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_Lightfv, parameters) +#define GET_Lightfv(disp) GET_by_offset(disp, _gloffset_Lightfv) +#define SET_Lightfv(disp, fn) SET_by_offset(disp, _gloffset_Lightfv, fn) +#define CALL_Lighti(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_Lighti, parameters) +#define GET_Lighti(disp) GET_by_offset(disp, _gloffset_Lighti) +#define SET_Lighti(disp, fn) SET_by_offset(disp, _gloffset_Lighti, fn) +#define CALL_Lightiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_Lightiv, parameters) +#define GET_Lightiv(disp) GET_by_offset(disp, _gloffset_Lightiv) +#define SET_Lightiv(disp, fn) SET_by_offset(disp, _gloffset_Lightiv, fn) +#define CALL_LightModelf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_LightModelf, parameters) +#define GET_LightModelf(disp) GET_by_offset(disp, _gloffset_LightModelf) +#define SET_LightModelf(disp, fn) SET_by_offset(disp, _gloffset_LightModelf, fn) +#define CALL_LightModelfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_LightModelfv, parameters) +#define GET_LightModelfv(disp) GET_by_offset(disp, _gloffset_LightModelfv) +#define SET_LightModelfv(disp, fn) SET_by_offset(disp, _gloffset_LightModelfv, fn) +#define CALL_LightModeli(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_LightModeli, parameters) +#define GET_LightModeli(disp) GET_by_offset(disp, _gloffset_LightModeli) +#define SET_LightModeli(disp, fn) SET_by_offset(disp, _gloffset_LightModeli, fn) +#define CALL_LightModeliv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_LightModeliv, parameters) +#define GET_LightModeliv(disp) GET_by_offset(disp, _gloffset_LightModeliv) +#define SET_LightModeliv(disp, fn) SET_by_offset(disp, _gloffset_LightModeliv, fn) +#define CALL_LineStipple(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLushort)), _gloffset_LineStipple, parameters) +#define GET_LineStipple(disp) GET_by_offset(disp, _gloffset_LineStipple) +#define SET_LineStipple(disp, fn) SET_by_offset(disp, _gloffset_LineStipple, fn) +#define CALL_LineWidth(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_LineWidth, parameters) +#define GET_LineWidth(disp) GET_by_offset(disp, _gloffset_LineWidth) +#define SET_LineWidth(disp, fn) SET_by_offset(disp, _gloffset_LineWidth, fn) +#define CALL_Materialf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_Materialf, parameters) +#define GET_Materialf(disp) GET_by_offset(disp, _gloffset_Materialf) +#define SET_Materialf(disp, fn) SET_by_offset(disp, _gloffset_Materialf, fn) +#define CALL_Materialfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_Materialfv, parameters) +#define GET_Materialfv(disp) GET_by_offset(disp, _gloffset_Materialfv) +#define SET_Materialfv(disp, fn) SET_by_offset(disp, _gloffset_Materialfv, fn) +#define CALL_Materiali(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_Materiali, parameters) +#define GET_Materiali(disp) GET_by_offset(disp, _gloffset_Materiali) +#define SET_Materiali(disp, fn) SET_by_offset(disp, _gloffset_Materiali, fn) +#define CALL_Materialiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_Materialiv, parameters) +#define GET_Materialiv(disp) GET_by_offset(disp, _gloffset_Materialiv) +#define SET_Materialiv(disp, fn) SET_by_offset(disp, _gloffset_Materialiv, fn) +#define CALL_PointSize(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_PointSize, parameters) +#define GET_PointSize(disp) GET_by_offset(disp, _gloffset_PointSize) +#define SET_PointSize(disp, fn) SET_by_offset(disp, _gloffset_PointSize, fn) +#define CALL_PolygonMode(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_PolygonMode, parameters) +#define GET_PolygonMode(disp) GET_by_offset(disp, _gloffset_PolygonMode) +#define SET_PolygonMode(disp, fn) SET_by_offset(disp, _gloffset_PolygonMode, fn) +#define CALL_PolygonStipple(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), _gloffset_PolygonStipple, parameters) +#define GET_PolygonStipple(disp) GET_by_offset(disp, _gloffset_PolygonStipple) +#define SET_PolygonStipple(disp, fn) SET_by_offset(disp, _gloffset_PolygonStipple, fn) +#define CALL_Scissor(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLsizei, GLsizei)), _gloffset_Scissor, parameters) +#define GET_Scissor(disp) GET_by_offset(disp, _gloffset_Scissor) +#define SET_Scissor(disp, fn) SET_by_offset(disp, _gloffset_Scissor, fn) +#define CALL_ShadeModel(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ShadeModel, parameters) +#define GET_ShadeModel(disp) GET_by_offset(disp, _gloffset_ShadeModel) +#define SET_ShadeModel(disp, fn) SET_by_offset(disp, _gloffset_ShadeModel, fn) +#define CALL_TexParameterf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_TexParameterf, parameters) +#define GET_TexParameterf(disp) GET_by_offset(disp, _gloffset_TexParameterf) +#define SET_TexParameterf(disp, fn) SET_by_offset(disp, _gloffset_TexParameterf, fn) +#define CALL_TexParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_TexParameterfv, parameters) +#define GET_TexParameterfv(disp) GET_by_offset(disp, _gloffset_TexParameterfv) +#define SET_TexParameterfv(disp, fn) SET_by_offset(disp, _gloffset_TexParameterfv, fn) +#define CALL_TexParameteri(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_TexParameteri, parameters) +#define GET_TexParameteri(disp) GET_by_offset(disp, _gloffset_TexParameteri) +#define SET_TexParameteri(disp, fn) SET_by_offset(disp, _gloffset_TexParameteri, fn) +#define CALL_TexParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_TexParameteriv, parameters) +#define GET_TexParameteriv(disp) GET_by_offset(disp, _gloffset_TexParameteriv) +#define SET_TexParameteriv(disp, fn) SET_by_offset(disp, _gloffset_TexParameteriv, fn) +#define CALL_TexImage1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *)), _gloffset_TexImage1D, parameters) +#define GET_TexImage1D(disp) GET_by_offset(disp, _gloffset_TexImage1D) +#define SET_TexImage1D(disp, fn) SET_by_offset(disp, _gloffset_TexImage1D, fn) +#define CALL_TexImage2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)), _gloffset_TexImage2D, parameters) +#define GET_TexImage2D(disp) GET_by_offset(disp, _gloffset_TexImage2D) +#define SET_TexImage2D(disp, fn) SET_by_offset(disp, _gloffset_TexImage2D, fn) +#define CALL_TexEnvf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_TexEnvf, parameters) +#define GET_TexEnvf(disp) GET_by_offset(disp, _gloffset_TexEnvf) +#define SET_TexEnvf(disp, fn) SET_by_offset(disp, _gloffset_TexEnvf, fn) +#define CALL_TexEnvfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_TexEnvfv, parameters) +#define GET_TexEnvfv(disp) GET_by_offset(disp, _gloffset_TexEnvfv) +#define SET_TexEnvfv(disp, fn) SET_by_offset(disp, _gloffset_TexEnvfv, fn) +#define CALL_TexEnvi(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_TexEnvi, parameters) +#define GET_TexEnvi(disp) GET_by_offset(disp, _gloffset_TexEnvi) +#define SET_TexEnvi(disp, fn) SET_by_offset(disp, _gloffset_TexEnvi, fn) +#define CALL_TexEnviv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_TexEnviv, parameters) +#define GET_TexEnviv(disp) GET_by_offset(disp, _gloffset_TexEnviv) +#define SET_TexEnviv(disp, fn) SET_by_offset(disp, _gloffset_TexEnviv, fn) +#define CALL_TexGend(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLdouble)), _gloffset_TexGend, parameters) +#define GET_TexGend(disp) GET_by_offset(disp, _gloffset_TexGend) +#define SET_TexGend(disp, fn) SET_by_offset(disp, _gloffset_TexGend, fn) +#define CALL_TexGendv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLdouble *)), _gloffset_TexGendv, parameters) +#define GET_TexGendv(disp) GET_by_offset(disp, _gloffset_TexGendv) +#define SET_TexGendv(disp, fn) SET_by_offset(disp, _gloffset_TexGendv, fn) +#define CALL_TexGenf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_TexGenf, parameters) +#define GET_TexGenf(disp) GET_by_offset(disp, _gloffset_TexGenf) +#define SET_TexGenf(disp, fn) SET_by_offset(disp, _gloffset_TexGenf, fn) +#define CALL_TexGenfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_TexGenfv, parameters) +#define GET_TexGenfv(disp) GET_by_offset(disp, _gloffset_TexGenfv) +#define SET_TexGenfv(disp, fn) SET_by_offset(disp, _gloffset_TexGenfv, fn) +#define CALL_TexGeni(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_TexGeni, parameters) +#define GET_TexGeni(disp) GET_by_offset(disp, _gloffset_TexGeni) +#define SET_TexGeni(disp, fn) SET_by_offset(disp, _gloffset_TexGeni, fn) +#define CALL_TexGeniv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_TexGeniv, parameters) +#define GET_TexGeniv(disp) GET_by_offset(disp, _gloffset_TexGeniv) +#define SET_TexGeniv(disp, fn) SET_by_offset(disp, _gloffset_TexGeniv, fn) +#define CALL_FeedbackBuffer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLenum, GLfloat *)), _gloffset_FeedbackBuffer, parameters) +#define GET_FeedbackBuffer(disp) GET_by_offset(disp, _gloffset_FeedbackBuffer) +#define SET_FeedbackBuffer(disp, fn) SET_by_offset(disp, _gloffset_FeedbackBuffer, fn) +#define CALL_SelectBuffer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_SelectBuffer, parameters) +#define GET_SelectBuffer(disp) GET_by_offset(disp, _gloffset_SelectBuffer) +#define SET_SelectBuffer(disp, fn) SET_by_offset(disp, _gloffset_SelectBuffer, fn) +#define CALL_RenderMode(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLenum)), _gloffset_RenderMode, parameters) +#define GET_RenderMode(disp) GET_by_offset(disp, _gloffset_RenderMode) +#define SET_RenderMode(disp, fn) SET_by_offset(disp, _gloffset_RenderMode, fn) +#define CALL_InitNames(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_InitNames, parameters) +#define GET_InitNames(disp) GET_by_offset(disp, _gloffset_InitNames) +#define SET_InitNames(disp, fn) SET_by_offset(disp, _gloffset_InitNames, fn) +#define CALL_LoadName(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_LoadName, parameters) +#define GET_LoadName(disp) GET_by_offset(disp, _gloffset_LoadName) +#define SET_LoadName(disp, fn) SET_by_offset(disp, _gloffset_LoadName, fn) +#define CALL_PassThrough(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_PassThrough, parameters) +#define GET_PassThrough(disp) GET_by_offset(disp, _gloffset_PassThrough) +#define SET_PassThrough(disp, fn) SET_by_offset(disp, _gloffset_PassThrough, fn) +#define CALL_PopName(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PopName, parameters) +#define GET_PopName(disp) GET_by_offset(disp, _gloffset_PopName) +#define SET_PopName(disp, fn) SET_by_offset(disp, _gloffset_PopName, fn) +#define CALL_PushName(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_PushName, parameters) +#define GET_PushName(disp) GET_by_offset(disp, _gloffset_PushName) +#define SET_PushName(disp, fn) SET_by_offset(disp, _gloffset_PushName, fn) +#define CALL_DrawBuffer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_DrawBuffer, parameters) +#define GET_DrawBuffer(disp) GET_by_offset(disp, _gloffset_DrawBuffer) +#define SET_DrawBuffer(disp, fn) SET_by_offset(disp, _gloffset_DrawBuffer, fn) +#define CALL_Clear(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbitfield)), _gloffset_Clear, parameters) +#define GET_Clear(disp) GET_by_offset(disp, _gloffset_Clear) +#define SET_Clear(disp, fn) SET_by_offset(disp, _gloffset_Clear, fn) +#define CALL_ClearAccum(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_ClearAccum, parameters) +#define GET_ClearAccum(disp) GET_by_offset(disp, _gloffset_ClearAccum) +#define SET_ClearAccum(disp, fn) SET_by_offset(disp, _gloffset_ClearAccum, fn) +#define CALL_ClearIndex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_ClearIndex, parameters) +#define GET_ClearIndex(disp) GET_by_offset(disp, _gloffset_ClearIndex) +#define SET_ClearIndex(disp, fn) SET_by_offset(disp, _gloffset_ClearIndex, fn) +#define CALL_ClearColor(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLclampf, GLclampf, GLclampf)), _gloffset_ClearColor, parameters) +#define GET_ClearColor(disp) GET_by_offset(disp, _gloffset_ClearColor) +#define SET_ClearColor(disp, fn) SET_by_offset(disp, _gloffset_ClearColor, fn) +#define CALL_ClearStencil(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), _gloffset_ClearStencil, parameters) +#define GET_ClearStencil(disp) GET_by_offset(disp, _gloffset_ClearStencil) +#define SET_ClearStencil(disp, fn) SET_by_offset(disp, _gloffset_ClearStencil, fn) +#define CALL_ClearDepth(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd)), _gloffset_ClearDepth, parameters) +#define GET_ClearDepth(disp) GET_by_offset(disp, _gloffset_ClearDepth) +#define SET_ClearDepth(disp, fn) SET_by_offset(disp, _gloffset_ClearDepth, fn) +#define CALL_StencilMask(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_StencilMask, parameters) +#define GET_StencilMask(disp) GET_by_offset(disp, _gloffset_StencilMask) +#define SET_StencilMask(disp, fn) SET_by_offset(disp, _gloffset_StencilMask, fn) +#define CALL_ColorMask(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLboolean, GLboolean, GLboolean, GLboolean)), _gloffset_ColorMask, parameters) +#define GET_ColorMask(disp) GET_by_offset(disp, _gloffset_ColorMask) +#define SET_ColorMask(disp, fn) SET_by_offset(disp, _gloffset_ColorMask, fn) +#define CALL_DepthMask(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLboolean)), _gloffset_DepthMask, parameters) +#define GET_DepthMask(disp) GET_by_offset(disp, _gloffset_DepthMask) +#define SET_DepthMask(disp, fn) SET_by_offset(disp, _gloffset_DepthMask, fn) +#define CALL_IndexMask(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_IndexMask, parameters) +#define GET_IndexMask(disp) GET_by_offset(disp, _gloffset_IndexMask) +#define SET_IndexMask(disp, fn) SET_by_offset(disp, _gloffset_IndexMask, fn) +#define CALL_Accum(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_Accum, parameters) +#define GET_Accum(disp) GET_by_offset(disp, _gloffset_Accum) +#define SET_Accum(disp, fn) SET_by_offset(disp, _gloffset_Accum, fn) +#define CALL_Disable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_Disable, parameters) +#define GET_Disable(disp) GET_by_offset(disp, _gloffset_Disable) +#define SET_Disable(disp, fn) SET_by_offset(disp, _gloffset_Disable, fn) +#define CALL_Enable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_Enable, parameters) +#define GET_Enable(disp) GET_by_offset(disp, _gloffset_Enable) +#define SET_Enable(disp, fn) SET_by_offset(disp, _gloffset_Enable, fn) +#define CALL_Finish(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_Finish, parameters) +#define GET_Finish(disp) GET_by_offset(disp, _gloffset_Finish) +#define SET_Finish(disp, fn) SET_by_offset(disp, _gloffset_Finish, fn) +#define CALL_Flush(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_Flush, parameters) +#define GET_Flush(disp) GET_by_offset(disp, _gloffset_Flush) +#define SET_Flush(disp, fn) SET_by_offset(disp, _gloffset_Flush, fn) +#define CALL_PopAttrib(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PopAttrib, parameters) +#define GET_PopAttrib(disp) GET_by_offset(disp, _gloffset_PopAttrib) +#define SET_PopAttrib(disp, fn) SET_by_offset(disp, _gloffset_PopAttrib, fn) +#define CALL_PushAttrib(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbitfield)), _gloffset_PushAttrib, parameters) +#define GET_PushAttrib(disp) GET_by_offset(disp, _gloffset_PushAttrib) +#define SET_PushAttrib(disp, fn) SET_by_offset(disp, _gloffset_PushAttrib, fn) +#define CALL_Map1d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *)), _gloffset_Map1d, parameters) +#define GET_Map1d(disp) GET_by_offset(disp, _gloffset_Map1d) +#define SET_Map1d(disp, fn) SET_by_offset(disp, _gloffset_Map1d, fn) +#define CALL_Map1f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *)), _gloffset_Map1f, parameters) +#define GET_Map1f(disp) GET_by_offset(disp, _gloffset_Map1f) +#define SET_Map1f(disp, fn) SET_by_offset(disp, _gloffset_Map1f, fn) +#define CALL_Map2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *)), _gloffset_Map2d, parameters) +#define GET_Map2d(disp) GET_by_offset(disp, _gloffset_Map2d) +#define SET_Map2d(disp, fn) SET_by_offset(disp, _gloffset_Map2d, fn) +#define CALL_Map2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *)), _gloffset_Map2f, parameters) +#define GET_Map2f(disp) GET_by_offset(disp, _gloffset_Map2f) +#define SET_Map2f(disp, fn) SET_by_offset(disp, _gloffset_Map2f, fn) +#define CALL_MapGrid1d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLdouble, GLdouble)), _gloffset_MapGrid1d, parameters) +#define GET_MapGrid1d(disp) GET_by_offset(disp, _gloffset_MapGrid1d) +#define SET_MapGrid1d(disp, fn) SET_by_offset(disp, _gloffset_MapGrid1d, fn) +#define CALL_MapGrid1f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat)), _gloffset_MapGrid1f, parameters) +#define GET_MapGrid1f(disp) GET_by_offset(disp, _gloffset_MapGrid1f) +#define SET_MapGrid1f(disp, fn) SET_by_offset(disp, _gloffset_MapGrid1f, fn) +#define CALL_MapGrid2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble)), _gloffset_MapGrid2d, parameters) +#define GET_MapGrid2d(disp) GET_by_offset(disp, _gloffset_MapGrid2d) +#define SET_MapGrid2d(disp, fn) SET_by_offset(disp, _gloffset_MapGrid2d, fn) +#define CALL_MapGrid2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat)), _gloffset_MapGrid2f, parameters) +#define GET_MapGrid2f(disp) GET_by_offset(disp, _gloffset_MapGrid2f) +#define SET_MapGrid2f(disp, fn) SET_by_offset(disp, _gloffset_MapGrid2f, fn) +#define CALL_EvalCoord1d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), _gloffset_EvalCoord1d, parameters) +#define GET_EvalCoord1d(disp) GET_by_offset(disp, _gloffset_EvalCoord1d) +#define SET_EvalCoord1d(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord1d, fn) +#define CALL_EvalCoord1dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_EvalCoord1dv, parameters) +#define GET_EvalCoord1dv(disp) GET_by_offset(disp, _gloffset_EvalCoord1dv) +#define SET_EvalCoord1dv(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord1dv, fn) +#define CALL_EvalCoord1f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_EvalCoord1f, parameters) +#define GET_EvalCoord1f(disp) GET_by_offset(disp, _gloffset_EvalCoord1f) +#define SET_EvalCoord1f(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord1f, fn) +#define CALL_EvalCoord1fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_EvalCoord1fv, parameters) +#define GET_EvalCoord1fv(disp) GET_by_offset(disp, _gloffset_EvalCoord1fv) +#define SET_EvalCoord1fv(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord1fv, fn) +#define CALL_EvalCoord2d(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), _gloffset_EvalCoord2d, parameters) +#define GET_EvalCoord2d(disp) GET_by_offset(disp, _gloffset_EvalCoord2d) +#define SET_EvalCoord2d(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord2d, fn) +#define CALL_EvalCoord2dv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_EvalCoord2dv, parameters) +#define GET_EvalCoord2dv(disp) GET_by_offset(disp, _gloffset_EvalCoord2dv) +#define SET_EvalCoord2dv(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord2dv, fn) +#define CALL_EvalCoord2f(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_EvalCoord2f, parameters) +#define GET_EvalCoord2f(disp) GET_by_offset(disp, _gloffset_EvalCoord2f) +#define SET_EvalCoord2f(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord2f, fn) +#define CALL_EvalCoord2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_EvalCoord2fv, parameters) +#define GET_EvalCoord2fv(disp) GET_by_offset(disp, _gloffset_EvalCoord2fv) +#define SET_EvalCoord2fv(disp, fn) SET_by_offset(disp, _gloffset_EvalCoord2fv, fn) +#define CALL_EvalMesh1(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint)), _gloffset_EvalMesh1, parameters) +#define GET_EvalMesh1(disp) GET_by_offset(disp, _gloffset_EvalMesh1) +#define SET_EvalMesh1(disp, fn) SET_by_offset(disp, _gloffset_EvalMesh1, fn) +#define CALL_EvalPoint1(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), _gloffset_EvalPoint1, parameters) +#define GET_EvalPoint1(disp) GET_by_offset(disp, _gloffset_EvalPoint1) +#define SET_EvalPoint1(disp, fn) SET_by_offset(disp, _gloffset_EvalPoint1, fn) +#define CALL_EvalMesh2(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint)), _gloffset_EvalMesh2, parameters) +#define GET_EvalMesh2(disp) GET_by_offset(disp, _gloffset_EvalMesh2) +#define SET_EvalMesh2(disp, fn) SET_by_offset(disp, _gloffset_EvalMesh2, fn) +#define CALL_EvalPoint2(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_EvalPoint2, parameters) +#define GET_EvalPoint2(disp) GET_by_offset(disp, _gloffset_EvalPoint2) +#define SET_EvalPoint2(disp, fn) SET_by_offset(disp, _gloffset_EvalPoint2, fn) +#define CALL_AlphaFunc(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLclampf)), _gloffset_AlphaFunc, parameters) +#define GET_AlphaFunc(disp) GET_by_offset(disp, _gloffset_AlphaFunc) +#define SET_AlphaFunc(disp, fn) SET_by_offset(disp, _gloffset_AlphaFunc, fn) +#define CALL_BlendFunc(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_BlendFunc, parameters) +#define GET_BlendFunc(disp) GET_by_offset(disp, _gloffset_BlendFunc) +#define SET_BlendFunc(disp, fn) SET_by_offset(disp, _gloffset_BlendFunc, fn) +#define CALL_LogicOp(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_LogicOp, parameters) +#define GET_LogicOp(disp) GET_by_offset(disp, _gloffset_LogicOp) +#define SET_LogicOp(disp, fn) SET_by_offset(disp, _gloffset_LogicOp, fn) +#define CALL_StencilFunc(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLuint)), _gloffset_StencilFunc, parameters) +#define GET_StencilFunc(disp) GET_by_offset(disp, _gloffset_StencilFunc) +#define SET_StencilFunc(disp, fn) SET_by_offset(disp, _gloffset_StencilFunc, fn) +#define CALL_StencilOp(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum)), _gloffset_StencilOp, parameters) +#define GET_StencilOp(disp) GET_by_offset(disp, _gloffset_StencilOp) +#define SET_StencilOp(disp, fn) SET_by_offset(disp, _gloffset_StencilOp, fn) +#define CALL_DepthFunc(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_DepthFunc, parameters) +#define GET_DepthFunc(disp) GET_by_offset(disp, _gloffset_DepthFunc) +#define SET_DepthFunc(disp, fn) SET_by_offset(disp, _gloffset_DepthFunc, fn) +#define CALL_PixelZoom(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_PixelZoom, parameters) +#define GET_PixelZoom(disp) GET_by_offset(disp, _gloffset_PixelZoom) +#define SET_PixelZoom(disp, fn) SET_by_offset(disp, _gloffset_PixelZoom, fn) +#define CALL_PixelTransferf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_PixelTransferf, parameters) +#define GET_PixelTransferf(disp) GET_by_offset(disp, _gloffset_PixelTransferf) +#define SET_PixelTransferf(disp, fn) SET_by_offset(disp, _gloffset_PixelTransferf, fn) +#define CALL_PixelTransferi(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_PixelTransferi, parameters) +#define GET_PixelTransferi(disp) GET_by_offset(disp, _gloffset_PixelTransferi) +#define SET_PixelTransferi(disp, fn) SET_by_offset(disp, _gloffset_PixelTransferi, fn) +#define CALL_PixelStoref(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_PixelStoref, parameters) +#define GET_PixelStoref(disp) GET_by_offset(disp, _gloffset_PixelStoref) +#define SET_PixelStoref(disp, fn) SET_by_offset(disp, _gloffset_PixelStoref, fn) +#define CALL_PixelStorei(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_PixelStorei, parameters) +#define GET_PixelStorei(disp) GET_by_offset(disp, _gloffset_PixelStorei) +#define SET_PixelStorei(disp, fn) SET_by_offset(disp, _gloffset_PixelStorei, fn) +#define CALL_PixelMapfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLfloat *)), _gloffset_PixelMapfv, parameters) +#define GET_PixelMapfv(disp) GET_by_offset(disp, _gloffset_PixelMapfv) +#define SET_PixelMapfv(disp, fn) SET_by_offset(disp, _gloffset_PixelMapfv, fn) +#define CALL_PixelMapuiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLuint *)), _gloffset_PixelMapuiv, parameters) +#define GET_PixelMapuiv(disp) GET_by_offset(disp, _gloffset_PixelMapuiv) +#define SET_PixelMapuiv(disp, fn) SET_by_offset(disp, _gloffset_PixelMapuiv, fn) +#define CALL_PixelMapusv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLushort *)), _gloffset_PixelMapusv, parameters) +#define GET_PixelMapusv(disp) GET_by_offset(disp, _gloffset_PixelMapusv) +#define SET_PixelMapusv(disp, fn) SET_by_offset(disp, _gloffset_PixelMapusv, fn) +#define CALL_ReadBuffer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ReadBuffer, parameters) +#define GET_ReadBuffer(disp) GET_by_offset(disp, _gloffset_ReadBuffer) +#define SET_ReadBuffer(disp, fn) SET_by_offset(disp, _gloffset_ReadBuffer, fn) +#define CALL_CopyPixels(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLsizei, GLsizei, GLenum)), _gloffset_CopyPixels, parameters) +#define GET_CopyPixels(disp) GET_by_offset(disp, _gloffset_CopyPixels) +#define SET_CopyPixels(disp, fn) SET_by_offset(disp, _gloffset_CopyPixels, fn) +#define CALL_ReadPixels(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)), _gloffset_ReadPixels, parameters) +#define GET_ReadPixels(disp) GET_by_offset(disp, _gloffset_ReadPixels) +#define SET_ReadPixels(disp, fn) SET_by_offset(disp, _gloffset_ReadPixels, fn) +#define CALL_DrawPixels(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_DrawPixels, parameters) +#define GET_DrawPixels(disp) GET_by_offset(disp, _gloffset_DrawPixels) +#define SET_DrawPixels(disp, fn) SET_by_offset(disp, _gloffset_DrawPixels, fn) +#define CALL_GetBooleanv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLboolean *)), _gloffset_GetBooleanv, parameters) +#define GET_GetBooleanv(disp) GET_by_offset(disp, _gloffset_GetBooleanv) +#define SET_GetBooleanv(disp, fn) SET_by_offset(disp, _gloffset_GetBooleanv, fn) +#define CALL_GetClipPlane(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble *)), _gloffset_GetClipPlane, parameters) +#define GET_GetClipPlane(disp) GET_by_offset(disp, _gloffset_GetClipPlane) +#define SET_GetClipPlane(disp, fn) SET_by_offset(disp, _gloffset_GetClipPlane, fn) +#define CALL_GetDoublev(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble *)), _gloffset_GetDoublev, parameters) +#define GET_GetDoublev(disp) GET_by_offset(disp, _gloffset_GetDoublev) +#define SET_GetDoublev(disp, fn) SET_by_offset(disp, _gloffset_GetDoublev, fn) +#define CALL_GetError(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(void)), _gloffset_GetError, parameters) +#define GET_GetError(disp) GET_by_offset(disp, _gloffset_GetError) +#define SET_GetError(disp, fn) SET_by_offset(disp, _gloffset_GetError, fn) +#define CALL_GetFloatv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), _gloffset_GetFloatv, parameters) +#define GET_GetFloatv(disp) GET_by_offset(disp, _gloffset_GetFloatv) +#define SET_GetFloatv(disp, fn) SET_by_offset(disp, _gloffset_GetFloatv, fn) +#define CALL_GetIntegerv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), _gloffset_GetIntegerv, parameters) +#define GET_GetIntegerv(disp) GET_by_offset(disp, _gloffset_GetIntegerv) +#define SET_GetIntegerv(disp, fn) SET_by_offset(disp, _gloffset_GetIntegerv, fn) +#define CALL_GetLightfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetLightfv, parameters) +#define GET_GetLightfv(disp) GET_by_offset(disp, _gloffset_GetLightfv) +#define SET_GetLightfv(disp, fn) SET_by_offset(disp, _gloffset_GetLightfv, fn) +#define CALL_GetLightiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetLightiv, parameters) +#define GET_GetLightiv(disp) GET_by_offset(disp, _gloffset_GetLightiv) +#define SET_GetLightiv(disp, fn) SET_by_offset(disp, _gloffset_GetLightiv, fn) +#define CALL_GetMapdv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLdouble *)), _gloffset_GetMapdv, parameters) +#define GET_GetMapdv(disp) GET_by_offset(disp, _gloffset_GetMapdv) +#define SET_GetMapdv(disp, fn) SET_by_offset(disp, _gloffset_GetMapdv, fn) +#define CALL_GetMapfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetMapfv, parameters) +#define GET_GetMapfv(disp) GET_by_offset(disp, _gloffset_GetMapfv) +#define SET_GetMapfv(disp, fn) SET_by_offset(disp, _gloffset_GetMapfv, fn) +#define CALL_GetMapiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetMapiv, parameters) +#define GET_GetMapiv(disp) GET_by_offset(disp, _gloffset_GetMapiv) +#define SET_GetMapiv(disp, fn) SET_by_offset(disp, _gloffset_GetMapiv, fn) +#define CALL_GetMaterialfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetMaterialfv, parameters) +#define GET_GetMaterialfv(disp) GET_by_offset(disp, _gloffset_GetMaterialfv) +#define SET_GetMaterialfv(disp, fn) SET_by_offset(disp, _gloffset_GetMaterialfv, fn) +#define CALL_GetMaterialiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetMaterialiv, parameters) +#define GET_GetMaterialiv(disp) GET_by_offset(disp, _gloffset_GetMaterialiv) +#define SET_GetMaterialiv(disp, fn) SET_by_offset(disp, _gloffset_GetMaterialiv, fn) +#define CALL_GetPixelMapfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), _gloffset_GetPixelMapfv, parameters) +#define GET_GetPixelMapfv(disp) GET_by_offset(disp, _gloffset_GetPixelMapfv) +#define SET_GetPixelMapfv(disp, fn) SET_by_offset(disp, _gloffset_GetPixelMapfv, fn) +#define CALL_GetPixelMapuiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint *)), _gloffset_GetPixelMapuiv, parameters) +#define GET_GetPixelMapuiv(disp) GET_by_offset(disp, _gloffset_GetPixelMapuiv) +#define SET_GetPixelMapuiv(disp, fn) SET_by_offset(disp, _gloffset_GetPixelMapuiv, fn) +#define CALL_GetPixelMapusv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLushort *)), _gloffset_GetPixelMapusv, parameters) +#define GET_GetPixelMapusv(disp) GET_by_offset(disp, _gloffset_GetPixelMapusv) +#define SET_GetPixelMapusv(disp, fn) SET_by_offset(disp, _gloffset_GetPixelMapusv, fn) +#define CALL_GetPolygonStipple(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte *)), _gloffset_GetPolygonStipple, parameters) +#define GET_GetPolygonStipple(disp) GET_by_offset(disp, _gloffset_GetPolygonStipple) +#define SET_GetPolygonStipple(disp, fn) SET_by_offset(disp, _gloffset_GetPolygonStipple, fn) +#define CALL_GetString(disp, parameters) CALL_by_offset(disp, (const GLubyte * (GLAPIENTRYP)(GLenum)), _gloffset_GetString, parameters) +#define GET_GetString(disp) GET_by_offset(disp, _gloffset_GetString) +#define SET_GetString(disp, fn) SET_by_offset(disp, _gloffset_GetString, fn) +#define CALL_GetTexEnvfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetTexEnvfv, parameters) +#define GET_GetTexEnvfv(disp) GET_by_offset(disp, _gloffset_GetTexEnvfv) +#define SET_GetTexEnvfv(disp, fn) SET_by_offset(disp, _gloffset_GetTexEnvfv, fn) +#define CALL_GetTexEnviv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetTexEnviv, parameters) +#define GET_GetTexEnviv(disp) GET_by_offset(disp, _gloffset_GetTexEnviv) +#define SET_GetTexEnviv(disp, fn) SET_by_offset(disp, _gloffset_GetTexEnviv, fn) +#define CALL_GetTexGendv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLdouble *)), _gloffset_GetTexGendv, parameters) +#define GET_GetTexGendv(disp) GET_by_offset(disp, _gloffset_GetTexGendv) +#define SET_GetTexGendv(disp, fn) SET_by_offset(disp, _gloffset_GetTexGendv, fn) +#define CALL_GetTexGenfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetTexGenfv, parameters) +#define GET_GetTexGenfv(disp) GET_by_offset(disp, _gloffset_GetTexGenfv) +#define SET_GetTexGenfv(disp, fn) SET_by_offset(disp, _gloffset_GetTexGenfv, fn) +#define CALL_GetTexGeniv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetTexGeniv, parameters) +#define GET_GetTexGeniv(disp) GET_by_offset(disp, _gloffset_GetTexGeniv) +#define SET_GetTexGeniv(disp, fn) SET_by_offset(disp, _gloffset_GetTexGeniv, fn) +#define CALL_GetTexImage(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLenum, GLvoid *)), _gloffset_GetTexImage, parameters) +#define GET_GetTexImage(disp) GET_by_offset(disp, _gloffset_GetTexImage) +#define SET_GetTexImage(disp, fn) SET_by_offset(disp, _gloffset_GetTexImage, fn) +#define CALL_GetTexParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetTexParameterfv, parameters) +#define GET_GetTexParameterfv(disp) GET_by_offset(disp, _gloffset_GetTexParameterfv) +#define SET_GetTexParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetTexParameterfv, fn) +#define CALL_GetTexParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetTexParameteriv, parameters) +#define GET_GetTexParameteriv(disp) GET_by_offset(disp, _gloffset_GetTexParameteriv) +#define SET_GetTexParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetTexParameteriv, fn) +#define CALL_GetTexLevelParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLfloat *)), _gloffset_GetTexLevelParameterfv, parameters) +#define GET_GetTexLevelParameterfv(disp) GET_by_offset(disp, _gloffset_GetTexLevelParameterfv) +#define SET_GetTexLevelParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetTexLevelParameterfv, fn) +#define CALL_GetTexLevelParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLint *)), _gloffset_GetTexLevelParameteriv, parameters) +#define GET_GetTexLevelParameteriv(disp) GET_by_offset(disp, _gloffset_GetTexLevelParameteriv) +#define SET_GetTexLevelParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetTexLevelParameteriv, fn) +#define CALL_IsEnabled(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum)), _gloffset_IsEnabled, parameters) +#define GET_IsEnabled(disp) GET_by_offset(disp, _gloffset_IsEnabled) +#define SET_IsEnabled(disp, fn) SET_by_offset(disp, _gloffset_IsEnabled, fn) +#define CALL_IsList(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsList, parameters) +#define GET_IsList(disp) GET_by_offset(disp, _gloffset_IsList) +#define SET_IsList(disp, fn) SET_by_offset(disp, _gloffset_IsList, fn) +#define CALL_DepthRange(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd, GLclampd)), _gloffset_DepthRange, parameters) +#define GET_DepthRange(disp) GET_by_offset(disp, _gloffset_DepthRange) +#define SET_DepthRange(disp, fn) SET_by_offset(disp, _gloffset_DepthRange, fn) +#define CALL_Frustum(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Frustum, parameters) +#define GET_Frustum(disp) GET_by_offset(disp, _gloffset_Frustum) +#define SET_Frustum(disp, fn) SET_by_offset(disp, _gloffset_Frustum, fn) +#define CALL_LoadIdentity(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_LoadIdentity, parameters) +#define GET_LoadIdentity(disp) GET_by_offset(disp, _gloffset_LoadIdentity) +#define SET_LoadIdentity(disp, fn) SET_by_offset(disp, _gloffset_LoadIdentity, fn) +#define CALL_LoadMatrixf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_LoadMatrixf, parameters) +#define GET_LoadMatrixf(disp) GET_by_offset(disp, _gloffset_LoadMatrixf) +#define SET_LoadMatrixf(disp, fn) SET_by_offset(disp, _gloffset_LoadMatrixf, fn) +#define CALL_LoadMatrixd(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_LoadMatrixd, parameters) +#define GET_LoadMatrixd(disp) GET_by_offset(disp, _gloffset_LoadMatrixd) +#define SET_LoadMatrixd(disp, fn) SET_by_offset(disp, _gloffset_LoadMatrixd, fn) +#define CALL_MatrixMode(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_MatrixMode, parameters) +#define GET_MatrixMode(disp) GET_by_offset(disp, _gloffset_MatrixMode) +#define SET_MatrixMode(disp, fn) SET_by_offset(disp, _gloffset_MatrixMode, fn) +#define CALL_MultMatrixf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_MultMatrixf, parameters) +#define GET_MultMatrixf(disp) GET_by_offset(disp, _gloffset_MultMatrixf) +#define SET_MultMatrixf(disp, fn) SET_by_offset(disp, _gloffset_MultMatrixf, fn) +#define CALL_MultMatrixd(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_MultMatrixd, parameters) +#define GET_MultMatrixd(disp) GET_by_offset(disp, _gloffset_MultMatrixd) +#define SET_MultMatrixd(disp, fn) SET_by_offset(disp, _gloffset_MultMatrixd, fn) +#define CALL_Ortho(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Ortho, parameters) +#define GET_Ortho(disp) GET_by_offset(disp, _gloffset_Ortho) +#define SET_Ortho(disp, fn) SET_by_offset(disp, _gloffset_Ortho, fn) +#define CALL_PopMatrix(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PopMatrix, parameters) +#define GET_PopMatrix(disp) GET_by_offset(disp, _gloffset_PopMatrix) +#define SET_PopMatrix(disp, fn) SET_by_offset(disp, _gloffset_PopMatrix, fn) +#define CALL_PushMatrix(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PushMatrix, parameters) +#define GET_PushMatrix(disp) GET_by_offset(disp, _gloffset_PushMatrix) +#define SET_PushMatrix(disp, fn) SET_by_offset(disp, _gloffset_PushMatrix, fn) +#define CALL_Rotated(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_Rotated, parameters) +#define GET_Rotated(disp) GET_by_offset(disp, _gloffset_Rotated) +#define SET_Rotated(disp, fn) SET_by_offset(disp, _gloffset_Rotated, fn) +#define CALL_Rotatef(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_Rotatef, parameters) +#define GET_Rotatef(disp) GET_by_offset(disp, _gloffset_Rotatef) +#define SET_Rotatef(disp, fn) SET_by_offset(disp, _gloffset_Rotatef, fn) +#define CALL_Scaled(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_Scaled, parameters) +#define GET_Scaled(disp) GET_by_offset(disp, _gloffset_Scaled) +#define SET_Scaled(disp, fn) SET_by_offset(disp, _gloffset_Scaled, fn) +#define CALL_Scalef(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_Scalef, parameters) +#define GET_Scalef(disp) GET_by_offset(disp, _gloffset_Scalef) +#define SET_Scalef(disp, fn) SET_by_offset(disp, _gloffset_Scalef, fn) +#define CALL_Translated(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_Translated, parameters) +#define GET_Translated(disp) GET_by_offset(disp, _gloffset_Translated) +#define SET_Translated(disp, fn) SET_by_offset(disp, _gloffset_Translated, fn) +#define CALL_Translatef(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_Translatef, parameters) +#define GET_Translatef(disp) GET_by_offset(disp, _gloffset_Translatef) +#define SET_Translatef(disp, fn) SET_by_offset(disp, _gloffset_Translatef, fn) +#define CALL_Viewport(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLsizei, GLsizei)), _gloffset_Viewport, parameters) +#define GET_Viewport(disp) GET_by_offset(disp, _gloffset_Viewport) +#define SET_Viewport(disp, fn) SET_by_offset(disp, _gloffset_Viewport, fn) +#define CALL_ArrayElement(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), _gloffset_ArrayElement, parameters) +#define GET_ArrayElement(disp) GET_by_offset(disp, _gloffset_ArrayElement) +#define SET_ArrayElement(disp, fn) SET_by_offset(disp, _gloffset_ArrayElement, fn) +#define CALL_BindTexture(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindTexture, parameters) +#define GET_BindTexture(disp) GET_by_offset(disp, _gloffset_BindTexture) +#define SET_BindTexture(disp, fn) SET_by_offset(disp, _gloffset_BindTexture, fn) +#define CALL_ColorPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_ColorPointer, parameters) +#define GET_ColorPointer(disp) GET_by_offset(disp, _gloffset_ColorPointer) +#define SET_ColorPointer(disp, fn) SET_by_offset(disp, _gloffset_ColorPointer, fn) +#define CALL_DisableClientState(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_DisableClientState, parameters) +#define GET_DisableClientState(disp) GET_by_offset(disp, _gloffset_DisableClientState) +#define SET_DisableClientState(disp, fn) SET_by_offset(disp, _gloffset_DisableClientState, fn) +#define CALL_DrawArrays(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLsizei)), _gloffset_DrawArrays, parameters) +#define GET_DrawArrays(disp) GET_by_offset(disp, _gloffset_DrawArrays) +#define SET_DrawArrays(disp, fn) SET_by_offset(disp, _gloffset_DrawArrays, fn) +#define CALL_DrawElements(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, const GLvoid *)), _gloffset_DrawElements, parameters) +#define GET_DrawElements(disp) GET_by_offset(disp, _gloffset_DrawElements) +#define SET_DrawElements(disp, fn) SET_by_offset(disp, _gloffset_DrawElements, fn) +#define CALL_EdgeFlagPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLvoid *)), _gloffset_EdgeFlagPointer, parameters) +#define GET_EdgeFlagPointer(disp) GET_by_offset(disp, _gloffset_EdgeFlagPointer) +#define SET_EdgeFlagPointer(disp, fn) SET_by_offset(disp, _gloffset_EdgeFlagPointer, fn) +#define CALL_EnableClientState(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_EnableClientState, parameters) +#define GET_EnableClientState(disp) GET_by_offset(disp, _gloffset_EnableClientState) +#define SET_EnableClientState(disp, fn) SET_by_offset(disp, _gloffset_EnableClientState, fn) +#define CALL_IndexPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), _gloffset_IndexPointer, parameters) +#define GET_IndexPointer(disp) GET_by_offset(disp, _gloffset_IndexPointer) +#define SET_IndexPointer(disp, fn) SET_by_offset(disp, _gloffset_IndexPointer, fn) +#define CALL_Indexub(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte)), _gloffset_Indexub, parameters) +#define GET_Indexub(disp) GET_by_offset(disp, _gloffset_Indexub) +#define SET_Indexub(disp, fn) SET_by_offset(disp, _gloffset_Indexub, fn) +#define CALL_Indexubv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), _gloffset_Indexubv, parameters) +#define GET_Indexubv(disp) GET_by_offset(disp, _gloffset_Indexubv) +#define SET_Indexubv(disp, fn) SET_by_offset(disp, _gloffset_Indexubv, fn) +#define CALL_InterleavedArrays(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), _gloffset_InterleavedArrays, parameters) +#define GET_InterleavedArrays(disp) GET_by_offset(disp, _gloffset_InterleavedArrays) +#define SET_InterleavedArrays(disp, fn) SET_by_offset(disp, _gloffset_InterleavedArrays, fn) +#define CALL_NormalPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), _gloffset_NormalPointer, parameters) +#define GET_NormalPointer(disp) GET_by_offset(disp, _gloffset_NormalPointer) +#define SET_NormalPointer(disp, fn) SET_by_offset(disp, _gloffset_NormalPointer, fn) +#define CALL_PolygonOffset(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_PolygonOffset, parameters) +#define GET_PolygonOffset(disp) GET_by_offset(disp, _gloffset_PolygonOffset) +#define SET_PolygonOffset(disp, fn) SET_by_offset(disp, _gloffset_PolygonOffset, fn) +#define CALL_TexCoordPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_TexCoordPointer, parameters) +#define GET_TexCoordPointer(disp) GET_by_offset(disp, _gloffset_TexCoordPointer) +#define SET_TexCoordPointer(disp, fn) SET_by_offset(disp, _gloffset_TexCoordPointer, fn) +#define CALL_VertexPointer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_VertexPointer, parameters) +#define GET_VertexPointer(disp) GET_by_offset(disp, _gloffset_VertexPointer) +#define SET_VertexPointer(disp, fn) SET_by_offset(disp, _gloffset_VertexPointer, fn) +#define CALL_AreTexturesResident(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), _gloffset_AreTexturesResident, parameters) +#define GET_AreTexturesResident(disp) GET_by_offset(disp, _gloffset_AreTexturesResident) +#define SET_AreTexturesResident(disp, fn) SET_by_offset(disp, _gloffset_AreTexturesResident, fn) +#define CALL_CopyTexImage1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint)), _gloffset_CopyTexImage1D, parameters) +#define GET_CopyTexImage1D(disp) GET_by_offset(disp, _gloffset_CopyTexImage1D) +#define SET_CopyTexImage1D(disp, fn) SET_by_offset(disp, _gloffset_CopyTexImage1D, fn) +#define CALL_CopyTexImage2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint)), _gloffset_CopyTexImage2D, parameters) +#define GET_CopyTexImage2D(disp) GET_by_offset(disp, _gloffset_CopyTexImage2D) +#define SET_CopyTexImage2D(disp, fn) SET_by_offset(disp, _gloffset_CopyTexImage2D, fn) +#define CALL_CopyTexSubImage1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei)), _gloffset_CopyTexSubImage1D, parameters) +#define GET_CopyTexSubImage1D(disp) GET_by_offset(disp, _gloffset_CopyTexSubImage1D) +#define SET_CopyTexSubImage1D(disp, fn) SET_by_offset(disp, _gloffset_CopyTexSubImage1D, fn) +#define CALL_CopyTexSubImage2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei)), _gloffset_CopyTexSubImage2D, parameters) +#define GET_CopyTexSubImage2D(disp) GET_by_offset(disp, _gloffset_CopyTexSubImage2D) +#define SET_CopyTexSubImage2D(disp, fn) SET_by_offset(disp, _gloffset_CopyTexSubImage2D, fn) +#define CALL_DeleteTextures(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteTextures, parameters) +#define GET_DeleteTextures(disp) GET_by_offset(disp, _gloffset_DeleteTextures) +#define SET_DeleteTextures(disp, fn) SET_by_offset(disp, _gloffset_DeleteTextures, fn) +#define CALL_GenTextures(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenTextures, parameters) +#define GET_GenTextures(disp) GET_by_offset(disp, _gloffset_GenTextures) +#define SET_GenTextures(disp, fn) SET_by_offset(disp, _gloffset_GenTextures, fn) +#define CALL_GetPointerv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLvoid **)), _gloffset_GetPointerv, parameters) +#define GET_GetPointerv(disp) GET_by_offset(disp, _gloffset_GetPointerv) +#define SET_GetPointerv(disp, fn) SET_by_offset(disp, _gloffset_GetPointerv, fn) +#define CALL_IsTexture(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsTexture, parameters) +#define GET_IsTexture(disp) GET_by_offset(disp, _gloffset_IsTexture) +#define SET_IsTexture(disp, fn) SET_by_offset(disp, _gloffset_IsTexture, fn) +#define CALL_PrioritizeTextures(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *, const GLclampf *)), _gloffset_PrioritizeTextures, parameters) +#define GET_PrioritizeTextures(disp) GET_by_offset(disp, _gloffset_PrioritizeTextures) +#define SET_PrioritizeTextures(disp, fn) SET_by_offset(disp, _gloffset_PrioritizeTextures, fn) +#define CALL_TexSubImage1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_TexSubImage1D, parameters) +#define GET_TexSubImage1D(disp) GET_by_offset(disp, _gloffset_TexSubImage1D) +#define SET_TexSubImage1D(disp, fn) SET_by_offset(disp, _gloffset_TexSubImage1D, fn) +#define CALL_TexSubImage2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_TexSubImage2D, parameters) +#define GET_TexSubImage2D(disp) GET_by_offset(disp, _gloffset_TexSubImage2D) +#define SET_TexSubImage2D(disp, fn) SET_by_offset(disp, _gloffset_TexSubImage2D, fn) +#define CALL_PopClientAttrib(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PopClientAttrib, parameters) +#define GET_PopClientAttrib(disp) GET_by_offset(disp, _gloffset_PopClientAttrib) +#define SET_PopClientAttrib(disp, fn) SET_by_offset(disp, _gloffset_PopClientAttrib, fn) +#define CALL_PushClientAttrib(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbitfield)), _gloffset_PushClientAttrib, parameters) +#define GET_PushClientAttrib(disp) GET_by_offset(disp, _gloffset_PushClientAttrib) +#define SET_PushClientAttrib(disp, fn) SET_by_offset(disp, _gloffset_PushClientAttrib, fn) +#define CALL_BlendColor(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLclampf, GLclampf, GLclampf)), _gloffset_BlendColor, parameters) +#define GET_BlendColor(disp) GET_by_offset(disp, _gloffset_BlendColor) +#define SET_BlendColor(disp, fn) SET_by_offset(disp, _gloffset_BlendColor, fn) +#define CALL_BlendEquation(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_BlendEquation, parameters) +#define GET_BlendEquation(disp) GET_by_offset(disp, _gloffset_BlendEquation) +#define SET_BlendEquation(disp, fn) SET_by_offset(disp, _gloffset_BlendEquation, fn) +#define CALL_DrawRangeElements(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *)), _gloffset_DrawRangeElements, parameters) +#define GET_DrawRangeElements(disp) GET_by_offset(disp, _gloffset_DrawRangeElements) +#define SET_DrawRangeElements(disp, fn) SET_by_offset(disp, _gloffset_DrawRangeElements, fn) +#define CALL_ColorTable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_ColorTable, parameters) +#define GET_ColorTable(disp) GET_by_offset(disp, _gloffset_ColorTable) +#define SET_ColorTable(disp, fn) SET_by_offset(disp, _gloffset_ColorTable, fn) +#define CALL_ColorTableParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_ColorTableParameterfv, parameters) +#define GET_ColorTableParameterfv(disp) GET_by_offset(disp, _gloffset_ColorTableParameterfv) +#define SET_ColorTableParameterfv(disp, fn) SET_by_offset(disp, _gloffset_ColorTableParameterfv, fn) +#define CALL_ColorTableParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_ColorTableParameteriv, parameters) +#define GET_ColorTableParameteriv(disp) GET_by_offset(disp, _gloffset_ColorTableParameteriv) +#define SET_ColorTableParameteriv(disp, fn) SET_by_offset(disp, _gloffset_ColorTableParameteriv, fn) +#define CALL_CopyColorTable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLint, GLsizei)), _gloffset_CopyColorTable, parameters) +#define GET_CopyColorTable(disp) GET_by_offset(disp, _gloffset_CopyColorTable) +#define SET_CopyColorTable(disp, fn) SET_by_offset(disp, _gloffset_CopyColorTable, fn) +#define CALL_GetColorTable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *)), _gloffset_GetColorTable, parameters) +#define GET_GetColorTable(disp) GET_by_offset(disp, _gloffset_GetColorTable) +#define SET_GetColorTable(disp, fn) SET_by_offset(disp, _gloffset_GetColorTable, fn) +#define CALL_GetColorTableParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetColorTableParameterfv, parameters) +#define GET_GetColorTableParameterfv(disp) GET_by_offset(disp, _gloffset_GetColorTableParameterfv) +#define SET_GetColorTableParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetColorTableParameterfv, fn) +#define CALL_GetColorTableParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetColorTableParameteriv, parameters) +#define GET_GetColorTableParameteriv(disp) GET_by_offset(disp, _gloffset_GetColorTableParameteriv) +#define SET_GetColorTableParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetColorTableParameteriv, fn) +#define CALL_ColorSubTable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_ColorSubTable, parameters) +#define GET_ColorSubTable(disp) GET_by_offset(disp, _gloffset_ColorSubTable) +#define SET_ColorSubTable(disp, fn) SET_by_offset(disp, _gloffset_ColorSubTable, fn) +#define CALL_CopyColorSubTable(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLint, GLint, GLsizei)), _gloffset_CopyColorSubTable, parameters) +#define GET_CopyColorSubTable(disp) GET_by_offset(disp, _gloffset_CopyColorSubTable) +#define SET_CopyColorSubTable(disp, fn) SET_by_offset(disp, _gloffset_CopyColorSubTable, fn) +#define CALL_ConvolutionFilter1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_ConvolutionFilter1D, parameters) +#define GET_ConvolutionFilter1D(disp) GET_by_offset(disp, _gloffset_ConvolutionFilter1D) +#define SET_ConvolutionFilter1D(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionFilter1D, fn) +#define CALL_ConvolutionFilter2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_ConvolutionFilter2D, parameters) +#define GET_ConvolutionFilter2D(disp) GET_by_offset(disp, _gloffset_ConvolutionFilter2D) +#define SET_ConvolutionFilter2D(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionFilter2D, fn) +#define CALL_ConvolutionParameterf(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), _gloffset_ConvolutionParameterf, parameters) +#define GET_ConvolutionParameterf(disp) GET_by_offset(disp, _gloffset_ConvolutionParameterf) +#define SET_ConvolutionParameterf(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionParameterf, fn) +#define CALL_ConvolutionParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), _gloffset_ConvolutionParameterfv, parameters) +#define GET_ConvolutionParameterfv(disp) GET_by_offset(disp, _gloffset_ConvolutionParameterfv) +#define SET_ConvolutionParameterfv(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionParameterfv, fn) +#define CALL_ConvolutionParameteri(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_ConvolutionParameteri, parameters) +#define GET_ConvolutionParameteri(disp) GET_by_offset(disp, _gloffset_ConvolutionParameteri) +#define SET_ConvolutionParameteri(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionParameteri, fn) +#define CALL_ConvolutionParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_ConvolutionParameteriv, parameters) +#define GET_ConvolutionParameteriv(disp) GET_by_offset(disp, _gloffset_ConvolutionParameteriv) +#define SET_ConvolutionParameteriv(disp, fn) SET_by_offset(disp, _gloffset_ConvolutionParameteriv, fn) +#define CALL_CopyConvolutionFilter1D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLint, GLsizei)), _gloffset_CopyConvolutionFilter1D, parameters) +#define GET_CopyConvolutionFilter1D(disp) GET_by_offset(disp, _gloffset_CopyConvolutionFilter1D) +#define SET_CopyConvolutionFilter1D(disp, fn) SET_by_offset(disp, _gloffset_CopyConvolutionFilter1D, fn) +#define CALL_CopyConvolutionFilter2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLint, GLsizei, GLsizei)), _gloffset_CopyConvolutionFilter2D, parameters) +#define GET_CopyConvolutionFilter2D(disp) GET_by_offset(disp, _gloffset_CopyConvolutionFilter2D) +#define SET_CopyConvolutionFilter2D(disp, fn) SET_by_offset(disp, _gloffset_CopyConvolutionFilter2D, fn) +#define CALL_GetConvolutionFilter(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *)), _gloffset_GetConvolutionFilter, parameters) +#define GET_GetConvolutionFilter(disp) GET_by_offset(disp, _gloffset_GetConvolutionFilter) +#define SET_GetConvolutionFilter(disp, fn) SET_by_offset(disp, _gloffset_GetConvolutionFilter, fn) +#define CALL_GetConvolutionParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetConvolutionParameterfv, parameters) +#define GET_GetConvolutionParameterfv(disp) GET_by_offset(disp, _gloffset_GetConvolutionParameterfv) +#define SET_GetConvolutionParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetConvolutionParameterfv, fn) +#define CALL_GetConvolutionParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetConvolutionParameteriv, parameters) +#define GET_GetConvolutionParameteriv(disp) GET_by_offset(disp, _gloffset_GetConvolutionParameteriv) +#define SET_GetConvolutionParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetConvolutionParameteriv, fn) +#define CALL_GetSeparableFilter(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *)), _gloffset_GetSeparableFilter, parameters) +#define GET_GetSeparableFilter(disp) GET_by_offset(disp, _gloffset_GetSeparableFilter) +#define SET_GetSeparableFilter(disp, fn) SET_by_offset(disp, _gloffset_GetSeparableFilter, fn) +#define CALL_SeparableFilter2D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *)), _gloffset_SeparableFilter2D, parameters) +#define GET_SeparableFilter2D(disp) GET_by_offset(disp, _gloffset_SeparableFilter2D) +#define SET_SeparableFilter2D(disp, fn) SET_by_offset(disp, _gloffset_SeparableFilter2D, fn) +#define CALL_GetHistogram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLboolean, GLenum, GLenum, GLvoid *)), _gloffset_GetHistogram, parameters) +#define GET_GetHistogram(disp) GET_by_offset(disp, _gloffset_GetHistogram) +#define SET_GetHistogram(disp, fn) SET_by_offset(disp, _gloffset_GetHistogram, fn) +#define CALL_GetHistogramParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetHistogramParameterfv, parameters) +#define GET_GetHistogramParameterfv(disp) GET_by_offset(disp, _gloffset_GetHistogramParameterfv) +#define SET_GetHistogramParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetHistogramParameterfv, fn) +#define CALL_GetHistogramParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetHistogramParameteriv, parameters) +#define GET_GetHistogramParameteriv(disp) GET_by_offset(disp, _gloffset_GetHistogramParameteriv) +#define SET_GetHistogramParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetHistogramParameteriv, fn) +#define CALL_GetMinmax(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLboolean, GLenum, GLenum, GLvoid *)), _gloffset_GetMinmax, parameters) +#define GET_GetMinmax(disp) GET_by_offset(disp, _gloffset_GetMinmax) +#define SET_GetMinmax(disp, fn) SET_by_offset(disp, _gloffset_GetMinmax, fn) +#define CALL_GetMinmaxParameterfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetMinmaxParameterfv, parameters) +#define GET_GetMinmaxParameterfv(disp) GET_by_offset(disp, _gloffset_GetMinmaxParameterfv) +#define SET_GetMinmaxParameterfv(disp, fn) SET_by_offset(disp, _gloffset_GetMinmaxParameterfv, fn) +#define CALL_GetMinmaxParameteriv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetMinmaxParameteriv, parameters) +#define GET_GetMinmaxParameteriv(disp) GET_by_offset(disp, _gloffset_GetMinmaxParameteriv) +#define SET_GetMinmaxParameteriv(disp, fn) SET_by_offset(disp, _gloffset_GetMinmaxParameteriv, fn) +#define CALL_Histogram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, GLboolean)), _gloffset_Histogram, parameters) +#define GET_Histogram(disp) GET_by_offset(disp, _gloffset_Histogram) +#define SET_Histogram(disp, fn) SET_by_offset(disp, _gloffset_Histogram, fn) +#define CALL_Minmax(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLboolean)), _gloffset_Minmax, parameters) +#define GET_Minmax(disp) GET_by_offset(disp, _gloffset_Minmax) +#define SET_Minmax(disp, fn) SET_by_offset(disp, _gloffset_Minmax, fn) +#define CALL_ResetHistogram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ResetHistogram, parameters) +#define GET_ResetHistogram(disp) GET_by_offset(disp, _gloffset_ResetHistogram) +#define SET_ResetHistogram(disp, fn) SET_by_offset(disp, _gloffset_ResetHistogram, fn) +#define CALL_ResetMinmax(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ResetMinmax, parameters) +#define GET_ResetMinmax(disp) GET_by_offset(disp, _gloffset_ResetMinmax) +#define SET_ResetMinmax(disp, fn) SET_by_offset(disp, _gloffset_ResetMinmax, fn) +#define CALL_TexImage3D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)), _gloffset_TexImage3D, parameters) +#define GET_TexImage3D(disp) GET_by_offset(disp, _gloffset_TexImage3D) +#define SET_TexImage3D(disp, fn) SET_by_offset(disp, _gloffset_TexImage3D, fn) +#define CALL_TexSubImage3D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), _gloffset_TexSubImage3D, parameters) +#define GET_TexSubImage3D(disp) GET_by_offset(disp, _gloffset_TexSubImage3D) +#define SET_TexSubImage3D(disp, fn) SET_by_offset(disp, _gloffset_TexSubImage3D, fn) +#define CALL_CopyTexSubImage3D(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei)), _gloffset_CopyTexSubImage3D, parameters) +#define GET_CopyTexSubImage3D(disp) GET_by_offset(disp, _gloffset_CopyTexSubImage3D) +#define SET_CopyTexSubImage3D(disp, fn) SET_by_offset(disp, _gloffset_CopyTexSubImage3D, fn) +#define CALL_ActiveTextureARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ActiveTextureARB, parameters) +#define GET_ActiveTextureARB(disp) GET_by_offset(disp, _gloffset_ActiveTextureARB) +#define SET_ActiveTextureARB(disp, fn) SET_by_offset(disp, _gloffset_ActiveTextureARB, fn) +#define CALL_ClientActiveTextureARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ClientActiveTextureARB, parameters) +#define GET_ClientActiveTextureARB(disp) GET_by_offset(disp, _gloffset_ClientActiveTextureARB) +#define SET_ClientActiveTextureARB(disp, fn) SET_by_offset(disp, _gloffset_ClientActiveTextureARB, fn) +#define CALL_MultiTexCoord1dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble)), _gloffset_MultiTexCoord1dARB, parameters) +#define GET_MultiTexCoord1dARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1dARB) +#define SET_MultiTexCoord1dARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1dARB, fn) +#define CALL_MultiTexCoord1dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLdouble *)), _gloffset_MultiTexCoord1dvARB, parameters) +#define GET_MultiTexCoord1dvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1dvARB) +#define SET_MultiTexCoord1dvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1dvARB, fn) +#define CALL_MultiTexCoord1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_MultiTexCoord1fARB, parameters) +#define GET_MultiTexCoord1fARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1fARB) +#define SET_MultiTexCoord1fARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1fARB, fn) +#define CALL_MultiTexCoord1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_MultiTexCoord1fvARB, parameters) +#define GET_MultiTexCoord1fvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1fvARB) +#define SET_MultiTexCoord1fvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1fvARB, fn) +#define CALL_MultiTexCoord1iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_MultiTexCoord1iARB, parameters) +#define GET_MultiTexCoord1iARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1iARB) +#define SET_MultiTexCoord1iARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1iARB, fn) +#define CALL_MultiTexCoord1ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_MultiTexCoord1ivARB, parameters) +#define GET_MultiTexCoord1ivARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1ivARB) +#define SET_MultiTexCoord1ivARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1ivARB, fn) +#define CALL_MultiTexCoord1sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLshort)), _gloffset_MultiTexCoord1sARB, parameters) +#define GET_MultiTexCoord1sARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1sARB) +#define SET_MultiTexCoord1sARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1sARB, fn) +#define CALL_MultiTexCoord1svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLshort *)), _gloffset_MultiTexCoord1svARB, parameters) +#define GET_MultiTexCoord1svARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord1svARB) +#define SET_MultiTexCoord1svARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord1svARB, fn) +#define CALL_MultiTexCoord2dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble, GLdouble)), _gloffset_MultiTexCoord2dARB, parameters) +#define GET_MultiTexCoord2dARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2dARB) +#define SET_MultiTexCoord2dARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2dARB, fn) +#define CALL_MultiTexCoord2dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLdouble *)), _gloffset_MultiTexCoord2dvARB, parameters) +#define GET_MultiTexCoord2dvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2dvARB) +#define SET_MultiTexCoord2dvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2dvARB, fn) +#define CALL_MultiTexCoord2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat, GLfloat)), _gloffset_MultiTexCoord2fARB, parameters) +#define GET_MultiTexCoord2fARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2fARB) +#define SET_MultiTexCoord2fARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2fARB, fn) +#define CALL_MultiTexCoord2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_MultiTexCoord2fvARB, parameters) +#define GET_MultiTexCoord2fvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2fvARB) +#define SET_MultiTexCoord2fvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2fvARB, fn) +#define CALL_MultiTexCoord2iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint)), _gloffset_MultiTexCoord2iARB, parameters) +#define GET_MultiTexCoord2iARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2iARB) +#define SET_MultiTexCoord2iARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2iARB, fn) +#define CALL_MultiTexCoord2ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_MultiTexCoord2ivARB, parameters) +#define GET_MultiTexCoord2ivARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2ivARB) +#define SET_MultiTexCoord2ivARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2ivARB, fn) +#define CALL_MultiTexCoord2sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLshort, GLshort)), _gloffset_MultiTexCoord2sARB, parameters) +#define GET_MultiTexCoord2sARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2sARB) +#define SET_MultiTexCoord2sARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2sARB, fn) +#define CALL_MultiTexCoord2svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLshort *)), _gloffset_MultiTexCoord2svARB, parameters) +#define GET_MultiTexCoord2svARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord2svARB) +#define SET_MultiTexCoord2svARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord2svARB, fn) +#define CALL_MultiTexCoord3dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble, GLdouble, GLdouble)), _gloffset_MultiTexCoord3dARB, parameters) +#define GET_MultiTexCoord3dARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3dARB) +#define SET_MultiTexCoord3dARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3dARB, fn) +#define CALL_MultiTexCoord3dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLdouble *)), _gloffset_MultiTexCoord3dvARB, parameters) +#define GET_MultiTexCoord3dvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3dvARB) +#define SET_MultiTexCoord3dvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3dvARB, fn) +#define CALL_MultiTexCoord3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat, GLfloat, GLfloat)), _gloffset_MultiTexCoord3fARB, parameters) +#define GET_MultiTexCoord3fARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3fARB) +#define SET_MultiTexCoord3fARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3fARB, fn) +#define CALL_MultiTexCoord3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_MultiTexCoord3fvARB, parameters) +#define GET_MultiTexCoord3fvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3fvARB) +#define SET_MultiTexCoord3fvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3fvARB, fn) +#define CALL_MultiTexCoord3iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint)), _gloffset_MultiTexCoord3iARB, parameters) +#define GET_MultiTexCoord3iARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3iARB) +#define SET_MultiTexCoord3iARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3iARB, fn) +#define CALL_MultiTexCoord3ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_MultiTexCoord3ivARB, parameters) +#define GET_MultiTexCoord3ivARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3ivARB) +#define SET_MultiTexCoord3ivARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3ivARB, fn) +#define CALL_MultiTexCoord3sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLshort, GLshort, GLshort)), _gloffset_MultiTexCoord3sARB, parameters) +#define GET_MultiTexCoord3sARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3sARB) +#define SET_MultiTexCoord3sARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3sARB, fn) +#define CALL_MultiTexCoord3svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLshort *)), _gloffset_MultiTexCoord3svARB, parameters) +#define GET_MultiTexCoord3svARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord3svARB) +#define SET_MultiTexCoord3svARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord3svARB, fn) +#define CALL_MultiTexCoord4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_MultiTexCoord4dARB, parameters) +#define GET_MultiTexCoord4dARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4dARB) +#define SET_MultiTexCoord4dARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4dARB, fn) +#define CALL_MultiTexCoord4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLdouble *)), _gloffset_MultiTexCoord4dvARB, parameters) +#define GET_MultiTexCoord4dvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4dvARB) +#define SET_MultiTexCoord4dvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4dvARB, fn) +#define CALL_MultiTexCoord4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_MultiTexCoord4fARB, parameters) +#define GET_MultiTexCoord4fARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4fARB) +#define SET_MultiTexCoord4fARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4fARB, fn) +#define CALL_MultiTexCoord4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_MultiTexCoord4fvARB, parameters) +#define GET_MultiTexCoord4fvARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4fvARB) +#define SET_MultiTexCoord4fvARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4fvARB, fn) +#define CALL_MultiTexCoord4iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint)), _gloffset_MultiTexCoord4iARB, parameters) +#define GET_MultiTexCoord4iARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4iARB) +#define SET_MultiTexCoord4iARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4iARB, fn) +#define CALL_MultiTexCoord4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_MultiTexCoord4ivARB, parameters) +#define GET_MultiTexCoord4ivARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4ivARB) +#define SET_MultiTexCoord4ivARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4ivARB, fn) +#define CALL_MultiTexCoord4sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLshort, GLshort, GLshort, GLshort)), _gloffset_MultiTexCoord4sARB, parameters) +#define GET_MultiTexCoord4sARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4sARB) +#define SET_MultiTexCoord4sARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4sARB, fn) +#define CALL_MultiTexCoord4svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLshort *)), _gloffset_MultiTexCoord4svARB, parameters) +#define GET_MultiTexCoord4svARB(disp) GET_by_offset(disp, _gloffset_MultiTexCoord4svARB) +#define SET_MultiTexCoord4svARB(disp, fn) SET_by_offset(disp, _gloffset_MultiTexCoord4svARB, fn) +#define CALL_AttachShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), _gloffset_AttachShader, parameters) +#define GET_AttachShader(disp) GET_by_offset(disp, _gloffset_AttachShader) +#define SET_AttachShader(disp, fn) SET_by_offset(disp, _gloffset_AttachShader, fn) +#define CALL_CreateProgram(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(void)), _gloffset_CreateProgram, parameters) +#define GET_CreateProgram(disp) GET_by_offset(disp, _gloffset_CreateProgram) +#define SET_CreateProgram(disp, fn) SET_by_offset(disp, _gloffset_CreateProgram, fn) +#define CALL_CreateShader(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLenum)), _gloffset_CreateShader, parameters) +#define GET_CreateShader(disp) GET_by_offset(disp, _gloffset_CreateShader) +#define SET_CreateShader(disp, fn) SET_by_offset(disp, _gloffset_CreateShader, fn) +#define CALL_DeleteProgram(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_DeleteProgram, parameters) +#define GET_DeleteProgram(disp) GET_by_offset(disp, _gloffset_DeleteProgram) +#define SET_DeleteProgram(disp, fn) SET_by_offset(disp, _gloffset_DeleteProgram, fn) +#define CALL_DeleteShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_DeleteShader, parameters) +#define GET_DeleteShader(disp) GET_by_offset(disp, _gloffset_DeleteShader) +#define SET_DeleteShader(disp, fn) SET_by_offset(disp, _gloffset_DeleteShader, fn) +#define CALL_DetachShader(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), _gloffset_DetachShader, parameters) +#define GET_DetachShader(disp) GET_by_offset(disp, _gloffset_DetachShader) +#define SET_DetachShader(disp, fn) SET_by_offset(disp, _gloffset_DetachShader, fn) +#define CALL_GetAttachedShaders(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLuint *)), _gloffset_GetAttachedShaders, parameters) +#define GET_GetAttachedShaders(disp) GET_by_offset(disp, _gloffset_GetAttachedShaders) +#define SET_GetAttachedShaders(disp, fn) SET_by_offset(disp, _gloffset_GetAttachedShaders, fn) +#define CALL_GetProgramInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), _gloffset_GetProgramInfoLog, parameters) +#define GET_GetProgramInfoLog(disp) GET_by_offset(disp, _gloffset_GetProgramInfoLog) +#define SET_GetProgramInfoLog(disp, fn) SET_by_offset(disp, _gloffset_GetProgramInfoLog, fn) +#define CALL_GetProgramiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetProgramiv, parameters) +#define GET_GetProgramiv(disp) GET_by_offset(disp, _gloffset_GetProgramiv) +#define SET_GetProgramiv(disp, fn) SET_by_offset(disp, _gloffset_GetProgramiv, fn) +#define CALL_GetShaderInfoLog(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, GLsizei *, GLchar *)), _gloffset_GetShaderInfoLog, parameters) +#define GET_GetShaderInfoLog(disp) GET_by_offset(disp, _gloffset_GetShaderInfoLog) +#define SET_GetShaderInfoLog(disp, fn) SET_by_offset(disp, _gloffset_GetShaderInfoLog, fn) +#define CALL_GetShaderiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetShaderiv, parameters) +#define GET_GetShaderiv(disp) GET_by_offset(disp, _gloffset_GetShaderiv) +#define SET_GetShaderiv(disp, fn) SET_by_offset(disp, _gloffset_GetShaderiv, fn) +#define CALL_IsProgram(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsProgram, parameters) +#define GET_IsProgram(disp) GET_by_offset(disp, _gloffset_IsProgram) +#define SET_IsProgram(disp, fn) SET_by_offset(disp, _gloffset_IsProgram, fn) +#define CALL_IsShader(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsShader, parameters) +#define GET_IsShader(disp) GET_by_offset(disp, _gloffset_IsShader) +#define SET_IsShader(disp, fn) SET_by_offset(disp, _gloffset_IsShader, fn) +#define CALL_StencilFuncSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), _gloffset_StencilFuncSeparate, parameters) +#define GET_StencilFuncSeparate(disp) GET_by_offset(disp, _gloffset_StencilFuncSeparate) +#define SET_StencilFuncSeparate(disp, fn) SET_by_offset(disp, _gloffset_StencilFuncSeparate, fn) +#define CALL_StencilMaskSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_StencilMaskSeparate, parameters) +#define GET_StencilMaskSeparate(disp) GET_by_offset(disp, _gloffset_StencilMaskSeparate) +#define SET_StencilMaskSeparate(disp, fn) SET_by_offset(disp, _gloffset_StencilMaskSeparate, fn) +#define CALL_StencilOpSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), _gloffset_StencilOpSeparate, parameters) +#define GET_StencilOpSeparate(disp) GET_by_offset(disp, _gloffset_StencilOpSeparate) +#define SET_StencilOpSeparate(disp, fn) SET_by_offset(disp, _gloffset_StencilOpSeparate, fn) +#define CALL_UniformMatrix2x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix2x3fv, parameters) +#define GET_UniformMatrix2x3fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix2x3fv) +#define SET_UniformMatrix2x3fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix2x3fv, fn) +#define CALL_UniformMatrix2x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix2x4fv, parameters) +#define GET_UniformMatrix2x4fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix2x4fv) +#define SET_UniformMatrix2x4fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix2x4fv, fn) +#define CALL_UniformMatrix3x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix3x2fv, parameters) +#define GET_UniformMatrix3x2fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix3x2fv) +#define SET_UniformMatrix3x2fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix3x2fv, fn) +#define CALL_UniformMatrix3x4fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix3x4fv, parameters) +#define GET_UniformMatrix3x4fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix3x4fv) +#define SET_UniformMatrix3x4fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix3x4fv, fn) +#define CALL_UniformMatrix4x2fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix4x2fv, parameters) +#define GET_UniformMatrix4x2fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix4x2fv) +#define SET_UniformMatrix4x2fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix4x2fv, fn) +#define CALL_UniformMatrix4x3fv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix4x3fv, parameters) +#define GET_UniformMatrix4x3fv(disp) GET_by_offset(disp, _gloffset_UniformMatrix4x3fv) +#define SET_UniformMatrix4x3fv(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix4x3fv, fn) +#define CALL_ClampColor(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_ClampColor, parameters) +#define GET_ClampColor(disp) GET_by_offset(disp, _gloffset_ClampColor) +#define SET_ClampColor(disp, fn) SET_by_offset(disp, _gloffset_ClampColor, fn) +#define CALL_ClearBufferfi(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, const GLfloat, const GLint)), _gloffset_ClearBufferfi, parameters) +#define GET_ClearBufferfi(disp) GET_by_offset(disp, _gloffset_ClearBufferfi) +#define SET_ClearBufferfi(disp, fn) SET_by_offset(disp, _gloffset_ClearBufferfi, fn) +#define CALL_ClearBufferfv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, const GLfloat *)), _gloffset_ClearBufferfv, parameters) +#define GET_ClearBufferfv(disp) GET_by_offset(disp, _gloffset_ClearBufferfv) +#define SET_ClearBufferfv(disp, fn) SET_by_offset(disp, _gloffset_ClearBufferfv, fn) +#define CALL_ClearBufferiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, const GLint *)), _gloffset_ClearBufferiv, parameters) +#define GET_ClearBufferiv(disp) GET_by_offset(disp, _gloffset_ClearBufferiv) +#define SET_ClearBufferiv(disp, fn) SET_by_offset(disp, _gloffset_ClearBufferiv, fn) +#define CALL_ClearBufferuiv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, const GLuint *)), _gloffset_ClearBufferuiv, parameters) +#define GET_ClearBufferuiv(disp) GET_by_offset(disp, _gloffset_ClearBufferuiv) +#define SET_ClearBufferuiv(disp, fn) SET_by_offset(disp, _gloffset_ClearBufferuiv, fn) +#define CALL_GetStringi(disp, parameters) CALL_by_offset(disp, (const GLubyte * (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_GetStringi, parameters) +#define GET_GetStringi(disp) GET_by_offset(disp, _gloffset_GetStringi) +#define SET_GetStringi(disp, fn) SET_by_offset(disp, _gloffset_GetStringi, fn) +#define CALL_TexBuffer(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint)), _gloffset_TexBuffer, parameters) +#define GET_TexBuffer(disp) GET_by_offset(disp, _gloffset_TexBuffer) +#define SET_TexBuffer(disp, fn) SET_by_offset(disp, _gloffset_TexBuffer, fn) +#define CALL_FramebufferTexture(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint)), _gloffset_FramebufferTexture, parameters) +#define GET_FramebufferTexture(disp) GET_by_offset(disp, _gloffset_FramebufferTexture) +#define SET_FramebufferTexture(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTexture, fn) +#define CALL_GetBufferParameteri64v(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint64 *)), _gloffset_GetBufferParameteri64v, parameters) +#define GET_GetBufferParameteri64v(disp) GET_by_offset(disp, _gloffset_GetBufferParameteri64v) +#define SET_GetBufferParameteri64v(disp, fn) SET_by_offset(disp, _gloffset_GetBufferParameteri64v, fn) +#define CALL_GetInteger64i_v(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLint64 *)), _gloffset_GetInteger64i_v, parameters) +#define GET_GetInteger64i_v(disp) GET_by_offset(disp, _gloffset_GetInteger64i_v) +#define SET_GetInteger64i_v(disp, fn) SET_by_offset(disp, _gloffset_GetInteger64i_v, fn) +#define CALL_VertexAttribDivisor(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), _gloffset_VertexAttribDivisor, parameters) +#define GET_VertexAttribDivisor(disp) GET_by_offset(disp, _gloffset_VertexAttribDivisor) +#define SET_VertexAttribDivisor(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribDivisor, fn) +#define CALL_LoadTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_LoadTransposeMatrixdARB, parameters) +#define GET_LoadTransposeMatrixdARB(disp) GET_by_offset(disp, _gloffset_LoadTransposeMatrixdARB) +#define SET_LoadTransposeMatrixdARB(disp, fn) SET_by_offset(disp, _gloffset_LoadTransposeMatrixdARB, fn) +#define CALL_LoadTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_LoadTransposeMatrixfARB, parameters) +#define GET_LoadTransposeMatrixfARB(disp) GET_by_offset(disp, _gloffset_LoadTransposeMatrixfARB) +#define SET_LoadTransposeMatrixfARB(disp, fn) SET_by_offset(disp, _gloffset_LoadTransposeMatrixfARB, fn) +#define CALL_MultTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_MultTransposeMatrixdARB, parameters) +#define GET_MultTransposeMatrixdARB(disp) GET_by_offset(disp, _gloffset_MultTransposeMatrixdARB) +#define SET_MultTransposeMatrixdARB(disp, fn) SET_by_offset(disp, _gloffset_MultTransposeMatrixdARB, fn) +#define CALL_MultTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_MultTransposeMatrixfARB, parameters) +#define GET_MultTransposeMatrixfARB(disp) GET_by_offset(disp, _gloffset_MultTransposeMatrixfARB) +#define SET_MultTransposeMatrixfARB(disp, fn) SET_by_offset(disp, _gloffset_MultTransposeMatrixfARB, fn) +#define CALL_SampleCoverageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), _gloffset_SampleCoverageARB, parameters) +#define GET_SampleCoverageARB(disp) GET_by_offset(disp, _gloffset_SampleCoverageARB) +#define SET_SampleCoverageARB(disp, fn) SET_by_offset(disp, _gloffset_SampleCoverageARB, fn) +#define CALL_CompressedTexImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *)), _gloffset_CompressedTexImage1DARB, parameters) +#define GET_CompressedTexImage1DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexImage1DARB) +#define SET_CompressedTexImage1DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexImage1DARB, fn) +#define CALL_CompressedTexImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), _gloffset_CompressedTexImage2DARB, parameters) +#define GET_CompressedTexImage2DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexImage2DARB) +#define SET_CompressedTexImage2DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexImage2DARB, fn) +#define CALL_CompressedTexImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), _gloffset_CompressedTexImage3DARB, parameters) +#define GET_CompressedTexImage3DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexImage3DARB) +#define SET_CompressedTexImage3DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexImage3DARB, fn) +#define CALL_CompressedTexSubImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *)), _gloffset_CompressedTexSubImage1DARB, parameters) +#define GET_CompressedTexSubImage1DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexSubImage1DARB) +#define SET_CompressedTexSubImage1DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexSubImage1DARB, fn) +#define CALL_CompressedTexSubImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), _gloffset_CompressedTexSubImage2DARB, parameters) +#define GET_CompressedTexSubImage2DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexSubImage2DARB) +#define SET_CompressedTexSubImage2DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexSubImage2DARB, fn) +#define CALL_CompressedTexSubImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), _gloffset_CompressedTexSubImage3DARB, parameters) +#define GET_CompressedTexSubImage3DARB(disp) GET_by_offset(disp, _gloffset_CompressedTexSubImage3DARB) +#define SET_CompressedTexSubImage3DARB(disp, fn) SET_by_offset(disp, _gloffset_CompressedTexSubImage3DARB, fn) +#define CALL_GetCompressedTexImageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLvoid *)), _gloffset_GetCompressedTexImageARB, parameters) +#define GET_GetCompressedTexImageARB(disp) GET_by_offset(disp, _gloffset_GetCompressedTexImageARB) +#define SET_GetCompressedTexImageARB(disp, fn) SET_by_offset(disp, _gloffset_GetCompressedTexImageARB, fn) +#define CALL_DisableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_DisableVertexAttribArrayARB, parameters) +#define GET_DisableVertexAttribArrayARB(disp) GET_by_offset(disp, _gloffset_DisableVertexAttribArrayARB) +#define SET_DisableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, _gloffset_DisableVertexAttribArrayARB, fn) +#define CALL_EnableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_EnableVertexAttribArrayARB, parameters) +#define GET_EnableVertexAttribArrayARB(disp) GET_by_offset(disp, _gloffset_EnableVertexAttribArrayARB) +#define SET_EnableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, _gloffset_EnableVertexAttribArrayARB, fn) +#define CALL_GetProgramEnvParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), _gloffset_GetProgramEnvParameterdvARB, parameters) +#define GET_GetProgramEnvParameterdvARB(disp) GET_by_offset(disp, _gloffset_GetProgramEnvParameterdvARB) +#define SET_GetProgramEnvParameterdvARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramEnvParameterdvARB, fn) +#define CALL_GetProgramEnvParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), _gloffset_GetProgramEnvParameterfvARB, parameters) +#define GET_GetProgramEnvParameterfvARB(disp) GET_by_offset(disp, _gloffset_GetProgramEnvParameterfvARB) +#define SET_GetProgramEnvParameterfvARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramEnvParameterfvARB, fn) +#define CALL_GetProgramLocalParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), _gloffset_GetProgramLocalParameterdvARB, parameters) +#define GET_GetProgramLocalParameterdvARB(disp) GET_by_offset(disp, _gloffset_GetProgramLocalParameterdvARB) +#define SET_GetProgramLocalParameterdvARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramLocalParameterdvARB, fn) +#define CALL_GetProgramLocalParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), _gloffset_GetProgramLocalParameterfvARB, parameters) +#define GET_GetProgramLocalParameterfvARB(disp) GET_by_offset(disp, _gloffset_GetProgramLocalParameterfvARB) +#define SET_GetProgramLocalParameterfvARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramLocalParameterfvARB, fn) +#define CALL_GetProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid *)), _gloffset_GetProgramStringARB, parameters) +#define GET_GetProgramStringARB(disp) GET_by_offset(disp, _gloffset_GetProgramStringARB) +#define SET_GetProgramStringARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramStringARB, fn) +#define CALL_GetProgramivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetProgramivARB, parameters) +#define GET_GetProgramivARB(disp) GET_by_offset(disp, _gloffset_GetProgramivARB) +#define SET_GetProgramivARB(disp, fn) SET_by_offset(disp, _gloffset_GetProgramivARB, fn) +#define CALL_GetVertexAttribdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), _gloffset_GetVertexAttribdvARB, parameters) +#define GET_GetVertexAttribdvARB(disp) GET_by_offset(disp, _gloffset_GetVertexAttribdvARB) +#define SET_GetVertexAttribdvARB(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribdvARB, fn) +#define CALL_GetVertexAttribfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), _gloffset_GetVertexAttribfvARB, parameters) +#define GET_GetVertexAttribfvARB(disp) GET_by_offset(disp, _gloffset_GetVertexAttribfvARB) +#define SET_GetVertexAttribfvARB(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribfvARB, fn) +#define CALL_GetVertexAttribivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetVertexAttribivARB, parameters) +#define GET_GetVertexAttribivARB(disp) GET_by_offset(disp, _gloffset_GetVertexAttribivARB) +#define SET_GetVertexAttribivARB(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribivARB, fn) +#define CALL_ProgramEnvParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_ProgramEnvParameter4dARB, parameters) +#define GET_ProgramEnvParameter4dARB(disp) GET_by_offset(disp, _gloffset_ProgramEnvParameter4dARB) +#define SET_ProgramEnvParameter4dARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramEnvParameter4dARB, fn) +#define CALL_ProgramEnvParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), _gloffset_ProgramEnvParameter4dvARB, parameters) +#define GET_ProgramEnvParameter4dvARB(disp) GET_by_offset(disp, _gloffset_ProgramEnvParameter4dvARB) +#define SET_ProgramEnvParameter4dvARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramEnvParameter4dvARB, fn) +#define CALL_ProgramEnvParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_ProgramEnvParameter4fARB, parameters) +#define GET_ProgramEnvParameter4fARB(disp) GET_by_offset(disp, _gloffset_ProgramEnvParameter4fARB) +#define SET_ProgramEnvParameter4fARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramEnvParameter4fARB, fn) +#define CALL_ProgramEnvParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), _gloffset_ProgramEnvParameter4fvARB, parameters) +#define GET_ProgramEnvParameter4fvARB(disp) GET_by_offset(disp, _gloffset_ProgramEnvParameter4fvARB) +#define SET_ProgramEnvParameter4fvARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramEnvParameter4fvARB, fn) +#define CALL_ProgramLocalParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_ProgramLocalParameter4dARB, parameters) +#define GET_ProgramLocalParameter4dARB(disp) GET_by_offset(disp, _gloffset_ProgramLocalParameter4dARB) +#define SET_ProgramLocalParameter4dARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramLocalParameter4dARB, fn) +#define CALL_ProgramLocalParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), _gloffset_ProgramLocalParameter4dvARB, parameters) +#define GET_ProgramLocalParameter4dvARB(disp) GET_by_offset(disp, _gloffset_ProgramLocalParameter4dvARB) +#define SET_ProgramLocalParameter4dvARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramLocalParameter4dvARB, fn) +#define CALL_ProgramLocalParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_ProgramLocalParameter4fARB, parameters) +#define GET_ProgramLocalParameter4fARB(disp) GET_by_offset(disp, _gloffset_ProgramLocalParameter4fARB) +#define SET_ProgramLocalParameter4fARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramLocalParameter4fARB, fn) +#define CALL_ProgramLocalParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), _gloffset_ProgramLocalParameter4fvARB, parameters) +#define GET_ProgramLocalParameter4fvARB(disp) GET_by_offset(disp, _gloffset_ProgramLocalParameter4fvARB) +#define SET_ProgramLocalParameter4fvARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramLocalParameter4fvARB, fn) +#define CALL_ProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, const GLvoid *)), _gloffset_ProgramStringARB, parameters) +#define GET_ProgramStringARB(disp) GET_by_offset(disp, _gloffset_ProgramStringARB) +#define SET_ProgramStringARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramStringARB, fn) +#define CALL_VertexAttrib1dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), _gloffset_VertexAttrib1dARB, parameters) +#define GET_VertexAttrib1dARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1dARB) +#define SET_VertexAttrib1dARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1dARB, fn) +#define CALL_VertexAttrib1dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib1dvARB, parameters) +#define GET_VertexAttrib1dvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1dvARB) +#define SET_VertexAttrib1dvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1dvARB, fn) +#define CALL_VertexAttrib1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), _gloffset_VertexAttrib1fARB, parameters) +#define GET_VertexAttrib1fARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1fARB) +#define SET_VertexAttrib1fARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1fARB, fn) +#define CALL_VertexAttrib1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib1fvARB, parameters) +#define GET_VertexAttrib1fvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1fvARB) +#define SET_VertexAttrib1fvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1fvARB, fn) +#define CALL_VertexAttrib1sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), _gloffset_VertexAttrib1sARB, parameters) +#define GET_VertexAttrib1sARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1sARB) +#define SET_VertexAttrib1sARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1sARB, fn) +#define CALL_VertexAttrib1svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib1svARB, parameters) +#define GET_VertexAttrib1svARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib1svARB) +#define SET_VertexAttrib1svARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1svARB, fn) +#define CALL_VertexAttrib2dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), _gloffset_VertexAttrib2dARB, parameters) +#define GET_VertexAttrib2dARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2dARB) +#define SET_VertexAttrib2dARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2dARB, fn) +#define CALL_VertexAttrib2dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib2dvARB, parameters) +#define GET_VertexAttrib2dvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2dvARB) +#define SET_VertexAttrib2dvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2dvARB, fn) +#define CALL_VertexAttrib2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), _gloffset_VertexAttrib2fARB, parameters) +#define GET_VertexAttrib2fARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2fARB) +#define SET_VertexAttrib2fARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2fARB, fn) +#define CALL_VertexAttrib2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib2fvARB, parameters) +#define GET_VertexAttrib2fvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2fvARB) +#define SET_VertexAttrib2fvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2fvARB, fn) +#define CALL_VertexAttrib2sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), _gloffset_VertexAttrib2sARB, parameters) +#define GET_VertexAttrib2sARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2sARB) +#define SET_VertexAttrib2sARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2sARB, fn) +#define CALL_VertexAttrib2svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib2svARB, parameters) +#define GET_VertexAttrib2svARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib2svARB) +#define SET_VertexAttrib2svARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2svARB, fn) +#define CALL_VertexAttrib3dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), _gloffset_VertexAttrib3dARB, parameters) +#define GET_VertexAttrib3dARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3dARB) +#define SET_VertexAttrib3dARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3dARB, fn) +#define CALL_VertexAttrib3dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib3dvARB, parameters) +#define GET_VertexAttrib3dvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3dvARB) +#define SET_VertexAttrib3dvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3dvARB, fn) +#define CALL_VertexAttrib3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), _gloffset_VertexAttrib3fARB, parameters) +#define GET_VertexAttrib3fARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3fARB) +#define SET_VertexAttrib3fARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3fARB, fn) +#define CALL_VertexAttrib3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib3fvARB, parameters) +#define GET_VertexAttrib3fvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3fvARB) +#define SET_VertexAttrib3fvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3fvARB, fn) +#define CALL_VertexAttrib3sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), _gloffset_VertexAttrib3sARB, parameters) +#define GET_VertexAttrib3sARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3sARB) +#define SET_VertexAttrib3sARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3sARB, fn) +#define CALL_VertexAttrib3svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib3svARB, parameters) +#define GET_VertexAttrib3svARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib3svARB) +#define SET_VertexAttrib3svARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3svARB, fn) +#define CALL_VertexAttrib4NbvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), _gloffset_VertexAttrib4NbvARB, parameters) +#define GET_VertexAttrib4NbvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NbvARB) +#define SET_VertexAttrib4NbvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NbvARB, fn) +#define CALL_VertexAttrib4NivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttrib4NivARB, parameters) +#define GET_VertexAttrib4NivARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NivARB) +#define SET_VertexAttrib4NivARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NivARB, fn) +#define CALL_VertexAttrib4NsvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib4NsvARB, parameters) +#define GET_VertexAttrib4NsvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NsvARB) +#define SET_VertexAttrib4NsvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NsvARB, fn) +#define CALL_VertexAttrib4NubARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), _gloffset_VertexAttrib4NubARB, parameters) +#define GET_VertexAttrib4NubARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NubARB) +#define SET_VertexAttrib4NubARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NubARB, fn) +#define CALL_VertexAttrib4NubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), _gloffset_VertexAttrib4NubvARB, parameters) +#define GET_VertexAttrib4NubvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NubvARB) +#define SET_VertexAttrib4NubvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NubvARB, fn) +#define CALL_VertexAttrib4NuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttrib4NuivARB, parameters) +#define GET_VertexAttrib4NuivARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NuivARB) +#define SET_VertexAttrib4NuivARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NuivARB, fn) +#define CALL_VertexAttrib4NusvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), _gloffset_VertexAttrib4NusvARB, parameters) +#define GET_VertexAttrib4NusvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4NusvARB) +#define SET_VertexAttrib4NusvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4NusvARB, fn) +#define CALL_VertexAttrib4bvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), _gloffset_VertexAttrib4bvARB, parameters) +#define GET_VertexAttrib4bvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4bvARB) +#define SET_VertexAttrib4bvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4bvARB, fn) +#define CALL_VertexAttrib4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_VertexAttrib4dARB, parameters) +#define GET_VertexAttrib4dARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4dARB) +#define SET_VertexAttrib4dARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4dARB, fn) +#define CALL_VertexAttrib4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib4dvARB, parameters) +#define GET_VertexAttrib4dvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4dvARB) +#define SET_VertexAttrib4dvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4dvARB, fn) +#define CALL_VertexAttrib4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_VertexAttrib4fARB, parameters) +#define GET_VertexAttrib4fARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4fARB) +#define SET_VertexAttrib4fARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4fARB, fn) +#define CALL_VertexAttrib4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib4fvARB, parameters) +#define GET_VertexAttrib4fvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4fvARB) +#define SET_VertexAttrib4fvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4fvARB, fn) +#define CALL_VertexAttrib4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttrib4ivARB, parameters) +#define GET_VertexAttrib4ivARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4ivARB) +#define SET_VertexAttrib4ivARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4ivARB, fn) +#define CALL_VertexAttrib4sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), _gloffset_VertexAttrib4sARB, parameters) +#define GET_VertexAttrib4sARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4sARB) +#define SET_VertexAttrib4sARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4sARB, fn) +#define CALL_VertexAttrib4svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib4svARB, parameters) +#define GET_VertexAttrib4svARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4svARB) +#define SET_VertexAttrib4svARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4svARB, fn) +#define CALL_VertexAttrib4ubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), _gloffset_VertexAttrib4ubvARB, parameters) +#define GET_VertexAttrib4ubvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4ubvARB) +#define SET_VertexAttrib4ubvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4ubvARB, fn) +#define CALL_VertexAttrib4uivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttrib4uivARB, parameters) +#define GET_VertexAttrib4uivARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4uivARB) +#define SET_VertexAttrib4uivARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4uivARB, fn) +#define CALL_VertexAttrib4usvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), _gloffset_VertexAttrib4usvARB, parameters) +#define GET_VertexAttrib4usvARB(disp) GET_by_offset(disp, _gloffset_VertexAttrib4usvARB) +#define SET_VertexAttrib4usvARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4usvARB, fn) +#define CALL_VertexAttribPointerARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)), _gloffset_VertexAttribPointerARB, parameters) +#define GET_VertexAttribPointerARB(disp) GET_by_offset(disp, _gloffset_VertexAttribPointerARB) +#define SET_VertexAttribPointerARB(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribPointerARB, fn) +#define CALL_BindBufferARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindBufferARB, parameters) +#define GET_BindBufferARB(disp) GET_by_offset(disp, _gloffset_BindBufferARB) +#define SET_BindBufferARB(disp, fn) SET_by_offset(disp, _gloffset_BindBufferARB, fn) +#define CALL_BufferDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)), _gloffset_BufferDataARB, parameters) +#define GET_BufferDataARB(disp) GET_by_offset(disp, _gloffset_BufferDataARB) +#define SET_BufferDataARB(disp, fn) SET_by_offset(disp, _gloffset_BufferDataARB, fn) +#define CALL_BufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)), _gloffset_BufferSubDataARB, parameters) +#define GET_BufferSubDataARB(disp) GET_by_offset(disp, _gloffset_BufferSubDataARB) +#define SET_BufferSubDataARB(disp, fn) SET_by_offset(disp, _gloffset_BufferSubDataARB, fn) +#define CALL_DeleteBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteBuffersARB, parameters) +#define GET_DeleteBuffersARB(disp) GET_by_offset(disp, _gloffset_DeleteBuffersARB) +#define SET_DeleteBuffersARB(disp, fn) SET_by_offset(disp, _gloffset_DeleteBuffersARB, fn) +#define CALL_GenBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenBuffersARB, parameters) +#define GET_GenBuffersARB(disp) GET_by_offset(disp, _gloffset_GenBuffersARB) +#define SET_GenBuffersARB(disp, fn) SET_by_offset(disp, _gloffset_GenBuffersARB, fn) +#define CALL_GetBufferParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetBufferParameterivARB, parameters) +#define GET_GetBufferParameterivARB(disp) GET_by_offset(disp, _gloffset_GetBufferParameterivARB) +#define SET_GetBufferParameterivARB(disp, fn) SET_by_offset(disp, _gloffset_GetBufferParameterivARB, fn) +#define CALL_GetBufferPointervARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), _gloffset_GetBufferPointervARB, parameters) +#define GET_GetBufferPointervARB(disp) GET_by_offset(disp, _gloffset_GetBufferPointervARB) +#define SET_GetBufferPointervARB(disp, fn) SET_by_offset(disp, _gloffset_GetBufferPointervARB, fn) +#define CALL_GetBufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)), _gloffset_GetBufferSubDataARB, parameters) +#define GET_GetBufferSubDataARB(disp) GET_by_offset(disp, _gloffset_GetBufferSubDataARB) +#define SET_GetBufferSubDataARB(disp, fn) SET_by_offset(disp, _gloffset_GetBufferSubDataARB, fn) +#define CALL_IsBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsBufferARB, parameters) +#define GET_IsBufferARB(disp) GET_by_offset(disp, _gloffset_IsBufferARB) +#define SET_IsBufferARB(disp, fn) SET_by_offset(disp, _gloffset_IsBufferARB, fn) +#define CALL_MapBufferARB(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_MapBufferARB, parameters) +#define GET_MapBufferARB(disp) GET_by_offset(disp, _gloffset_MapBufferARB) +#define SET_MapBufferARB(disp, fn) SET_by_offset(disp, _gloffset_MapBufferARB, fn) +#define CALL_UnmapBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum)), _gloffset_UnmapBufferARB, parameters) +#define GET_UnmapBufferARB(disp) GET_by_offset(disp, _gloffset_UnmapBufferARB) +#define SET_UnmapBufferARB(disp, fn) SET_by_offset(disp, _gloffset_UnmapBufferARB, fn) +#define CALL_BeginQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BeginQueryARB, parameters) +#define GET_BeginQueryARB(disp) GET_by_offset(disp, _gloffset_BeginQueryARB) +#define SET_BeginQueryARB(disp, fn) SET_by_offset(disp, _gloffset_BeginQueryARB, fn) +#define CALL_DeleteQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteQueriesARB, parameters) +#define GET_DeleteQueriesARB(disp) GET_by_offset(disp, _gloffset_DeleteQueriesARB) +#define SET_DeleteQueriesARB(disp, fn) SET_by_offset(disp, _gloffset_DeleteQueriesARB, fn) +#define CALL_EndQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_EndQueryARB, parameters) +#define GET_EndQueryARB(disp) GET_by_offset(disp, _gloffset_EndQueryARB) +#define SET_EndQueryARB(disp, fn) SET_by_offset(disp, _gloffset_EndQueryARB, fn) +#define CALL_GenQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenQueriesARB, parameters) +#define GET_GenQueriesARB(disp) GET_by_offset(disp, _gloffset_GenQueriesARB) +#define SET_GenQueriesARB(disp, fn) SET_by_offset(disp, _gloffset_GenQueriesARB, fn) +#define CALL_GetQueryObjectivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetQueryObjectivARB, parameters) +#define GET_GetQueryObjectivARB(disp) GET_by_offset(disp, _gloffset_GetQueryObjectivARB) +#define SET_GetQueryObjectivARB(disp, fn) SET_by_offset(disp, _gloffset_GetQueryObjectivARB, fn) +#define CALL_GetQueryObjectuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint *)), _gloffset_GetQueryObjectuivARB, parameters) +#define GET_GetQueryObjectuivARB(disp) GET_by_offset(disp, _gloffset_GetQueryObjectuivARB) +#define SET_GetQueryObjectuivARB(disp, fn) SET_by_offset(disp, _gloffset_GetQueryObjectuivARB, fn) +#define CALL_GetQueryivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetQueryivARB, parameters) +#define GET_GetQueryivARB(disp) GET_by_offset(disp, _gloffset_GetQueryivARB) +#define SET_GetQueryivARB(disp, fn) SET_by_offset(disp, _gloffset_GetQueryivARB, fn) +#define CALL_IsQueryARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsQueryARB, parameters) +#define GET_IsQueryARB(disp) GET_by_offset(disp, _gloffset_IsQueryARB) +#define SET_IsQueryARB(disp, fn) SET_by_offset(disp, _gloffset_IsQueryARB, fn) +#define CALL_AttachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), _gloffset_AttachObjectARB, parameters) +#define GET_AttachObjectARB(disp) GET_by_offset(disp, _gloffset_AttachObjectARB) +#define SET_AttachObjectARB(disp, fn) SET_by_offset(disp, _gloffset_AttachObjectARB, fn) +#define CALL_CompileShaderARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), _gloffset_CompileShaderARB, parameters) +#define GET_CompileShaderARB(disp) GET_by_offset(disp, _gloffset_CompileShaderARB) +#define SET_CompileShaderARB(disp, fn) SET_by_offset(disp, _gloffset_CompileShaderARB, fn) +#define CALL_CreateProgramObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(void)), _gloffset_CreateProgramObjectARB, parameters) +#define GET_CreateProgramObjectARB(disp) GET_by_offset(disp, _gloffset_CreateProgramObjectARB) +#define SET_CreateProgramObjectARB(disp, fn) SET_by_offset(disp, _gloffset_CreateProgramObjectARB, fn) +#define CALL_CreateShaderObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), _gloffset_CreateShaderObjectARB, parameters) +#define GET_CreateShaderObjectARB(disp) GET_by_offset(disp, _gloffset_CreateShaderObjectARB) +#define SET_CreateShaderObjectARB(disp, fn) SET_by_offset(disp, _gloffset_CreateShaderObjectARB, fn) +#define CALL_DeleteObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), _gloffset_DeleteObjectARB, parameters) +#define GET_DeleteObjectARB(disp) GET_by_offset(disp, _gloffset_DeleteObjectARB) +#define SET_DeleteObjectARB(disp, fn) SET_by_offset(disp, _gloffset_DeleteObjectARB, fn) +#define CALL_DetachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), _gloffset_DetachObjectARB, parameters) +#define GET_DetachObjectARB(disp) GET_by_offset(disp, _gloffset_DetachObjectARB) +#define SET_DetachObjectARB(disp, fn) SET_by_offset(disp, _gloffset_DetachObjectARB, fn) +#define CALL_GetActiveUniformARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), _gloffset_GetActiveUniformARB, parameters) +#define GET_GetActiveUniformARB(disp) GET_by_offset(disp, _gloffset_GetActiveUniformARB) +#define SET_GetActiveUniformARB(disp, fn) SET_by_offset(disp, _gloffset_GetActiveUniformARB, fn) +#define CALL_GetAttachedObjectsARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *)), _gloffset_GetAttachedObjectsARB, parameters) +#define GET_GetAttachedObjectsARB(disp) GET_by_offset(disp, _gloffset_GetAttachedObjectsARB) +#define SET_GetAttachedObjectsARB(disp, fn) SET_by_offset(disp, _gloffset_GetAttachedObjectsARB, fn) +#define CALL_GetHandleARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), _gloffset_GetHandleARB, parameters) +#define GET_GetHandleARB(disp) GET_by_offset(disp, _gloffset_GetHandleARB) +#define SET_GetHandleARB(disp, fn) SET_by_offset(disp, _gloffset_GetHandleARB, fn) +#define CALL_GetInfoLogARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), _gloffset_GetInfoLogARB, parameters) +#define GET_GetInfoLogARB(disp) GET_by_offset(disp, _gloffset_GetInfoLogARB) +#define SET_GetInfoLogARB(disp, fn) SET_by_offset(disp, _gloffset_GetInfoLogARB, fn) +#define CALL_GetObjectParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLfloat *)), _gloffset_GetObjectParameterfvARB, parameters) +#define GET_GetObjectParameterfvARB(disp) GET_by_offset(disp, _gloffset_GetObjectParameterfvARB) +#define SET_GetObjectParameterfvARB(disp, fn) SET_by_offset(disp, _gloffset_GetObjectParameterfvARB, fn) +#define CALL_GetObjectParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLint *)), _gloffset_GetObjectParameterivARB, parameters) +#define GET_GetObjectParameterivARB(disp) GET_by_offset(disp, _gloffset_GetObjectParameterivARB) +#define SET_GetObjectParameterivARB(disp, fn) SET_by_offset(disp, _gloffset_GetObjectParameterivARB, fn) +#define CALL_GetShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), _gloffset_GetShaderSourceARB, parameters) +#define GET_GetShaderSourceARB(disp) GET_by_offset(disp, _gloffset_GetShaderSourceARB) +#define SET_GetShaderSourceARB(disp, fn) SET_by_offset(disp, _gloffset_GetShaderSourceARB, fn) +#define CALL_GetUniformLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), _gloffset_GetUniformLocationARB, parameters) +#define GET_GetUniformLocationARB(disp) GET_by_offset(disp, _gloffset_GetUniformLocationARB) +#define SET_GetUniformLocationARB(disp, fn) SET_by_offset(disp, _gloffset_GetUniformLocationARB, fn) +#define CALL_GetUniformfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLfloat *)), _gloffset_GetUniformfvARB, parameters) +#define GET_GetUniformfvARB(disp) GET_by_offset(disp, _gloffset_GetUniformfvARB) +#define SET_GetUniformfvARB(disp, fn) SET_by_offset(disp, _gloffset_GetUniformfvARB, fn) +#define CALL_GetUniformivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLint *)), _gloffset_GetUniformivARB, parameters) +#define GET_GetUniformivARB(disp) GET_by_offset(disp, _gloffset_GetUniformivARB) +#define SET_GetUniformivARB(disp, fn) SET_by_offset(disp, _gloffset_GetUniformivARB, fn) +#define CALL_LinkProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), _gloffset_LinkProgramARB, parameters) +#define GET_LinkProgramARB(disp) GET_by_offset(disp, _gloffset_LinkProgramARB) +#define SET_LinkProgramARB(disp, fn) SET_by_offset(disp, _gloffset_LinkProgramARB, fn) +#define CALL_ShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *)), _gloffset_ShaderSourceARB, parameters) +#define GET_ShaderSourceARB(disp) GET_by_offset(disp, _gloffset_ShaderSourceARB) +#define SET_ShaderSourceARB(disp, fn) SET_by_offset(disp, _gloffset_ShaderSourceARB, fn) +#define CALL_Uniform1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat)), _gloffset_Uniform1fARB, parameters) +#define GET_Uniform1fARB(disp) GET_by_offset(disp, _gloffset_Uniform1fARB) +#define SET_Uniform1fARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform1fARB, fn) +#define CALL_Uniform1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), _gloffset_Uniform1fvARB, parameters) +#define GET_Uniform1fvARB(disp) GET_by_offset(disp, _gloffset_Uniform1fvARB) +#define SET_Uniform1fvARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform1fvARB, fn) +#define CALL_Uniform1iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_Uniform1iARB, parameters) +#define GET_Uniform1iARB(disp) GET_by_offset(disp, _gloffset_Uniform1iARB) +#define SET_Uniform1iARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform1iARB, fn) +#define CALL_Uniform1ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), _gloffset_Uniform1ivARB, parameters) +#define GET_Uniform1ivARB(disp) GET_by_offset(disp, _gloffset_Uniform1ivARB) +#define SET_Uniform1ivARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform1ivARB, fn) +#define CALL_Uniform2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat)), _gloffset_Uniform2fARB, parameters) +#define GET_Uniform2fARB(disp) GET_by_offset(disp, _gloffset_Uniform2fARB) +#define SET_Uniform2fARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform2fARB, fn) +#define CALL_Uniform2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), _gloffset_Uniform2fvARB, parameters) +#define GET_Uniform2fvARB(disp) GET_by_offset(disp, _gloffset_Uniform2fvARB) +#define SET_Uniform2fvARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform2fvARB, fn) +#define CALL_Uniform2iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_Uniform2iARB, parameters) +#define GET_Uniform2iARB(disp) GET_by_offset(disp, _gloffset_Uniform2iARB) +#define SET_Uniform2iARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform2iARB, fn) +#define CALL_Uniform2ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), _gloffset_Uniform2ivARB, parameters) +#define GET_Uniform2ivARB(disp) GET_by_offset(disp, _gloffset_Uniform2ivARB) +#define SET_Uniform2ivARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform2ivARB, fn) +#define CALL_Uniform3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat)), _gloffset_Uniform3fARB, parameters) +#define GET_Uniform3fARB(disp) GET_by_offset(disp, _gloffset_Uniform3fARB) +#define SET_Uniform3fARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform3fARB, fn) +#define CALL_Uniform3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), _gloffset_Uniform3fvARB, parameters) +#define GET_Uniform3fvARB(disp) GET_by_offset(disp, _gloffset_Uniform3fvARB) +#define SET_Uniform3fvARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform3fvARB, fn) +#define CALL_Uniform3iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_Uniform3iARB, parameters) +#define GET_Uniform3iARB(disp) GET_by_offset(disp, _gloffset_Uniform3iARB) +#define SET_Uniform3iARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform3iARB, fn) +#define CALL_Uniform3ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), _gloffset_Uniform3ivARB, parameters) +#define GET_Uniform3ivARB(disp) GET_by_offset(disp, _gloffset_Uniform3ivARB) +#define SET_Uniform3ivARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform3ivARB, fn) +#define CALL_Uniform4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_Uniform4fARB, parameters) +#define GET_Uniform4fARB(disp) GET_by_offset(disp, _gloffset_Uniform4fARB) +#define SET_Uniform4fARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform4fARB, fn) +#define CALL_Uniform4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), _gloffset_Uniform4fvARB, parameters) +#define GET_Uniform4fvARB(disp) GET_by_offset(disp, _gloffset_Uniform4fvARB) +#define SET_Uniform4fvARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform4fvARB, fn) +#define CALL_Uniform4iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint)), _gloffset_Uniform4iARB, parameters) +#define GET_Uniform4iARB(disp) GET_by_offset(disp, _gloffset_Uniform4iARB) +#define SET_Uniform4iARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform4iARB, fn) +#define CALL_Uniform4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), _gloffset_Uniform4ivARB, parameters) +#define GET_Uniform4ivARB(disp) GET_by_offset(disp, _gloffset_Uniform4ivARB) +#define SET_Uniform4ivARB(disp, fn) SET_by_offset(disp, _gloffset_Uniform4ivARB, fn) +#define CALL_UniformMatrix2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix2fvARB, parameters) +#define GET_UniformMatrix2fvARB(disp) GET_by_offset(disp, _gloffset_UniformMatrix2fvARB) +#define SET_UniformMatrix2fvARB(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix2fvARB, fn) +#define CALL_UniformMatrix3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix3fvARB, parameters) +#define GET_UniformMatrix3fvARB(disp) GET_by_offset(disp, _gloffset_UniformMatrix3fvARB) +#define SET_UniformMatrix3fvARB(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix3fvARB, fn) +#define CALL_UniformMatrix4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), _gloffset_UniformMatrix4fvARB, parameters) +#define GET_UniformMatrix4fvARB(disp) GET_by_offset(disp, _gloffset_UniformMatrix4fvARB) +#define SET_UniformMatrix4fvARB(disp, fn) SET_by_offset(disp, _gloffset_UniformMatrix4fvARB, fn) +#define CALL_UseProgramObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), _gloffset_UseProgramObjectARB, parameters) +#define GET_UseProgramObjectARB(disp) GET_by_offset(disp, _gloffset_UseProgramObjectARB) +#define SET_UseProgramObjectARB(disp, fn) SET_by_offset(disp, _gloffset_UseProgramObjectARB, fn) +#define CALL_ValidateProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), _gloffset_ValidateProgramARB, parameters) +#define GET_ValidateProgramARB(disp) GET_by_offset(disp, _gloffset_ValidateProgramARB) +#define SET_ValidateProgramARB(disp, fn) SET_by_offset(disp, _gloffset_ValidateProgramARB, fn) +#define CALL_BindAttribLocationARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, const GLcharARB *)), _gloffset_BindAttribLocationARB, parameters) +#define GET_BindAttribLocationARB(disp) GET_by_offset(disp, _gloffset_BindAttribLocationARB) +#define SET_BindAttribLocationARB(disp, fn) SET_by_offset(disp, _gloffset_BindAttribLocationARB, fn) +#define CALL_GetActiveAttribARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), _gloffset_GetActiveAttribARB, parameters) +#define GET_GetActiveAttribARB(disp) GET_by_offset(disp, _gloffset_GetActiveAttribARB) +#define SET_GetActiveAttribARB(disp, fn) SET_by_offset(disp, _gloffset_GetActiveAttribARB, fn) +#define CALL_GetAttribLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), _gloffset_GetAttribLocationARB, parameters) +#define GET_GetAttribLocationARB(disp) GET_by_offset(disp, _gloffset_GetAttribLocationARB) +#define SET_GetAttribLocationARB(disp, fn) SET_by_offset(disp, _gloffset_GetAttribLocationARB, fn) +#define CALL_DrawBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLenum *)), _gloffset_DrawBuffersARB, parameters) +#define GET_DrawBuffersARB(disp) GET_by_offset(disp, _gloffset_DrawBuffersARB) +#define SET_DrawBuffersARB(disp, fn) SET_by_offset(disp, _gloffset_DrawBuffersARB, fn) +#define CALL_DrawArraysInstancedARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLsizei, GLsizei)), _gloffset_DrawArraysInstancedARB, parameters) +#define GET_DrawArraysInstancedARB(disp) GET_by_offset(disp, _gloffset_DrawArraysInstancedARB) +#define SET_DrawArraysInstancedARB(disp, fn) SET_by_offset(disp, _gloffset_DrawArraysInstancedARB, fn) +#define CALL_DrawElementsInstancedARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei)), _gloffset_DrawElementsInstancedARB, parameters) +#define GET_DrawElementsInstancedARB(disp) GET_by_offset(disp, _gloffset_DrawElementsInstancedARB) +#define SET_DrawElementsInstancedARB(disp, fn) SET_by_offset(disp, _gloffset_DrawElementsInstancedARB, fn) +#define CALL_RenderbufferStorageMultisample(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)), _gloffset_RenderbufferStorageMultisample, parameters) +#define GET_RenderbufferStorageMultisample(disp) GET_by_offset(disp, _gloffset_RenderbufferStorageMultisample) +#define SET_RenderbufferStorageMultisample(disp, fn) SET_by_offset(disp, _gloffset_RenderbufferStorageMultisample, fn) +#define CALL_FramebufferTextureARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint)), _gloffset_FramebufferTextureARB, parameters) +#define GET_FramebufferTextureARB(disp) GET_by_offset(disp, _gloffset_FramebufferTextureARB) +#define SET_FramebufferTextureARB(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTextureARB, fn) +#define CALL_FramebufferTextureFaceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint, GLenum)), _gloffset_FramebufferTextureFaceARB, parameters) +#define GET_FramebufferTextureFaceARB(disp) GET_by_offset(disp, _gloffset_FramebufferTextureFaceARB) +#define SET_FramebufferTextureFaceARB(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTextureFaceARB, fn) +#define CALL_ProgramParameteriARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint)), _gloffset_ProgramParameteriARB, parameters) +#define GET_ProgramParameteriARB(disp) GET_by_offset(disp, _gloffset_ProgramParameteriARB) +#define SET_ProgramParameteriARB(disp, fn) SET_by_offset(disp, _gloffset_ProgramParameteriARB, fn) +#define CALL_FlushMappedBufferRange(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr)), _gloffset_FlushMappedBufferRange, parameters) +#define GET_FlushMappedBufferRange(disp) GET_by_offset(disp, _gloffset_FlushMappedBufferRange) +#define SET_FlushMappedBufferRange(disp, fn) SET_by_offset(disp, _gloffset_FlushMappedBufferRange, fn) +#define CALL_MapBufferRange(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr, GLbitfield)), _gloffset_MapBufferRange, parameters) +#define GET_MapBufferRange(disp) GET_by_offset(disp, _gloffset_MapBufferRange) +#define SET_MapBufferRange(disp, fn) SET_by_offset(disp, _gloffset_MapBufferRange, fn) +#define CALL_BindVertexArray(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_BindVertexArray, parameters) +#define GET_BindVertexArray(disp) GET_by_offset(disp, _gloffset_BindVertexArray) +#define SET_BindVertexArray(disp, fn) SET_by_offset(disp, _gloffset_BindVertexArray, fn) +#define CALL_GenVertexArrays(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenVertexArrays, parameters) +#define GET_GenVertexArrays(disp) GET_by_offset(disp, _gloffset_GenVertexArrays) +#define SET_GenVertexArrays(disp, fn) SET_by_offset(disp, _gloffset_GenVertexArrays, fn) +#define CALL_CopyBufferSubData(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr)), _gloffset_CopyBufferSubData, parameters) +#define GET_CopyBufferSubData(disp) GET_by_offset(disp, _gloffset_CopyBufferSubData) +#define SET_CopyBufferSubData(disp, fn) SET_by_offset(disp, _gloffset_CopyBufferSubData, fn) +#define CALL_ClientWaitSync(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), _gloffset_ClientWaitSync, parameters) +#define GET_ClientWaitSync(disp) GET_by_offset(disp, _gloffset_ClientWaitSync) +#define SET_ClientWaitSync(disp, fn) SET_by_offset(disp, _gloffset_ClientWaitSync, fn) +#define CALL_DeleteSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync)), _gloffset_DeleteSync, parameters) +#define GET_DeleteSync(disp) GET_by_offset(disp, _gloffset_DeleteSync) +#define SET_DeleteSync(disp, fn) SET_by_offset(disp, _gloffset_DeleteSync, fn) +#define CALL_FenceSync(disp, parameters) CALL_by_offset(disp, (GLsync (GLAPIENTRYP)(GLenum, GLbitfield)), _gloffset_FenceSync, parameters) +#define GET_FenceSync(disp) GET_by_offset(disp, _gloffset_FenceSync) +#define SET_FenceSync(disp, fn) SET_by_offset(disp, _gloffset_FenceSync, fn) +#define CALL_GetInteger64v(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint64 *)), _gloffset_GetInteger64v, parameters) +#define GET_GetInteger64v(disp) GET_by_offset(disp, _gloffset_GetInteger64v) +#define SET_GetInteger64v(disp, fn) SET_by_offset(disp, _gloffset_GetInteger64v, fn) +#define CALL_GetSynciv(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLenum, GLsizei, GLsizei *, GLint *)), _gloffset_GetSynciv, parameters) +#define GET_GetSynciv(disp) GET_by_offset(disp, _gloffset_GetSynciv) +#define SET_GetSynciv(disp, fn) SET_by_offset(disp, _gloffset_GetSynciv, fn) +#define CALL_IsSync(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsync)), _gloffset_IsSync, parameters) +#define GET_IsSync(disp) GET_by_offset(disp, _gloffset_IsSync) +#define SET_IsSync(disp, fn) SET_by_offset(disp, _gloffset_IsSync, fn) +#define CALL_WaitSync(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsync, GLbitfield, GLuint64)), _gloffset_WaitSync, parameters) +#define GET_WaitSync(disp) GET_by_offset(disp, _gloffset_WaitSync) +#define SET_WaitSync(disp, fn) SET_by_offset(disp, _gloffset_WaitSync, fn) +#define CALL_DrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLenum, const GLvoid *, GLint)), _gloffset_DrawElementsBaseVertex, parameters) +#define GET_DrawElementsBaseVertex(disp) GET_by_offset(disp, _gloffset_DrawElementsBaseVertex) +#define SET_DrawElementsBaseVertex(disp, fn) SET_by_offset(disp, _gloffset_DrawElementsBaseVertex, fn) +#define CALL_DrawRangeElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint)), _gloffset_DrawRangeElementsBaseVertex, parameters) +#define GET_DrawRangeElementsBaseVertex(disp) GET_by_offset(disp, _gloffset_DrawRangeElementsBaseVertex) +#define SET_DrawRangeElementsBaseVertex(disp, fn) SET_by_offset(disp, _gloffset_DrawRangeElementsBaseVertex, fn) +#define CALL_MultiDrawElementsBaseVertex(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei, const GLint *)), _gloffset_MultiDrawElementsBaseVertex, parameters) +#define GET_MultiDrawElementsBaseVertex(disp) GET_by_offset(disp, _gloffset_MultiDrawElementsBaseVertex) +#define SET_MultiDrawElementsBaseVertex(disp, fn) SET_by_offset(disp, _gloffset_MultiDrawElementsBaseVertex, fn) +#define CALL_BindTransformFeedback(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindTransformFeedback, parameters) +#define GET_BindTransformFeedback(disp) GET_by_offset(disp, _gloffset_BindTransformFeedback) +#define SET_BindTransformFeedback(disp, fn) SET_by_offset(disp, _gloffset_BindTransformFeedback, fn) +#define CALL_DeleteTransformFeedbacks(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteTransformFeedbacks, parameters) +#define GET_DeleteTransformFeedbacks(disp) GET_by_offset(disp, _gloffset_DeleteTransformFeedbacks) +#define SET_DeleteTransformFeedbacks(disp, fn) SET_by_offset(disp, _gloffset_DeleteTransformFeedbacks, fn) +#define CALL_DrawTransformFeedback(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_DrawTransformFeedback, parameters) +#define GET_DrawTransformFeedback(disp) GET_by_offset(disp, _gloffset_DrawTransformFeedback) +#define SET_DrawTransformFeedback(disp, fn) SET_by_offset(disp, _gloffset_DrawTransformFeedback, fn) +#define CALL_GenTransformFeedbacks(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenTransformFeedbacks, parameters) +#define GET_GenTransformFeedbacks(disp) GET_by_offset(disp, _gloffset_GenTransformFeedbacks) +#define SET_GenTransformFeedbacks(disp, fn) SET_by_offset(disp, _gloffset_GenTransformFeedbacks, fn) +#define CALL_IsTransformFeedback(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsTransformFeedback, parameters) +#define GET_IsTransformFeedback(disp) GET_by_offset(disp, _gloffset_IsTransformFeedback) +#define SET_IsTransformFeedback(disp, fn) SET_by_offset(disp, _gloffset_IsTransformFeedback, fn) +#define CALL_PauseTransformFeedback(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PauseTransformFeedback, parameters) +#define GET_PauseTransformFeedback(disp) GET_by_offset(disp, _gloffset_PauseTransformFeedback) +#define SET_PauseTransformFeedback(disp, fn) SET_by_offset(disp, _gloffset_PauseTransformFeedback, fn) +#define CALL_ResumeTransformFeedback(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_ResumeTransformFeedback, parameters) +#define GET_ResumeTransformFeedback(disp) GET_by_offset(disp, _gloffset_ResumeTransformFeedback) +#define SET_ResumeTransformFeedback(disp, fn) SET_by_offset(disp, _gloffset_ResumeTransformFeedback, fn) +#define CALL_PolygonOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_PolygonOffsetEXT, parameters) +#define GET_PolygonOffsetEXT(disp) GET_by_offset(disp, _gloffset_PolygonOffsetEXT) +#define SET_PolygonOffsetEXT(disp, fn) SET_by_offset(disp, _gloffset_PolygonOffsetEXT, fn) +#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), _gloffset_GetPixelTexGenParameterfvSGIS, parameters) +#define GET_GetPixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, _gloffset_GetPixelTexGenParameterfvSGIS) +#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, _gloffset_GetPixelTexGenParameterfvSGIS, fn) +#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), _gloffset_GetPixelTexGenParameterivSGIS, parameters) +#define GET_GetPixelTexGenParameterivSGIS(disp) GET_by_offset(disp, _gloffset_GetPixelTexGenParameterivSGIS) +#define SET_GetPixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, _gloffset_GetPixelTexGenParameterivSGIS, fn) +#define CALL_PixelTexGenParameterfSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_PixelTexGenParameterfSGIS, parameters) +#define GET_PixelTexGenParameterfSGIS(disp) GET_by_offset(disp, _gloffset_PixelTexGenParameterfSGIS) +#define SET_PixelTexGenParameterfSGIS(disp, fn) SET_by_offset(disp, _gloffset_PixelTexGenParameterfSGIS, fn) +#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_PixelTexGenParameterfvSGIS, parameters) +#define GET_PixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, _gloffset_PixelTexGenParameterfvSGIS) +#define SET_PixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, _gloffset_PixelTexGenParameterfvSGIS, fn) +#define CALL_PixelTexGenParameteriSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_PixelTexGenParameteriSGIS, parameters) +#define GET_PixelTexGenParameteriSGIS(disp) GET_by_offset(disp, _gloffset_PixelTexGenParameteriSGIS) +#define SET_PixelTexGenParameteriSGIS(disp, fn) SET_by_offset(disp, _gloffset_PixelTexGenParameteriSGIS, fn) +#define CALL_PixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_PixelTexGenParameterivSGIS, parameters) +#define GET_PixelTexGenParameterivSGIS(disp) GET_by_offset(disp, _gloffset_PixelTexGenParameterivSGIS) +#define SET_PixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, _gloffset_PixelTexGenParameterivSGIS, fn) +#define CALL_SampleMaskSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), _gloffset_SampleMaskSGIS, parameters) +#define GET_SampleMaskSGIS(disp) GET_by_offset(disp, _gloffset_SampleMaskSGIS) +#define SET_SampleMaskSGIS(disp, fn) SET_by_offset(disp, _gloffset_SampleMaskSGIS, fn) +#define CALL_SamplePatternSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_SamplePatternSGIS, parameters) +#define GET_SamplePatternSGIS(disp) GET_by_offset(disp, _gloffset_SamplePatternSGIS) +#define SET_SamplePatternSGIS(disp, fn) SET_by_offset(disp, _gloffset_SamplePatternSGIS, fn) +#define CALL_ColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), _gloffset_ColorPointerEXT, parameters) +#define GET_ColorPointerEXT(disp) GET_by_offset(disp, _gloffset_ColorPointerEXT) +#define SET_ColorPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_ColorPointerEXT, fn) +#define CALL_EdgeFlagPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, const GLboolean *)), _gloffset_EdgeFlagPointerEXT, parameters) +#define GET_EdgeFlagPointerEXT(disp) GET_by_offset(disp, _gloffset_EdgeFlagPointerEXT) +#define SET_EdgeFlagPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_EdgeFlagPointerEXT, fn) +#define CALL_IndexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), _gloffset_IndexPointerEXT, parameters) +#define GET_IndexPointerEXT(disp) GET_by_offset(disp, _gloffset_IndexPointerEXT) +#define SET_IndexPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_IndexPointerEXT, fn) +#define CALL_NormalPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), _gloffset_NormalPointerEXT, parameters) +#define GET_NormalPointerEXT(disp) GET_by_offset(disp, _gloffset_NormalPointerEXT) +#define SET_NormalPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_NormalPointerEXT, fn) +#define CALL_TexCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), _gloffset_TexCoordPointerEXT, parameters) +#define GET_TexCoordPointerEXT(disp) GET_by_offset(disp, _gloffset_TexCoordPointerEXT) +#define SET_TexCoordPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_TexCoordPointerEXT, fn) +#define CALL_VertexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), _gloffset_VertexPointerEXT, parameters) +#define GET_VertexPointerEXT(disp) GET_by_offset(disp, _gloffset_VertexPointerEXT) +#define SET_VertexPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexPointerEXT, fn) +#define CALL_PointParameterfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_PointParameterfEXT, parameters) +#define GET_PointParameterfEXT(disp) GET_by_offset(disp, _gloffset_PointParameterfEXT) +#define SET_PointParameterfEXT(disp, fn) SET_by_offset(disp, _gloffset_PointParameterfEXT, fn) +#define CALL_PointParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_PointParameterfvEXT, parameters) +#define GET_PointParameterfvEXT(disp) GET_by_offset(disp, _gloffset_PointParameterfvEXT) +#define SET_PointParameterfvEXT(disp, fn) SET_by_offset(disp, _gloffset_PointParameterfvEXT, fn) +#define CALL_LockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei)), _gloffset_LockArraysEXT, parameters) +#define GET_LockArraysEXT(disp) GET_by_offset(disp, _gloffset_LockArraysEXT) +#define SET_LockArraysEXT(disp, fn) SET_by_offset(disp, _gloffset_LockArraysEXT, fn) +#define CALL_UnlockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_UnlockArraysEXT, parameters) +#define GET_UnlockArraysEXT(disp) GET_by_offset(disp, _gloffset_UnlockArraysEXT) +#define SET_UnlockArraysEXT(disp, fn) SET_by_offset(disp, _gloffset_UnlockArraysEXT, fn) +#define CALL_SecondaryColor3bEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), _gloffset_SecondaryColor3bEXT, parameters) +#define GET_SecondaryColor3bEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3bEXT) +#define SET_SecondaryColor3bEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3bEXT, fn) +#define CALL_SecondaryColor3bvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), _gloffset_SecondaryColor3bvEXT, parameters) +#define GET_SecondaryColor3bvEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3bvEXT) +#define SET_SecondaryColor3bvEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3bvEXT, fn) +#define CALL_SecondaryColor3dEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_SecondaryColor3dEXT, parameters) +#define GET_SecondaryColor3dEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3dEXT) +#define SET_SecondaryColor3dEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3dEXT, fn) +#define CALL_SecondaryColor3dvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_SecondaryColor3dvEXT, parameters) +#define GET_SecondaryColor3dvEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3dvEXT) +#define SET_SecondaryColor3dvEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3dvEXT, fn) +#define CALL_SecondaryColor3fEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_SecondaryColor3fEXT, parameters) +#define GET_SecondaryColor3fEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3fEXT) +#define SET_SecondaryColor3fEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3fEXT, fn) +#define CALL_SecondaryColor3fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_SecondaryColor3fvEXT, parameters) +#define GET_SecondaryColor3fvEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3fvEXT) +#define SET_SecondaryColor3fvEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3fvEXT, fn) +#define CALL_SecondaryColor3iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_SecondaryColor3iEXT, parameters) +#define GET_SecondaryColor3iEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3iEXT) +#define SET_SecondaryColor3iEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3iEXT, fn) +#define CALL_SecondaryColor3ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_SecondaryColor3ivEXT, parameters) +#define GET_SecondaryColor3ivEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3ivEXT) +#define SET_SecondaryColor3ivEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3ivEXT, fn) +#define CALL_SecondaryColor3sEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_SecondaryColor3sEXT, parameters) +#define GET_SecondaryColor3sEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3sEXT) +#define SET_SecondaryColor3sEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3sEXT, fn) +#define CALL_SecondaryColor3svEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_SecondaryColor3svEXT, parameters) +#define GET_SecondaryColor3svEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3svEXT) +#define SET_SecondaryColor3svEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3svEXT, fn) +#define CALL_SecondaryColor3ubEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte)), _gloffset_SecondaryColor3ubEXT, parameters) +#define GET_SecondaryColor3ubEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3ubEXT) +#define SET_SecondaryColor3ubEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3ubEXT, fn) +#define CALL_SecondaryColor3ubvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), _gloffset_SecondaryColor3ubvEXT, parameters) +#define GET_SecondaryColor3ubvEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3ubvEXT) +#define SET_SecondaryColor3ubvEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3ubvEXT, fn) +#define CALL_SecondaryColor3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), _gloffset_SecondaryColor3uiEXT, parameters) +#define GET_SecondaryColor3uiEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3uiEXT) +#define SET_SecondaryColor3uiEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3uiEXT, fn) +#define CALL_SecondaryColor3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), _gloffset_SecondaryColor3uivEXT, parameters) +#define GET_SecondaryColor3uivEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3uivEXT) +#define SET_SecondaryColor3uivEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3uivEXT, fn) +#define CALL_SecondaryColor3usEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort)), _gloffset_SecondaryColor3usEXT, parameters) +#define GET_SecondaryColor3usEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3usEXT) +#define SET_SecondaryColor3usEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3usEXT, fn) +#define CALL_SecondaryColor3usvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), _gloffset_SecondaryColor3usvEXT, parameters) +#define GET_SecondaryColor3usvEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColor3usvEXT) +#define SET_SecondaryColor3usvEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColor3usvEXT, fn) +#define CALL_SecondaryColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_SecondaryColorPointerEXT, parameters) +#define GET_SecondaryColorPointerEXT(disp) GET_by_offset(disp, _gloffset_SecondaryColorPointerEXT) +#define SET_SecondaryColorPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_SecondaryColorPointerEXT, fn) +#define CALL_MultiDrawArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *, const GLsizei *, GLsizei)), _gloffset_MultiDrawArraysEXT, parameters) +#define GET_MultiDrawArraysEXT(disp) GET_by_offset(disp, _gloffset_MultiDrawArraysEXT) +#define SET_MultiDrawArraysEXT(disp, fn) SET_by_offset(disp, _gloffset_MultiDrawArraysEXT, fn) +#define CALL_MultiDrawElementsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei)), _gloffset_MultiDrawElementsEXT, parameters) +#define GET_MultiDrawElementsEXT(disp) GET_by_offset(disp, _gloffset_MultiDrawElementsEXT) +#define SET_MultiDrawElementsEXT(disp, fn) SET_by_offset(disp, _gloffset_MultiDrawElementsEXT, fn) +#define CALL_FogCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), _gloffset_FogCoordPointerEXT, parameters) +#define GET_FogCoordPointerEXT(disp) GET_by_offset(disp, _gloffset_FogCoordPointerEXT) +#define SET_FogCoordPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_FogCoordPointerEXT, fn) +#define CALL_FogCoorddEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), _gloffset_FogCoorddEXT, parameters) +#define GET_FogCoorddEXT(disp) GET_by_offset(disp, _gloffset_FogCoorddEXT) +#define SET_FogCoorddEXT(disp, fn) SET_by_offset(disp, _gloffset_FogCoorddEXT, fn) +#define CALL_FogCoorddvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_FogCoorddvEXT, parameters) +#define GET_FogCoorddvEXT(disp) GET_by_offset(disp, _gloffset_FogCoorddvEXT) +#define SET_FogCoorddvEXT(disp, fn) SET_by_offset(disp, _gloffset_FogCoorddvEXT, fn) +#define CALL_FogCoordfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), _gloffset_FogCoordfEXT, parameters) +#define GET_FogCoordfEXT(disp) GET_by_offset(disp, _gloffset_FogCoordfEXT) +#define SET_FogCoordfEXT(disp, fn) SET_by_offset(disp, _gloffset_FogCoordfEXT, fn) +#define CALL_FogCoordfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_FogCoordfvEXT, parameters) +#define GET_FogCoordfvEXT(disp) GET_by_offset(disp, _gloffset_FogCoordfvEXT) +#define SET_FogCoordfvEXT(disp, fn) SET_by_offset(disp, _gloffset_FogCoordfvEXT, fn) +#define CALL_PixelTexGenSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_PixelTexGenSGIX, parameters) +#define GET_PixelTexGenSGIX(disp) GET_by_offset(disp, _gloffset_PixelTexGenSGIX) +#define SET_PixelTexGenSGIX(disp, fn) SET_by_offset(disp, _gloffset_PixelTexGenSGIX, fn) +#define CALL_BlendFuncSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), _gloffset_BlendFuncSeparateEXT, parameters) +#define GET_BlendFuncSeparateEXT(disp) GET_by_offset(disp, _gloffset_BlendFuncSeparateEXT) +#define SET_BlendFuncSeparateEXT(disp, fn) SET_by_offset(disp, _gloffset_BlendFuncSeparateEXT, fn) +#define CALL_FlushVertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_FlushVertexArrayRangeNV, parameters) +#define GET_FlushVertexArrayRangeNV(disp) GET_by_offset(disp, _gloffset_FlushVertexArrayRangeNV) +#define SET_FlushVertexArrayRangeNV(disp, fn) SET_by_offset(disp, _gloffset_FlushVertexArrayRangeNV, fn) +#define CALL_VertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLvoid *)), _gloffset_VertexArrayRangeNV, parameters) +#define GET_VertexArrayRangeNV(disp) GET_by_offset(disp, _gloffset_VertexArrayRangeNV) +#define SET_VertexArrayRangeNV(disp, fn) SET_by_offset(disp, _gloffset_VertexArrayRangeNV, fn) +#define CALL_CombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum)), _gloffset_CombinerInputNV, parameters) +#define GET_CombinerInputNV(disp) GET_by_offset(disp, _gloffset_CombinerInputNV) +#define SET_CombinerInputNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerInputNV, fn) +#define CALL_CombinerOutputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean)), _gloffset_CombinerOutputNV, parameters) +#define GET_CombinerOutputNV(disp) GET_by_offset(disp, _gloffset_CombinerOutputNV) +#define SET_CombinerOutputNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerOutputNV, fn) +#define CALL_CombinerParameterfNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), _gloffset_CombinerParameterfNV, parameters) +#define GET_CombinerParameterfNV(disp) GET_by_offset(disp, _gloffset_CombinerParameterfNV) +#define SET_CombinerParameterfNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerParameterfNV, fn) +#define CALL_CombinerParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_CombinerParameterfvNV, parameters) +#define GET_CombinerParameterfvNV(disp) GET_by_offset(disp, _gloffset_CombinerParameterfvNV) +#define SET_CombinerParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerParameterfvNV, fn) +#define CALL_CombinerParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_CombinerParameteriNV, parameters) +#define GET_CombinerParameteriNV(disp) GET_by_offset(disp, _gloffset_CombinerParameteriNV) +#define SET_CombinerParameteriNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerParameteriNV, fn) +#define CALL_CombinerParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_CombinerParameterivNV, parameters) +#define GET_CombinerParameterivNV(disp) GET_by_offset(disp, _gloffset_CombinerParameterivNV) +#define SET_CombinerParameterivNV(disp, fn) SET_by_offset(disp, _gloffset_CombinerParameterivNV, fn) +#define CALL_FinalCombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), _gloffset_FinalCombinerInputNV, parameters) +#define GET_FinalCombinerInputNV(disp) GET_by_offset(disp, _gloffset_FinalCombinerInputNV) +#define SET_FinalCombinerInputNV(disp, fn) SET_by_offset(disp, _gloffset_FinalCombinerInputNV, fn) +#define CALL_GetCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLfloat *)), _gloffset_GetCombinerInputParameterfvNV, parameters) +#define GET_GetCombinerInputParameterfvNV(disp) GET_by_offset(disp, _gloffset_GetCombinerInputParameterfvNV) +#define SET_GetCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetCombinerInputParameterfvNV, fn) +#define CALL_GetCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLint *)), _gloffset_GetCombinerInputParameterivNV, parameters) +#define GET_GetCombinerInputParameterivNV(disp) GET_by_offset(disp, _gloffset_GetCombinerInputParameterivNV) +#define SET_GetCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, _gloffset_GetCombinerInputParameterivNV, fn) +#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLfloat *)), _gloffset_GetCombinerOutputParameterfvNV, parameters) +#define GET_GetCombinerOutputParameterfvNV(disp) GET_by_offset(disp, _gloffset_GetCombinerOutputParameterfvNV) +#define SET_GetCombinerOutputParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetCombinerOutputParameterfvNV, fn) +#define CALL_GetCombinerOutputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), _gloffset_GetCombinerOutputParameterivNV, parameters) +#define GET_GetCombinerOutputParameterivNV(disp) GET_by_offset(disp, _gloffset_GetCombinerOutputParameterivNV) +#define SET_GetCombinerOutputParameterivNV(disp, fn) SET_by_offset(disp, _gloffset_GetCombinerOutputParameterivNV, fn) +#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), _gloffset_GetFinalCombinerInputParameterfvNV, parameters) +#define GET_GetFinalCombinerInputParameterfvNV(disp) GET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterfvNV) +#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterfvNV, fn) +#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetFinalCombinerInputParameterivNV, parameters) +#define GET_GetFinalCombinerInputParameterivNV(disp) GET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterivNV) +#define SET_GetFinalCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, _gloffset_GetFinalCombinerInputParameterivNV, fn) +#define CALL_ResizeBuffersMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_ResizeBuffersMESA, parameters) +#define GET_ResizeBuffersMESA(disp) GET_by_offset(disp, _gloffset_ResizeBuffersMESA) +#define SET_ResizeBuffersMESA(disp, fn) SET_by_offset(disp, _gloffset_ResizeBuffersMESA, fn) +#define CALL_WindowPos2dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), _gloffset_WindowPos2dMESA, parameters) +#define GET_WindowPos2dMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2dMESA) +#define SET_WindowPos2dMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2dMESA, fn) +#define CALL_WindowPos2dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_WindowPos2dvMESA, parameters) +#define GET_WindowPos2dvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2dvMESA) +#define SET_WindowPos2dvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2dvMESA, fn) +#define CALL_WindowPos2fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), _gloffset_WindowPos2fMESA, parameters) +#define GET_WindowPos2fMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2fMESA) +#define SET_WindowPos2fMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2fMESA, fn) +#define CALL_WindowPos2fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_WindowPos2fvMESA, parameters) +#define GET_WindowPos2fvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2fvMESA) +#define SET_WindowPos2fvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2fvMESA, fn) +#define CALL_WindowPos2iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), _gloffset_WindowPos2iMESA, parameters) +#define GET_WindowPos2iMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2iMESA) +#define SET_WindowPos2iMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2iMESA, fn) +#define CALL_WindowPos2ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_WindowPos2ivMESA, parameters) +#define GET_WindowPos2ivMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2ivMESA) +#define SET_WindowPos2ivMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2ivMESA, fn) +#define CALL_WindowPos2sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), _gloffset_WindowPos2sMESA, parameters) +#define GET_WindowPos2sMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2sMESA) +#define SET_WindowPos2sMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2sMESA, fn) +#define CALL_WindowPos2svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_WindowPos2svMESA, parameters) +#define GET_WindowPos2svMESA(disp) GET_by_offset(disp, _gloffset_WindowPos2svMESA) +#define SET_WindowPos2svMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos2svMESA, fn) +#define CALL_WindowPos3dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), _gloffset_WindowPos3dMESA, parameters) +#define GET_WindowPos3dMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3dMESA) +#define SET_WindowPos3dMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3dMESA, fn) +#define CALL_WindowPos3dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_WindowPos3dvMESA, parameters) +#define GET_WindowPos3dvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3dvMESA) +#define SET_WindowPos3dvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3dvMESA, fn) +#define CALL_WindowPos3fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), _gloffset_WindowPos3fMESA, parameters) +#define GET_WindowPos3fMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3fMESA) +#define SET_WindowPos3fMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3fMESA, fn) +#define CALL_WindowPos3fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_WindowPos3fvMESA, parameters) +#define GET_WindowPos3fvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3fvMESA) +#define SET_WindowPos3fvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3fvMESA, fn) +#define CALL_WindowPos3iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), _gloffset_WindowPos3iMESA, parameters) +#define GET_WindowPos3iMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3iMESA) +#define SET_WindowPos3iMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3iMESA, fn) +#define CALL_WindowPos3ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_WindowPos3ivMESA, parameters) +#define GET_WindowPos3ivMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3ivMESA) +#define SET_WindowPos3ivMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3ivMESA, fn) +#define CALL_WindowPos3sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), _gloffset_WindowPos3sMESA, parameters) +#define GET_WindowPos3sMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3sMESA) +#define SET_WindowPos3sMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3sMESA, fn) +#define CALL_WindowPos3svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_WindowPos3svMESA, parameters) +#define GET_WindowPos3svMESA(disp) GET_by_offset(disp, _gloffset_WindowPos3svMESA) +#define SET_WindowPos3svMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos3svMESA, fn) +#define CALL_WindowPos4dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_WindowPos4dMESA, parameters) +#define GET_WindowPos4dMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4dMESA) +#define SET_WindowPos4dMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4dMESA, fn) +#define CALL_WindowPos4dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), _gloffset_WindowPos4dvMESA, parameters) +#define GET_WindowPos4dvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4dvMESA) +#define SET_WindowPos4dvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4dvMESA, fn) +#define CALL_WindowPos4fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_WindowPos4fMESA, parameters) +#define GET_WindowPos4fMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4fMESA) +#define SET_WindowPos4fMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4fMESA, fn) +#define CALL_WindowPos4fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), _gloffset_WindowPos4fvMESA, parameters) +#define GET_WindowPos4fvMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4fvMESA) +#define SET_WindowPos4fvMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4fvMESA, fn) +#define CALL_WindowPos4iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_WindowPos4iMESA, parameters) +#define GET_WindowPos4iMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4iMESA) +#define SET_WindowPos4iMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4iMESA, fn) +#define CALL_WindowPos4ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), _gloffset_WindowPos4ivMESA, parameters) +#define GET_WindowPos4ivMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4ivMESA) +#define SET_WindowPos4ivMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4ivMESA, fn) +#define CALL_WindowPos4sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), _gloffset_WindowPos4sMESA, parameters) +#define GET_WindowPos4sMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4sMESA) +#define SET_WindowPos4sMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4sMESA, fn) +#define CALL_WindowPos4svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), _gloffset_WindowPos4svMESA, parameters) +#define GET_WindowPos4svMESA(disp) GET_by_offset(disp, _gloffset_WindowPos4svMESA) +#define SET_WindowPos4svMESA(disp, fn) SET_by_offset(disp, _gloffset_WindowPos4svMESA, fn) +#define CALL_MultiModeDrawArraysIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint)), _gloffset_MultiModeDrawArraysIBM, parameters) +#define GET_MultiModeDrawArraysIBM(disp) GET_by_offset(disp, _gloffset_MultiModeDrawArraysIBM) +#define SET_MultiModeDrawArraysIBM(disp, fn) SET_by_offset(disp, _gloffset_MultiModeDrawArraysIBM, fn) +#define CALL_MultiModeDrawElementsIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint)), _gloffset_MultiModeDrawElementsIBM, parameters) +#define GET_MultiModeDrawElementsIBM(disp) GET_by_offset(disp, _gloffset_MultiModeDrawElementsIBM) +#define SET_MultiModeDrawElementsIBM(disp, fn) SET_by_offset(disp, _gloffset_MultiModeDrawElementsIBM, fn) +#define CALL_DeleteFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteFencesNV, parameters) +#define GET_DeleteFencesNV(disp) GET_by_offset(disp, _gloffset_DeleteFencesNV) +#define SET_DeleteFencesNV(disp, fn) SET_by_offset(disp, _gloffset_DeleteFencesNV, fn) +#define CALL_FinishFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_FinishFenceNV, parameters) +#define GET_FinishFenceNV(disp) GET_by_offset(disp, _gloffset_FinishFenceNV) +#define SET_FinishFenceNV(disp, fn) SET_by_offset(disp, _gloffset_FinishFenceNV, fn) +#define CALL_GenFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenFencesNV, parameters) +#define GET_GenFencesNV(disp) GET_by_offset(disp, _gloffset_GenFencesNV) +#define SET_GenFencesNV(disp, fn) SET_by_offset(disp, _gloffset_GenFencesNV, fn) +#define CALL_GetFenceivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetFenceivNV, parameters) +#define GET_GetFenceivNV(disp) GET_by_offset(disp, _gloffset_GetFenceivNV) +#define SET_GetFenceivNV(disp, fn) SET_by_offset(disp, _gloffset_GetFenceivNV, fn) +#define CALL_IsFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsFenceNV, parameters) +#define GET_IsFenceNV(disp) GET_by_offset(disp, _gloffset_IsFenceNV) +#define SET_IsFenceNV(disp, fn) SET_by_offset(disp, _gloffset_IsFenceNV, fn) +#define CALL_SetFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), _gloffset_SetFenceNV, parameters) +#define GET_SetFenceNV(disp) GET_by_offset(disp, _gloffset_SetFenceNV) +#define SET_SetFenceNV(disp, fn) SET_by_offset(disp, _gloffset_SetFenceNV, fn) +#define CALL_TestFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_TestFenceNV, parameters) +#define GET_TestFenceNV(disp) GET_by_offset(disp, _gloffset_TestFenceNV) +#define SET_TestFenceNV(disp, fn) SET_by_offset(disp, _gloffset_TestFenceNV, fn) +#define CALL_AreProgramsResidentNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), _gloffset_AreProgramsResidentNV, parameters) +#define GET_AreProgramsResidentNV(disp) GET_by_offset(disp, _gloffset_AreProgramsResidentNV) +#define SET_AreProgramsResidentNV(disp, fn) SET_by_offset(disp, _gloffset_AreProgramsResidentNV, fn) +#define CALL_BindProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindProgramNV, parameters) +#define GET_BindProgramNV(disp) GET_by_offset(disp, _gloffset_BindProgramNV) +#define SET_BindProgramNV(disp, fn) SET_by_offset(disp, _gloffset_BindProgramNV, fn) +#define CALL_DeleteProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteProgramsNV, parameters) +#define GET_DeleteProgramsNV(disp) GET_by_offset(disp, _gloffset_DeleteProgramsNV) +#define SET_DeleteProgramsNV(disp, fn) SET_by_offset(disp, _gloffset_DeleteProgramsNV, fn) +#define CALL_ExecuteProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), _gloffset_ExecuteProgramNV, parameters) +#define GET_ExecuteProgramNV(disp) GET_by_offset(disp, _gloffset_ExecuteProgramNV) +#define SET_ExecuteProgramNV(disp, fn) SET_by_offset(disp, _gloffset_ExecuteProgramNV, fn) +#define CALL_GenProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenProgramsNV, parameters) +#define GET_GenProgramsNV(disp) GET_by_offset(disp, _gloffset_GenProgramsNV) +#define SET_GenProgramsNV(disp, fn) SET_by_offset(disp, _gloffset_GenProgramsNV, fn) +#define CALL_GetProgramParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLdouble *)), _gloffset_GetProgramParameterdvNV, parameters) +#define GET_GetProgramParameterdvNV(disp) GET_by_offset(disp, _gloffset_GetProgramParameterdvNV) +#define SET_GetProgramParameterdvNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramParameterdvNV, fn) +#define CALL_GetProgramParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLfloat *)), _gloffset_GetProgramParameterfvNV, parameters) +#define GET_GetProgramParameterfvNV(disp) GET_by_offset(disp, _gloffset_GetProgramParameterfvNV) +#define SET_GetProgramParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramParameterfvNV, fn) +#define CALL_GetProgramStringNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)), _gloffset_GetProgramStringNV, parameters) +#define GET_GetProgramStringNV(disp) GET_by_offset(disp, _gloffset_GetProgramStringNV) +#define SET_GetProgramStringNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramStringNV, fn) +#define CALL_GetProgramivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetProgramivNV, parameters) +#define GET_GetProgramivNV(disp) GET_by_offset(disp, _gloffset_GetProgramivNV) +#define SET_GetProgramivNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramivNV, fn) +#define CALL_GetTrackMatrixivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLint *)), _gloffset_GetTrackMatrixivNV, parameters) +#define GET_GetTrackMatrixivNV(disp) GET_by_offset(disp, _gloffset_GetTrackMatrixivNV) +#define SET_GetTrackMatrixivNV(disp, fn) SET_by_offset(disp, _gloffset_GetTrackMatrixivNV, fn) +#define CALL_GetVertexAttribPointervNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLvoid **)), _gloffset_GetVertexAttribPointervNV, parameters) +#define GET_GetVertexAttribPointervNV(disp) GET_by_offset(disp, _gloffset_GetVertexAttribPointervNV) +#define SET_GetVertexAttribPointervNV(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribPointervNV, fn) +#define CALL_GetVertexAttribdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), _gloffset_GetVertexAttribdvNV, parameters) +#define GET_GetVertexAttribdvNV(disp) GET_by_offset(disp, _gloffset_GetVertexAttribdvNV) +#define SET_GetVertexAttribdvNV(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribdvNV, fn) +#define CALL_GetVertexAttribfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), _gloffset_GetVertexAttribfvNV, parameters) +#define GET_GetVertexAttribfvNV(disp) GET_by_offset(disp, _gloffset_GetVertexAttribfvNV) +#define SET_GetVertexAttribfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribfvNV, fn) +#define CALL_GetVertexAttribivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetVertexAttribivNV, parameters) +#define GET_GetVertexAttribivNV(disp) GET_by_offset(disp, _gloffset_GetVertexAttribivNV) +#define SET_GetVertexAttribivNV(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribivNV, fn) +#define CALL_IsProgramNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsProgramNV, parameters) +#define GET_IsProgramNV(disp) GET_by_offset(disp, _gloffset_IsProgramNV) +#define SET_IsProgramNV(disp, fn) SET_by_offset(disp, _gloffset_IsProgramNV, fn) +#define CALL_LoadProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLubyte *)), _gloffset_LoadProgramNV, parameters) +#define GET_LoadProgramNV(disp) GET_by_offset(disp, _gloffset_LoadProgramNV) +#define SET_LoadProgramNV(disp, fn) SET_by_offset(disp, _gloffset_LoadProgramNV, fn) +#define CALL_ProgramParameters4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLdouble *)), _gloffset_ProgramParameters4dvNV, parameters) +#define GET_ProgramParameters4dvNV(disp) GET_by_offset(disp, _gloffset_ProgramParameters4dvNV) +#define SET_ProgramParameters4dvNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramParameters4dvNV, fn) +#define CALL_ProgramParameters4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), _gloffset_ProgramParameters4fvNV, parameters) +#define GET_ProgramParameters4fvNV(disp) GET_by_offset(disp, _gloffset_ProgramParameters4fvNV) +#define SET_ProgramParameters4fvNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramParameters4fvNV, fn) +#define CALL_RequestResidentProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_RequestResidentProgramsNV, parameters) +#define GET_RequestResidentProgramsNV(disp) GET_by_offset(disp, _gloffset_RequestResidentProgramsNV) +#define SET_RequestResidentProgramsNV(disp, fn) SET_by_offset(disp, _gloffset_RequestResidentProgramsNV, fn) +#define CALL_TrackMatrixNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLenum)), _gloffset_TrackMatrixNV, parameters) +#define GET_TrackMatrixNV(disp) GET_by_offset(disp, _gloffset_TrackMatrixNV) +#define SET_TrackMatrixNV(disp, fn) SET_by_offset(disp, _gloffset_TrackMatrixNV, fn) +#define CALL_VertexAttrib1dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), _gloffset_VertexAttrib1dNV, parameters) +#define GET_VertexAttrib1dNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1dNV) +#define SET_VertexAttrib1dNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1dNV, fn) +#define CALL_VertexAttrib1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib1dvNV, parameters) +#define GET_VertexAttrib1dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1dvNV) +#define SET_VertexAttrib1dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1dvNV, fn) +#define CALL_VertexAttrib1fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), _gloffset_VertexAttrib1fNV, parameters) +#define GET_VertexAttrib1fNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1fNV) +#define SET_VertexAttrib1fNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1fNV, fn) +#define CALL_VertexAttrib1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib1fvNV, parameters) +#define GET_VertexAttrib1fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1fvNV) +#define SET_VertexAttrib1fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1fvNV, fn) +#define CALL_VertexAttrib1sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), _gloffset_VertexAttrib1sNV, parameters) +#define GET_VertexAttrib1sNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1sNV) +#define SET_VertexAttrib1sNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1sNV, fn) +#define CALL_VertexAttrib1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib1svNV, parameters) +#define GET_VertexAttrib1svNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib1svNV) +#define SET_VertexAttrib1svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib1svNV, fn) +#define CALL_VertexAttrib2dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), _gloffset_VertexAttrib2dNV, parameters) +#define GET_VertexAttrib2dNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2dNV) +#define SET_VertexAttrib2dNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2dNV, fn) +#define CALL_VertexAttrib2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib2dvNV, parameters) +#define GET_VertexAttrib2dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2dvNV) +#define SET_VertexAttrib2dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2dvNV, fn) +#define CALL_VertexAttrib2fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), _gloffset_VertexAttrib2fNV, parameters) +#define GET_VertexAttrib2fNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2fNV) +#define SET_VertexAttrib2fNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2fNV, fn) +#define CALL_VertexAttrib2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib2fvNV, parameters) +#define GET_VertexAttrib2fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2fvNV) +#define SET_VertexAttrib2fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2fvNV, fn) +#define CALL_VertexAttrib2sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), _gloffset_VertexAttrib2sNV, parameters) +#define GET_VertexAttrib2sNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2sNV) +#define SET_VertexAttrib2sNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2sNV, fn) +#define CALL_VertexAttrib2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib2svNV, parameters) +#define GET_VertexAttrib2svNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib2svNV) +#define SET_VertexAttrib2svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib2svNV, fn) +#define CALL_VertexAttrib3dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), _gloffset_VertexAttrib3dNV, parameters) +#define GET_VertexAttrib3dNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3dNV) +#define SET_VertexAttrib3dNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3dNV, fn) +#define CALL_VertexAttrib3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib3dvNV, parameters) +#define GET_VertexAttrib3dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3dvNV) +#define SET_VertexAttrib3dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3dvNV, fn) +#define CALL_VertexAttrib3fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), _gloffset_VertexAttrib3fNV, parameters) +#define GET_VertexAttrib3fNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3fNV) +#define SET_VertexAttrib3fNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3fNV, fn) +#define CALL_VertexAttrib3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib3fvNV, parameters) +#define GET_VertexAttrib3fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3fvNV) +#define SET_VertexAttrib3fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3fvNV, fn) +#define CALL_VertexAttrib3sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), _gloffset_VertexAttrib3sNV, parameters) +#define GET_VertexAttrib3sNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3sNV) +#define SET_VertexAttrib3sNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3sNV, fn) +#define CALL_VertexAttrib3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib3svNV, parameters) +#define GET_VertexAttrib3svNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib3svNV) +#define SET_VertexAttrib3svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib3svNV, fn) +#define CALL_VertexAttrib4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_VertexAttrib4dNV, parameters) +#define GET_VertexAttrib4dNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4dNV) +#define SET_VertexAttrib4dNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4dNV, fn) +#define CALL_VertexAttrib4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), _gloffset_VertexAttrib4dvNV, parameters) +#define GET_VertexAttrib4dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4dvNV) +#define SET_VertexAttrib4dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4dvNV, fn) +#define CALL_VertexAttrib4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_VertexAttrib4fNV, parameters) +#define GET_VertexAttrib4fNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4fNV) +#define SET_VertexAttrib4fNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4fNV, fn) +#define CALL_VertexAttrib4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_VertexAttrib4fvNV, parameters) +#define GET_VertexAttrib4fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4fvNV) +#define SET_VertexAttrib4fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4fvNV, fn) +#define CALL_VertexAttrib4sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), _gloffset_VertexAttrib4sNV, parameters) +#define GET_VertexAttrib4sNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4sNV) +#define SET_VertexAttrib4sNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4sNV, fn) +#define CALL_VertexAttrib4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttrib4svNV, parameters) +#define GET_VertexAttrib4svNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4svNV) +#define SET_VertexAttrib4svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4svNV, fn) +#define CALL_VertexAttrib4ubNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), _gloffset_VertexAttrib4ubNV, parameters) +#define GET_VertexAttrib4ubNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4ubNV) +#define SET_VertexAttrib4ubNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4ubNV, fn) +#define CALL_VertexAttrib4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), _gloffset_VertexAttrib4ubvNV, parameters) +#define GET_VertexAttrib4ubvNV(disp) GET_by_offset(disp, _gloffset_VertexAttrib4ubvNV) +#define SET_VertexAttrib4ubvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttrib4ubvNV, fn) +#define CALL_VertexAttribPointerNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_VertexAttribPointerNV, parameters) +#define GET_VertexAttribPointerNV(disp) GET_by_offset(disp, _gloffset_VertexAttribPointerNV) +#define SET_VertexAttribPointerNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribPointerNV, fn) +#define CALL_VertexAttribs1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), _gloffset_VertexAttribs1dvNV, parameters) +#define GET_VertexAttribs1dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs1dvNV) +#define SET_VertexAttribs1dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs1dvNV, fn) +#define CALL_VertexAttribs1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), _gloffset_VertexAttribs1fvNV, parameters) +#define GET_VertexAttribs1fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs1fvNV) +#define SET_VertexAttribs1fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs1fvNV, fn) +#define CALL_VertexAttribs1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), _gloffset_VertexAttribs1svNV, parameters) +#define GET_VertexAttribs1svNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs1svNV) +#define SET_VertexAttribs1svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs1svNV, fn) +#define CALL_VertexAttribs2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), _gloffset_VertexAttribs2dvNV, parameters) +#define GET_VertexAttribs2dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs2dvNV) +#define SET_VertexAttribs2dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs2dvNV, fn) +#define CALL_VertexAttribs2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), _gloffset_VertexAttribs2fvNV, parameters) +#define GET_VertexAttribs2fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs2fvNV) +#define SET_VertexAttribs2fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs2fvNV, fn) +#define CALL_VertexAttribs2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), _gloffset_VertexAttribs2svNV, parameters) +#define GET_VertexAttribs2svNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs2svNV) +#define SET_VertexAttribs2svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs2svNV, fn) +#define CALL_VertexAttribs3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), _gloffset_VertexAttribs3dvNV, parameters) +#define GET_VertexAttribs3dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs3dvNV) +#define SET_VertexAttribs3dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs3dvNV, fn) +#define CALL_VertexAttribs3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), _gloffset_VertexAttribs3fvNV, parameters) +#define GET_VertexAttribs3fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs3fvNV) +#define SET_VertexAttribs3fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs3fvNV, fn) +#define CALL_VertexAttribs3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), _gloffset_VertexAttribs3svNV, parameters) +#define GET_VertexAttribs3svNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs3svNV) +#define SET_VertexAttribs3svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs3svNV, fn) +#define CALL_VertexAttribs4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), _gloffset_VertexAttribs4dvNV, parameters) +#define GET_VertexAttribs4dvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs4dvNV) +#define SET_VertexAttribs4dvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs4dvNV, fn) +#define CALL_VertexAttribs4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), _gloffset_VertexAttribs4fvNV, parameters) +#define GET_VertexAttribs4fvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs4fvNV) +#define SET_VertexAttribs4fvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs4fvNV, fn) +#define CALL_VertexAttribs4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), _gloffset_VertexAttribs4svNV, parameters) +#define GET_VertexAttribs4svNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs4svNV) +#define SET_VertexAttribs4svNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs4svNV, fn) +#define CALL_VertexAttribs4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *)), _gloffset_VertexAttribs4ubvNV, parameters) +#define GET_VertexAttribs4ubvNV(disp) GET_by_offset(disp, _gloffset_VertexAttribs4ubvNV) +#define SET_VertexAttribs4ubvNV(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribs4ubvNV, fn) +#define CALL_GetTexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), _gloffset_GetTexBumpParameterfvATI, parameters) +#define GET_GetTexBumpParameterfvATI(disp) GET_by_offset(disp, _gloffset_GetTexBumpParameterfvATI) +#define SET_GetTexBumpParameterfvATI(disp, fn) SET_by_offset(disp, _gloffset_GetTexBumpParameterfvATI, fn) +#define CALL_GetTexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), _gloffset_GetTexBumpParameterivATI, parameters) +#define GET_GetTexBumpParameterivATI(disp) GET_by_offset(disp, _gloffset_GetTexBumpParameterivATI) +#define SET_GetTexBumpParameterivATI(disp, fn) SET_by_offset(disp, _gloffset_GetTexBumpParameterivATI, fn) +#define CALL_TexBumpParameterfvATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), _gloffset_TexBumpParameterfvATI, parameters) +#define GET_TexBumpParameterfvATI(disp) GET_by_offset(disp, _gloffset_TexBumpParameterfvATI) +#define SET_TexBumpParameterfvATI(disp, fn) SET_by_offset(disp, _gloffset_TexBumpParameterfvATI, fn) +#define CALL_TexBumpParameterivATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_TexBumpParameterivATI, parameters) +#define GET_TexBumpParameterivATI(disp) GET_by_offset(disp, _gloffset_TexBumpParameterivATI) +#define SET_TexBumpParameterivATI(disp, fn) SET_by_offset(disp, _gloffset_TexBumpParameterivATI, fn) +#define CALL_AlphaFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_AlphaFragmentOp1ATI, parameters) +#define GET_AlphaFragmentOp1ATI(disp) GET_by_offset(disp, _gloffset_AlphaFragmentOp1ATI) +#define SET_AlphaFragmentOp1ATI(disp, fn) SET_by_offset(disp, _gloffset_AlphaFragmentOp1ATI, fn) +#define CALL_AlphaFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_AlphaFragmentOp2ATI, parameters) +#define GET_AlphaFragmentOp2ATI(disp) GET_by_offset(disp, _gloffset_AlphaFragmentOp2ATI) +#define SET_AlphaFragmentOp2ATI(disp, fn) SET_by_offset(disp, _gloffset_AlphaFragmentOp2ATI, fn) +#define CALL_AlphaFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_AlphaFragmentOp3ATI, parameters) +#define GET_AlphaFragmentOp3ATI(disp) GET_by_offset(disp, _gloffset_AlphaFragmentOp3ATI) +#define SET_AlphaFragmentOp3ATI(disp, fn) SET_by_offset(disp, _gloffset_AlphaFragmentOp3ATI, fn) +#define CALL_BeginFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_BeginFragmentShaderATI, parameters) +#define GET_BeginFragmentShaderATI(disp) GET_by_offset(disp, _gloffset_BeginFragmentShaderATI) +#define SET_BeginFragmentShaderATI(disp, fn) SET_by_offset(disp, _gloffset_BeginFragmentShaderATI, fn) +#define CALL_BindFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_BindFragmentShaderATI, parameters) +#define GET_BindFragmentShaderATI(disp) GET_by_offset(disp, _gloffset_BindFragmentShaderATI) +#define SET_BindFragmentShaderATI(disp, fn) SET_by_offset(disp, _gloffset_BindFragmentShaderATI, fn) +#define CALL_ColorFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_ColorFragmentOp1ATI, parameters) +#define GET_ColorFragmentOp1ATI(disp) GET_by_offset(disp, _gloffset_ColorFragmentOp1ATI) +#define SET_ColorFragmentOp1ATI(disp, fn) SET_by_offset(disp, _gloffset_ColorFragmentOp1ATI, fn) +#define CALL_ColorFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_ColorFragmentOp2ATI, parameters) +#define GET_ColorFragmentOp2ATI(disp) GET_by_offset(disp, _gloffset_ColorFragmentOp2ATI) +#define SET_ColorFragmentOp2ATI(disp, fn) SET_by_offset(disp, _gloffset_ColorFragmentOp2ATI, fn) +#define CALL_ColorFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_ColorFragmentOp3ATI, parameters) +#define GET_ColorFragmentOp3ATI(disp) GET_by_offset(disp, _gloffset_ColorFragmentOp3ATI) +#define SET_ColorFragmentOp3ATI(disp, fn) SET_by_offset(disp, _gloffset_ColorFragmentOp3ATI, fn) +#define CALL_DeleteFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_DeleteFragmentShaderATI, parameters) +#define GET_DeleteFragmentShaderATI(disp) GET_by_offset(disp, _gloffset_DeleteFragmentShaderATI) +#define SET_DeleteFragmentShaderATI(disp, fn) SET_by_offset(disp, _gloffset_DeleteFragmentShaderATI, fn) +#define CALL_EndFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_EndFragmentShaderATI, parameters) +#define GET_EndFragmentShaderATI(disp) GET_by_offset(disp, _gloffset_EndFragmentShaderATI) +#define SET_EndFragmentShaderATI(disp, fn) SET_by_offset(disp, _gloffset_EndFragmentShaderATI, fn) +#define CALL_GenFragmentShadersATI(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLuint)), _gloffset_GenFragmentShadersATI, parameters) +#define GET_GenFragmentShadersATI(disp) GET_by_offset(disp, _gloffset_GenFragmentShadersATI) +#define SET_GenFragmentShadersATI(disp, fn) SET_by_offset(disp, _gloffset_GenFragmentShadersATI, fn) +#define CALL_PassTexCoordATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), _gloffset_PassTexCoordATI, parameters) +#define GET_PassTexCoordATI(disp) GET_by_offset(disp, _gloffset_PassTexCoordATI) +#define SET_PassTexCoordATI(disp, fn) SET_by_offset(disp, _gloffset_PassTexCoordATI, fn) +#define CALL_SampleMapATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), _gloffset_SampleMapATI, parameters) +#define GET_SampleMapATI(disp) GET_by_offset(disp, _gloffset_SampleMapATI) +#define SET_SampleMapATI(disp, fn) SET_by_offset(disp, _gloffset_SampleMapATI, fn) +#define CALL_SetFragmentShaderConstantATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), _gloffset_SetFragmentShaderConstantATI, parameters) +#define GET_SetFragmentShaderConstantATI(disp) GET_by_offset(disp, _gloffset_SetFragmentShaderConstantATI) +#define SET_SetFragmentShaderConstantATI(disp, fn) SET_by_offset(disp, _gloffset_SetFragmentShaderConstantATI, fn) +#define CALL_PointParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), _gloffset_PointParameteriNV, parameters) +#define GET_PointParameteriNV(disp) GET_by_offset(disp, _gloffset_PointParameteriNV) +#define SET_PointParameteriNV(disp, fn) SET_by_offset(disp, _gloffset_PointParameteriNV, fn) +#define CALL_PointParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), _gloffset_PointParameterivNV, parameters) +#define GET_PointParameterivNV(disp) GET_by_offset(disp, _gloffset_PointParameterivNV) +#define SET_PointParameterivNV(disp, fn) SET_by_offset(disp, _gloffset_PointParameterivNV, fn) +#define CALL_ActiveStencilFaceEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ActiveStencilFaceEXT, parameters) +#define GET_ActiveStencilFaceEXT(disp) GET_by_offset(disp, _gloffset_ActiveStencilFaceEXT) +#define SET_ActiveStencilFaceEXT(disp, fn) SET_by_offset(disp, _gloffset_ActiveStencilFaceEXT, fn) +#define CALL_BindVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_BindVertexArrayAPPLE, parameters) +#define GET_BindVertexArrayAPPLE(disp) GET_by_offset(disp, _gloffset_BindVertexArrayAPPLE) +#define SET_BindVertexArrayAPPLE(disp, fn) SET_by_offset(disp, _gloffset_BindVertexArrayAPPLE, fn) +#define CALL_DeleteVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteVertexArraysAPPLE, parameters) +#define GET_DeleteVertexArraysAPPLE(disp) GET_by_offset(disp, _gloffset_DeleteVertexArraysAPPLE) +#define SET_DeleteVertexArraysAPPLE(disp, fn) SET_by_offset(disp, _gloffset_DeleteVertexArraysAPPLE, fn) +#define CALL_GenVertexArraysAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenVertexArraysAPPLE, parameters) +#define GET_GenVertexArraysAPPLE(disp) GET_by_offset(disp, _gloffset_GenVertexArraysAPPLE) +#define SET_GenVertexArraysAPPLE(disp, fn) SET_by_offset(disp, _gloffset_GenVertexArraysAPPLE, fn) +#define CALL_IsVertexArrayAPPLE(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsVertexArrayAPPLE, parameters) +#define GET_IsVertexArrayAPPLE(disp) GET_by_offset(disp, _gloffset_IsVertexArrayAPPLE) +#define SET_IsVertexArrayAPPLE(disp, fn) SET_by_offset(disp, _gloffset_IsVertexArrayAPPLE, fn) +#define CALL_GetProgramNamedParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble *)), _gloffset_GetProgramNamedParameterdvNV, parameters) +#define GET_GetProgramNamedParameterdvNV(disp) GET_by_offset(disp, _gloffset_GetProgramNamedParameterdvNV) +#define SET_GetProgramNamedParameterdvNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramNamedParameterdvNV, fn) +#define CALL_GetProgramNamedParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat *)), _gloffset_GetProgramNamedParameterfvNV, parameters) +#define GET_GetProgramNamedParameterfvNV(disp) GET_by_offset(disp, _gloffset_GetProgramNamedParameterfvNV) +#define SET_GetProgramNamedParameterfvNV(disp, fn) SET_by_offset(disp, _gloffset_GetProgramNamedParameterfvNV, fn) +#define CALL_ProgramNamedParameter4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble)), _gloffset_ProgramNamedParameter4dNV, parameters) +#define GET_ProgramNamedParameter4dNV(disp) GET_by_offset(disp, _gloffset_ProgramNamedParameter4dNV) +#define SET_ProgramNamedParameter4dNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramNamedParameter4dNV, fn) +#define CALL_ProgramNamedParameter4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLdouble *)), _gloffset_ProgramNamedParameter4dvNV, parameters) +#define GET_ProgramNamedParameter4dvNV(disp) GET_by_offset(disp, _gloffset_ProgramNamedParameter4dvNV) +#define SET_ProgramNamedParameter4dvNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramNamedParameter4dvNV, fn) +#define CALL_ProgramNamedParameter4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat)), _gloffset_ProgramNamedParameter4fNV, parameters) +#define GET_ProgramNamedParameter4fNV(disp) GET_by_offset(disp, _gloffset_ProgramNamedParameter4fNV) +#define SET_ProgramNamedParameter4fNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramNamedParameter4fNV, fn) +#define CALL_ProgramNamedParameter4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLfloat *)), _gloffset_ProgramNamedParameter4fvNV, parameters) +#define GET_ProgramNamedParameter4fvNV(disp) GET_by_offset(disp, _gloffset_ProgramNamedParameter4fvNV) +#define SET_ProgramNamedParameter4fvNV(disp, fn) SET_by_offset(disp, _gloffset_ProgramNamedParameter4fvNV, fn) +#define CALL_PrimitiveRestartIndexNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_PrimitiveRestartIndexNV, parameters) +#define GET_PrimitiveRestartIndexNV(disp) GET_by_offset(disp, _gloffset_PrimitiveRestartIndexNV) +#define SET_PrimitiveRestartIndexNV(disp, fn) SET_by_offset(disp, _gloffset_PrimitiveRestartIndexNV, fn) +#define CALL_PrimitiveRestartNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_PrimitiveRestartNV, parameters) +#define GET_PrimitiveRestartNV(disp) GET_by_offset(disp, _gloffset_PrimitiveRestartNV) +#define SET_PrimitiveRestartNV(disp, fn) SET_by_offset(disp, _gloffset_PrimitiveRestartNV, fn) +#define CALL_DepthBoundsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd, GLclampd)), _gloffset_DepthBoundsEXT, parameters) +#define GET_DepthBoundsEXT(disp) GET_by_offset(disp, _gloffset_DepthBoundsEXT) +#define SET_DepthBoundsEXT(disp, fn) SET_by_offset(disp, _gloffset_DepthBoundsEXT, fn) +#define CALL_BlendEquationSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), _gloffset_BlendEquationSeparateEXT, parameters) +#define GET_BlendEquationSeparateEXT(disp) GET_by_offset(disp, _gloffset_BlendEquationSeparateEXT) +#define SET_BlendEquationSeparateEXT(disp, fn) SET_by_offset(disp, _gloffset_BlendEquationSeparateEXT, fn) +#define CALL_BindFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindFramebufferEXT, parameters) +#define GET_BindFramebufferEXT(disp) GET_by_offset(disp, _gloffset_BindFramebufferEXT) +#define SET_BindFramebufferEXT(disp, fn) SET_by_offset(disp, _gloffset_BindFramebufferEXT, fn) +#define CALL_BindRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_BindRenderbufferEXT, parameters) +#define GET_BindRenderbufferEXT(disp) GET_by_offset(disp, _gloffset_BindRenderbufferEXT) +#define SET_BindRenderbufferEXT(disp, fn) SET_by_offset(disp, _gloffset_BindRenderbufferEXT, fn) +#define CALL_CheckFramebufferStatusEXT(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum)), _gloffset_CheckFramebufferStatusEXT, parameters) +#define GET_CheckFramebufferStatusEXT(disp) GET_by_offset(disp, _gloffset_CheckFramebufferStatusEXT) +#define SET_CheckFramebufferStatusEXT(disp, fn) SET_by_offset(disp, _gloffset_CheckFramebufferStatusEXT, fn) +#define CALL_DeleteFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteFramebuffersEXT, parameters) +#define GET_DeleteFramebuffersEXT(disp) GET_by_offset(disp, _gloffset_DeleteFramebuffersEXT) +#define SET_DeleteFramebuffersEXT(disp, fn) SET_by_offset(disp, _gloffset_DeleteFramebuffersEXT, fn) +#define CALL_DeleteRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), _gloffset_DeleteRenderbuffersEXT, parameters) +#define GET_DeleteRenderbuffersEXT(disp) GET_by_offset(disp, _gloffset_DeleteRenderbuffersEXT) +#define SET_DeleteRenderbuffersEXT(disp, fn) SET_by_offset(disp, _gloffset_DeleteRenderbuffersEXT, fn) +#define CALL_FramebufferRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint)), _gloffset_FramebufferRenderbufferEXT, parameters) +#define GET_FramebufferRenderbufferEXT(disp) GET_by_offset(disp, _gloffset_FramebufferRenderbufferEXT) +#define SET_FramebufferRenderbufferEXT(disp, fn) SET_by_offset(disp, _gloffset_FramebufferRenderbufferEXT, fn) +#define CALL_FramebufferTexture1DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), _gloffset_FramebufferTexture1DEXT, parameters) +#define GET_FramebufferTexture1DEXT(disp) GET_by_offset(disp, _gloffset_FramebufferTexture1DEXT) +#define SET_FramebufferTexture1DEXT(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTexture1DEXT, fn) +#define CALL_FramebufferTexture2DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), _gloffset_FramebufferTexture2DEXT, parameters) +#define GET_FramebufferTexture2DEXT(disp) GET_by_offset(disp, _gloffset_FramebufferTexture2DEXT) +#define SET_FramebufferTexture2DEXT(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTexture2DEXT, fn) +#define CALL_FramebufferTexture3DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLint)), _gloffset_FramebufferTexture3DEXT, parameters) +#define GET_FramebufferTexture3DEXT(disp) GET_by_offset(disp, _gloffset_FramebufferTexture3DEXT) +#define SET_FramebufferTexture3DEXT(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTexture3DEXT, fn) +#define CALL_GenFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenFramebuffersEXT, parameters) +#define GET_GenFramebuffersEXT(disp) GET_by_offset(disp, _gloffset_GenFramebuffersEXT) +#define SET_GenFramebuffersEXT(disp, fn) SET_by_offset(disp, _gloffset_GenFramebuffersEXT, fn) +#define CALL_GenRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), _gloffset_GenRenderbuffersEXT, parameters) +#define GET_GenRenderbuffersEXT(disp) GET_by_offset(disp, _gloffset_GenRenderbuffersEXT) +#define SET_GenRenderbuffersEXT(disp, fn) SET_by_offset(disp, _gloffset_GenRenderbuffersEXT, fn) +#define CALL_GenerateMipmapEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_GenerateMipmapEXT, parameters) +#define GET_GenerateMipmapEXT(disp) GET_by_offset(disp, _gloffset_GenerateMipmapEXT) +#define SET_GenerateMipmapEXT(disp, fn) SET_by_offset(disp, _gloffset_GenerateMipmapEXT, fn) +#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), _gloffset_GetFramebufferAttachmentParameterivEXT, parameters) +#define GET_GetFramebufferAttachmentParameterivEXT(disp) GET_by_offset(disp, _gloffset_GetFramebufferAttachmentParameterivEXT) +#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetFramebufferAttachmentParameterivEXT, fn) +#define CALL_GetRenderbufferParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetRenderbufferParameterivEXT, parameters) +#define GET_GetRenderbufferParameterivEXT(disp) GET_by_offset(disp, _gloffset_GetRenderbufferParameterivEXT) +#define SET_GetRenderbufferParameterivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetRenderbufferParameterivEXT, fn) +#define CALL_IsFramebufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsFramebufferEXT, parameters) +#define GET_IsFramebufferEXT(disp) GET_by_offset(disp, _gloffset_IsFramebufferEXT) +#define SET_IsFramebufferEXT(disp, fn) SET_by_offset(disp, _gloffset_IsFramebufferEXT, fn) +#define CALL_IsRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), _gloffset_IsRenderbufferEXT, parameters) +#define GET_IsRenderbufferEXT(disp) GET_by_offset(disp, _gloffset_IsRenderbufferEXT) +#define SET_IsRenderbufferEXT(disp, fn) SET_by_offset(disp, _gloffset_IsRenderbufferEXT, fn) +#define CALL_RenderbufferStorageEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei)), _gloffset_RenderbufferStorageEXT, parameters) +#define GET_RenderbufferStorageEXT(disp) GET_by_offset(disp, _gloffset_RenderbufferStorageEXT) +#define SET_RenderbufferStorageEXT(disp, fn) SET_by_offset(disp, _gloffset_RenderbufferStorageEXT, fn) +#define CALL_BlitFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum)), _gloffset_BlitFramebufferEXT, parameters) +#define GET_BlitFramebufferEXT(disp) GET_by_offset(disp, _gloffset_BlitFramebufferEXT) +#define SET_BlitFramebufferEXT(disp, fn) SET_by_offset(disp, _gloffset_BlitFramebufferEXT, fn) +#define CALL_BufferParameteriAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), _gloffset_BufferParameteriAPPLE, parameters) +#define GET_BufferParameteriAPPLE(disp) GET_by_offset(disp, _gloffset_BufferParameteriAPPLE) +#define SET_BufferParameteriAPPLE(disp, fn) SET_by_offset(disp, _gloffset_BufferParameteriAPPLE, fn) +#define CALL_FlushMappedBufferRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptr, GLsizeiptr)), _gloffset_FlushMappedBufferRangeAPPLE, parameters) +#define GET_FlushMappedBufferRangeAPPLE(disp) GET_by_offset(disp, _gloffset_FlushMappedBufferRangeAPPLE) +#define SET_FlushMappedBufferRangeAPPLE(disp, fn) SET_by_offset(disp, _gloffset_FlushMappedBufferRangeAPPLE, fn) +#define CALL_BindFragDataLocationEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, const GLchar *)), _gloffset_BindFragDataLocationEXT, parameters) +#define GET_BindFragDataLocationEXT(disp) GET_by_offset(disp, _gloffset_BindFragDataLocationEXT) +#define SET_BindFragDataLocationEXT(disp, fn) SET_by_offset(disp, _gloffset_BindFragDataLocationEXT, fn) +#define CALL_GetFragDataLocationEXT(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLuint, const GLchar *)), _gloffset_GetFragDataLocationEXT, parameters) +#define GET_GetFragDataLocationEXT(disp) GET_by_offset(disp, _gloffset_GetFragDataLocationEXT) +#define SET_GetFragDataLocationEXT(disp, fn) SET_by_offset(disp, _gloffset_GetFragDataLocationEXT, fn) +#define CALL_GetUniformuivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLuint *)), _gloffset_GetUniformuivEXT, parameters) +#define GET_GetUniformuivEXT(disp) GET_by_offset(disp, _gloffset_GetUniformuivEXT) +#define SET_GetUniformuivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetUniformuivEXT, fn) +#define CALL_GetVertexAttribIivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), _gloffset_GetVertexAttribIivEXT, parameters) +#define GET_GetVertexAttribIivEXT(disp) GET_by_offset(disp, _gloffset_GetVertexAttribIivEXT) +#define SET_GetVertexAttribIivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribIivEXT, fn) +#define CALL_GetVertexAttribIuivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint *)), _gloffset_GetVertexAttribIuivEXT, parameters) +#define GET_GetVertexAttribIuivEXT(disp) GET_by_offset(disp, _gloffset_GetVertexAttribIuivEXT) +#define SET_GetVertexAttribIuivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetVertexAttribIuivEXT, fn) +#define CALL_Uniform1uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLuint)), _gloffset_Uniform1uiEXT, parameters) +#define GET_Uniform1uiEXT(disp) GET_by_offset(disp, _gloffset_Uniform1uiEXT) +#define SET_Uniform1uiEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform1uiEXT, fn) +#define CALL_Uniform1uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLuint *)), _gloffset_Uniform1uivEXT, parameters) +#define GET_Uniform1uivEXT(disp) GET_by_offset(disp, _gloffset_Uniform1uivEXT) +#define SET_Uniform1uivEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform1uivEXT, fn) +#define CALL_Uniform2uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLuint, GLuint)), _gloffset_Uniform2uiEXT, parameters) +#define GET_Uniform2uiEXT(disp) GET_by_offset(disp, _gloffset_Uniform2uiEXT) +#define SET_Uniform2uiEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform2uiEXT, fn) +#define CALL_Uniform2uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLuint *)), _gloffset_Uniform2uivEXT, parameters) +#define GET_Uniform2uivEXT(disp) GET_by_offset(disp, _gloffset_Uniform2uivEXT) +#define SET_Uniform2uivEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform2uivEXT, fn) +#define CALL_Uniform3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLuint, GLuint, GLuint)), _gloffset_Uniform3uiEXT, parameters) +#define GET_Uniform3uiEXT(disp) GET_by_offset(disp, _gloffset_Uniform3uiEXT) +#define SET_Uniform3uiEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform3uiEXT, fn) +#define CALL_Uniform3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLuint *)), _gloffset_Uniform3uivEXT, parameters) +#define GET_Uniform3uivEXT(disp) GET_by_offset(disp, _gloffset_Uniform3uivEXT) +#define SET_Uniform3uivEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform3uivEXT, fn) +#define CALL_Uniform4uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLuint, GLuint, GLuint, GLuint)), _gloffset_Uniform4uiEXT, parameters) +#define GET_Uniform4uiEXT(disp) GET_by_offset(disp, _gloffset_Uniform4uiEXT) +#define SET_Uniform4uiEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform4uiEXT, fn) +#define CALL_Uniform4uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLuint *)), _gloffset_Uniform4uivEXT, parameters) +#define GET_Uniform4uivEXT(disp) GET_by_offset(disp, _gloffset_Uniform4uivEXT) +#define SET_Uniform4uivEXT(disp, fn) SET_by_offset(disp, _gloffset_Uniform4uivEXT, fn) +#define CALL_VertexAttribI1iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint)), _gloffset_VertexAttribI1iEXT, parameters) +#define GET_VertexAttribI1iEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI1iEXT) +#define SET_VertexAttribI1iEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI1iEXT, fn) +#define CALL_VertexAttribI1ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttribI1ivEXT, parameters) +#define GET_VertexAttribI1ivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI1ivEXT) +#define SET_VertexAttribI1ivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI1ivEXT, fn) +#define CALL_VertexAttribI1uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint)), _gloffset_VertexAttribI1uiEXT, parameters) +#define GET_VertexAttribI1uiEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI1uiEXT) +#define SET_VertexAttribI1uiEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI1uiEXT, fn) +#define CALL_VertexAttribI1uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttribI1uivEXT, parameters) +#define GET_VertexAttribI1uivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI1uivEXT) +#define SET_VertexAttribI1uivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI1uivEXT, fn) +#define CALL_VertexAttribI2iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLint)), _gloffset_VertexAttribI2iEXT, parameters) +#define GET_VertexAttribI2iEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI2iEXT) +#define SET_VertexAttribI2iEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI2iEXT, fn) +#define CALL_VertexAttribI2ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttribI2ivEXT, parameters) +#define GET_VertexAttribI2ivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI2ivEXT) +#define SET_VertexAttribI2ivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI2ivEXT, fn) +#define CALL_VertexAttribI2uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), _gloffset_VertexAttribI2uiEXT, parameters) +#define GET_VertexAttribI2uiEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI2uiEXT) +#define SET_VertexAttribI2uiEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI2uiEXT, fn) +#define CALL_VertexAttribI2uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttribI2uivEXT, parameters) +#define GET_VertexAttribI2uivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI2uivEXT) +#define SET_VertexAttribI2uivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI2uivEXT, fn) +#define CALL_VertexAttribI3iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLint, GLint)), _gloffset_VertexAttribI3iEXT, parameters) +#define GET_VertexAttribI3iEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI3iEXT) +#define SET_VertexAttribI3iEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI3iEXT, fn) +#define CALL_VertexAttribI3ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttribI3ivEXT, parameters) +#define GET_VertexAttribI3ivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI3ivEXT) +#define SET_VertexAttribI3ivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI3ivEXT, fn) +#define CALL_VertexAttribI3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint, GLuint)), _gloffset_VertexAttribI3uiEXT, parameters) +#define GET_VertexAttribI3uiEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI3uiEXT) +#define SET_VertexAttribI3uiEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI3uiEXT, fn) +#define CALL_VertexAttribI3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttribI3uivEXT, parameters) +#define GET_VertexAttribI3uivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI3uivEXT) +#define SET_VertexAttribI3uivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI3uivEXT, fn) +#define CALL_VertexAttribI4bvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), _gloffset_VertexAttribI4bvEXT, parameters) +#define GET_VertexAttribI4bvEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4bvEXT) +#define SET_VertexAttribI4bvEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4bvEXT, fn) +#define CALL_VertexAttribI4iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLint, GLint, GLint)), _gloffset_VertexAttribI4iEXT, parameters) +#define GET_VertexAttribI4iEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4iEXT) +#define SET_VertexAttribI4iEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4iEXT, fn) +#define CALL_VertexAttribI4ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), _gloffset_VertexAttribI4ivEXT, parameters) +#define GET_VertexAttribI4ivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4ivEXT) +#define SET_VertexAttribI4ivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4ivEXT, fn) +#define CALL_VertexAttribI4svEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), _gloffset_VertexAttribI4svEXT, parameters) +#define GET_VertexAttribI4svEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4svEXT) +#define SET_VertexAttribI4svEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4svEXT, fn) +#define CALL_VertexAttribI4ubvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), _gloffset_VertexAttribI4ubvEXT, parameters) +#define GET_VertexAttribI4ubvEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4ubvEXT) +#define SET_VertexAttribI4ubvEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4ubvEXT, fn) +#define CALL_VertexAttribI4uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint, GLuint, GLuint)), _gloffset_VertexAttribI4uiEXT, parameters) +#define GET_VertexAttribI4uiEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4uiEXT) +#define SET_VertexAttribI4uiEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4uiEXT, fn) +#define CALL_VertexAttribI4uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), _gloffset_VertexAttribI4uivEXT, parameters) +#define GET_VertexAttribI4uivEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4uivEXT) +#define SET_VertexAttribI4uivEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4uivEXT, fn) +#define CALL_VertexAttribI4usvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), _gloffset_VertexAttribI4usvEXT, parameters) +#define GET_VertexAttribI4usvEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribI4usvEXT) +#define SET_VertexAttribI4usvEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribI4usvEXT, fn) +#define CALL_VertexAttribIPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)), _gloffset_VertexAttribIPointerEXT, parameters) +#define GET_VertexAttribIPointerEXT(disp) GET_by_offset(disp, _gloffset_VertexAttribIPointerEXT) +#define SET_VertexAttribIPointerEXT(disp, fn) SET_by_offset(disp, _gloffset_VertexAttribIPointerEXT, fn) +#define CALL_FramebufferTextureLayerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint, GLint, GLint)), _gloffset_FramebufferTextureLayerEXT, parameters) +#define GET_FramebufferTextureLayerEXT(disp) GET_by_offset(disp, _gloffset_FramebufferTextureLayerEXT) +#define SET_FramebufferTextureLayerEXT(disp, fn) SET_by_offset(disp, _gloffset_FramebufferTextureLayerEXT, fn) +#define CALL_ColorMaskIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean)), _gloffset_ColorMaskIndexedEXT, parameters) +#define GET_ColorMaskIndexedEXT(disp) GET_by_offset(disp, _gloffset_ColorMaskIndexedEXT) +#define SET_ColorMaskIndexedEXT(disp, fn) SET_by_offset(disp, _gloffset_ColorMaskIndexedEXT, fn) +#define CALL_DisableIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_DisableIndexedEXT, parameters) +#define GET_DisableIndexedEXT(disp) GET_by_offset(disp, _gloffset_DisableIndexedEXT) +#define SET_DisableIndexedEXT(disp, fn) SET_by_offset(disp, _gloffset_DisableIndexedEXT, fn) +#define CALL_EnableIndexedEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_EnableIndexedEXT, parameters) +#define GET_EnableIndexedEXT(disp) GET_by_offset(disp, _gloffset_EnableIndexedEXT) +#define SET_EnableIndexedEXT(disp, fn) SET_by_offset(disp, _gloffset_EnableIndexedEXT, fn) +#define CALL_GetBooleanIndexedvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLboolean *)), _gloffset_GetBooleanIndexedvEXT, parameters) +#define GET_GetBooleanIndexedvEXT(disp) GET_by_offset(disp, _gloffset_GetBooleanIndexedvEXT) +#define SET_GetBooleanIndexedvEXT(disp, fn) SET_by_offset(disp, _gloffset_GetBooleanIndexedvEXT, fn) +#define CALL_GetIntegerIndexedvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLint *)), _gloffset_GetIntegerIndexedvEXT, parameters) +#define GET_GetIntegerIndexedvEXT(disp) GET_by_offset(disp, _gloffset_GetIntegerIndexedvEXT) +#define SET_GetIntegerIndexedvEXT(disp, fn) SET_by_offset(disp, _gloffset_GetIntegerIndexedvEXT, fn) +#define CALL_IsEnabledIndexedEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_IsEnabledIndexedEXT, parameters) +#define GET_IsEnabledIndexedEXT(disp) GET_by_offset(disp, _gloffset_IsEnabledIndexedEXT) +#define SET_IsEnabledIndexedEXT(disp, fn) SET_by_offset(disp, _gloffset_IsEnabledIndexedEXT, fn) +#define CALL_ClearColorIiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), _gloffset_ClearColorIiEXT, parameters) +#define GET_ClearColorIiEXT(disp) GET_by_offset(disp, _gloffset_ClearColorIiEXT) +#define SET_ClearColorIiEXT(disp, fn) SET_by_offset(disp, _gloffset_ClearColorIiEXT, fn) +#define CALL_ClearColorIuiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint, GLuint)), _gloffset_ClearColorIuiEXT, parameters) +#define GET_ClearColorIuiEXT(disp) GET_by_offset(disp, _gloffset_ClearColorIuiEXT) +#define SET_ClearColorIuiEXT(disp, fn) SET_by_offset(disp, _gloffset_ClearColorIuiEXT, fn) +#define CALL_GetTexParameterIivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), _gloffset_GetTexParameterIivEXT, parameters) +#define GET_GetTexParameterIivEXT(disp) GET_by_offset(disp, _gloffset_GetTexParameterIivEXT) +#define SET_GetTexParameterIivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetTexParameterIivEXT, fn) +#define CALL_GetTexParameterIuivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLuint *)), _gloffset_GetTexParameterIuivEXT, parameters) +#define GET_GetTexParameterIuivEXT(disp) GET_by_offset(disp, _gloffset_GetTexParameterIuivEXT) +#define SET_GetTexParameterIuivEXT(disp, fn) SET_by_offset(disp, _gloffset_GetTexParameterIuivEXT, fn) +#define CALL_TexParameterIivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), _gloffset_TexParameterIivEXT, parameters) +#define GET_TexParameterIivEXT(disp) GET_by_offset(disp, _gloffset_TexParameterIivEXT) +#define SET_TexParameterIivEXT(disp, fn) SET_by_offset(disp, _gloffset_TexParameterIivEXT, fn) +#define CALL_TexParameterIuivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLuint *)), _gloffset_TexParameterIuivEXT, parameters) +#define GET_TexParameterIuivEXT(disp) GET_by_offset(disp, _gloffset_TexParameterIuivEXT) +#define SET_TexParameterIuivEXT(disp, fn) SET_by_offset(disp, _gloffset_TexParameterIuivEXT, fn) +#define CALL_BeginConditionalRenderNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), _gloffset_BeginConditionalRenderNV, parameters) +#define GET_BeginConditionalRenderNV(disp) GET_by_offset(disp, _gloffset_BeginConditionalRenderNV) +#define SET_BeginConditionalRenderNV(disp, fn) SET_by_offset(disp, _gloffset_BeginConditionalRenderNV, fn) +#define CALL_EndConditionalRenderNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_EndConditionalRenderNV, parameters) +#define GET_EndConditionalRenderNV(disp) GET_by_offset(disp, _gloffset_EndConditionalRenderNV) +#define SET_EndConditionalRenderNV(disp, fn) SET_by_offset(disp, _gloffset_EndConditionalRenderNV, fn) +#define CALL_BeginTransformFeedbackEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_BeginTransformFeedbackEXT, parameters) +#define GET_BeginTransformFeedbackEXT(disp) GET_by_offset(disp, _gloffset_BeginTransformFeedbackEXT) +#define SET_BeginTransformFeedbackEXT(disp, fn) SET_by_offset(disp, _gloffset_BeginTransformFeedbackEXT, fn) +#define CALL_BindBufferBaseEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint)), _gloffset_BindBufferBaseEXT, parameters) +#define GET_BindBufferBaseEXT(disp) GET_by_offset(disp, _gloffset_BindBufferBaseEXT) +#define SET_BindBufferBaseEXT(disp, fn) SET_by_offset(disp, _gloffset_BindBufferBaseEXT, fn) +#define CALL_BindBufferOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLintptr)), _gloffset_BindBufferOffsetEXT, parameters) +#define GET_BindBufferOffsetEXT(disp) GET_by_offset(disp, _gloffset_BindBufferOffsetEXT) +#define SET_BindBufferOffsetEXT(disp, fn) SET_by_offset(disp, _gloffset_BindBufferOffsetEXT, fn) +#define CALL_BindBufferRangeEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr)), _gloffset_BindBufferRangeEXT, parameters) +#define GET_BindBufferRangeEXT(disp) GET_by_offset(disp, _gloffset_BindBufferRangeEXT) +#define SET_BindBufferRangeEXT(disp, fn) SET_by_offset(disp, _gloffset_BindBufferRangeEXT, fn) +#define CALL_EndTransformFeedbackEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), _gloffset_EndTransformFeedbackEXT, parameters) +#define GET_EndTransformFeedbackEXT(disp) GET_by_offset(disp, _gloffset_EndTransformFeedbackEXT) +#define SET_EndTransformFeedbackEXT(disp, fn) SET_by_offset(disp, _gloffset_EndTransformFeedbackEXT, fn) +#define CALL_GetTransformFeedbackVaryingEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *)), _gloffset_GetTransformFeedbackVaryingEXT, parameters) +#define GET_GetTransformFeedbackVaryingEXT(disp) GET_by_offset(disp, _gloffset_GetTransformFeedbackVaryingEXT) +#define SET_GetTransformFeedbackVaryingEXT(disp, fn) SET_by_offset(disp, _gloffset_GetTransformFeedbackVaryingEXT, fn) +#define CALL_TransformFeedbackVaryingsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const char **, GLenum)), _gloffset_TransformFeedbackVaryingsEXT, parameters) +#define GET_TransformFeedbackVaryingsEXT(disp) GET_by_offset(disp, _gloffset_TransformFeedbackVaryingsEXT) +#define SET_TransformFeedbackVaryingsEXT(disp, fn) SET_by_offset(disp, _gloffset_TransformFeedbackVaryingsEXT, fn) +#define CALL_ProvokingVertexEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), _gloffset_ProvokingVertexEXT, parameters) +#define GET_ProvokingVertexEXT(disp) GET_by_offset(disp, _gloffset_ProvokingVertexEXT) +#define SET_ProvokingVertexEXT(disp, fn) SET_by_offset(disp, _gloffset_ProvokingVertexEXT, fn) +#define CALL_GetTexParameterPointervAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), _gloffset_GetTexParameterPointervAPPLE, parameters) +#define GET_GetTexParameterPointervAPPLE(disp) GET_by_offset(disp, _gloffset_GetTexParameterPointervAPPLE) +#define SET_GetTexParameterPointervAPPLE(disp, fn) SET_by_offset(disp, _gloffset_GetTexParameterPointervAPPLE, fn) +#define CALL_TextureRangeAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLvoid *)), _gloffset_TextureRangeAPPLE, parameters) +#define GET_TextureRangeAPPLE(disp) GET_by_offset(disp, _gloffset_TextureRangeAPPLE) +#define SET_TextureRangeAPPLE(disp, fn) SET_by_offset(disp, _gloffset_TextureRangeAPPLE, fn) +#define CALL_GetObjectParameterivAPPLE(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLint *)), _gloffset_GetObjectParameterivAPPLE, parameters) +#define GET_GetObjectParameterivAPPLE(disp) GET_by_offset(disp, _gloffset_GetObjectParameterivAPPLE) +#define SET_GetObjectParameterivAPPLE(disp, fn) SET_by_offset(disp, _gloffset_GetObjectParameterivAPPLE, fn) +#define CALL_ObjectPurgeableAPPLE(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum, GLuint, GLenum)), _gloffset_ObjectPurgeableAPPLE, parameters) +#define GET_ObjectPurgeableAPPLE(disp) GET_by_offset(disp, _gloffset_ObjectPurgeableAPPLE) +#define SET_ObjectPurgeableAPPLE(disp, fn) SET_by_offset(disp, _gloffset_ObjectPurgeableAPPLE, fn) +#define CALL_ObjectUnpurgeableAPPLE(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum, GLuint, GLenum)), _gloffset_ObjectUnpurgeableAPPLE, parameters) +#define GET_ObjectUnpurgeableAPPLE(disp) GET_by_offset(disp, _gloffset_ObjectUnpurgeableAPPLE) +#define SET_ObjectUnpurgeableAPPLE(disp, fn) SET_by_offset(disp, _gloffset_ObjectUnpurgeableAPPLE, fn) +#define CALL_ActiveProgramEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), _gloffset_ActiveProgramEXT, parameters) +#define GET_ActiveProgramEXT(disp) GET_by_offset(disp, _gloffset_ActiveProgramEXT) +#define SET_ActiveProgramEXT(disp, fn) SET_by_offset(disp, _gloffset_ActiveProgramEXT, fn) +#define CALL_CreateShaderProgramEXT(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLenum, const GLchar *)), _gloffset_CreateShaderProgramEXT, parameters) +#define GET_CreateShaderProgramEXT(disp) GET_by_offset(disp, _gloffset_CreateShaderProgramEXT) +#define SET_CreateShaderProgramEXT(disp, fn) SET_by_offset(disp, _gloffset_CreateShaderProgramEXT, fn) +#define CALL_UseShaderProgramEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), _gloffset_UseShaderProgramEXT, parameters) +#define GET_UseShaderProgramEXT(disp) GET_by_offset(disp, _gloffset_UseShaderProgramEXT) +#define SET_UseShaderProgramEXT(disp, fn) SET_by_offset(disp, _gloffset_UseShaderProgramEXT, fn) +#define CALL_StencilFuncSeparateATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), _gloffset_StencilFuncSeparateATI, parameters) +#define GET_StencilFuncSeparateATI(disp) GET_by_offset(disp, _gloffset_StencilFuncSeparateATI) +#define SET_StencilFuncSeparateATI(disp, fn) SET_by_offset(disp, _gloffset_StencilFuncSeparateATI, fn) +#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), _gloffset_ProgramEnvParameters4fvEXT, parameters) +#define GET_ProgramEnvParameters4fvEXT(disp) GET_by_offset(disp, _gloffset_ProgramEnvParameters4fvEXT) +#define SET_ProgramEnvParameters4fvEXT(disp, fn) SET_by_offset(disp, _gloffset_ProgramEnvParameters4fvEXT, fn) +#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLfloat *)), _gloffset_ProgramLocalParameters4fvEXT, parameters) +#define GET_ProgramLocalParameters4fvEXT(disp) GET_by_offset(disp, _gloffset_ProgramLocalParameters4fvEXT) +#define SET_ProgramLocalParameters4fvEXT(disp, fn) SET_by_offset(disp, _gloffset_ProgramLocalParameters4fvEXT, fn) +#define CALL_GetQueryObjecti64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint64EXT *)), _gloffset_GetQueryObjecti64vEXT, parameters) +#define GET_GetQueryObjecti64vEXT(disp) GET_by_offset(disp, _gloffset_GetQueryObjecti64vEXT) +#define SET_GetQueryObjecti64vEXT(disp, fn) SET_by_offset(disp, _gloffset_GetQueryObjecti64vEXT, fn) +#define CALL_GetQueryObjectui64vEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint64EXT *)), _gloffset_GetQueryObjectui64vEXT, parameters) +#define GET_GetQueryObjectui64vEXT(disp) GET_by_offset(disp, _gloffset_GetQueryObjectui64vEXT) +#define SET_GetQueryObjectui64vEXT(disp, fn) SET_by_offset(disp, _gloffset_GetQueryObjectui64vEXT, fn) +#define CALL_EGLImageTargetRenderbufferStorageOES(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLvoid *)), _gloffset_EGLImageTargetRenderbufferStorageOES, parameters) +#define GET_EGLImageTargetRenderbufferStorageOES(disp) GET_by_offset(disp, _gloffset_EGLImageTargetRenderbufferStorageOES) +#define SET_EGLImageTargetRenderbufferStorageOES(disp, fn) SET_by_offset(disp, _gloffset_EGLImageTargetRenderbufferStorageOES, fn) +#define CALL_EGLImageTargetTexture2DOES(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLvoid *)), _gloffset_EGLImageTargetTexture2DOES, parameters) +#define GET_EGLImageTargetTexture2DOES(disp) GET_by_offset(disp, _gloffset_EGLImageTargetTexture2DOES) +#define SET_EGLImageTargetTexture2DOES(disp, fn) SET_by_offset(disp, _gloffset_EGLImageTargetTexture2DOES, fn) + +#endif /* !defined( _GLAPI_DISPATCH_H_ ) */ diff --git a/mesalib/src/mesa/main/glheader.h b/mesalib/src/mesa/main/glheader.h index 45f7b55ad..5ca44deb0 100644 --- a/mesalib/src/mesa/main/glheader.h +++ b/mesalib/src/mesa/main/glheader.h @@ -1,145 +1,163 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file glheader.h - * Wrapper for GL/gl.h and GL/glext.h - */ - - -#ifndef GLHEADER_H -#define GLHEADER_H - - -#ifdef WGLAPI -#undef WGLAPI -#endif - - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define WGLAPI __declspec(dllexport) -# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define WGLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define WGLAPI __declspec(dllimport) -# endif /* _STATIC_MESA support */ -#endif /* WIN32 / CYGWIN bracket */ - - -#define GL_GLEXT_PROTOTYPES -#include "GL/gl.h" -#include "GL/glext.h" -#include "GL/internal/glcore.h" - - -/** - * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). - */ -typedef int GLfixed; -typedef int GLclampx; - - -#ifndef GL_OES_EGL_image -typedef void *GLeglImageOES; -#endif - - -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - - -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif - - -#ifndef GL_PROGRAM_BINARY_LENGTH_OES -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#endif - -/* GLES 2.0 tokens */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif - -#ifndef GL_TEXTURE_GEN_STR_OES -#define GL_TEXTURE_GEN_STR_OES 0x8D60 -#endif - -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -#ifndef GL_OES_matrix_get -#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#endif - -#ifndef GL_ES_VERSION_2_0 -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - - - -/** - * Internal token to represent a GLSL shader program (a collection of - * one or more shaders that get linked together). Note that GLSL - * shaders and shader programs share one name space (one hash table) - * so we need a value that's different from any of the - * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. - */ -#define GL_SHADER_PROGRAM_MESA 0x9999 - - -/** - * Internal token for geometry programs. - * Use the value for GL_GEOMETRY_PROGRAM_NV for now. - */ -#define MESA_GEOMETRY_PROGRAM 0x8c26 - - - -#endif /* GLHEADER_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file glheader.h + * Wrapper for GL/gl.h and GL/glext.h + */ + + +#ifndef GLHEADER_H +#define GLHEADER_H + + +#ifdef WGLAPI +#undef WGLAPI +#endif + + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define WGLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define WGLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define WGLAPI __declspec(dllimport) +# endif /* _STATIC_MESA support */ +#endif /* WIN32 / CYGWIN bracket */ + + +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "GL/glext.h" + + +/** + * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). + */ +typedef int GLfixed; +typedef int GLclampx; + + +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif + + +#ifndef GL_OES_point_size_array +#define GL_POINT_SIZE_ARRAY_OES 0x8B9C +#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A +#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B +#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C +#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F +#endif + + +#ifndef GL_OES_draw_texture +#define GL_TEXTURE_CROP_RECT_OES 0x8B9D +#endif + + +#ifndef GL_PROGRAM_BINARY_LENGTH_OES +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#endif + +/* GLES 2.0 tokens */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_TEXTURE_GEN_STR_OES +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +#ifndef GL_ES_VERSION_2_0 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + + + +/** + * Internal token to represent a GLSL shader program (a collection of + * one or more shaders that get linked together). Note that GLSL + * shaders and shader programs share one name space (one hash table) + * so we need a value that's different from any of the + * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. + */ +#define GL_SHADER_PROGRAM_MESA 0x9999 + + +/** + * Internal token for geometry programs. + * Use the value for GL_GEOMETRY_PROGRAM_NV for now. + */ +#define MESA_GEOMETRY_PROGRAM 0x8c26 + +/* Several fields of struct gl_config can take these as values. Since + * GLX header files may not be available everywhere they need to be used, + * redefine them here. + */ +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 + +#define GLX_DONT_CARE 0xFFFFFFFF + +#endif /* GLHEADER_H */ diff --git a/mesalib/src/mesa/main/hash.c b/mesalib/src/mesa/main/hash.c index b624e6eca..63f5c90fa 100644 --- a/mesalib/src/mesa/main/hash.c +++ b/mesalib/src/mesa/main/hash.c @@ -1,547 +1,547 @@ -/** - * \file hash.c - * Generic hash table. - * - * Used for display lists, texture objects, vertex/fragment programs, - * buffer objects, etc. The hash functions are thread-safe. - * - * \note key=0 is illegal. - * - * \author Brian Paul - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "glapi/glthread.h" -#include "hash.h" - - -#define TABLE_SIZE 1023 /**< Size of lookup table/array */ - -#define HASH_FUNC(K) ((K) % TABLE_SIZE) - - -/** - * An entry in the hash table. - */ -struct HashEntry { - GLuint Key; /**< the entry's key */ - void *Data; /**< the entry's data */ - struct HashEntry *Next; /**< pointer to next entry */ -}; - - -/** - * The hash table data structure. - */ -struct _mesa_HashTable { - struct HashEntry *Table[TABLE_SIZE]; /**< the lookup table */ - GLuint MaxKey; /**< highest key inserted so far */ - _glthread_Mutex Mutex; /**< mutual exclusion lock */ - _glthread_Mutex WalkMutex; /**< for _mesa_HashWalk() */ - GLboolean InDeleteAll; /**< Debug check */ -}; - - - -/** - * Create a new hash table. - * - * \return pointer to a new, empty hash table. - */ -struct _mesa_HashTable * -_mesa_NewHashTable(void) -{ - struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable); - if (table) { - _glthread_INIT_MUTEX(table->Mutex); - _glthread_INIT_MUTEX(table->WalkMutex); - } - return table; -} - - - -/** - * Delete a hash table. - * Frees each entry on the hash table and then the hash table structure itself. - * Note that the caller should have already traversed the table and deleted - * the objects in the table (i.e. We don't free the entries' data pointer). - * - * \param table the hash table to delete. - */ -void -_mesa_DeleteHashTable(struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry = table->Table[pos]; - while (entry) { - struct HashEntry *next = entry->Next; - if (entry->Data) { - _mesa_problem(NULL, - "In _mesa_DeleteHashTable, found non-freed data"); - } - free(entry); - entry = next; - } - } - _glthread_DESTROY_MUTEX(table->Mutex); - _glthread_DESTROY_MUTEX(table->WalkMutex); - free(table); -} - - - -/** - * Lookup an entry in the hash table, without locking. - * \sa _mesa_HashLookup - */ -static INLINE void * -_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) -{ - GLuint pos; - const struct HashEntry *entry; - - assert(table); - assert(key); - - pos = HASH_FUNC(key); - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - return entry->Data; - } - entry = entry->Next; - } - return NULL; -} - - -/** - * Lookup an entry in the hash table. - * - * \param table the hash table. - * \param key the key. - * - * \return pointer to user's data or NULL if key not in table - */ -void * -_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) -{ - void *res; - assert(table); - _glthread_LOCK_MUTEX(table->Mutex); - res = _mesa_HashLookup_unlocked(table, key); - _glthread_UNLOCK_MUTEX(table->Mutex); - return res; -} - - -/** - * Insert a key/pointer pair into the hash table. - * If an entry with this key already exists we'll replace the existing entry. - * - * \param table the hash table. - * \param key the key (not zero). - * \param data pointer to user data. - */ -void -_mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) -{ - /* search for existing entry with this key */ - GLuint pos; - struct HashEntry *entry; - - assert(table); - assert(key); - - _glthread_LOCK_MUTEX(table->Mutex); - - if (key > table->MaxKey) - table->MaxKey = key; - - pos = HASH_FUNC(key); - - /* check if replacing an existing entry with same key */ - for (entry = table->Table[pos]; entry; entry = entry->Next) { - if (entry->Key == key) { - /* replace entry's data */ -#if 0 /* not sure this check is always valid */ - if (entry->Data) { - _mesa_problem(NULL, "Memory leak detected in _mesa_HashInsert"); - } -#endif - entry->Data = data; - _glthread_UNLOCK_MUTEX(table->Mutex); - return; - } - } - - /* alloc and insert new table entry */ - entry = MALLOC_STRUCT(HashEntry); - if (entry) { - entry->Key = key; - entry->Data = data; - entry->Next = table->Table[pos]; - table->Table[pos] = entry; - } - - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - - -/** - * Remove an entry from the hash table. - * - * \param table the hash table. - * \param key key of entry to remove. - * - * While holding the hash table's lock, searches the entry with the matching - * key and unlinks it. - */ -void -_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) -{ - GLuint pos; - struct HashEntry *entry, *prev; - - assert(table); - assert(key); - - /* have to check this outside of mutex lock */ - if (table->InDeleteAll) { - _mesa_problem(NULL, "_mesa_HashRemove illegally called from " - "_mesa_HashDeleteAll callback function"); - return; - } - - _glthread_LOCK_MUTEX(table->Mutex); - - pos = HASH_FUNC(key); - prev = NULL; - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - /* found it! */ - if (prev) { - prev->Next = entry->Next; - } - else { - table->Table[pos] = entry->Next; - } - free(entry); - _glthread_UNLOCK_MUTEX(table->Mutex); - return; - } - prev = entry; - entry = entry->Next; - } - - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - - -/** - * Delete all entries in a hash table, but don't delete the table itself. - * Invoke the given callback function for each table entry. - * - * \param table the hash table to delete - * \param callback the callback function - * \param userData arbitrary pointer to pass along to the callback - * (this is typically a GLcontext pointer) - */ -void -_mesa_HashDeleteAll(struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData) -{ - GLuint pos; - ASSERT(table); - ASSERT(callback); - _glthread_LOCK_MUTEX(table->Mutex); - table->InDeleteAll = GL_TRUE; - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry, *next; - for (entry = table->Table[pos]; entry; entry = next) { - callback(entry->Key, entry->Data, userData); - next = entry->Next; - free(entry); - } - table->Table[pos] = NULL; - } - table->InDeleteAll = GL_FALSE; - _glthread_UNLOCK_MUTEX(table->Mutex); -} - - -/** - * Walk over all entries in a hash table, calling callback function for each. - * Note: we use a separate mutex in this function to avoid a recursive - * locking deadlock (in case the callback calls _mesa_HashRemove()) and to - * prevent multiple threads/contexts from getting tangled up. - * A lock-less version of this function could be used when the table will - * not be modified. - * \param table the hash table to walk - * \param callback the callback function - * \param userData arbitrary pointer to pass along to the callback - * (this is typically a GLcontext pointer) - */ -void -_mesa_HashWalk(const struct _mesa_HashTable *table, - void (*callback)(GLuint key, void *data, void *userData), - void *userData) -{ - /* cast-away const */ - struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; - GLuint pos; - ASSERT(table); - ASSERT(callback); - _glthread_LOCK_MUTEX(table2->WalkMutex); - for (pos = 0; pos < TABLE_SIZE; pos++) { - struct HashEntry *entry, *next; - for (entry = table->Table[pos]; entry; entry = next) { - /* save 'next' pointer now in case the callback deletes the entry */ - next = entry->Next; - callback(entry->Key, entry->Data, userData); - } - } - _glthread_UNLOCK_MUTEX(table2->WalkMutex); -} - - -/** - * Return the key of the "first" entry in the hash table. - * While holding the lock, walks through all table positions until finding - * the first entry of the first non-empty one. - * - * \param table the hash table - * \return key for the "first" entry in the hash table. - */ -GLuint -_mesa_HashFirstEntry(struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - _glthread_LOCK_MUTEX(table->Mutex); - for (pos = 0; pos < TABLE_SIZE; pos++) { - if (table->Table[pos]) { - _glthread_UNLOCK_MUTEX(table->Mutex); - return table->Table[pos]->Key; - } - } - _glthread_UNLOCK_MUTEX(table->Mutex); - return 0; -} - - -/** - * Given a hash table key, return the next key. This is used to walk - * over all entries in the table. Note that the keys returned during - * walking won't be in any particular order. - * \return next hash key or 0 if end of table. - */ -GLuint -_mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key) -{ - const struct HashEntry *entry; - GLuint pos; - - assert(table); - assert(key); - - /* Find the entry with given key */ - pos = HASH_FUNC(key); - for (entry = table->Table[pos]; entry ; entry = entry->Next) { - if (entry->Key == key) { - break; - } - } - - if (!entry) { - /* the given key was not found, so we can't find the next entry */ - return 0; - } - - if (entry->Next) { - /* return next in linked list */ - return entry->Next->Key; - } - else { - /* look for next non-empty table slot */ - pos++; - while (pos < TABLE_SIZE) { - if (table->Table[pos]) { - return table->Table[pos]->Key; - } - pos++; - } - return 0; - } -} - - -/** - * Dump contents of hash table for debugging. - * - * \param table the hash table. - */ -void -_mesa_HashPrint(const struct _mesa_HashTable *table) -{ - GLuint pos; - assert(table); - for (pos = 0; pos < TABLE_SIZE; pos++) { - const struct HashEntry *entry = table->Table[pos]; - while (entry) { - _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data); - entry = entry->Next; - } - } -} - - - -/** - * Find a block of adjacent unused hash keys. - * - * \param table the hash table. - * \param numKeys number of keys needed. - * - * \return Starting key of free block or 0 if failure. - * - * If there are enough free keys between the maximum key existing in the table - * (_mesa_HashTable::MaxKey) and the maximum key possible, then simply return - * the adjacent key. Otherwise do a full search for a free key block in the - * allowable key range. - */ -GLuint -_mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) -{ - const GLuint maxKey = ~((GLuint) 0); - _glthread_LOCK_MUTEX(table->Mutex); - if (maxKey - numKeys > table->MaxKey) { - /* the quick solution */ - _glthread_UNLOCK_MUTEX(table->Mutex); - return table->MaxKey + 1; - } - else { - /* the slow solution */ - GLuint freeCount = 0; - GLuint freeStart = 1; - GLuint key; - for (key = 1; key != maxKey; key++) { - if (_mesa_HashLookup_unlocked(table, key)) { - /* darn, this key is already in use */ - freeCount = 0; - freeStart = key+1; - } - else { - /* this key not in use, check if we've found enough */ - freeCount++; - if (freeCount == numKeys) { - _glthread_UNLOCK_MUTEX(table->Mutex); - return freeStart; - } - } - } - /* cannot allocate a block of numKeys consecutive keys */ - _glthread_UNLOCK_MUTEX(table->Mutex); - return 0; - } -} - - -#if 0 /* debug only */ - -/** - * Test walking over all the entries in a hash table. - */ -static void -test_hash_walking(void) -{ - struct _mesa_HashTable *t = _mesa_NewHashTable(); - const GLuint limit = 50000; - GLuint i; - - /* create some entries */ - for (i = 0; i < limit; i++) { - GLuint dummy; - GLuint k = (rand() % (limit * 10)) + 1; - while (_mesa_HashLookup(t, k)) { - /* id already in use, try another */ - k = (rand() % (limit * 10)) + 1; - } - _mesa_HashInsert(t, k, &dummy); - } - - /* walk over all entries */ - { - GLuint k = _mesa_HashFirstEntry(t); - GLuint count = 0; - while (k) { - GLuint knext = _mesa_HashNextEntry(t, k); - assert(knext != k); - _mesa_HashRemove(t, k); - count++; - k = knext; - } - assert(count == limit); - k = _mesa_HashFirstEntry(t); - assert(k==0); - } - - _mesa_DeleteHashTable(t); -} - - -void -_mesa_test_hash_functions(void) -{ - int a, b, c; - struct _mesa_HashTable *t; - - t = _mesa_NewHashTable(); - _mesa_HashInsert(t, 501, &a); - _mesa_HashInsert(t, 10, &c); - _mesa_HashInsert(t, 0xfffffff8, &b); - /*_mesa_HashPrint(t);*/ - - assert(_mesa_HashLookup(t,501)); - assert(!_mesa_HashLookup(t,1313)); - assert(_mesa_HashFindFreeKeyBlock(t, 100)); - - _mesa_DeleteHashTable(t); - - test_hash_walking(); -} - -#endif +/** + * \file hash.c + * Generic hash table. + * + * Used for display lists, texture objects, vertex/fragment programs, + * buffer objects, etc. The hash functions are thread-safe. + * + * \note key=0 is illegal. + * + * \author Brian Paul + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "glapi/glthread.h" +#include "hash.h" + + +#define TABLE_SIZE 1023 /**< Size of lookup table/array */ + +#define HASH_FUNC(K) ((K) % TABLE_SIZE) + + +/** + * An entry in the hash table. + */ +struct HashEntry { + GLuint Key; /**< the entry's key */ + void *Data; /**< the entry's data */ + struct HashEntry *Next; /**< pointer to next entry */ +}; + + +/** + * The hash table data structure. + */ +struct _mesa_HashTable { + struct HashEntry *Table[TABLE_SIZE]; /**< the lookup table */ + GLuint MaxKey; /**< highest key inserted so far */ + _glthread_Mutex Mutex; /**< mutual exclusion lock */ + _glthread_Mutex WalkMutex; /**< for _mesa_HashWalk() */ + GLboolean InDeleteAll; /**< Debug check */ +}; + + + +/** + * Create a new hash table. + * + * \return pointer to a new, empty hash table. + */ +struct _mesa_HashTable * +_mesa_NewHashTable(void) +{ + struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable); + if (table) { + _glthread_INIT_MUTEX(table->Mutex); + _glthread_INIT_MUTEX(table->WalkMutex); + } + return table; +} + + + +/** + * Delete a hash table. + * Frees each entry on the hash table and then the hash table structure itself. + * Note that the caller should have already traversed the table and deleted + * the objects in the table (i.e. We don't free the entries' data pointer). + * + * \param table the hash table to delete. + */ +void +_mesa_DeleteHashTable(struct _mesa_HashTable *table) +{ + GLuint pos; + assert(table); + for (pos = 0; pos < TABLE_SIZE; pos++) { + struct HashEntry *entry = table->Table[pos]; + while (entry) { + struct HashEntry *next = entry->Next; + if (entry->Data) { + _mesa_problem(NULL, + "In _mesa_DeleteHashTable, found non-freed data"); + } + free(entry); + entry = next; + } + } + _glthread_DESTROY_MUTEX(table->Mutex); + _glthread_DESTROY_MUTEX(table->WalkMutex); + free(table); +} + + + +/** + * Lookup an entry in the hash table, without locking. + * \sa _mesa_HashLookup + */ +static INLINE void * +_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key) +{ + GLuint pos; + const struct HashEntry *entry; + + assert(table); + assert(key); + + pos = HASH_FUNC(key); + entry = table->Table[pos]; + while (entry) { + if (entry->Key == key) { + return entry->Data; + } + entry = entry->Next; + } + return NULL; +} + + +/** + * Lookup an entry in the hash table. + * + * \param table the hash table. + * \param key the key. + * + * \return pointer to user's data or NULL if key not in table + */ +void * +_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key) +{ + void *res; + assert(table); + _glthread_LOCK_MUTEX(table->Mutex); + res = _mesa_HashLookup_unlocked(table, key); + _glthread_UNLOCK_MUTEX(table->Mutex); + return res; +} + + +/** + * Insert a key/pointer pair into the hash table. + * If an entry with this key already exists we'll replace the existing entry. + * + * \param table the hash table. + * \param key the key (not zero). + * \param data pointer to user data. + */ +void +_mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data) +{ + /* search for existing entry with this key */ + GLuint pos; + struct HashEntry *entry; + + assert(table); + assert(key); + + _glthread_LOCK_MUTEX(table->Mutex); + + if (key > table->MaxKey) + table->MaxKey = key; + + pos = HASH_FUNC(key); + + /* check if replacing an existing entry with same key */ + for (entry = table->Table[pos]; entry; entry = entry->Next) { + if (entry->Key == key) { + /* replace entry's data */ +#if 0 /* not sure this check is always valid */ + if (entry->Data) { + _mesa_problem(NULL, "Memory leak detected in _mesa_HashInsert"); + } +#endif + entry->Data = data; + _glthread_UNLOCK_MUTEX(table->Mutex); + return; + } + } + + /* alloc and insert new table entry */ + entry = MALLOC_STRUCT(HashEntry); + if (entry) { + entry->Key = key; + entry->Data = data; + entry->Next = table->Table[pos]; + table->Table[pos] = entry; + } + + _glthread_UNLOCK_MUTEX(table->Mutex); +} + + + +/** + * Remove an entry from the hash table. + * + * \param table the hash table. + * \param key key of entry to remove. + * + * While holding the hash table's lock, searches the entry with the matching + * key and unlinks it. + */ +void +_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) +{ + GLuint pos; + struct HashEntry *entry, *prev; + + assert(table); + assert(key); + + /* have to check this outside of mutex lock */ + if (table->InDeleteAll) { + _mesa_problem(NULL, "_mesa_HashRemove illegally called from " + "_mesa_HashDeleteAll callback function"); + return; + } + + _glthread_LOCK_MUTEX(table->Mutex); + + pos = HASH_FUNC(key); + prev = NULL; + entry = table->Table[pos]; + while (entry) { + if (entry->Key == key) { + /* found it! */ + if (prev) { + prev->Next = entry->Next; + } + else { + table->Table[pos] = entry->Next; + } + free(entry); + _glthread_UNLOCK_MUTEX(table->Mutex); + return; + } + prev = entry; + entry = entry->Next; + } + + _glthread_UNLOCK_MUTEX(table->Mutex); +} + + + +/** + * Delete all entries in a hash table, but don't delete the table itself. + * Invoke the given callback function for each table entry. + * + * \param table the hash table to delete + * \param callback the callback function + * \param userData arbitrary pointer to pass along to the callback + * (this is typically a struct gl_context pointer) + */ +void +_mesa_HashDeleteAll(struct _mesa_HashTable *table, + void (*callback)(GLuint key, void *data, void *userData), + void *userData) +{ + GLuint pos; + ASSERT(table); + ASSERT(callback); + _glthread_LOCK_MUTEX(table->Mutex); + table->InDeleteAll = GL_TRUE; + for (pos = 0; pos < TABLE_SIZE; pos++) { + struct HashEntry *entry, *next; + for (entry = table->Table[pos]; entry; entry = next) { + callback(entry->Key, entry->Data, userData); + next = entry->Next; + free(entry); + } + table->Table[pos] = NULL; + } + table->InDeleteAll = GL_FALSE; + _glthread_UNLOCK_MUTEX(table->Mutex); +} + + +/** + * Walk over all entries in a hash table, calling callback function for each. + * Note: we use a separate mutex in this function to avoid a recursive + * locking deadlock (in case the callback calls _mesa_HashRemove()) and to + * prevent multiple threads/contexts from getting tangled up. + * A lock-less version of this function could be used when the table will + * not be modified. + * \param table the hash table to walk + * \param callback the callback function + * \param userData arbitrary pointer to pass along to the callback + * (this is typically a struct gl_context pointer) + */ +void +_mesa_HashWalk(const struct _mesa_HashTable *table, + void (*callback)(GLuint key, void *data, void *userData), + void *userData) +{ + /* cast-away const */ + struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; + GLuint pos; + ASSERT(table); + ASSERT(callback); + _glthread_LOCK_MUTEX(table2->WalkMutex); + for (pos = 0; pos < TABLE_SIZE; pos++) { + struct HashEntry *entry, *next; + for (entry = table->Table[pos]; entry; entry = next) { + /* save 'next' pointer now in case the callback deletes the entry */ + next = entry->Next; + callback(entry->Key, entry->Data, userData); + } + } + _glthread_UNLOCK_MUTEX(table2->WalkMutex); +} + + +/** + * Return the key of the "first" entry in the hash table. + * While holding the lock, walks through all table positions until finding + * the first entry of the first non-empty one. + * + * \param table the hash table + * \return key for the "first" entry in the hash table. + */ +GLuint +_mesa_HashFirstEntry(struct _mesa_HashTable *table) +{ + GLuint pos; + assert(table); + _glthread_LOCK_MUTEX(table->Mutex); + for (pos = 0; pos < TABLE_SIZE; pos++) { + if (table->Table[pos]) { + _glthread_UNLOCK_MUTEX(table->Mutex); + return table->Table[pos]->Key; + } + } + _glthread_UNLOCK_MUTEX(table->Mutex); + return 0; +} + + +/** + * Given a hash table key, return the next key. This is used to walk + * over all entries in the table. Note that the keys returned during + * walking won't be in any particular order. + * \return next hash key or 0 if end of table. + */ +GLuint +_mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key) +{ + const struct HashEntry *entry; + GLuint pos; + + assert(table); + assert(key); + + /* Find the entry with given key */ + pos = HASH_FUNC(key); + for (entry = table->Table[pos]; entry ; entry = entry->Next) { + if (entry->Key == key) { + break; + } + } + + if (!entry) { + /* the given key was not found, so we can't find the next entry */ + return 0; + } + + if (entry->Next) { + /* return next in linked list */ + return entry->Next->Key; + } + else { + /* look for next non-empty table slot */ + pos++; + while (pos < TABLE_SIZE) { + if (table->Table[pos]) { + return table->Table[pos]->Key; + } + pos++; + } + return 0; + } +} + + +/** + * Dump contents of hash table for debugging. + * + * \param table the hash table. + */ +void +_mesa_HashPrint(const struct _mesa_HashTable *table) +{ + GLuint pos; + assert(table); + for (pos = 0; pos < TABLE_SIZE; pos++) { + const struct HashEntry *entry = table->Table[pos]; + while (entry) { + _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data); + entry = entry->Next; + } + } +} + + + +/** + * Find a block of adjacent unused hash keys. + * + * \param table the hash table. + * \param numKeys number of keys needed. + * + * \return Starting key of free block or 0 if failure. + * + * If there are enough free keys between the maximum key existing in the table + * (_mesa_HashTable::MaxKey) and the maximum key possible, then simply return + * the adjacent key. Otherwise do a full search for a free key block in the + * allowable key range. + */ +GLuint +_mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys) +{ + const GLuint maxKey = ~((GLuint) 0); + _glthread_LOCK_MUTEX(table->Mutex); + if (maxKey - numKeys > table->MaxKey) { + /* the quick solution */ + _glthread_UNLOCK_MUTEX(table->Mutex); + return table->MaxKey + 1; + } + else { + /* the slow solution */ + GLuint freeCount = 0; + GLuint freeStart = 1; + GLuint key; + for (key = 1; key != maxKey; key++) { + if (_mesa_HashLookup_unlocked(table, key)) { + /* darn, this key is already in use */ + freeCount = 0; + freeStart = key+1; + } + else { + /* this key not in use, check if we've found enough */ + freeCount++; + if (freeCount == numKeys) { + _glthread_UNLOCK_MUTEX(table->Mutex); + return freeStart; + } + } + } + /* cannot allocate a block of numKeys consecutive keys */ + _glthread_UNLOCK_MUTEX(table->Mutex); + return 0; + } +} + + +#if 0 /* debug only */ + +/** + * Test walking over all the entries in a hash table. + */ +static void +test_hash_walking(void) +{ + struct _mesa_HashTable *t = _mesa_NewHashTable(); + const GLuint limit = 50000; + GLuint i; + + /* create some entries */ + for (i = 0; i < limit; i++) { + GLuint dummy; + GLuint k = (rand() % (limit * 10)) + 1; + while (_mesa_HashLookup(t, k)) { + /* id already in use, try another */ + k = (rand() % (limit * 10)) + 1; + } + _mesa_HashInsert(t, k, &dummy); + } + + /* walk over all entries */ + { + GLuint k = _mesa_HashFirstEntry(t); + GLuint count = 0; + while (k) { + GLuint knext = _mesa_HashNextEntry(t, k); + assert(knext != k); + _mesa_HashRemove(t, k); + count++; + k = knext; + } + assert(count == limit); + k = _mesa_HashFirstEntry(t); + assert(k==0); + } + + _mesa_DeleteHashTable(t); +} + + +void +_mesa_test_hash_functions(void) +{ + int a, b, c; + struct _mesa_HashTable *t; + + t = _mesa_NewHashTable(); + _mesa_HashInsert(t, 501, &a); + _mesa_HashInsert(t, 10, &c); + _mesa_HashInsert(t, 0xfffffff8, &b); + /*_mesa_HashPrint(t);*/ + + assert(_mesa_HashLookup(t,501)); + assert(!_mesa_HashLookup(t,1313)); + assert(_mesa_HashFindFreeKeyBlock(t, 100)); + + _mesa_DeleteHashTable(t); + + test_hash_walking(); +} + +#endif diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c index e2d4129a3..ccec1d285 100644 --- a/mesalib/src/mesa/main/hint.c +++ b/mesalib/src/mesa/main/hint.c @@ -1,149 +1,145 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "enums.h" -#include "context.h" -#include "hint.h" -#include "imports.h" - - - -void GLAPIENTRY -_mesa_Hint( GLenum target, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glHint %s %d\n", - _mesa_lookup_enum_by_nr(target), mode); - - if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); - return; - } - - switch (target) { - case GL_FOG_HINT: - if (ctx->Hint.Fog == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.Fog = mode; - break; - case GL_LINE_SMOOTH_HINT: - if (ctx->Hint.LineSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.LineSmooth = mode; - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - if (ctx->Hint.PerspectiveCorrection == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PerspectiveCorrection = mode; - break; - case GL_POINT_SMOOTH_HINT: - if (ctx->Hint.PointSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PointSmooth = mode; - break; - case GL_POLYGON_SMOOTH_HINT: - if (ctx->Hint.PolygonSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PolygonSmooth = mode; - break; - - /* GL_EXT_clip_volume_hint */ - case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - if (ctx->Hint.ClipVolumeClipping == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.ClipVolumeClipping = mode; - break; - - /* GL_ARB_texture_compression */ - case GL_TEXTURE_COMPRESSION_HINT_ARB: - if (ctx->Hint.TextureCompression == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.TextureCompression = mode; - break; - - /* GL_SGIS_generate_mipmap */ - case GL_GENERATE_MIPMAP_HINT_SGIS: - if (!ctx->Extensions.SGIS_generate_mipmap) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - if (ctx->Hint.GenerateMipmap == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.GenerateMipmap = mode; - break; - - /* GL_ARB_fragment_shader */ - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - if (!ctx->Extensions.ARB_fragment_shader) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - if (ctx->Hint.FragmentShaderDerivative == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.FragmentShaderDerivative = mode; - break; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - - if (ctx->Driver.Hint) { - (*ctx->Driver.Hint)( ctx, target, mode ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_hint( GLcontext * ctx ) -{ - /* Hint group */ - ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; - ctx->Hint.PointSmooth = GL_DONT_CARE; - ctx->Hint.LineSmooth = GL_DONT_CARE; - ctx->Hint.PolygonSmooth = GL_DONT_CARE; - ctx->Hint.Fog = GL_DONT_CARE; - ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; - ctx->Hint.TextureCompression = GL_DONT_CARE; - ctx->Hint.GenerateMipmap = GL_DONT_CARE; - ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; -} + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "enums.h" +#include "context.h" +#include "hint.h" +#include "imports.h" + + + +void GLAPIENTRY +_mesa_Hint( GLenum target, GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glHint %s %d\n", + _mesa_lookup_enum_by_nr(target), mode); + + if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); + return; + } + + switch (target) { + case GL_FOG_HINT: + if (ctx->Hint.Fog == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.Fog = mode; + break; + case GL_LINE_SMOOTH_HINT: + if (ctx->Hint.LineSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.LineSmooth = mode; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + if (ctx->Hint.PerspectiveCorrection == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PerspectiveCorrection = mode; + break; + case GL_POINT_SMOOTH_HINT: + if (ctx->Hint.PointSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PointSmooth = mode; + break; + case GL_POLYGON_SMOOTH_HINT: + if (ctx->Hint.PolygonSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PolygonSmooth = mode; + break; + + /* GL_EXT_clip_volume_hint */ + case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: + if (ctx->Hint.ClipVolumeClipping == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.ClipVolumeClipping = mode; + break; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Hint.TextureCompression == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.TextureCompression = mode; + break; + + /* GL_SGIS_generate_mipmap */ + case GL_GENERATE_MIPMAP_HINT_SGIS: + if (ctx->Hint.GenerateMipmap == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.GenerateMipmap = mode; + break; + + /* GL_ARB_fragment_shader */ + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: + if (!ctx->Extensions.ARB_fragment_shader) { + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + return; + } + if (ctx->Hint.FragmentShaderDerivative == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.FragmentShaderDerivative = mode; + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + return; + } + + if (ctx->Driver.Hint) { + (*ctx->Driver.Hint)( ctx, target, mode ); + } +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void _mesa_init_hint( struct gl_context * ctx ) +{ + /* Hint group */ + ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; + ctx->Hint.PointSmooth = GL_DONT_CARE; + ctx->Hint.LineSmooth = GL_DONT_CARE; + ctx->Hint.PolygonSmooth = GL_DONT_CARE; + ctx->Hint.Fog = GL_DONT_CARE; + ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; + ctx->Hint.TextureCompression = GL_DONT_CARE; + ctx->Hint.GenerateMipmap = GL_DONT_CARE; + ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; +} diff --git a/mesalib/src/mesa/main/hint.h b/mesalib/src/mesa/main/hint.h index bfc388710..3cdd2d650 100644 --- a/mesalib/src/mesa/main/hint.h +++ b/mesalib/src/mesa/main/hint.h @@ -1,57 +1,59 @@ -/** - * \file hint.h - * Hints operations. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef HINT_H -#define HINT_H - - -#include "mtypes.h" - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_Hint( GLenum target, GLenum mode ); - -extern void -_mesa_init_hint( GLcontext * ctx ); - -#else - -/** No-op */ -#define _mesa_init_hint( c ) ((void) 0) - -#endif - -#endif +/** + * \file hint.h + * Hints operations. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef HINT_H +#define HINT_H + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + +#if _HAVE_FULL_GL + +extern void GLAPIENTRY +_mesa_Hint( GLenum target, GLenum mode ); + +extern void +_mesa_init_hint( struct gl_context * ctx ); + +#else + +/** No-op */ +#define _mesa_init_hint( c ) ((void) 0) + +#endif + +#endif diff --git a/mesalib/src/mesa/main/histogram.c b/mesalib/src/mesa/main/histogram.c index 4e482bcd5..f12428121 100644 --- a/mesalib/src/mesa/main/histogram.c +++ b/mesalib/src/mesa/main/histogram.c @@ -1,1105 +1,150 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "context.h" -#include "image.h" -#include "histogram.h" -#include "macros.h" -#include "main/dispatch.h" - - -#if FEATURE_histogram - - -/* - * XXX the packed pixel formats haven't been tested. - */ -static void -pack_histogram( GLcontext *ctx, - GLuint n, CONST GLuint rgba[][4], - GLenum format, GLenum type, GLvoid *destination, - const struct gl_pixelstore_attrib *packing ) -{ - const GLint comps = _mesa_components_in_format(format); - GLuint luminance[MAX_WIDTH]; - - if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { - GLuint i; - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - } - } - -#define PACK_MACRO(TYPE) \ - { \ - GLuint i; \ - switch (format) { \ - case GL_RED: \ - for (i=0;iSwapBytes) { - _mesa_swap2(dst, n * comps); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) destination; - PACK_MACRO(GLshort); - if (packing->SwapBytes) { - _mesa_swap2((GLushort *) dst, n * comps); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) destination; - PACK_MACRO(GLuint); - if (packing->SwapBytes) { - _mesa_swap4(dst, n * comps); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) destination; - PACK_MACRO(GLint); - if (packing->SwapBytes) { - _mesa_swap4((GLuint *) dst, n * comps); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) destination; - PACK_MACRO(GLfloat); - if (packing->SwapBytes) { - _mesa_swap4((GLuint *) dst, n * comps); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - /* temporarily store as GLuints */ - GLuint temp[4*HISTOGRAM_TABLE_SIZE]; - GLuint *dst = temp; - GLhalfARB *half = (GLhalfARB *) destination; - GLuint i; - /* get GLuint values */ - PACK_MACRO(GLuint); - /* convert to GLhalf */ - for (i = 0; i < n * comps; i++) { - half[i] = _mesa_float_to_half((GLfloat) temp[i]); - } - if (packing->SwapBytes) { - _mesa_swap2((GLushort *) half, n * comps); - } - } - break; - case GL_UNSIGNED_BYTE_3_3_2: - if (format == GL_RGB) { - GLubyte *dst = (GLubyte *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x7) << 5) - | ((rgba[i][GCOMP] & 0x7) << 2) - | ((rgba[i][BCOMP] & 0x3) ); - } - } - else { - GLubyte *dst = (GLubyte *) destination; - GLuint i; - ASSERT(format == GL_BGR); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x7) << 5) - | ((rgba[i][GCOMP] & 0x7) << 2) - | ((rgba[i][RCOMP] & 0x3) ); - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - if (format == GL_RGB) { - GLubyte *dst = (GLubyte *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x3) << 6) - | ((rgba[i][GCOMP] & 0x7) << 3) - | ((rgba[i][BCOMP] & 0x7) ); - } - } - else { - GLubyte *dst = (GLubyte *) destination; - GLuint i; - ASSERT(format == GL_BGR); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x3) << 6) - | ((rgba[i][GCOMP] & 0x7) << 3) - | ((rgba[i][RCOMP] & 0x7) ); - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (format == GL_RGB) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x3f) << 5) - | ((rgba[i][BCOMP] & 0x1f) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_BGR); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x3f) << 5) - | ((rgba[i][RCOMP] & 0x1f) ); - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (format == GL_RGB) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x3f) << 5) - | ((rgba[i][RCOMP] & 0x1f) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_BGR); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x3f) << 5) - | ((rgba[i][BCOMP] & 0x1f) ); - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (format == GL_RGBA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0xf) << 12) - | ((rgba[i][GCOMP] & 0xf) << 8) - | ((rgba[i][BCOMP] & 0xf) << 4) - | ((rgba[i][ACOMP] & 0xf) ); - } - } - else if (format == GL_BGRA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0xf) << 12) - | ((rgba[i][GCOMP] & 0xf) << 8) - | ((rgba[i][RCOMP] & 0xf) << 4) - | ((rgba[i][ACOMP] & 0xf) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) - | ((rgba[i][BCOMP] & 0xf) << 8) - | ((rgba[i][GCOMP] & 0xf) << 4) - | ((rgba[i][RCOMP] & 0xf) ); - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (format == GL_RGBA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) - | ((rgba[i][BCOMP] & 0xf) << 8) - | ((rgba[i][GCOMP] & 0xf) << 4) - | ((rgba[i][RCOMP] & 0xf) ); - } - } - else if (format == GL_BGRA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xf) << 12) - | ((rgba[i][RCOMP] & 0xf) << 8) - | ((rgba[i][GCOMP] & 0xf) << 4) - | ((rgba[i][BCOMP] & 0xf) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0xf) << 12) - | ((rgba[i][GCOMP] & 0xf) << 8) - | ((rgba[i][BCOMP] & 0xf) << 4) - | ((rgba[i][ACOMP] & 0xf) ); - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (format == GL_RGBA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x1f) << 6) - | ((rgba[i][BCOMP] & 0x1f) << 1) - | ((rgba[i][ACOMP] & 0x1) ); - } - } - else if (format == GL_BGRA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x1f) << 6) - | ((rgba[i][RCOMP] & 0x1f) << 1) - | ((rgba[i][ACOMP] & 0x1) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) - | ((rgba[i][BCOMP] & 0x1f) << 6) - | ((rgba[i][GCOMP] & 0x1f) << 1) - | ((rgba[i][RCOMP] & 0x1) ); - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (format == GL_RGBA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) - | ((rgba[i][BCOMP] & 0x1f) << 6) - | ((rgba[i][GCOMP] & 0x1f) << 1) - | ((rgba[i][RCOMP] & 0x1) ); - } - } - else if (format == GL_BGRA) { - GLushort *dst = (GLushort *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11) - | ((rgba[i][RCOMP] & 0x1f) << 6) - | ((rgba[i][GCOMP] & 0x1f) << 1) - | ((rgba[i][BCOMP] & 0x1) ); - } - } - else { - GLushort *dst = (GLushort *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11) - | ((rgba[i][GCOMP] & 0x1f) << 6) - | ((rgba[i][BCOMP] & 0x1f) << 1) - | ((rgba[i][ACOMP] & 0x1) ); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (format == GL_RGBA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0xff) << 24) - | ((rgba[i][GCOMP] & 0xff) << 16) - | ((rgba[i][BCOMP] & 0xff) << 8) - | ((rgba[i][ACOMP] & 0xff) ); - } - } - else if (format == GL_BGRA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0xff) << 24) - | ((rgba[i][GCOMP] & 0xff) << 16) - | ((rgba[i][RCOMP] & 0xff) << 8) - | ((rgba[i][ACOMP] & 0xff) ); - } - } - else { - GLuint *dst = (GLuint *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) - | ((rgba[i][BCOMP] & 0xff) << 16) - | ((rgba[i][GCOMP] & 0xff) << 8) - | ((rgba[i][RCOMP] & 0xff) ); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (format == GL_RGBA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) - | ((rgba[i][BCOMP] & 0xff) << 16) - | ((rgba[i][GCOMP] & 0xff) << 8) - | ((rgba[i][RCOMP] & 0xff) ); - } - } - else if (format == GL_BGRA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0xff) << 24) - | ((rgba[i][RCOMP] & 0xff) << 16) - | ((rgba[i][GCOMP] & 0xff) << 8) - | ((rgba[i][BCOMP] & 0xff) ); - } - } - else { - GLuint *dst = (GLuint *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0xff) << 24) - | ((rgba[i][GCOMP] & 0xff) << 16) - | ((rgba[i][BCOMP] & 0xff) << 8) - | ((rgba[i][ACOMP] & 0xff) ); - } - } - break; - case GL_UNSIGNED_INT_10_10_10_2: - if (format == GL_RGBA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22) - | ((rgba[i][GCOMP] & 0x3ff) << 12) - | ((rgba[i][BCOMP] & 0x3ff) << 2) - | ((rgba[i][ACOMP] & 0x3) ); - } - } - else if (format == GL_BGRA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][BCOMP] & 0x3ff) << 22) - | ((rgba[i][GCOMP] & 0x3ff) << 12) - | ((rgba[i][RCOMP] & 0x3ff) << 2) - | ((rgba[i][ACOMP] & 0x3) ); - } - } - else { - GLuint *dst = (GLuint *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) - | ((rgba[i][BCOMP] & 0x3ff) << 12) - | ((rgba[i][GCOMP] & 0x3ff) << 2) - | ((rgba[i][RCOMP] & 0x3) ); - } - } - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (format == GL_RGBA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) - | ((rgba[i][BCOMP] & 0x3ff) << 12) - | ((rgba[i][GCOMP] & 0x3ff) << 2) - | ((rgba[i][RCOMP] & 0x3) ); - } - } - else if (format == GL_BGRA) { - GLuint *dst = (GLuint *) destination; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22) - | ((rgba[i][RCOMP] & 0x3ff) << 12) - | ((rgba[i][GCOMP] & 0x3ff) << 2) - | ((rgba[i][BCOMP] & 0x3) ); - } - } - else { - GLuint *dst = (GLuint *) destination; - GLuint i; - ASSERT(format == GL_ABGR_EXT); - for (i = 0; i < n; i++) { - dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22) - | ((rgba[i][GCOMP] & 0x3ff) << 12) - | ((rgba[i][BCOMP] & 0x3ff) << 2) - | ((rgba[i][ACOMP] & 0x3) ); - } - } - break; - default: - _mesa_problem(ctx, "Bad type in pack_histogram"); - } - -#undef PACK_MACRO -} - - -/* - * Given an internalFormat token passed to glHistogram or glMinMax, - * return the corresponding base format. - * Return -1 if invalid token. - */ -static GLint -base_histogram_format( GLenum format ) -{ - switch (format) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - return -1; /* error */ - } -} - - - -/********************************************************************** - * API functions - */ - - -/* this is defined below */ -static void GLAPIENTRY _mesa_ResetMinmax(GLenum target); - - -static void GLAPIENTRY -_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax"); - return; - } - - if (target != GL_MINMAX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmax(target)"); - return; - } - - if (format != GL_RED && - format != GL_GREEN && - format != GL_BLUE && - format != GL_ALPHA && - format != GL_RGB && - format != GL_BGR && - format != GL_RGBA && - format != GL_BGRA && - format != GL_ABGR_EXT && - format != GL_LUMINANCE && - format != GL_LUMINANCE_ALPHA) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMax(format)"); - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax(format or type)"); - return; - } - - - values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, 2, 1, 1, - format, type, values, "glGetMinmax"); - if (!values) - return; - - { - GLfloat minmax[2][4]; - minmax[0][RCOMP] = CLAMP(ctx->MinMax.Min[RCOMP], 0.0F, 1.0F); - minmax[0][GCOMP] = CLAMP(ctx->MinMax.Min[GCOMP], 0.0F, 1.0F); - minmax[0][BCOMP] = CLAMP(ctx->MinMax.Min[BCOMP], 0.0F, 1.0F); - minmax[0][ACOMP] = CLAMP(ctx->MinMax.Min[ACOMP], 0.0F, 1.0F); - minmax[1][RCOMP] = CLAMP(ctx->MinMax.Max[RCOMP], 0.0F, 1.0F); - minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F); - minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F); - minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F); - _mesa_pack_rgba_span_float(ctx, 2, minmax, - format, type, values, &ctx->Pack, 0x0); - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - - if (reset) { - _mesa_ResetMinmax(GL_MINMAX); - } -} - - -static void GLAPIENTRY -_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram"); - return; - } - - if (target != GL_HISTOGRAM) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(target)"); - return; - } - - if (format != GL_RED && - format != GL_GREEN && - format != GL_BLUE && - format != GL_ALPHA && - format != GL_RGB && - format != GL_BGR && - format != GL_RGBA && - format != GL_BGRA && - format != GL_ABGR_EXT && - format != GL_LUMINANCE && - format != GL_LUMINANCE_ALPHA) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)"); - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram(format or type)"); - return; - } - - values = _mesa_map_validate_pbo_dest(ctx, 1, &ctx->Pack, - ctx->Histogram.Width, 1, 1, - format, type, values, - "glGetHistogram"); - if (!values) - return; - - pack_histogram(ctx, ctx->Histogram.Width, - (CONST GLuint (*)[4]) ctx->Histogram.Count, - format, type, values, &ctx->Pack); - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - - if (reset) { - GLuint i; - for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { - ctx->Histogram.Count[i][0] = 0; - ctx->Histogram.Count[i][1] = 0; - ctx->Histogram.Count[i][2] = 0; - ctx->Histogram.Count[i][3] = 0; - } - } -} - - -static void GLAPIENTRY -_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv"); - return; - } - - if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(target)"); - return; - } - - switch (pname) { - case GL_HISTOGRAM_WIDTH: - *params = (GLfloat) ctx->Histogram.Width; - break; - case GL_HISTOGRAM_FORMAT: - *params = (GLfloat) ctx->Histogram.Format; - break; - case GL_HISTOGRAM_RED_SIZE: - *params = (GLfloat) ctx->Histogram.RedSize; - break; - case GL_HISTOGRAM_GREEN_SIZE: - *params = (GLfloat) ctx->Histogram.GreenSize; - break; - case GL_HISTOGRAM_BLUE_SIZE: - *params = (GLfloat) ctx->Histogram.BlueSize; - break; - case GL_HISTOGRAM_ALPHA_SIZE: - *params = (GLfloat) ctx->Histogram.AlphaSize; - break; - case GL_HISTOGRAM_LUMINANCE_SIZE: - *params = (GLfloat) ctx->Histogram.LuminanceSize; - break; - case GL_HISTOGRAM_SINK: - *params = (GLfloat) ctx->Histogram.Sink; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(pname)"); - } -} - - -static void GLAPIENTRY -_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv"); - return; - } - - if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(target)"); - return; - } - - switch (pname) { - case GL_HISTOGRAM_WIDTH: - *params = (GLint) ctx->Histogram.Width; - break; - case GL_HISTOGRAM_FORMAT: - *params = (GLint) ctx->Histogram.Format; - break; - case GL_HISTOGRAM_RED_SIZE: - *params = (GLint) ctx->Histogram.RedSize; - break; - case GL_HISTOGRAM_GREEN_SIZE: - *params = (GLint) ctx->Histogram.GreenSize; - break; - case GL_HISTOGRAM_BLUE_SIZE: - *params = (GLint) ctx->Histogram.BlueSize; - break; - case GL_HISTOGRAM_ALPHA_SIZE: - *params = (GLint) ctx->Histogram.AlphaSize; - break; - case GL_HISTOGRAM_LUMINANCE_SIZE: - *params = (GLint) ctx->Histogram.LuminanceSize; - break; - case GL_HISTOGRAM_SINK: - *params = (GLint) ctx->Histogram.Sink; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(pname)"); - } -} - - -static void GLAPIENTRY -_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv"); - return; - } - if (target != GL_MINMAX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameterfv(target)"); - return; - } - if (pname == GL_MINMAX_FORMAT) { - *params = (GLfloat) ctx->MinMax.Format; - } - else if (pname == GL_MINMAX_SINK) { - *params = (GLfloat) ctx->MinMax.Sink; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameterfv(pname)"); - } -} - - -static void GLAPIENTRY -_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv"); - return; - } - if (target != GL_MINMAX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameteriv(target)"); - return; - } - if (pname == GL_MINMAX_FORMAT) { - *params = (GLint) ctx->MinMax.Format; - } - else if (pname == GL_MINMAX_SINK) { - *params = (GLint) ctx->MinMax.Sink; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameteriv(pname)"); - } -} - - -static void GLAPIENTRY -_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) -{ - GLuint i; - GLboolean error = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */ - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram"); - return; - } - - if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHistogram(target)"); - return; - } - - if (width < 0 || width > HISTOGRAM_TABLE_SIZE) { - if (target == GL_PROXY_HISTOGRAM) { - error = GL_TRUE; - } - else { - if (width < 0) - _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); - else - _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glHistogram(width)"); - return; - } - } - - if (width != 0 && !_mesa_is_pow_two(width)) { - if (target == GL_PROXY_HISTOGRAM) { - error = GL_TRUE; - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); - return; - } - } - - if (base_histogram_format(internalFormat) < 0) { - if (target == GL_PROXY_HISTOGRAM) { - error = GL_TRUE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glHistogram(internalFormat)"); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - /* reset histograms */ - for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { - ctx->Histogram.Count[i][0] = 0; - ctx->Histogram.Count[i][1] = 0; - ctx->Histogram.Count[i][2] = 0; - ctx->Histogram.Count[i][3] = 0; - } - - if (error) { - ctx->Histogram.Width = 0; - ctx->Histogram.Format = 0; - ctx->Histogram.RedSize = 0; - ctx->Histogram.GreenSize = 0; - ctx->Histogram.BlueSize = 0; - ctx->Histogram.AlphaSize = 0; - ctx->Histogram.LuminanceSize = 0; - } - else { - ctx->Histogram.Width = width; - ctx->Histogram.Format = internalFormat; - ctx->Histogram.Sink = sink; - ctx->Histogram.RedSize = 8 * sizeof(GLuint); - ctx->Histogram.GreenSize = 8 * sizeof(GLuint); - ctx->Histogram.BlueSize = 8 * sizeof(GLuint); - ctx->Histogram.AlphaSize = 8 * sizeof(GLuint); - ctx->Histogram.LuminanceSize = 8 * sizeof(GLuint); - } -} - - -static void GLAPIENTRY -_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax"); - return; - } - - if (target != GL_MINMAX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(target)"); - return; - } - - if (base_histogram_format(internalFormat) < 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(internalFormat)"); - return; - } - - if (ctx->MinMax.Sink == sink) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->MinMax.Sink = sink; -} - - -static void GLAPIENTRY -_mesa_ResetHistogram(GLenum target) -{ - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */ - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram"); - return; - } - - if (target != GL_HISTOGRAM) { - _mesa_error(ctx, GL_INVALID_ENUM, "glResetHistogram(target)"); - return; - } - - for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { - ctx->Histogram.Count[i][0] = 0; - ctx->Histogram.Count[i][1] = 0; - ctx->Histogram.Count[i][2] = 0; - ctx->Histogram.Count[i][3] = 0; - } -} - - -static void GLAPIENTRY -_mesa_ResetMinmax(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax"); - return; - } - - if (target != GL_MINMAX) { - _mesa_error(ctx, GL_INVALID_ENUM, "glResetMinMax(target)"); - return; - } - - ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; - ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; - ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; - ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; -} - - -void -_mesa_init_histogram_dispatch(struct _glapi_table *disp) -{ - SET_GetHistogram(disp, _mesa_GetHistogram); - SET_GetHistogramParameterfv(disp, _mesa_GetHistogramParameterfv); - SET_GetHistogramParameteriv(disp, _mesa_GetHistogramParameteriv); - SET_GetMinmax(disp, _mesa_GetMinmax); - SET_GetMinmaxParameterfv(disp, _mesa_GetMinmaxParameterfv); - SET_GetMinmaxParameteriv(disp, _mesa_GetMinmaxParameteriv); - SET_Histogram(disp, _mesa_Histogram); - SET_Minmax(disp, _mesa_Minmax); - SET_ResetHistogram(disp, _mesa_ResetHistogram); - SET_ResetMinmax(disp, _mesa_ResetMinmax); -} - - -#endif /* FEATURE_histogram */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_histogram( GLcontext * ctx ) -{ - int i; - - /* Histogram group */ - ctx->Histogram.Width = 0; - ctx->Histogram.Format = GL_RGBA; - ctx->Histogram.Sink = GL_FALSE; - ctx->Histogram.RedSize = 0; - ctx->Histogram.GreenSize = 0; - ctx->Histogram.BlueSize = 0; - ctx->Histogram.AlphaSize = 0; - ctx->Histogram.LuminanceSize = 0; - for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { - ctx->Histogram.Count[i][0] = 0; - ctx->Histogram.Count[i][1] = 0; - ctx->Histogram.Count[i][2] = 0; - ctx->Histogram.Count[i][3] = 0; - } - - /* Min/Max group */ - ctx->MinMax.Format = GL_RGBA; - ctx->MinMax.Sink = GL_FALSE; - ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; - ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; - ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; - ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; -} +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "histogram.h" +#include "macros.h" +#include "main/dispatch.h" + + +#if FEATURE_histogram + +/********************************************************************** + * API functions + */ + + +/* this is defined below */ +static void GLAPIENTRY _mesa_ResetMinmax(GLenum target); + + +static void GLAPIENTRY +_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax"); +} + + +static void GLAPIENTRY +_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram"); +} + + +static void GLAPIENTRY +_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv"); +} + + +static void GLAPIENTRY +_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv"); +} + + +static void GLAPIENTRY +_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram"); +} + + +static void GLAPIENTRY +_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax"); +} + + +static void GLAPIENTRY +_mesa_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram"); +} + + +static void GLAPIENTRY +_mesa_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax"); +} + + +void +_mesa_init_histogram_dispatch(struct _glapi_table *disp) +{ + SET_GetHistogram(disp, _mesa_GetHistogram); + SET_GetHistogramParameterfv(disp, _mesa_GetHistogramParameterfv); + SET_GetHistogramParameteriv(disp, _mesa_GetHistogramParameteriv); + SET_GetMinmax(disp, _mesa_GetMinmax); + SET_GetMinmaxParameterfv(disp, _mesa_GetMinmaxParameterfv); + SET_GetMinmaxParameteriv(disp, _mesa_GetMinmaxParameteriv); + SET_Histogram(disp, _mesa_Histogram); + SET_Minmax(disp, _mesa_Minmax); + SET_ResetHistogram(disp, _mesa_ResetHistogram); + SET_ResetMinmax(disp, _mesa_ResetMinmax); +} + +#endif /* FEATURE_histogram */ diff --git a/mesalib/src/mesa/main/histogram.h b/mesalib/src/mesa/main/histogram.h index dbae1bbd0..f9c7310fe 100644 --- a/mesalib/src/mesa/main/histogram.h +++ b/mesalib/src/mesa/main/histogram.h @@ -1,57 +1,58 @@ -/** - * \file histogram.h - * Histogram. - * - * \if subset - * (No-op) - * - * \endif - */ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef HISTOGRAM_H -#define HISTOGRAM_H - -#include "main/mtypes.h" - -#if FEATURE_histogram - -extern void -_mesa_init_histogram_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_histogram */ - -static INLINE void -_mesa_init_histogram_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_histogram */ - -extern void _mesa_init_histogram( GLcontext * ctx ); - -#endif /* HISTOGRAM_H */ +/** + * \file histogram.h + * Histogram. + * + * \if subset + * (No-op) + * + * \endif + */ + +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef HISTOGRAM_H +#define HISTOGRAM_H + +#include "compiler.h" +#include "mfeatures.h" + +struct _glapi_table; + +#if FEATURE_histogram + +extern void +_mesa_init_histogram_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_histogram */ + +static INLINE void +_mesa_init_histogram_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_histogram */ + +#endif /* HISTOGRAM_H */ diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c index 86aa6d0d7..08d25c8d1 100644 --- a/mesalib/src/mesa/main/image.c +++ b/mesalib/src/mesa/main/image.c @@ -1,6073 +1,1874 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file image.c - * Image handling. - */ - - -#include "glheader.h" -#include "colormac.h" -#include "enums.h" -#include "image.h" -#include "imports.h" -#include "macros.h" - - -/** - * NOTE: - * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when - * we later convert the float to a packed integer value (such as for - * GL_RGB5_A1) because we'll wind up with a non-zero value. - * - * We redefine the macros here so zero is handled correctly. - */ -#undef BYTE_TO_FLOAT -#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F))) - -#undef SHORT_TO_FLOAT -#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))) - - - -/** Compute ceiling of integer quotient of A divided by B. */ -#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) - - -/** - * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. - */ -GLboolean -_mesa_type_is_packed(GLenum type) -{ - switch (type) { - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - case GL_UNSIGNED_INT_24_8_EXT: - return GL_TRUE; - } - - return GL_FALSE; -} - -/** - * Flip the 8 bits in each byte of the given array. - * - * \param p array. - * \param n number of bytes. - * - * \todo try this trick to flip bytes someday: - * \code - * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); - * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); - * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); - * \endcode - */ -static void -flip_bytes( GLubyte *p, GLuint n ) -{ - GLuint i, a, b; - for (i = 0; i < n; i++) { - b = (GLuint) p[i]; /* words are often faster than bytes */ - a = ((b & 0x01) << 7) | - ((b & 0x02) << 5) | - ((b & 0x04) << 3) | - ((b & 0x08) << 1) | - ((b & 0x10) >> 1) | - ((b & 0x20) >> 3) | - ((b & 0x40) >> 5) | - ((b & 0x80) >> 7); - p[i] = (GLubyte) a; - } -} - - -/** - * Flip the order of the 2 bytes in each word in the given array. - * - * \param p array. - * \param n number of words. - */ -void -_mesa_swap2( GLushort *p, GLuint n ) -{ - GLuint i; - for (i = 0; i < n; i++) { - p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00); - } -} - - - -/* - * Flip the order of the 4 bytes in each word in the given array. - */ -void -_mesa_swap4( GLuint *p, GLuint n ) -{ - GLuint i, a, b; - for (i = 0; i < n; i++) { - b = p[i]; - a = (b >> 24) - | ((b >> 8) & 0xff00) - | ((b << 8) & 0xff0000) - | ((b << 24) & 0xff000000); - p[i] = a; - } -} - - -/** - * Get the size of a GL data type. - * - * \param type GL data type. - * - * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1 - * if an invalid type enum. - */ -GLint -_mesa_sizeof_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_DOUBLE: - return sizeof(GLdouble); - case GL_HALF_FLOAT_ARB: - return sizeof(GLhalfARB); - default: - return -1; - } -} - - -/** - * Same as _mesa_sizeof_type() but also accepting the packed pixel - * format data types. - */ -GLint -_mesa_sizeof_packed_type( GLenum type ) -{ - switch (type) { - case GL_BITMAP: - return 0; - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_HALF_FLOAT_ARB: - return sizeof(GLhalfARB); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_UNSIGNED_BYTE_3_3_2: - return sizeof(GLubyte); - case GL_UNSIGNED_BYTE_2_3_3_REV: - return sizeof(GLubyte); - case GL_UNSIGNED_SHORT_5_6_5: - return sizeof(GLushort); - case GL_UNSIGNED_SHORT_5_6_5_REV: - return sizeof(GLushort); - case GL_UNSIGNED_SHORT_4_4_4_4: - return sizeof(GLushort); - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - return sizeof(GLushort); - case GL_UNSIGNED_SHORT_5_5_5_1: - return sizeof(GLushort); - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - return sizeof(GLushort); - case GL_UNSIGNED_INT_8_8_8_8: - return sizeof(GLuint); - case GL_UNSIGNED_INT_8_8_8_8_REV: - return sizeof(GLuint); - case GL_UNSIGNED_INT_10_10_10_2: - return sizeof(GLuint); - case GL_UNSIGNED_INT_2_10_10_10_REV: - return sizeof(GLuint); - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - return sizeof(GLushort); - case GL_UNSIGNED_INT_24_8_EXT: - return sizeof(GLuint); - default: - return -1; - } -} - - -/** - * Get the number of components in a pixel format. - * - * \param format pixel format. - * - * \return the number of components in the given format, or -1 if a bad format. - */ -GLint -_mesa_components_in_format( GLenum format ) -{ - switch (format) { - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - case GL_RED: - case GL_RED_INTEGER_EXT: - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - case GL_INTENSITY: - return 1; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - return 2; - case GL_RGB: - case GL_RGB_INTEGER_EXT: - return 3; - case GL_RGBA: - case GL_RGBA_INTEGER_EXT: - return 4; - case GL_BGR: - return 3; - case GL_BGRA: - return 4; - case GL_ABGR_EXT: - return 4; - case GL_YCBCR_MESA: - return 2; - case GL_DEPTH_STENCIL_EXT: - return 2; - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return 2; - default: - return -1; - } -} - - -/** - * Get the bytes per pixel of pixel format type pair. - * - * \param format pixel format. - * \param type pixel type. - * - * \return bytes per pixel, or -1 if a bad format or type was given. - */ -GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ) -{ - GLint comps = _mesa_components_in_format( format ); - if (comps < 0) - return -1; - - switch (type) { - case GL_BITMAP: - return 0; /* special case */ - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return comps * sizeof(GLubyte); - case GL_SHORT: - case GL_UNSIGNED_SHORT: - return comps * sizeof(GLshort); - case GL_INT: - case GL_UNSIGNED_INT: - return comps * sizeof(GLint); - case GL_FLOAT: - return comps * sizeof(GLfloat); - case GL_HALF_FLOAT_ARB: - return comps * sizeof(GLhalfARB); - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - if (format == GL_RGB || format == GL_BGR) - return sizeof(GLubyte); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (format == GL_RGB || format == GL_BGR) - return sizeof(GLushort); - else - return -1; /* error */ - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT) - return sizeof(GLuint); - else - return -1; - case GL_UNSIGNED_SHORT_8_8_MESA: - case GL_UNSIGNED_SHORT_8_8_REV_MESA: - if (format == GL_YCBCR_MESA) - return sizeof(GLushort); - else - return -1; - case GL_UNSIGNED_INT_24_8_EXT: - if (format == GL_DEPTH_STENCIL_EXT) - return sizeof(GLuint); - else - return -1; - default: - return -1; - } -} - - -/** - * Test for a legal pixel format and type. - * - * \param format pixel format. - * \param type pixel type. - * - * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE - * otherwise. - */ -GLboolean -_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ) -{ - switch (format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - switch (type) { - case GL_BITMAP: - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_TRUE; - case GL_HALF_FLOAT_ARB: - return ctx->Extensions.ARB_half_float_pixel; - default: - return GL_FALSE; - } - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: -#if 0 /* not legal! see table 3.6 of the 1.5 spec */ - case GL_INTENSITY: -#endif - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_DEPTH_COMPONENT: - 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: - return GL_TRUE; - case GL_HALF_FLOAT_ARB: - return ctx->Extensions.ARB_half_float_pixel; - default: - return GL_FALSE; - } - case GL_RGB: - 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_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - return GL_TRUE; - case GL_HALF_FLOAT_ARB: - return ctx->Extensions.ARB_half_float_pixel; - default: - return GL_FALSE; - } - case GL_BGR: - switch (type) { - /* NOTE: no packed types are supported with BGR. That's - * intentional, according to the GL spec. - */ - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_TRUE; - case GL_HALF_FLOAT_ARB: - return ctx->Extensions.ARB_half_float_pixel; - default: - return GL_FALSE; - } - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - 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_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - return GL_TRUE; - case GL_HALF_FLOAT_ARB: - return ctx->Extensions.ARB_half_float_pixel; - default: - return GL_FALSE; - } - case GL_YCBCR_MESA: - if (type == GL_UNSIGNED_SHORT_8_8_MESA || - type == GL_UNSIGNED_SHORT_8_8_REV_MESA) - return GL_TRUE; - else - return GL_FALSE; - case GL_DEPTH_STENCIL_EXT: - if (ctx->Extensions.EXT_packed_depth_stencil - && type == GL_UNSIGNED_INT_24_8_EXT) - return GL_TRUE; - else - return GL_FALSE; - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - 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: - return GL_TRUE; - default: - return GL_FALSE; - } - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - return ctx->Extensions.EXT_texture_integer; - default: - return GL_FALSE; - } - - default: - ; /* fall-through */ - } - return GL_FALSE; -} - - -/** - * Test if the given image format is a color/RGBA format (i.e., not color - * index, depth, stencil, etc). - * \param format the image format value (may by an internal texture format) - * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise. - */ -GLboolean -_mesa_is_color_format(GLenum format) -{ - switch (format) { - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case 3: - case GL_RGB: - case GL_BGR: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - case 4: - case GL_ABGR_EXT: - case GL_RGBA: - case GL_BGRA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - /* float texture formats */ - case GL_ALPHA16F_ARB: - case GL_ALPHA32F_ARB: - case GL_LUMINANCE16F_ARB: - case GL_LUMINANCE32F_ARB: - case GL_LUMINANCE_ALPHA16F_ARB: - case GL_LUMINANCE_ALPHA32F_ARB: - case GL_INTENSITY16F_ARB: - case GL_INTENSITY32F_ARB: - case GL_RGB16F_ARB: - case GL_RGB32F_ARB: - case GL_RGBA16F_ARB: - case GL_RGBA32F_ARB: - /* compressed formats */ - case GL_COMPRESSED_ALPHA: - case GL_COMPRESSED_LUMINANCE: - case GL_COMPRESSED_LUMINANCE_ALPHA: - case GL_COMPRESSED_INTENSITY: - case GL_COMPRESSED_RGB: - case GL_COMPRESSED_RGBA: - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RGB_FXT1_3DFX: - case GL_COMPRESSED_RGBA_FXT1_3DFX: -#if FEATURE_EXT_texture_sRGB - case GL_SRGB_EXT: - case GL_SRGB8_EXT: - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: - case GL_COMPRESSED_SRGB_EXT: - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - case GL_COMPRESSED_SLUMINANCE_EXT: - case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: -#endif /* FEATURE_EXT_texture_sRGB */ - return GL_TRUE; - /* signed texture formats */ - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - return GL_TRUE; - case GL_YCBCR_MESA: /* not considered to be RGB */ - /* fall-through */ - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a color index format. - */ -GLboolean -_mesa_is_index_format(GLenum format) -{ - switch (format) { - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a depth component format. - */ -GLboolean -_mesa_is_depth_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a stencil format. - */ -GLboolean -_mesa_is_stencil_format(GLenum format) -{ - switch (format) { - case GL_STENCIL_INDEX: - case GL_DEPTH_STENCIL: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a YCbCr format. - */ -GLboolean -_mesa_is_ycbcr_format(GLenum format) -{ - switch (format) { - case GL_YCBCR_MESA: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a depth+stencil format. - */ -GLboolean -_mesa_is_depthstencil_format(GLenum format) -{ - switch (format) { - case GL_DEPTH24_STENCIL8_EXT: - case GL_DEPTH_STENCIL_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a depth or stencil format. - */ -GLboolean -_mesa_is_depth_or_stencil_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given image format is a dudv format. - */ -GLboolean -_mesa_is_dudv_format(GLenum format) -{ - switch (format) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given format is an integer (non-normalized) format. - */ -GLboolean -_mesa_is_integer_format(GLenum format) -{ - switch (format) { - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if an image format is a supported compressed format. - * \param format the internal format token provided by the user. - * \return GL_TRUE if compressed, GL_FALSE if uncompressed - */ -GLboolean -_mesa_is_compressed_format(GLcontext *ctx, GLenum format) -{ - switch (format) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_compression_s3tc; - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return ctx->Extensions.S3_s3tc; - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_sRGB - && ctx->Extensions.EXT_texture_compression_s3tc; - case GL_COMPRESSED_RGB_FXT1_3DFX: - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return ctx->Extensions.TDFX_texture_compression_FXT1; - default: - return GL_FALSE; - } -} - - -/** - * Return the address of a specific pixel in an image (1D, 2D or 3D). - * - * Pixel unpacking/packing parameters are observed according to \p packing. - * - * \param dimensions either 1, 2 or 3 to indicate dimensionality of image - * \param image starting address of image data - * \param width the image width - * \param height theimage height - * \param format the pixel format - * \param type the pixel data type - * \param packing the pixelstore attributes - * \param img which image in the volume (0 for 1D or 2D images) - * \param row row of pixel in the image (0 for 1D images) - * \param column column of pixel in the image - * - * \return address of pixel on success, or NULL on error. - * - * \sa gl_pixelstore_attrib. - */ -GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) -{ - GLint alignment; /* 1, 2 or 4 */ - GLint pixels_per_row; - GLint rows_per_image; - GLint skiprows; - GLint skippixels; - GLint skipimages; /* for 3-D volume images */ - GLubyte *pixel_addr; - - ASSERT(dimensions >= 1 && dimensions <= 3); - - alignment = packing->Alignment; - if (packing->RowLength > 0) { - pixels_per_row = packing->RowLength; - } - else { - pixels_per_row = width; - } - if (packing->ImageHeight > 0) { - rows_per_image = packing->ImageHeight; - } - else { - rows_per_image = height; - } - - skippixels = packing->SkipPixels; - /* Note: SKIP_ROWS _is_ used for 1D images */ - skiprows = packing->SkipRows; - /* Note: SKIP_IMAGES is only used for 3D images */ - skipimages = (dimensions == 3) ? packing->SkipImages : 0; - - if (type == GL_BITMAP) { - /* BITMAP data */ - GLint comp_per_pixel; /* components per pixel */ - GLint bytes_per_comp; /* bytes per component */ - GLint bytes_per_row; - GLint bytes_per_image; - - /* Compute bytes per component */ - bytes_per_comp = _mesa_sizeof_packed_type( type ); - if (bytes_per_comp < 0) { - return NULL; - } - - /* Compute number of components per pixel */ - comp_per_pixel = _mesa_components_in_format( format ); - if (comp_per_pixel < 0) { - return NULL; - } - - bytes_per_row = alignment - * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); - - bytes_per_image = bytes_per_row * rows_per_image; - - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image - + (skiprows + row) * bytes_per_row - + (skippixels + column) / 8; - } - else { - /* Non-BITMAP data */ - GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image; - GLint topOfImage; - - bytes_per_pixel = _mesa_bytes_per_pixel( format, type ); - - /* The pixel type and format should have been error checked earlier */ - assert(bytes_per_pixel > 0); - - bytes_per_row = pixels_per_row * bytes_per_pixel; - remainder = bytes_per_row % alignment; - if (remainder > 0) - bytes_per_row += (alignment - remainder); - - ASSERT(bytes_per_row % alignment == 0); - - bytes_per_image = bytes_per_row * rows_per_image; - - if (packing->Invert) { - /* set pixel_addr to the last row */ - topOfImage = bytes_per_row * (height - 1); - bytes_per_row = -bytes_per_row; - } - else { - topOfImage = 0; - } - - /* compute final pixel address */ - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image - + topOfImage - + (skiprows + row) * bytes_per_row - + (skippixels + column) * bytes_per_pixel; - } - - return (GLvoid *) pixel_addr; -} - - -GLvoid * -_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, - GLenum format, GLenum type, - GLint column ) -{ - return _mesa_image_address(1, packing, image, width, 1, - format, type, 0, 0, column); -} - - -GLvoid * -_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint row, GLint column ) -{ - return _mesa_image_address(2, packing, image, width, height, - format, type, 0, row, column); -} - - -GLvoid * -_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) -{ - return _mesa_image_address(3, packing, image, width, height, - format, type, img, row, column); -} - - - -/** - * Compute the stride (in bytes) between image rows. - * - * \param packing the pixelstore attributes - * \param width image width. - * \param format pixel format. - * \param type pixel data type. - * - * \return the stride in bytes for the given parameters, or -1 if error - */ -GLint -_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLenum format, GLenum type ) -{ - GLint bytesPerRow, remainder; - - ASSERT(packing); - - if (type == GL_BITMAP) { - if (packing->RowLength == 0) { - bytesPerRow = (width + 7) / 8; - } - else { - bytesPerRow = (packing->RowLength + 7) / 8; - } - } - else { - /* Non-BITMAP data */ - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - if (bytesPerPixel <= 0) - return -1; /* error */ - if (packing->RowLength == 0) { - bytesPerRow = bytesPerPixel * width; - } - else { - bytesPerRow = bytesPerPixel * packing->RowLength; - } - } - - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) { - bytesPerRow += (packing->Alignment - remainder); - } - - if (packing->Invert) { - /* negate the bytes per row (negative row stride) */ - bytesPerRow = -bytesPerRow; - } - - return bytesPerRow; -} - - -#if _HAVE_FULL_GL - -/* - * Compute the stride between images in a 3D texture (in bytes) for the given - * pixel packing parameters and image width, format and type. - */ -GLint -_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLint height, - GLenum format, GLenum type ) -{ - GLint bytesPerRow, bytesPerImage, remainder; - - ASSERT(packing); - - if (type == GL_BITMAP) { - if (packing->RowLength == 0) { - bytesPerRow = (width + 7) / 8; - } - else { - bytesPerRow = (packing->RowLength + 7) / 8; - } - } - else { - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - - if (bytesPerPixel <= 0) - return -1; /* error */ - if (packing->RowLength == 0) { - bytesPerRow = bytesPerPixel * width; - } - else { - bytesPerRow = bytesPerPixel * packing->RowLength; - } - } - - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); - - if (packing->ImageHeight == 0) - bytesPerImage = bytesPerRow * height; - else - bytesPerImage = bytesPerRow * packing->ImageHeight; - - return bytesPerImage; -} - - -/* - * Unpack a 32x32 pixel polygon stipple from user memory using the - * current pixel unpack settings. - */ -void -_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], - const struct gl_pixelstore_attrib *unpacking ) -{ - GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking); - if (ptrn) { - /* Convert pattern from GLubytes to GLuints and handle big/little - * endian differences - */ - GLubyte *p = ptrn; - GLint i; - for (i = 0; i < 32; i++) { - dest[i] = (p[0] << 24) - | (p[1] << 16) - | (p[2] << 8) - | (p[3] ); - p += 4; - } - free(ptrn); - } -} - - -/* - * Pack polygon stipple into user memory given current pixel packing - * settings. - */ -void -_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, - const struct gl_pixelstore_attrib *packing ) -{ - /* Convert pattern from GLuints to GLubytes to handle big/little - * endian differences. - */ - GLubyte ptrn[32*4]; - GLint i; - for (i = 0; i < 32; i++) { - ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); - ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); - ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); - ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); - } - - _mesa_pack_bitmap(32, 32, ptrn, dest, packing); -} - - -/* - * Unpack bitmap data. Resulting data will be in most-significant-bit-first - * order with row alignment = 1 byte. - */ -GLvoid * -_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - GLint bytes, row, width_in_bytes; - GLubyte *buffer, *dst; - - if (!pixels) - return NULL; - - /* Alloc dest storage */ - bytes = ((width + 7) / 8 * height); - buffer = (GLubyte *) malloc( bytes ); - if (!buffer) - return NULL; - - width_in_bytes = CEILING( width, 8 ); - dst = buffer; - for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(packing, pixels, width, height, - GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!src) { - free(buffer); - return NULL; - } - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - dst += width_in_bytes; - } - - return buffer; -} - - -/* - * Pack bitmap data. - */ -void -_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, - GLubyte *dest, const struct gl_pixelstore_attrib *packing ) -{ - GLint row, width_in_bytes; - const GLubyte *src; - - if (!source) - return; - - width_in_bytes = CEILING( width, 8 ); - src = source; - for (row = 0; row < height; row++) { - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, - width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!dst) - return; - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 128; - GLubyte dstMask = 1 << (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 128) { - dstMask = 1; - d++; - *d = 0; - } - else { - dstMask = dstMask << 1; - } - } - } - else { - GLubyte srcMask = 128; - GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - src += width_in_bytes; - } -} - - -/** - * "Expand" a bitmap from 1-bit per pixel to 8-bits per pixel. - * This is typically used to convert a bitmap into a GLubyte/pixel texture. - * "On" bits will set texels to \p onValue. - * "Off" bits will not modify texels. - * \param width src bitmap width in pixels - * \param height src bitmap height in pixels - * \param unpack bitmap unpacking state - * \param bitmap the src bitmap data - * \param destBuffer start of dest buffer - * \param destStride row stride in dest buffer - * \param onValue if bit is 1, set destBuffer pixel to this value - */ -void -_mesa_expand_bitmap(GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap, - GLubyte *destBuffer, GLint destStride, - GLubyte onValue) -{ - const GLubyte *srcRow = (const GLubyte *) - _mesa_image_address2d(unpack, bitmap, width, height, - GL_COLOR_INDEX, GL_BITMAP, 0, 0); - const GLint srcStride = _mesa_image_row_stride(unpack, width, - GL_COLOR_INDEX, GL_BITMAP); - GLint row, col; - -#define SET_PIXEL(COL, ROW) \ - destBuffer[(ROW) * destStride + (COL)] = onValue; - - for (row = 0; row < height; row++) { - const GLubyte *src = srcRow; - - if (unpack->LsbFirst) { - /* Lsb first */ - GLubyte mask = 1U << (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 128U) { - src++; - mask = 1U; - } - else { - mask = mask << 1; - } - } - - /* get ready for next row */ - if (mask != 1) - src++; - } - else { - /* Msb first */ - GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); - for (col = 0; col < width; col++) { - - if (*src & mask) { - SET_PIXEL(col, row); - } - - if (mask == 1U) { - src++; - mask = 128U; - } - else { - mask = mask >> 1; - } - } - - /* get ready for next row */ - if (mask != 128) - src++; - } - - srcRow += srcStride; - } /* row */ - -#undef SET_PIXEL -} - - -/**********************************************************************/ -/***** Pixel processing functions ******/ -/**********************************************************************/ - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void -_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], - GLfloat rScale, GLfloat gScale, - GLfloat bScale, GLfloat aScale, - GLfloat rBias, GLfloat gBias, - GLfloat bBias, GLfloat aBias) -{ - if (rScale != 1.0 || rBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = rgba[i][RCOMP] * rScale + rBias; - } - } - if (gScale != 1.0 || gBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][GCOMP] = rgba[i][GCOMP] * gScale + gBias; - } - } - if (bScale != 1.0 || bBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][BCOMP] = rgba[i][BCOMP] * bScale + bBias; - } - } - if (aScale != 1.0 || aBias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias; - } - } -} - - -/* - * Apply pixel mapping to an array of floating point RGBA pixels. - */ -void -_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) -{ - const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); - const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); - const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); - const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); - const GLfloat *rMap = ctx->PixelMaps.RtoR.Map; - const GLfloat *gMap = ctx->PixelMaps.GtoG.Map; - const GLfloat *bMap = ctx->PixelMaps.BtoB.Map; - const GLfloat *aMap = ctx->PixelMaps.AtoA.Map; - GLuint i; - for (i=0;iPixel.PostColorMatrixScale[0]; - const GLfloat rb = ctx->Pixel.PostColorMatrixBias[0]; - const GLfloat gs = ctx->Pixel.PostColorMatrixScale[1]; - const GLfloat gb = ctx->Pixel.PostColorMatrixBias[1]; - const GLfloat bs = ctx->Pixel.PostColorMatrixScale[2]; - const GLfloat bb = ctx->Pixel.PostColorMatrixBias[2]; - const GLfloat as = ctx->Pixel.PostColorMatrixScale[3]; - const GLfloat ab = ctx->Pixel.PostColorMatrixBias[3]; - const GLfloat *m = ctx->ColorMatrixStack.Top->m; - GLuint i; - for (i = 0; i < n; i++) { - const GLfloat r = rgba[i][RCOMP]; - const GLfloat g = rgba[i][GCOMP]; - const GLfloat b = rgba[i][BCOMP]; - const GLfloat a = rgba[i][ACOMP]; - rgba[i][RCOMP] = (m[0] * r + m[4] * g + m[ 8] * b + m[12] * a) * rs + rb; - rgba[i][GCOMP] = (m[1] * r + m[5] * g + m[ 9] * b + m[13] * a) * gs + gb; - rgba[i][BCOMP] = (m[2] * r + m[6] * g + m[10] * b + m[14] * a) * bs + bb; - rgba[i][ACOMP] = (m[3] * r + m[7] * g + m[11] * b + m[15] * a) * as + ab; - } -} - - -/** - * Apply a color table lookup to an array of floating point RGBA colors. - */ -void -_mesa_lookup_rgba_float(const struct gl_color_table *table, - GLuint n, GLfloat rgba[][4]) -{ - const GLint max = table->Size - 1; - const GLfloat scale = (GLfloat) max; - const GLfloat *lut = table->TableF; - GLuint i; - - if (!table->TableF || table->Size == 0) - return; - - switch (table->_BaseFormat) { - case GL_INTENSITY: - /* replace RGBA with I */ - for (i = 0; i < n; i++) { - GLint j = IROUND(rgba[i][RCOMP] * scale); - GLfloat c = lut[CLAMP(j, 0, max)]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = - rgba[i][ACOMP] = c; - } - break; - case GL_LUMINANCE: - /* replace RGB with L */ - for (i = 0; i < n; i++) { - GLint j = IROUND(rgba[i][RCOMP] * scale); - GLfloat c = lut[CLAMP(j, 0, max)]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = c; - } - break; - case GL_ALPHA: - /* replace A with A */ - for (i = 0; i < n; i++) { - GLint j = IROUND(rgba[i][ACOMP] * scale); - rgba[i][ACOMP] = lut[CLAMP(j, 0, max)]; - } - break; - case GL_LUMINANCE_ALPHA: - /* replace RGBA with LLLA */ - for (i = 0; i < n; i++) { - GLint jL = IROUND(rgba[i][RCOMP] * scale); - GLint jA = IROUND(rgba[i][ACOMP] * scale); - GLfloat luminance, alpha; - jL = CLAMP(jL, 0, max); - jA = CLAMP(jA, 0, max); - luminance = lut[jL * 2 + 0]; - alpha = lut[jA * 2 + 1]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = luminance; - rgba[i][ACOMP] = alpha;; - } - break; - case GL_RGB: - /* replace RGB with RGB */ - for (i = 0; i < n; i++) { - GLint jR = IROUND(rgba[i][RCOMP] * scale); - GLint jG = IROUND(rgba[i][GCOMP] * scale); - GLint jB = IROUND(rgba[i][BCOMP] * scale); - jR = CLAMP(jR, 0, max); - jG = CLAMP(jG, 0, max); - jB = CLAMP(jB, 0, max); - rgba[i][RCOMP] = lut[jR * 3 + 0]; - rgba[i][GCOMP] = lut[jG * 3 + 1]; - rgba[i][BCOMP] = lut[jB * 3 + 2]; - } - break; - case GL_RGBA: - /* replace RGBA with RGBA */ - for (i = 0; i < n; i++) { - GLint jR = IROUND(rgba[i][RCOMP] * scale); - GLint jG = IROUND(rgba[i][GCOMP] * scale); - GLint jB = IROUND(rgba[i][BCOMP] * scale); - GLint jA = IROUND(rgba[i][ACOMP] * scale); - jR = CLAMP(jR, 0, max); - jG = CLAMP(jG, 0, max); - jB = CLAMP(jB, 0, max); - jA = CLAMP(jA, 0, max); - rgba[i][RCOMP] = lut[jR * 4 + 0]; - rgba[i][GCOMP] = lut[jG * 4 + 1]; - rgba[i][BCOMP] = lut[jB * 4 + 2]; - rgba[i][ACOMP] = lut[jA * 4 + 3]; - } - break; - default: - _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_float"); - return; - } -} - - - -/** - * Apply a color table lookup to an array of ubyte/RGBA colors. - */ -void -_mesa_lookup_rgba_ubyte(const struct gl_color_table *table, - GLuint n, GLubyte rgba[][4]) -{ - const GLubyte *lut = table->TableUB; - const GLfloat scale = (GLfloat) (table->Size - 1) / (GLfloat)255.0; - GLuint i; - - if (!table->TableUB || table->Size == 0) - return; - - switch (table->_BaseFormat) { - case GL_INTENSITY: - /* replace RGBA with I */ - if (table->Size == 256) { - for (i = 0; i < n; i++) { - const GLubyte c = lut[rgba[i][RCOMP]]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = - rgba[i][ACOMP] = c; - } - } - else { - for (i = 0; i < n; i++) { - GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale); - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = - rgba[i][ACOMP] = lut[j]; - } - } - break; - case GL_LUMINANCE: - /* replace RGB with L */ - if (table->Size == 256) { - for (i = 0; i < n; i++) { - const GLubyte c = lut[rgba[i][RCOMP]]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = c; - } - } - else { - for (i = 0; i < n; i++) { - GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale); - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = lut[j]; - } - } - break; - case GL_ALPHA: - /* replace A with A */ - if (table->Size == 256) { - for (i = 0; i < n; i++) { - rgba[i][ACOMP] = lut[rgba[i][ACOMP]]; - } - } - else { - for (i = 0; i < n; i++) { - GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale); - rgba[i][ACOMP] = lut[j]; - } - } - break; - case GL_LUMINANCE_ALPHA: - /* replace RGBA with LLLA */ - if (table->Size == 256) { - for (i = 0; i < n; i++) { - GLubyte l = lut[rgba[i][RCOMP] * 2 + 0]; - GLubyte a = lut[rgba[i][ACOMP] * 2 + 1];; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = l; - rgba[i][ACOMP] = a; - } - } - else { - for (i = 0; i < n; i++) { - GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale); - GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale); - GLubyte luminance = lut[jL * 2 + 0]; - GLubyte alpha = lut[jA * 2 + 1]; - rgba[i][RCOMP] = - rgba[i][GCOMP] = - rgba[i][BCOMP] = luminance; - rgba[i][ACOMP] = alpha; - } - } - break; - case GL_RGB: - if (table->Size == 256) { - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0]; - rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1]; - rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2]; - } - } - else { - for (i = 0; i < n; i++) { - GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale); - GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale); - GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale); - rgba[i][RCOMP] = lut[jR * 3 + 0]; - rgba[i][GCOMP] = lut[jG * 3 + 1]; - rgba[i][BCOMP] = lut[jB * 3 + 2]; - } - } - break; - case GL_RGBA: - if (table->Size == 256) { - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0]; - rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1]; - rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2]; - rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3]; - } - } - else { - for (i = 0; i < n; i++) { - GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale); - GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale); - GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale); - GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale); - CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]); - CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]); - CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]); - CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]); - } - } - break; - default: - _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_chan"); - return; - } -} - - - -/* - * Map color indexes to float rgba values. - */ -void -_mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n, - const GLuint index[], GLfloat rgba[][4] ) -{ - GLuint rmask = ctx->PixelMaps.ItoR.Size - 1; - GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; - GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; - GLuint amask = ctx->PixelMaps.ItoA.Size - 1; - const GLfloat *rMap = ctx->PixelMaps.ItoR.Map; - const GLfloat *gMap = ctx->PixelMaps.ItoG.Map; - const GLfloat *bMap = ctx->PixelMaps.ItoB.Map; - const GLfloat *aMap = ctx->PixelMaps.ItoA.Map; - GLuint i; - for (i=0;iPixelMaps.ItoR.Size - 1; - GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; - GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; - GLuint amask = ctx->PixelMaps.ItoA.Size - 1; - const GLubyte *rMap = ctx->PixelMaps.ItoR.Map8; - const GLubyte *gMap = ctx->PixelMaps.ItoG.Map8; - const GLubyte *bMap = ctx->PixelMaps.ItoB.Map8; - const GLubyte *aMap = ctx->PixelMaps.ItoA.Map8; - GLuint i; - for (i=0;iPixel.DepthScale; - const GLfloat bias = ctx->Pixel.DepthBias; - GLuint i; - for (i = 0; i < n; i++) { - GLfloat d = depthValues[i] * scale + bias; - depthValues[i] = CLAMP(d, 0.0F, 1.0F); - } -} - - -void -_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n, - GLuint depthValues[]) -{ - const GLdouble max = (double) 0xffffffff; - const GLdouble scale = ctx->Pixel.DepthScale; - const GLdouble bias = ctx->Pixel.DepthBias * max; - GLuint i; - for (i = 0; i < n; i++) { - GLdouble d = (GLdouble) depthValues[i] * scale + bias; - d = CLAMP(d, 0.0, max); - depthValues[i] = (GLuint) d; - } -} - - - -/* - * Update the min/max values from an array of fragment colors. - */ -static void -update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) -{ - GLuint i; - for (i = 0; i < n; i++) { - /* update mins */ - if (rgba[i][RCOMP] < ctx->MinMax.Min[RCOMP]) - ctx->MinMax.Min[RCOMP] = rgba[i][RCOMP]; - if (rgba[i][GCOMP] < ctx->MinMax.Min[GCOMP]) - ctx->MinMax.Min[GCOMP] = rgba[i][GCOMP]; - if (rgba[i][BCOMP] < ctx->MinMax.Min[BCOMP]) - ctx->MinMax.Min[BCOMP] = rgba[i][BCOMP]; - if (rgba[i][ACOMP] < ctx->MinMax.Min[ACOMP]) - ctx->MinMax.Min[ACOMP] = rgba[i][ACOMP]; - - /* update maxs */ - if (rgba[i][RCOMP] > ctx->MinMax.Max[RCOMP]) - ctx->MinMax.Max[RCOMP] = rgba[i][RCOMP]; - if (rgba[i][GCOMP] > ctx->MinMax.Max[GCOMP]) - ctx->MinMax.Max[GCOMP] = rgba[i][GCOMP]; - if (rgba[i][BCOMP] > ctx->MinMax.Max[BCOMP]) - ctx->MinMax.Max[BCOMP] = rgba[i][BCOMP]; - if (rgba[i][ACOMP] > ctx->MinMax.Max[ACOMP]) - ctx->MinMax.Max[ACOMP] = rgba[i][ACOMP]; - } -} - - -/* - * Update the histogram values from an array of fragment colors. - */ -static void -update_histogram(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) -{ - const GLint max = ctx->Histogram.Width - 1; - GLfloat w = (GLfloat) max; - GLuint i; - - if (ctx->Histogram.Width == 0) - return; - - for (i = 0; i < n; i++) { - GLint ri = IROUND(rgba[i][RCOMP] * w); - GLint gi = IROUND(rgba[i][GCOMP] * w); - GLint bi = IROUND(rgba[i][BCOMP] * w); - GLint ai = IROUND(rgba[i][ACOMP] * w); - ri = CLAMP(ri, 0, max); - gi = CLAMP(gi, 0, max); - bi = CLAMP(bi, 0, max); - ai = CLAMP(ai, 0, max); - ctx->Histogram.Count[ri][RCOMP]++; - ctx->Histogram.Count[gi][GCOMP]++; - ctx->Histogram.Count[bi][BCOMP]++; - ctx->Histogram.Count[ai][ACOMP]++; - } -} - - -/** - * Apply various pixel transfer operations to an array of RGBA pixels - * as indicated by the transferOps bitmask - */ -void -_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, - GLuint n, GLfloat rgba[][4]) -{ - /* scale & bias */ - if (transferOps & IMAGE_SCALE_BIAS_BIT) { - _mesa_scale_and_bias_rgba(n, rgba, - ctx->Pixel.RedScale, ctx->Pixel.GreenScale, - ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale, - ctx->Pixel.RedBias, ctx->Pixel.GreenBias, - ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias); - } - /* color map lookup */ - if (transferOps & IMAGE_MAP_COLOR_BIT) { - _mesa_map_rgba( ctx, n, rgba ); - } - /* GL_COLOR_TABLE lookup */ - if (transferOps & IMAGE_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_PRECONVOLUTION], n, rgba); - } - /* convolution */ - if (transferOps & IMAGE_CONVOLUTION_BIT) { - /* this has to be done in the calling code */ - _mesa_problem(ctx, "IMAGE_CONVOLUTION_BIT set in _mesa_apply_transfer_ops"); - } - /* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */ - if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) { - _mesa_scale_and_bias_rgba(n, rgba, - ctx->Pixel.PostConvolutionScale[RCOMP], - ctx->Pixel.PostConvolutionScale[GCOMP], - ctx->Pixel.PostConvolutionScale[BCOMP], - ctx->Pixel.PostConvolutionScale[ACOMP], - ctx->Pixel.PostConvolutionBias[RCOMP], - ctx->Pixel.PostConvolutionBias[GCOMP], - ctx->Pixel.PostConvolutionBias[BCOMP], - ctx->Pixel.PostConvolutionBias[ACOMP]); - } - /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */ - if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCONVOLUTION], n, rgba); - } - /* color matrix transform */ - if (transferOps & IMAGE_COLOR_MATRIX_BIT) { - _mesa_transform_rgba(ctx, n, rgba); - } - /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ - if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) { - _mesa_lookup_rgba_float(&ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX], n, rgba); - } - /* update histogram count */ - if (transferOps & IMAGE_HISTOGRAM_BIT) { - update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba); - } - /* update min/max values */ - if (transferOps & IMAGE_MIN_MAX_BIT) { - update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); - } - /* clamping to [0,1] */ - if (transferOps & IMAGE_CLAMP_BIT) { - GLuint i; - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); - rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); - rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); - rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); - } - } -} - - -/* - * Apply color index shift and offset to an array of pixels. - */ -static void -shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) -{ - GLint shift = ctx->Pixel.IndexShift; - GLint offset = ctx->Pixel.IndexOffset; - GLuint i; - if (shift > 0) { - for (i=0;i> shift) + offset; - } - } - else { - for (i=0;iPixelMaps.ItoI.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - const GLuint j = indexes[i] & mask; - indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]); - } - } -} - - -/** - * Apply stencil index shift, offset and table lookup to an array - * of stencil values. - */ -void -_mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, - GLstencil stencil[]) -{ - if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) { - const GLint offset = ctx->Pixel.IndexOffset; - GLint shift = ctx->Pixel.IndexShift; - GLuint i; - if (shift > 0) { - for (i = 0; i < n; i++) { - stencil[i] = (stencil[i] << shift) + offset; - } - } - else if (shift < 0) { - shift = -shift; - for (i = 0; i < n; i++) { - stencil[i] = (stencil[i] >> shift) + offset; - } - } - else { - for (i = 0; i < n; i++) { - stencil[i] = stencil[i] + offset; - } - } - } - if (ctx->Pixel.MapStencilFlag) { - GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - stencil[i] = (GLstencil)ctx->PixelMaps.StoS.Map[ stencil[i] & mask ]; - } - } -} - - -/** - * Used to pack an array [][4] of RGBA float colors as specified - * by the dstFormat, dstType and dstPacking. Used by glReadPixels, - * glGetConvolutionFilter(), etc. - * Note: the rgba values will be modified by this function when any pixel - * transfer ops are enabled. - */ -void -_mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps) -{ - GLfloat luminance[MAX_WIDTH]; - const GLint comps = _mesa_components_in_format(dstFormat); - GLuint i; - - /* XXX - * This test should probably go away. Have the caller set/clear the - * IMAGE_CLAMP_BIT as needed. - */ - if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { - /* need to clamp to [0, 1] */ - transferOps |= IMAGE_CLAMP_BIT; - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - if ((transferOps & IMAGE_MIN_MAX_BIT) && ctx->MinMax.Sink) { - return; - } - } - - if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { - /* compute luminance values */ - if (transferOps & IMAGE_CLAMP_BIT) { - for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - luminance[i] = CLAMP(sum, 0.0F, 1.0F); - } - } - else { - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - } - } - } - - /* - * Pack/store the pixels. Ugh! Lots of cases!!! - */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dstAddr; - switch (dstFormat) { - case GL_RED: - for (i=0;iSwapBytes) { - GLint swapSize = _mesa_sizeof_packed_type(dstType); - if (swapSize == 2) { - if (dstPacking->SwapBytes) { - _mesa_swap2((GLushort *) dstAddr, n * comps); - } - } - else if (swapSize == 4) { - if (dstPacking->SwapBytes) { - _mesa_swap4((GLuint *) dstAddr, n * comps); - } - } - } -} - - -#define SWAP2BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[1]; \ - bytes[1] = tmp; \ - } - -#define SWAP4BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[3]; \ - bytes[3] = tmp; \ - tmp = bytes[1]; \ - bytes[1] = bytes[2]; \ - bytes[2] = tmp; \ - } - - -static void -extract_uint_indexes(GLuint n, GLuint indexes[], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - const struct gl_pixelstore_attrib *unpack ) -{ - ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_UNSIGNED_INT_24_8_EXT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - switch (srcType) { - case GL_BITMAP: - { - GLubyte *ubsrc = (GLubyte *) src; - if (unpack->LsbFirst) { - GLubyte mask = 1 << (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 128) { - mask = 1; - ubsrc++; - } - else { - mask = mask << 1; - } - } - } - else { - GLubyte mask = 128 >> (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 1) { - mask = 128; - ubsrc++; - } - else { - mask = mask >> 1; - } - } - } - } - break; - case GL_UNSIGNED_BYTE: - { - GLuint i; - const GLubyte *s = (const GLubyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_BYTE: - { - GLuint i; - const GLbyte *s = (const GLbyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint i; - const GLushort *s = (const GLushort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLushort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_SHORT: - { - GLuint i; - const GLshort *s = (const GLshort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLshort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_INT: - { - GLuint i; - const GLint *s = (const GLint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_FLOAT: - { - GLuint i; - const GLfloat *s = (const GLfloat *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLfloat value = s[i]; - SWAP4BYTE(value); - indexes[i] = (GLuint) value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = (GLuint) s[i]; - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLuint i; - const GLhalfARB *s = (const GLhalfARB *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLhalfARB value = s[i]; - SWAP2BYTE(value); - indexes[i] = (GLuint) _mesa_half_to_float(value); - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = (GLuint) _mesa_half_to_float(s[i]); - } - } - break; - case GL_UNSIGNED_INT_24_8_EXT: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value & 0xff; /* lower 8 bits */ - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i] & 0xff; /* lower 8 bits */ - } - } - break; - - default: - _mesa_problem(NULL, "bad srcType in extract_uint_indexes"); - return; - } -} - - -/* - * This function extracts floating point RGBA values from arbitrary - * image data. srcFormat and srcType are the format and type parameters - * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc. - * - * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function - * implements the "Conversion to floating point", "Conversion to RGB", - * and "Final Expansion to RGBA" operations. - * - * Args: n - number of pixels - * rgba - output colors - * srcFormat - format of incoming data - * srcType - data type of incoming data - * src - source data pointer - * swapBytes - perform byteswapping of incoming data? - */ -static void -extract_float_rgba(GLuint n, GLfloat rgba[][4], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - GLboolean swapBytes) -{ - GLint redIndex, greenIndex, blueIndex, alphaIndex; - GLint stride; - GLint rComp, bComp, gComp, aComp; - GLboolean intFormat; - GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */ - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_DU8DV8_ATI || - srcFormat == GL_DUDV_ATI || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - - rComp = gComp = bComp = aComp = -1; - - switch (srcFormat) { - case GL_RED: - case GL_RED_INTEGER_EXT: - redIndex = 0; - greenIndex = blueIndex = alphaIndex = -1; - stride = 1; - break; - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - greenIndex = 0; - redIndex = blueIndex = alphaIndex = -1; - stride = 1; - break; - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - blueIndex = 0; - redIndex = greenIndex = alphaIndex = -1; - stride = 1; - break; - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - redIndex = greenIndex = blueIndex = -1; - alphaIndex = 0; - stride = 1; - break; - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - redIndex = greenIndex = blueIndex = 0; - alphaIndex = -1; - stride = 1; - break; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - redIndex = greenIndex = blueIndex = 0; - alphaIndex = 1; - stride = 2; - break; - case GL_INTENSITY: - redIndex = greenIndex = blueIndex = alphaIndex = 0; - stride = 1; - break; - case GL_RGB: - case GL_RGB_INTEGER: - redIndex = 0; - greenIndex = 1; - blueIndex = 2; - alphaIndex = -1; - rComp = 0; - gComp = 1; - bComp = 2; - aComp = 3; - stride = 3; - break; - case GL_BGR: - redIndex = 2; - greenIndex = 1; - blueIndex = 0; - alphaIndex = -1; - rComp = 2; - gComp = 1; - bComp = 0; - aComp = 3; - stride = 3; - break; - case GL_RGBA: - case GL_RGBA_INTEGER: - redIndex = 0; - greenIndex = 1; - blueIndex = 2; - alphaIndex = 3; - rComp = 0; - gComp = 1; - bComp = 2; - aComp = 3; - stride = 4; - break; - case GL_BGRA: - redIndex = 2; - greenIndex = 1; - blueIndex = 0; - alphaIndex = 3; - rComp = 2; - gComp = 1; - bComp = 0; - aComp = 3; - stride = 4; - break; - case GL_ABGR_EXT: - redIndex = 3; - greenIndex = 2; - blueIndex = 1; - alphaIndex = 0; - rComp = 3; - gComp = 2; - bComp = 1; - aComp = 0; - stride = 4; - break; - case GL_DU8DV8_ATI: - case GL_DUDV_ATI: - redIndex = 0; - greenIndex = 1; - blueIndex = -1; - alphaIndex = -1; - stride = 2; - break; - default: - _mesa_problem(NULL, "bad srcFormat %s in extract float data", - _mesa_lookup_enum_by_nr(srcFormat)); - return; - } - - intFormat = _mesa_is_integer_format(srcFormat); - -#define PROCESS(INDEX, CHANNEL, DEFAULT, DEFAULT_INT, TYPE, CONVERSION) \ - if ((INDEX) < 0) { \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][CHANNEL] = DEFAULT_INT; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][CHANNEL] = DEFAULT; \ - } \ - } \ - } \ - else if (swapBytes) { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - TYPE value = s[INDEX]; \ - if (sizeof(TYPE) == 2) { \ - SWAP2BYTE(value); \ - } \ - else if (sizeof(TYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - if (intFormat) \ - rgba[i][CHANNEL] = (GLfloat) value; \ - else \ - rgba[i][CHANNEL] = (GLfloat) CONVERSION(value); \ - s += stride; \ - } \ - } \ - else { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][CHANNEL] = (GLfloat) s[INDEX]; \ - s += stride; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][CHANNEL] = (GLfloat) CONVERSION(s[INDEX]); \ - s += stride; \ - } \ - } \ - } - - switch (srcType) { - case GL_UNSIGNED_BYTE: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT); - break; - case GL_BYTE: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT); - break; - case GL_UNSIGNED_SHORT: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT); - break; - case GL_SHORT: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT); - break; - case GL_UNSIGNED_INT: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT); - break; - case GL_INT: - PROCESS(redIndex, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(greenIndex, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(blueIndex, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(alphaIndex, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT); - break; - case GL_FLOAT: - PROCESS(redIndex, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(greenIndex, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(blueIndex, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(alphaIndex, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); - break; - case GL_HALF_FLOAT_ARB: - PROCESS(redIndex, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(greenIndex, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(blueIndex, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(alphaIndex, ACOMP, 1.0F, 1.0F, GLhalfARB, _mesa_half_to_float); - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rComp] = ((p >> 5) ) * rs; - rgba[i][gComp] = ((p >> 2) & 0x7) * gs; - rgba[i][bComp] = ((p ) & 0x3) * bs; - rgba[i][aComp] = 1.0F; - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rComp] = ((p ) & 0x7) * rs; - rgba[i][gComp] = ((p >> 3) & 0x7) * gs; - rgba[i][bComp] = ((p >> 6) ) * bs; - rgba[i][aComp] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p >> 11) ) * rs; - rgba[i][gComp] = ((p >> 5) & 0x3f) * gs; - rgba[i][bComp] = ((p ) & 0x1f) * bs; - rgba[i][aComp] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p >> 11) ) * rs; - rgba[i][gComp] = ((p >> 5) & 0x3f) * gs; - rgba[i][bComp] = ((p ) & 0x1f) * bs; - rgba[i][aComp] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p ) & 0x1f) * rs; - rgba[i][gComp] = ((p >> 5) & 0x3f) * gs; - rgba[i][bComp] = ((p >> 11) ) * bs; - rgba[i][aComp] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p ) & 0x1f) * rs; - rgba[i][gComp] = ((p >> 5) & 0x3f) * gs; - rgba[i][bComp] = ((p >> 11) ) * bs; - rgba[i][aComp] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p >> 12) ) * rs; - rgba[i][gComp] = ((p >> 8) & 0xf) * gs; - rgba[i][bComp] = ((p >> 4) & 0xf) * bs; - rgba[i][aComp] = ((p ) & 0xf) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p >> 12) ) * rs; - rgba[i][gComp] = ((p >> 8) & 0xf) * gs; - rgba[i][bComp] = ((p >> 4) & 0xf) * bs; - rgba[i][aComp] = ((p ) & 0xf) * as; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p ) & 0xf) * rs; - rgba[i][gComp] = ((p >> 4) & 0xf) * gs; - rgba[i][bComp] = ((p >> 8) & 0xf) * bs; - rgba[i][aComp] = ((p >> 12) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p ) & 0xf) * rs; - rgba[i][gComp] = ((p >> 4) & 0xf) * gs; - rgba[i][bComp] = ((p >> 8) & 0xf) * bs; - rgba[i][aComp] = ((p >> 12) ) * as; - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p >> 11) ) * rs; - rgba[i][gComp] = ((p >> 6) & 0x1f) * gs; - rgba[i][bComp] = ((p >> 1) & 0x1f) * bs; - rgba[i][aComp] = ((p ) & 0x1) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p >> 11) ) * rs; - rgba[i][gComp] = ((p >> 6) & 0x1f) * gs; - rgba[i][bComp] = ((p >> 1) & 0x1f) * bs; - rgba[i][aComp] = ((p ) & 0x1) * as; - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rComp] = ((p ) & 0x1f) * rs; - rgba[i][gComp] = ((p >> 5) & 0x1f) * gs; - rgba[i][bComp] = ((p >> 10) & 0x1f) * bs; - rgba[i][aComp] = ((p >> 15) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rComp] = ((p ) & 0x1f) * rs; - rgba[i][gComp] = ((p >> 5) & 0x1f) * gs; - rgba[i][bComp] = ((p >> 10) & 0x1f) * bs; - rgba[i][aComp] = ((p >> 15) ) * as; - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = (GLfloat) ((p ) & 0xff); - rgba[i][gComp] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bComp] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aComp] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = (GLfloat) ((p >> 24) ); - rgba[i][gComp] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bComp] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aComp] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = (GLfloat) ((p >> 24) ); - rgba[i][gComp] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bComp] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aComp] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = (GLfloat) ((p ) & 0xff); - rgba[i][gComp] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bComp] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aComp] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - break; - case GL_UNSIGNED_INT_10_10_10_2: - if (!intFormat) { - rs = 1.0F / 1023.0F; - gs = 1.0F / 1023.0F; - bs = 1.0F / 1023.0F; - as = 1.0F / 3.0F; - } - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rComp] = ((p >> 22) ) * rs; - rgba[i][gComp] = ((p >> 12) & 0x3ff) * gs; - rgba[i][bComp] = ((p >> 2) & 0x3ff) * bs; - rgba[i][aComp] = ((p ) & 0x3 ) * as; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = ((p >> 22) ) * rs; - rgba[i][gComp] = ((p >> 12) & 0x3ff) * gs; - rgba[i][bComp] = ((p >> 2) & 0x3ff) * bs; - rgba[i][aComp] = ((p ) & 0x3 ) * as; - } - } - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (!intFormat) { - rs = 1.0F / 1023.0F; - gs = 1.0F / 1023.0F; - bs = 1.0F / 1023.0F; - as = 1.0F / 3.0F; - } - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rComp] = ((p ) & 0x3ff) * rs; - rgba[i][gComp] = ((p >> 10) & 0x3ff) * gs; - rgba[i][bComp] = ((p >> 20) & 0x3ff) * bs; - rgba[i][aComp] = ((p >> 30) ) * as; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rComp] = ((p ) & 0x3ff) * rs; - rgba[i][gComp] = ((p >> 10) & 0x3ff) * gs; - rgba[i][bComp] = ((p >> 20) & 0x3ff) * bs; - rgba[i][aComp] = ((p >> 30) ) * as; - } - } - break; - default: - _mesa_problem(NULL, "bad srcType in extract float data"); - break; - } -} - - -/* - * Unpack a row of color image data from a client buffer according to - * the pixel unpacking parameters. - * Return GLchan values in the specified dest image format. - * This is used by glDrawPixels and glTexImage?D(). - * \param ctx - the context - * n - number of pixels in the span - * dstFormat - format of destination color array - * dest - the destination color array - * srcFormat - source image format - * srcType - source image data type - * source - source image pointer - * srcPacking - pixel unpacking parameters - * transferOps - bitmask of IMAGE_*_BIT values of operations to apply - * - * XXX perhaps expand this to process whole images someday. - */ -void -_mesa_unpack_color_span_chan( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLchan dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RGB || - dstFormat == GL_RGBA || - dstFormat == GL_COLOR_INDEX); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - - /* Try simple cases first */ - if (transferOps == 0) { - if (srcType == CHAN_TYPE) { - if (dstFormat == GL_RGBA) { - if (srcFormat == GL_RGBA) { - memcpy( dest, source, n * 4 * sizeof(GLchan) ); - return; - } - else if (srcFormat == GL_RGB) { - GLuint i; - const GLchan *src = (const GLchan *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = CHAN_MAX; - src += 3; - dst += 4; - } - return; - } - } - else if (dstFormat == GL_RGB) { - if (srcFormat == GL_RGB) { - memcpy( dest, source, n * 3 * sizeof(GLchan) ); - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLchan *src = (const GLchan *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 4; - dst += 3; - } - return; - } - } - else if (dstFormat == srcFormat) { - GLint comps = _mesa_components_in_format(srcFormat); - assert(comps > 0); - memcpy( dest, source, n * comps * sizeof(GLchan) ); - return; - } - } - /* - * Common situation, loading 8bit RGBA/RGB source images - * into 16/32 bit destination. (OSMesa16/32) - */ - else if (srcType == GL_UNSIGNED_BYTE) { - if (dstFormat == GL_RGBA) { - if (srcFormat == GL_RGB) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - dst[3] = CHAN_MAX; - src += 3; - dst += 4; - } - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - dst[3] = UBYTE_TO_CHAN(src[3]); - src += 4; - dst += 4; - } - return; - } - } - else if (dstFormat == GL_RGB) { - if (srcFormat == GL_RGB) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - src += 3; - dst += 3; - } - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - src += 4; - dst += 3; - } - return; - } - } - } - } - - - /* general solution begins here */ - { - GLint dstComponents; - GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; - GLint dstLuminanceIndex, dstIntensityIndex; - GLfloat rgba[MAX_WIDTH][4]; - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - assert(n <= MAX_WIDTH); - if (srcFormat == GL_COLOR_INDEX) { - GLuint indexes[MAX_WIDTH]; - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - if (dstFormat == GL_COLOR_INDEX) { - GLuint i; - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - /* convert to GLchan and return */ - for (i = 0; i < n; i++) { - dest[i] = (GLchan) (indexes[i] & 0xff); - } - return; - } - else { - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - } - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - /* Need to clamp if returning GLubytes or GLushorts */ -#if CHAN_TYPE != GL_FLOAT - transferOps |= IMAGE_CLAMP_BIT; -#endif - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - /* Now determine which color channels we need to produce. - * And determine the dest index (offset) within each color tuple. - */ - switch (dstFormat) { - case GL_ALPHA: - dstAlphaIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = -1; - dstLuminanceIndex = dstIntensityIndex = -1; - break; - case GL_LUMINANCE: - dstLuminanceIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; - dstIntensityIndex = -1; - break; - case GL_LUMINANCE_ALPHA: - dstLuminanceIndex = 0; - dstAlphaIndex = 1; - dstRedIndex = dstGreenIndex = dstBlueIndex = -1; - dstIntensityIndex = -1; - break; - case GL_INTENSITY: - dstIntensityIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; - dstLuminanceIndex = -1; - break; - case GL_RGB: - dstRedIndex = 0; - dstGreenIndex = 1; - dstBlueIndex = 2; - dstAlphaIndex = dstLuminanceIndex = dstIntensityIndex = -1; - break; - case GL_RGBA: - dstRedIndex = 0; - dstGreenIndex = 1; - dstBlueIndex = 2; - dstAlphaIndex = 3; - dstLuminanceIndex = dstIntensityIndex = -1; - break; - default: - _mesa_problem(ctx, "bad dstFormat in _mesa_unpack_chan_span()"); - return; - } - - - /* Now return the GLchan data in the requested dstFormat */ - - if (dstRedIndex >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[dstRedIndex], rgba[i][RCOMP]); - dst += dstComponents; - } - } - - if (dstGreenIndex >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[dstGreenIndex], rgba[i][GCOMP]); - dst += dstComponents; - } - } - - if (dstBlueIndex >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[dstBlueIndex], rgba[i][BCOMP]); - dst += dstComponents; - } - } - - if (dstAlphaIndex >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[dstAlphaIndex], rgba[i][ACOMP]); - dst += dstComponents; - } - } - - if (dstIntensityIndex >= 0) { - GLchan *dst = dest; - GLuint i; - assert(dstIntensityIndex == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]); - } - } - - if (dstLuminanceIndex >= 0) { - GLchan *dst = dest; - GLuint i; - assert(dstLuminanceIndex == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]); - dst += dstComponents; - } - } - } -} - - -/** - * Same as _mesa_unpack_color_span_chan(), but return GLfloat data - * instead of GLchan. - */ -void -_mesa_unpack_color_span_float( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLfloat dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RGB || - dstFormat == GL_RGBA || - dstFormat == GL_COLOR_INDEX); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - - /* general solution, no special cases, yet */ - { - GLint dstComponents; - GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; - GLint dstLuminanceIndex, dstIntensityIndex; - GLfloat rgba[MAX_WIDTH][4]; - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - assert(n <= MAX_WIDTH); - if (srcFormat == GL_COLOR_INDEX) { - GLuint indexes[MAX_WIDTH]; - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - if (dstFormat == GL_COLOR_INDEX) { - GLuint i; - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - /* convert to GLchan and return */ - for (i = 0; i < n; i++) { - dest[i] = (GLchan) (indexes[i] & 0xff); - } - return; - } - else { - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - } - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - /* Now determine which color channels we need to produce. - * And determine the dest index (offset) within each color tuple. - */ - switch (dstFormat) { - case GL_ALPHA: - dstAlphaIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = -1; - dstLuminanceIndex = dstIntensityIndex = -1; - break; - case GL_LUMINANCE: - dstLuminanceIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; - dstIntensityIndex = -1; - break; - case GL_LUMINANCE_ALPHA: - dstLuminanceIndex = 0; - dstAlphaIndex = 1; - dstRedIndex = dstGreenIndex = dstBlueIndex = -1; - dstIntensityIndex = -1; - break; - case GL_INTENSITY: - dstIntensityIndex = 0; - dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; - dstLuminanceIndex = -1; - break; - case GL_RGB: - dstRedIndex = 0; - dstGreenIndex = 1; - dstBlueIndex = 2; - dstAlphaIndex = dstLuminanceIndex = dstIntensityIndex = -1; - break; - case GL_RGBA: - dstRedIndex = 0; - dstGreenIndex = 1; - dstBlueIndex = 2; - dstAlphaIndex = 3; - dstLuminanceIndex = dstIntensityIndex = -1; - break; - default: - _mesa_problem(ctx, "bad dstFormat in _mesa_unpack_color_span_float()"); - return; - } - - /* Now pack results in the requested dstFormat */ - if (dstRedIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[dstRedIndex] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - if (dstGreenIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[dstGreenIndex] = rgba[i][GCOMP]; - dst += dstComponents; - } - } - - if (dstBlueIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[dstBlueIndex] = rgba[i][BCOMP]; - dst += dstComponents; - } - } - - if (dstAlphaIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[dstAlphaIndex] = rgba[i][ACOMP]; - dst += dstComponents; - } - } - - if (dstIntensityIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(dstIntensityIndex == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - dst[i] = rgba[i][RCOMP]; - } - } - - if (dstLuminanceIndex >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(dstLuminanceIndex == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - dst[0] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - } -} - -/** - * Similar to _mesa_unpack_color_span_float(), but for dudv data instead of rgba, - * directly return GLbyte data, no transfer ops apply. - */ -void -_mesa_unpack_dudv_span_byte( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLbyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_DUDV_ATI); - ASSERT(srcFormat == GL_DUDV_ATI); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - /* general solution */ - { - GLint dstComponents; - GLfloat rgba[MAX_WIDTH][4]; - GLbyte *dst = dest; - GLuint i; - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - assert(n <= MAX_WIDTH); - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - - - /* Now determine which color channels we need to produce. - * And determine the dest index (offset) within each color tuple. - */ - - /* Now pack results in the requested dstFormat */ - for (i = 0; i < n; i++) { - /* not sure - need clamp[-1,1] here? */ - dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst += dstComponents; - } - } -} - -/* - * Unpack a row of color index data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc. - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - the pixel transfer operations to apply - */ -void -_mesa_unpack_index_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT); - - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - /* - * Try simple cases first - */ - if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE - && dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && srcType == GL_UNSIGNED_INT - && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint indexes[MAX_WIDTH]; - assert(n <= MAX_WIDTH); - - extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, - srcPacking); - - if (transferOps) - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span"); - } - } -} - - -void -_mesa_pack_index_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLuint *source, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps ) -{ - GLuint indexes[MAX_WIDTH]; - - ASSERT(n <= MAX_WIDTH); - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) { - /* make a copy of input */ - memcpy(indexes, source, n * sizeof(GLuint)); - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - source = indexes; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - *dst++ = (GLubyte) source[i]; - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLbyte) source[i]; - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLshort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLuint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLfloat) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = _mesa_float_to_half((GLfloat) source[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } -} - - -/* - * Unpack a row of stencil data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - apply offset/bias/lookup ops? - */ -void -_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_UNSIGNED_INT_24_8_EXT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT); - - /* only shift and offset apply to stencil */ - transferOps &= IMAGE_SHIFT_OFFSET_BIT; - - /* - * Try simple cases first - */ - if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_BYTE && - dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_INT && - dstType == GL_UNSIGNED_INT && - !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint indexes[MAX_WIDTH]; - assert(n <= MAX_WIDTH); - - extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, - srcPacking); - - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - /* shift and offset indexes */ - shift_and_offset_ci(ctx, n, indexes); - } - - if (ctx->Pixel.MapStencilFlag) { - /* Apply stencil lookup table */ - const GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (GLuint)ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; - } - } - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); - } - } -} - - -void -_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLstencil *source, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLstencil stencil[MAX_WIDTH]; - - ASSERT(n <= MAX_WIDTH); - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || - ctx->Pixel.MapStencilFlag) { - /* make a copy of input */ - memcpy(stencil, source, n * sizeof(GLstencil)); - _mesa_apply_stencil_transfer_ops(ctx, n, stencil); - source = stencil; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - if (sizeof(GLstencil) == 1) { - memcpy( dest, source, n ); - } - else { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_BITMAP: - if (dstPacking->LsbFirst) { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 0; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 0) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift++; - if (shift == 8) { - shift = 0; - dst++; - } - } - } - else { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 7; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 7) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift--; - if (shift < 0) { - shift = 7; - dst++; - } - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } -} - -#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ - do { \ - GLuint i; \ - const GLTYPE *src = (const GLTYPE *)source; \ - for (i = 0; i < n; i++) { \ - GLTYPE value = src[i]; \ - if (srcPacking->SwapBytes) { \ - if (sizeof(GLTYPE) == 2) { \ - SWAP2BYTE(value); \ - } else if (sizeof(GLTYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - } \ - depthValues[i] = GLTYPE2FLOAT(value); \ - } \ - } while (0) - - -/** - * Unpack a row of depth/z values from memory, returning GLushort, GLuint - * or GLfloat values. - * The glPixelTransfer (scale/bias) params will be applied. - * - * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT - * \param depthMax max value for returned GLushort or GLuint values - * (ignored for GLfloat). - */ -void -_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLuint depthMax, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLfloat depthTemp[MAX_WIDTH], *depthValues; - GLboolean needClamp = GL_FALSE; - - /* Look for special cases first. - * Not only are these faster, they're less prone to numeric conversion - * problems. Otherwise, converting from an int type to a float then - * back to an int type can introduce errors that will show up as - * artifacts in things like depth peeling which uses glCopyTexImage. - */ - if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { - if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { - const GLuint *src = (const GLuint *) source; - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] >> 16; - } - return; - } - if (srcType == GL_UNSIGNED_SHORT - && dstType == GL_UNSIGNED_INT - && depthMax == 0xffffffff) { - const GLushort *src = (const GLushort *) source; - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] | (src[i] << 16); - } - return; - } - if (srcType == GL_UNSIGNED_INT_24_8 - && dstType == GL_UNSIGNED_INT - && depthMax == 0xffffff) { - const GLuint *src = (const GLuint *) source; - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] >> 8; - } - return; - } - /* XXX may want to add additional cases here someday */ - } - - /* general case path follows */ - - if (dstType == GL_FLOAT) { - depthValues = (GLfloat *) dest; - } - else { - depthValues = depthTemp; - } - - /* Convert incoming values to GLfloat. Some conversions will require - * clamping, below. - */ - switch (srcType) { - case GL_BYTE: - DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_BYTE: - DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); - break; - case GL_SHORT: - DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_SHORT: - DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); - break; - case GL_INT: - DEPTH_VALUES(GLint, INT_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_INT: - DEPTH_VALUES(GLuint, UINT_TO_FLOAT); - break; - case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ - if (dstType == GL_UNSIGNED_INT_24_8_EXT && - depthMax == 0xffffff && - ctx->Pixel.DepthScale == 1.0 && - ctx->Pixel.DepthBias == 0.0) { - const GLuint *src = (const GLuint *) source; - GLuint *zValues = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - GLuint value = src[i]; - if (srcPacking->SwapBytes) { - SWAP4BYTE(value); - } - zValues[i] = value & 0xffffff00; - } - return; - } - else { - const GLuint *src = (const GLuint *) source; - const GLfloat scale = 1.0f / 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - GLuint value = src[i]; - if (srcPacking->SwapBytes) { - SWAP4BYTE(value); - } - depthValues[i] = (value >> 8) * scale; - } - } - break; - case GL_FLOAT: - DEPTH_VALUES(GLfloat, 1*); - needClamp = GL_TRUE; - break; - case GL_HALF_FLOAT_ARB: - { - GLuint i; - const GLhalfARB *src = (const GLhalfARB *) source; - for (i = 0; i < n; i++) { - GLhalfARB value = src[i]; - if (srcPacking->SwapBytes) { - SWAP2BYTE(value); - } - depthValues[i] = _mesa_half_to_float(value); - } - needClamp = GL_TRUE; - } - break; - default: - _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()"); - return; - } - - /* apply depth scale and bias */ - { - const GLfloat scale = ctx->Pixel.DepthScale; - const GLfloat bias = ctx->Pixel.DepthBias; - if (scale != 1.0 || bias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = depthValues[i] * scale + bias; - } - needClamp = GL_TRUE; - } - } - - /* clamp to [0, 1] */ - if (needClamp) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = (GLfloat)CLAMP(depthValues[i], 0.0, 1.0); - } - } - - /* - * Convert values to dstType - */ - if (dstType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) dest; - GLuint i; - if (depthMax <= 0xffffff) { - /* no overflow worries */ - for (i = 0; i < n; i++) { - zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); - } - } - else { - /* need to use double precision to prevent overflow problems */ - for (i = 0; i < n; i++) { - GLdouble z = depthValues[i] * (GLfloat) depthMax; - if (z >= (GLdouble) 0xffffffff) - zValues[i] = 0xffffffff; - else - zValues[i] = (GLuint) z; - } - } - } - else if (dstType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) dest; - GLuint i; - ASSERT(depthMax <= 0xffff); - for (i = 0; i < n; i++) { - zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); - } - } - else { - ASSERT(dstType == GL_FLOAT); - /*ASSERT(depthMax == 1.0F);*/ - } -} - - -/* - * Pack an array of depth values. The values are floats in [0,1]. - */ -void -_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest, - GLenum dstType, const GLfloat *depthSpan, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLfloat depthCopy[MAX_WIDTH]; - - ASSERT(n <= MAX_WIDTH); - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - memcpy(depthCopy, depthSpan, n * sizeof(GLfloat)); - _mesa_scale_and_bias_depth(ctx, n, depthCopy); - depthSpan = depthCopy; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UBYTE( depthSpan[i] ); - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_BYTE( depthSpan[i] ); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_SHORT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UINT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_INT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = depthSpan[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = _mesa_float_to_half(depthSpan[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_depth_span"); - } -} - - - -/** - * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8. - */ -void -_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest, - const GLfloat *depthVals, - const GLstencil *stencilVals, - const struct gl_pixelstore_attrib *dstPacking) -{ - GLfloat depthCopy[MAX_WIDTH]; - GLstencil stencilCopy[MAX_WIDTH]; - GLuint i; - - ASSERT(n <= MAX_WIDTH); - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - memcpy(depthCopy, depthVals, n * sizeof(GLfloat)); - _mesa_scale_and_bias_depth(ctx, n, depthCopy); - depthVals = depthCopy; - } - - if (ctx->Pixel.IndexShift || - ctx->Pixel.IndexOffset || - ctx->Pixel.MapStencilFlag) { - memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil)); - _mesa_apply_stencil_transfer_ops(ctx, n, stencilCopy); - stencilVals = stencilCopy; - } - - for (i = 0; i < n; i++) { - GLuint z = (GLuint) (depthVals[i] * 0xffffff); - dest[i] = (z << 8) | (stencilVals[i] & 0xff); - } - - if (dstPacking->SwapBytes) { - _mesa_swap4(dest, n); - } -} - - - - -/** - * Unpack image data. Apply byte swapping, byte flipping (bitmap). - * Return all image data in a contiguous block. This is used when we - * compile glDrawPixels, glTexImage, etc into a display list. We - * need a copy of the data in a standard format. - */ -void * -_mesa_unpack_image( GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack ) -{ - GLint bytesPerRow, compsPerRow; - GLboolean flipBytes, swap2, swap4; - - if (!pixels) - return NULL; /* not necessarily an error */ - - if (width <= 0 || height <= 0 || depth <= 0) - return NULL; /* generate error later */ - - if (type == GL_BITMAP) { - bytesPerRow = (width + 7) >> 3; - flipBytes = unpack->LsbFirst; - swap2 = swap4 = GL_FALSE; - compsPerRow = 0; - } - else { - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint components = _mesa_components_in_format(format); - GLint bytesPerComp; - - if (_mesa_type_is_packed(type)) - components = 1; - - if (bytesPerPixel <= 0 || components <= 0) - return NULL; /* bad format or type. generate error later */ - bytesPerRow = bytesPerPixel * width; - bytesPerComp = bytesPerPixel / components; - flipBytes = GL_FALSE; - swap2 = (bytesPerComp == 2) && unpack->SwapBytes; - swap4 = (bytesPerComp == 4) && unpack->SwapBytes; - compsPerRow = components * width; - assert(compsPerRow >= width); - } - - { - GLubyte *destBuffer - = (GLubyte *) malloc(bytesPerRow * height * depth); - GLubyte *dst; - GLint img, row; - if (!destBuffer) - return NULL; /* generate GL_OUT_OF_MEMORY later */ - - dst = destBuffer; - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, - width, height, format, type, img, row, 0); - - if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { - GLint i; - flipBytes = GL_FALSE; - if (unpack->LsbFirst) { - GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - else { - memcpy(dst, src, bytesPerRow); - } - - /* byte flipping/swapping */ - if (flipBytes) { - flip_bytes((GLubyte *) dst, bytesPerRow); - } - else if (swap2) { - _mesa_swap2((GLushort*) dst, compsPerRow); - } - else if (swap4) { - _mesa_swap4((GLuint*) dst, compsPerRow); - } - dst += bytesPerRow; - } - } - return destBuffer; - } -} - -#endif /* _HAVE_FULL_GL */ - - - -/** - * Convert an array of RGBA colors from one datatype to another. - * NOTE: src may equal dst. In that case, we use a temporary buffer. - */ -void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]) -{ - GLuint tempBuffer[MAX_WIDTH][4]; - const GLboolean useTemp = (src == dst); - - ASSERT(srcType != dstType); - - switch (srcType) { - case GL_UNSIGNED_BYTE: - if (dstType == GL_UNSIGNED_SHORT) { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]); - dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]); - dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]); - dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - else { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]); - dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]); - dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]); - dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_UNSIGNED_SHORT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]); - dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]); - dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]); - dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]); - dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]); - dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]); - dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_FLOAT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][RCOMP], src4[i][RCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][GCOMP], src4[i][GCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][BCOMP], src4[i][BCOMP]); - UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][ACOMP], src4[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - ASSERT(dstType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - break; - default: - _mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors"); - } -} - - - - -/** - * Perform basic clipping for glDrawPixels. The image's position and size - * and the unpack SkipPixels and SkipRows are adjusted so that the image - * region is entirely within the window and scissor bounds. - * NOTE: this will only work when glPixelZoom is (1, 1) or (1, -1). - * If Pixel.ZoomY is -1, *destY will be changed to be the first row which - * we'll actually write. Beforehand, *destY-1 is the first drawing row. - * - * \return GL_TRUE if image is ready for drawing or - * GL_FALSE if image was completely clipped away (draw nothing) - */ -GLboolean -_mesa_clip_drawpixels(const GLcontext *ctx, - GLint *destX, GLint *destY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *unpack) -{ - const GLframebuffer *buffer = ctx->DrawBuffer; - - if (unpack->RowLength == 0) { - unpack->RowLength = *width; - } - - ASSERT(ctx->Pixel.ZoomX == 1.0F); - ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F); - - /* left clipping */ - if (*destX < buffer->_Xmin) { - unpack->SkipPixels += (buffer->_Xmin - *destX); - *width -= (buffer->_Xmin - *destX); - *destX = buffer->_Xmin; - } - /* right clipping */ - if (*destX + *width > buffer->_Xmax) - *width -= (*destX + *width - buffer->_Xmax); - - if (*width <= 0) - return GL_FALSE; - - if (ctx->Pixel.ZoomY == 1.0F) { - /* bottom clipping */ - if (*destY < buffer->_Ymin) { - unpack->SkipRows += (buffer->_Ymin - *destY); - *height -= (buffer->_Ymin - *destY); - *destY = buffer->_Ymin; - } - /* top clipping */ - if (*destY + *height > buffer->_Ymax) - *height -= (*destY + *height - buffer->_Ymax); - } - else { /* upside down */ - /* top clipping */ - if (*destY > buffer->_Ymax) { - unpack->SkipRows += (*destY - buffer->_Ymax); - *height -= (*destY - buffer->_Ymax); - *destY = buffer->_Ymax; - } - /* bottom clipping */ - if (*destY - *height < buffer->_Ymin) - *height -= (buffer->_Ymin - (*destY - *height)); - /* adjust destY so it's the first row to write to */ - (*destY)--; - } - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Perform clipping for glReadPixels. The image's window position - * and size, and the pack skipPixels, skipRows and rowLength are adjusted - * so that the image region is entirely within the window bounds. - * Note: this is different from _mesa_clip_drawpixels() in that the - * scissor box is ignored, and we use the bounds of the current readbuffer - * surface. - * - * \return GL_TRUE if image is ready for drawing or - * GL_FALSE if image was completely clipped away (draw nothing) - */ -GLboolean -_mesa_clip_readpixels(const GLcontext *ctx, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *pack) -{ - const GLframebuffer *buffer = ctx->ReadBuffer; - - if (pack->RowLength == 0) { - pack->RowLength = *width; - } - - /* left clipping */ - if (*srcX < 0) { - pack->SkipPixels += (0 - *srcX); - *width -= (0 - *srcX); - *srcX = 0; - } - /* right clipping */ - if (*srcX + *width > (GLsizei) buffer->Width) - *width -= (*srcX + *width - buffer->Width); - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*srcY < 0) { - pack->SkipRows += (0 - *srcY); - *height -= (0 - *srcY); - *srcY = 0; - } - /* top clipping */ - if (*srcY + *height > (GLsizei) buffer->Height) - *height -= (*srcY + *height - buffer->Height); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Do clipping for a glCopyTexSubImage call. - * The framebuffer source region might extend outside the framebuffer - * bounds. Clip the source region against the framebuffer bounds and - * adjust the texture/dest position and size accordingly. - * - * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise. - */ -GLboolean -_mesa_clip_copytexsubimage(const GLcontext *ctx, - GLint *destX, GLint *destY, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height) -{ - const struct gl_framebuffer *fb = ctx->ReadBuffer; - const GLint srcX0 = *srcX, srcY0 = *srcY; - - if (_mesa_clip_to_region(0, 0, fb->Width, fb->Height, - srcX, srcY, width, height)) { - *destX = *destX + *srcX - srcX0; - *destY = *destY + *srcY - srcY0; - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/** - * Clip the rectangle defined by (x, y, width, height) against the bounds - * specified by [xmin, xmax) and [ymin, ymax). - * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise. - */ -GLboolean -_mesa_clip_to_region(GLint xmin, GLint ymin, - GLint xmax, GLint ymax, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < xmin) { - *width -= (xmin - *x); - *x = xmin; - } - - /* right clipping */ - if (*x + *width > xmax) - *width -= (*x + *width - xmax); - - if (*width <= 0) - return GL_FALSE; - - /* bottom (or top) clipping */ - if (*y < ymin) { - *height -= (ymin - *y); - *y = ymin; - } - - /* top (or bottom) clipping */ - if (*y + *height > ymax) - *height -= (*y + *height - ymax); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Clip dst coords against Xmax (or Ymax). - */ -static INLINE void -clip_right_or_top(GLint *srcX0, GLint *srcX1, - GLint *dstX0, GLint *dstX1, - GLint maxValue) -{ - GLfloat t, bias; - - if (*dstX1 > maxValue) { - /* X1 outside right edge */ - ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */ - t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); - /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX1 = maxValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; - *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); - } - else if (*dstX0 > maxValue) { - /* X0 outside right edge */ - ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */ - t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); - /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX0 = maxValue; - bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; - *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); - } -} - - -/** - * Clip dst coords against Xmin (or Ymin). - */ -static INLINE void -clip_left_or_bottom(GLint *srcX0, GLint *srcX1, - GLint *dstX0, GLint *dstX1, - GLint minValue) -{ - GLfloat t, bias; - - if (*dstX0 < minValue) { - /* X0 outside left edge */ - ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */ - t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); - /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX0 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */ - *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); - } - else if (*dstX1 < minValue) { - /* X1 outside left edge */ - ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */ - t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); - /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); - *dstX1 = minValue; - bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; - *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); - } -} - - -/** - * Do clipping of blit src/dest rectangles. - * The dest rect is clipped against both the buffer bounds and scissor bounds. - * The src rect is just clipped against the buffer bounds. - * - * When either the src or dest rect is clipped, the other is also clipped - * proportionately! - * - * Note that X0 need not be less than X1 (same for Y) for either the source - * and dest rects. That makes the clipping a little trickier. - * - * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped - */ -GLboolean -_mesa_clip_blit(GLcontext *ctx, - GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, - GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1) -{ - const GLint srcXmin = 0; - const GLint srcXmax = ctx->ReadBuffer->Width; - const GLint srcYmin = 0; - const GLint srcYmax = ctx->ReadBuffer->Height; - - /* these include scissor bounds */ - const GLint dstXmin = ctx->DrawBuffer->_Xmin; - const GLint dstXmax = ctx->DrawBuffer->_Xmax; - const GLint dstYmin = ctx->DrawBuffer->_Ymin; - const GLint dstYmax = ctx->DrawBuffer->_Ymax; - - /* - printf("PreClipX: src: %d .. %d dst: %d .. %d\n", - *srcX0, *srcX1, *dstX0, *dstX1); - printf("PreClipY: src: %d .. %d dst: %d .. %d\n", - *srcY0, *srcY1, *dstY0, *dstY1); - */ - - /* trivial rejection tests */ - if (*dstX0 == *dstX1) - return GL_FALSE; /* no width */ - if (*dstX0 <= dstXmin && *dstX1 <= dstXmin) - return GL_FALSE; /* totally out (left) of bounds */ - if (*dstX0 >= dstXmax && *dstX1 >= dstXmax) - return GL_FALSE; /* totally out (right) of bounds */ - - if (*dstY0 == *dstY1) - return GL_FALSE; - if (*dstY0 <= dstYmin && *dstY1 <= dstYmin) - return GL_FALSE; - if (*dstY0 >= dstYmax && *dstY1 >= dstYmax) - return GL_FALSE; - - if (*srcX0 == *srcX1) - return GL_FALSE; - if (*srcX0 <= srcXmin && *srcX1 <= srcXmin) - return GL_FALSE; - if (*srcX0 >= srcXmax && *srcX1 >= srcXmax) - return GL_FALSE; - - if (*srcY0 == *srcY1) - return GL_FALSE; - if (*srcY0 <= srcYmin && *srcY1 <= srcYmin) - return GL_FALSE; - if (*srcY0 >= srcYmax && *srcY1 >= srcYmax) - return GL_FALSE; - - /* - * dest clip - */ - clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax); - clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax); - clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin); - clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin); - - /* - * src clip (just swap src/dst values from above) - */ - clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax); - clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax); - clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin); - clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin); - - /* - printf("PostClipX: src: %d .. %d dst: %d .. %d\n", - *srcX0, *srcX1, *dstX0, *dstX1); - printf("PostClipY: src: %d .. %d dst: %d .. %d\n", - *srcY0, *srcY1, *dstY0, *dstY1); - */ - - ASSERT(*dstX0 >= dstXmin); - ASSERT(*dstX0 <= dstXmax); - ASSERT(*dstX1 >= dstXmin); - ASSERT(*dstX1 <= dstXmax); - - ASSERT(*dstY0 >= dstYmin); - ASSERT(*dstY0 <= dstYmax); - ASSERT(*dstY1 >= dstYmin); - ASSERT(*dstY1 <= dstYmax); - - ASSERT(*srcX0 >= srcXmin); - ASSERT(*srcX0 <= srcXmax); - ASSERT(*srcX1 >= srcXmin); - ASSERT(*srcX1 <= srcXmax); - - ASSERT(*srcY0 >= srcYmin); - ASSERT(*srcY0 <= srcYmax); - ASSERT(*srcY1 >= srcYmin); - ASSERT(*srcY1 <= srcYmax); - - return GL_TRUE; -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file image.c + * Image handling. + */ + + +#include "glheader.h" +#include "colormac.h" +#include "image.h" +#include "imports.h" +#include "macros.h" + + +/** + * NOTE: + * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when + * we later convert the float to a packed integer value (such as for + * GL_RGB5_A1) because we'll wind up with a non-zero value. + * + * We redefine the macros here so zero is handled correctly. + */ +#undef BYTE_TO_FLOAT +#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F))) + +#undef SHORT_TO_FLOAT +#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))) + + + +/** Compute ceiling of integer quotient of A divided by B. */ +#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) + + +/** + * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. + */ +GLboolean +_mesa_type_is_packed(GLenum type) +{ + switch (type) { + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + case GL_UNSIGNED_INT_24_8_EXT: + return GL_TRUE; + } + + return GL_FALSE; +} + + + +/** + * Flip the order of the 2 bytes in each word in the given array. + * + * \param p array. + * \param n number of words. + */ +void +_mesa_swap2( GLushort *p, GLuint n ) +{ + GLuint i; + for (i = 0; i < n; i++) { + p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00); + } +} + + + +/* + * Flip the order of the 4 bytes in each word in the given array. + */ +void +_mesa_swap4( GLuint *p, GLuint n ) +{ + GLuint i, a, b; + for (i = 0; i < n; i++) { + b = p[i]; + a = (b >> 24) + | ((b >> 8) & 0xff00) + | ((b << 8) & 0xff0000) + | ((b << 24) & 0xff000000); + p[i] = a; + } +} + + +/** + * Get the size of a GL data type. + * + * \param type GL data type. + * + * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1 + * if an invalid type enum. + */ +GLint +_mesa_sizeof_type( GLenum type ) +{ + switch (type) { + case GL_BITMAP: + return 0; + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_INT: + return sizeof(GLint); + case GL_FLOAT: + return sizeof(GLfloat); + case GL_DOUBLE: + return sizeof(GLdouble); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); + case GL_FIXED: + return sizeof(GLfixed); + default: + return -1; + } +} + + +/** + * Same as _mesa_sizeof_type() but also accepting the packed pixel + * format data types. + */ +GLint +_mesa_sizeof_packed_type( GLenum type ) +{ + switch (type) { + case GL_BITMAP: + return 0; + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_INT: + return sizeof(GLuint); + case GL_INT: + return sizeof(GLint); + case GL_HALF_FLOAT_ARB: + return sizeof(GLhalfARB); + case GL_FLOAT: + return sizeof(GLfloat); + case GL_UNSIGNED_BYTE_3_3_2: + return sizeof(GLubyte); + case GL_UNSIGNED_BYTE_2_3_3_REV: + return sizeof(GLubyte); + case GL_UNSIGNED_SHORT_5_6_5: + return sizeof(GLushort); + case GL_UNSIGNED_SHORT_5_6_5_REV: + return sizeof(GLushort); + case GL_UNSIGNED_SHORT_4_4_4_4: + return sizeof(GLushort); + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + return sizeof(GLushort); + case GL_UNSIGNED_SHORT_5_5_5_1: + return sizeof(GLushort); + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + return sizeof(GLushort); + case GL_UNSIGNED_INT_8_8_8_8: + return sizeof(GLuint); + case GL_UNSIGNED_INT_8_8_8_8_REV: + return sizeof(GLuint); + case GL_UNSIGNED_INT_10_10_10_2: + return sizeof(GLuint); + case GL_UNSIGNED_INT_2_10_10_10_REV: + return sizeof(GLuint); + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + return sizeof(GLushort); + case GL_UNSIGNED_INT_24_8_EXT: + return sizeof(GLuint); + default: + return -1; + } +} + + +/** + * Get the number of components in a pixel format. + * + * \param format pixel format. + * + * \return the number of components in the given format, or -1 if a bad format. + */ +GLint +_mesa_components_in_format( GLenum format ) +{ + switch (format) { + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_RED_INTEGER_EXT: + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + case GL_INTENSITY: + return 1; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + case GL_RG: + return 2; + case GL_RGB: + case GL_RGB_INTEGER_EXT: + return 3; + case GL_RGBA: + case GL_RGBA_INTEGER_EXT: + return 4; + case GL_BGR: + return 3; + case GL_BGRA: + return 4; + case GL_ABGR_EXT: + return 4; + case GL_YCBCR_MESA: + return 2; + case GL_DEPTH_STENCIL_EXT: + return 2; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return 2; + default: + return -1; + } +} + + +/** + * Get the bytes per pixel of pixel format type pair. + * + * \param format pixel format. + * \param type pixel type. + * + * \return bytes per pixel, or -1 if a bad format or type was given. + */ +GLint +_mesa_bytes_per_pixel( GLenum format, GLenum type ) +{ + GLint comps = _mesa_components_in_format( format ); + if (comps < 0) + return -1; + + switch (type) { + case GL_BITMAP: + return 0; /* special case */ + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return comps * sizeof(GLubyte); + case GL_SHORT: + case GL_UNSIGNED_SHORT: + return comps * sizeof(GLshort); + case GL_INT: + case GL_UNSIGNED_INT: + return comps * sizeof(GLint); + case GL_FLOAT: + return comps * sizeof(GLfloat); + case GL_HALF_FLOAT_ARB: + return comps * sizeof(GLhalfARB); + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + if (format == GL_RGB || format == GL_BGR || + format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) + return sizeof(GLubyte); + else + return -1; /* error */ + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (format == GL_RGB || format == GL_BGR || + format == GL_RGB_INTEGER_EXT || format == GL_BGR_INTEGER_EXT) + return sizeof(GLushort); + else + return -1; /* error */ + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || + format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) + return sizeof(GLushort); + else + return -1; + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT || + format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) + return sizeof(GLuint); + else + return -1; + case GL_UNSIGNED_SHORT_8_8_MESA: + case GL_UNSIGNED_SHORT_8_8_REV_MESA: + if (format == GL_YCBCR_MESA) + return sizeof(GLushort); + else + return -1; + case GL_UNSIGNED_INT_24_8_EXT: + if (format == GL_DEPTH_STENCIL_EXT) + return sizeof(GLuint); + else + return -1; + default: + return -1; + } +} + + +/** + * Test for a legal pixel format and type. + * + * \param format pixel format. + * \param type pixel type. + * + * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE + * otherwise. + */ +GLboolean +_mesa_is_legal_format_and_type(const struct gl_context *ctx, + GLenum format, GLenum type) +{ + switch (format) { + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + switch (type) { + case GL_BITMAP: + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: +#if 0 /* not legal! see table 3.6 of the 1.5 spec */ + case GL_INTENSITY: +#endif + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_DEPTH_COMPONENT: + 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: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_RG: + if (!ctx->Extensions.ARB_texture_rg) + return GL_FALSE; + + 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: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_RGB: + 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_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_BGR: + switch (type) { + /* NOTE: no packed types are supported with BGR. That's + * intentional, according to the GL spec. + */ + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + 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_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + return GL_TRUE; + case GL_HALF_FLOAT_ARB: + return ctx->Extensions.ARB_half_float_pixel; + default: + return GL_FALSE; + } + case GL_YCBCR_MESA: + if (type == GL_UNSIGNED_SHORT_8_8_MESA || + type == GL_UNSIGNED_SHORT_8_8_REV_MESA) + return GL_TRUE; + else + return GL_FALSE; + case GL_DEPTH_STENCIL_EXT: + if (ctx->Extensions.EXT_packed_depth_stencil + && type == GL_UNSIGNED_INT_24_8_EXT) + return GL_TRUE; + else + return GL_FALSE; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + 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: + return GL_TRUE; + default: + return GL_FALSE; + } + + /* integer-valued formats */ + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + return ctx->Extensions.EXT_texture_integer; + default: + return GL_FALSE; + } + + case GL_RGB_INTEGER_EXT: + 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_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + return ctx->Extensions.EXT_texture_integer; + default: + return GL_FALSE; + } + + case GL_BGR_INTEGER_EXT: + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + /* NOTE: no packed formats w/ BGR format */ + return ctx->Extensions.EXT_texture_integer; + default: + return GL_FALSE; + } + + case GL_RGBA_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + 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_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + return ctx->Extensions.EXT_texture_integer; + default: + return GL_FALSE; + } + + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + return ctx->Extensions.EXT_texture_integer; + default: + return GL_FALSE; + } + + default: + ; /* fall-through */ + } + return GL_FALSE; +} + + +/** + * Test if the given image format is a color/RGBA format (i.e., not color + * index, depth, stencil, etc). + * \param format the image format value (may by an internal texture format) + * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise. + */ +GLboolean +_mesa_is_color_format(GLenum format) +{ + switch (format) { + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + case GL_R8: + case GL_R16: + case GL_RG: + case GL_RG8: + case GL_RG16: + case 3: + case GL_RGB: + case GL_BGR: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + case 4: + case GL_ABGR_EXT: + case GL_RGBA: + case GL_BGRA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + /* float texture formats */ + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + case GL_R16F: + case GL_R32F: + case GL_RG16F: + case GL_RG32F: + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: + /* compressed formats */ + case GL_COMPRESSED_ALPHA: + case GL_COMPRESSED_LUMINANCE: + case GL_COMPRESSED_LUMINANCE_ALPHA: + case GL_COMPRESSED_INTENSITY: + case GL_COMPRESSED_RED: + case GL_COMPRESSED_RG: + case GL_COMPRESSED_RGB: + case GL_COMPRESSED_RGBA: + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: +#if FEATURE_EXT_texture_sRGB + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: +#endif /* FEATURE_EXT_texture_sRGB */ + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + /* signed, normalized texture formats */ + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + /* generic integer formats */ + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* sized integer formats */ + case GL_RGBA32UI_EXT: + case GL_RGB32UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGB16UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_RGBA8UI_EXT: + case GL_RGB8UI_EXT: + case GL_ALPHA8UI_EXT: + case GL_INTENSITY8UI_EXT: + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_RGBA32I_EXT: + case GL_RGB32I_EXT: + case GL_ALPHA32I_EXT: + case GL_INTENSITY32I_EXT: + case GL_LUMINANCE32I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + case GL_RGBA16I_EXT: + case GL_RGB16I_EXT: + case GL_ALPHA16I_EXT: + case GL_INTENSITY16I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_RGBA8I_EXT: + case GL_RGB8I_EXT: + case GL_ALPHA8I_EXT: + case GL_INTENSITY8I_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + return GL_TRUE; + case GL_YCBCR_MESA: /* not considered to be RGB */ + /* fall-through */ + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a color index format. + */ +GLboolean +_mesa_is_index_format(GLenum format) +{ + switch (format) { + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a depth component format. + */ +GLboolean +_mesa_is_depth_format(GLenum format) +{ + switch (format) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a stencil format. + */ +GLboolean +_mesa_is_stencil_format(GLenum format) +{ + switch (format) { + case GL_STENCIL_INDEX: + case GL_DEPTH_STENCIL: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a YCbCr format. + */ +GLboolean +_mesa_is_ycbcr_format(GLenum format) +{ + switch (format) { + case GL_YCBCR_MESA: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a depth+stencil format. + */ +GLboolean +_mesa_is_depthstencil_format(GLenum format) +{ + switch (format) { + case GL_DEPTH24_STENCIL8_EXT: + case GL_DEPTH_STENCIL_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a depth or stencil format. + */ +GLboolean +_mesa_is_depth_or_stencil_format(GLenum format) +{ + switch (format) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given image format is a dudv format. + */ +GLboolean +_mesa_is_dudv_format(GLenum format) +{ + switch (format) { + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if the given format is an integer (non-normalized) format. + */ +GLboolean +_mesa_is_integer_format(GLenum format) +{ + switch (format) { + /* generic integer formats */ + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* specific integer formats */ + case GL_RGBA32UI_EXT: + case GL_RGB32UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGB16UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_RGBA8UI_EXT: + case GL_RGB8UI_EXT: + case GL_ALPHA8UI_EXT: + case GL_INTENSITY8UI_EXT: + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_RGBA32I_EXT: + case GL_RGB32I_EXT: + case GL_ALPHA32I_EXT: + case GL_INTENSITY32I_EXT: + case GL_LUMINANCE32I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + case GL_RGBA16I_EXT: + case GL_RGB16I_EXT: + case GL_ALPHA16I_EXT: + case GL_INTENSITY16I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_RGBA8I_EXT: + case GL_RGB8I_EXT: + case GL_ALPHA8I_EXT: + case GL_INTENSITY8I_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if an image format is a supported compressed format. + * \param format the internal format token provided by the user. + * \return GL_TRUE if compressed, GL_FALSE if uncompressed + */ +GLboolean +_mesa_is_compressed_format(struct gl_context *ctx, GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_compression_s3tc; + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return ctx->Extensions.S3_s3tc; + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return ctx->Extensions.EXT_texture_sRGB + && ctx->Extensions.EXT_texture_compression_s3tc; + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return ctx->Extensions.TDFX_texture_compression_FXT1; + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return ctx->Extensions.ARB_texture_compression_rgtc; + default: + return GL_FALSE; + } +} + + +/** + * Return the address of a specific pixel in an image (1D, 2D or 3D). + * + * Pixel unpacking/packing parameters are observed according to \p packing. + * + * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param image starting address of image data + * \param width the image width + * \param height theimage height + * \param format the pixel format + * \param type the pixel data type + * \param packing the pixelstore attributes + * \param img which image in the volume (0 for 1D or 2D images) + * \param row row of pixel in the image (0 for 1D images) + * \param column column of pixel in the image + * + * \return address of pixel on success, or NULL on error. + * + * \sa gl_pixelstore_attrib. + */ +GLvoid * +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + GLint alignment; /* 1, 2 or 4 */ + GLint pixels_per_row; + GLint rows_per_image; + GLint skiprows; + GLint skippixels; + GLint skipimages; /* for 3-D volume images */ + GLubyte *pixel_addr; + + ASSERT(dimensions >= 1 && dimensions <= 3); + + alignment = packing->Alignment; + if (packing->RowLength > 0) { + pixels_per_row = packing->RowLength; + } + else { + pixels_per_row = width; + } + if (packing->ImageHeight > 0) { + rows_per_image = packing->ImageHeight; + } + else { + rows_per_image = height; + } + + skippixels = packing->SkipPixels; + /* Note: SKIP_ROWS _is_ used for 1D images */ + skiprows = packing->SkipRows; + /* Note: SKIP_IMAGES is only used for 3D images */ + skipimages = (dimensions == 3) ? packing->SkipImages : 0; + + if (type == GL_BITMAP) { + /* BITMAP data */ + GLint comp_per_pixel; /* components per pixel */ + GLint bytes_per_comp; /* bytes per component */ + GLint bytes_per_row; + GLint bytes_per_image; + + /* Compute bytes per component */ + bytes_per_comp = _mesa_sizeof_packed_type( type ); + if (bytes_per_comp < 0) { + return NULL; + } + + /* Compute number of components per pixel */ + comp_per_pixel = _mesa_components_in_format( format ); + if (comp_per_pixel < 0) { + return NULL; + } + + bytes_per_row = alignment + * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); + + bytes_per_image = bytes_per_row * rows_per_image; + + pixel_addr = (GLubyte *) image + + (skipimages + img) * bytes_per_image + + (skiprows + row) * bytes_per_row + + (skippixels + column) / 8; + } + else { + /* Non-BITMAP data */ + GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image; + GLint topOfImage; + + bytes_per_pixel = _mesa_bytes_per_pixel( format, type ); + + /* The pixel type and format should have been error checked earlier */ + assert(bytes_per_pixel > 0); + + bytes_per_row = pixels_per_row * bytes_per_pixel; + remainder = bytes_per_row % alignment; + if (remainder > 0) + bytes_per_row += (alignment - remainder); + + ASSERT(bytes_per_row % alignment == 0); + + bytes_per_image = bytes_per_row * rows_per_image; + + if (packing->Invert) { + /* set pixel_addr to the last row */ + topOfImage = bytes_per_row * (height - 1); + bytes_per_row = -bytes_per_row; + } + else { + topOfImage = 0; + } + + /* compute final pixel address */ + pixel_addr = (GLubyte *) image + + (skipimages + img) * bytes_per_image + + topOfImage + + (skiprows + row) * bytes_per_row + + (skippixels + column) * bytes_per_pixel; + } + + return (GLvoid *) pixel_addr; +} + + +GLvoid * +_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, + GLenum format, GLenum type, + GLint column ) +{ + return _mesa_image_address(1, packing, image, width, 1, + format, type, 0, 0, column); +} + + +GLvoid * +_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint row, GLint column ) +{ + return _mesa_image_address(2, packing, image, width, height, + format, type, 0, row, column); +} + + +GLvoid * +_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + return _mesa_image_address(3, packing, image, width, height, + format, type, img, row, column); +} + + + +/** + * Compute the stride (in bytes) between image rows. + * + * \param packing the pixelstore attributes + * \param width image width. + * \param format pixel format. + * \param type pixel data type. + * + * \return the stride in bytes for the given parameters, or -1 if error + */ +GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ) +{ + GLint bytesPerRow, remainder; + + ASSERT(packing); + + if (type == GL_BITMAP) { + if (packing->RowLength == 0) { + bytesPerRow = (width + 7) / 8; + } + else { + bytesPerRow = (packing->RowLength + 7) / 8; + } + } + else { + /* Non-BITMAP data */ + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + if (bytesPerPixel <= 0) + return -1; /* error */ + if (packing->RowLength == 0) { + bytesPerRow = bytesPerPixel * width; + } + else { + bytesPerRow = bytesPerPixel * packing->RowLength; + } + } + + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) { + bytesPerRow += (packing->Alignment - remainder); + } + + if (packing->Invert) { + /* negate the bytes per row (negative row stride) */ + bytesPerRow = -bytesPerRow; + } + + return bytesPerRow; +} + + +/* + * Compute the stride between images in a 3D texture (in bytes) for the given + * pixel packing parameters and image width, format and type. + */ +GLint +_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLint height, + GLenum format, GLenum type ) +{ + GLint bytesPerRow, bytesPerImage, remainder; + + ASSERT(packing); + + if (type == GL_BITMAP) { + if (packing->RowLength == 0) { + bytesPerRow = (width + 7) / 8; + } + else { + bytesPerRow = (packing->RowLength + 7) / 8; + } + } + else { + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + + if (bytesPerPixel <= 0) + return -1; /* error */ + if (packing->RowLength == 0) { + bytesPerRow = bytesPerPixel * width; + } + else { + bytesPerRow = bytesPerPixel * packing->RowLength; + } + } + + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) + bytesPerRow += (packing->Alignment - remainder); + + if (packing->ImageHeight == 0) + bytesPerImage = bytesPerRow * height; + else + bytesPerImage = bytesPerRow * packing->ImageHeight; + + return bytesPerImage; +} + + + +/** + * "Expand" a bitmap from 1-bit per pixel to 8-bits per pixel. + * This is typically used to convert a bitmap into a GLubyte/pixel texture. + * "On" bits will set texels to \p onValue. + * "Off" bits will not modify texels. + * \param width src bitmap width in pixels + * \param height src bitmap height in pixels + * \param unpack bitmap unpacking state + * \param bitmap the src bitmap data + * \param destBuffer start of dest buffer + * \param destStride row stride in dest buffer + * \param onValue if bit is 1, set destBuffer pixel to this value + */ +void +_mesa_expand_bitmap(GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap, + GLubyte *destBuffer, GLint destStride, + GLubyte onValue) +{ + const GLubyte *srcRow = (const GLubyte *) + _mesa_image_address2d(unpack, bitmap, width, height, + GL_COLOR_INDEX, GL_BITMAP, 0, 0); + const GLint srcStride = _mesa_image_row_stride(unpack, width, + GL_COLOR_INDEX, GL_BITMAP); + GLint row, col; + +#define SET_PIXEL(COL, ROW) \ + destBuffer[(ROW) * destStride + (COL)] = onValue; + + for (row = 0; row < height; row++) { + const GLubyte *src = srcRow; + + if (unpack->LsbFirst) { + /* Lsb first */ + GLubyte mask = 1U << (unpack->SkipPixels & 0x7); + for (col = 0; col < width; col++) { + + if (*src & mask) { + SET_PIXEL(col, row); + } + + if (mask == 128U) { + src++; + mask = 1U; + } + else { + mask = mask << 1; + } + } + + /* get ready for next row */ + if (mask != 1) + src++; + } + else { + /* Msb first */ + GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); + for (col = 0; col < width; col++) { + + if (*src & mask) { + SET_PIXEL(col, row); + } + + if (mask == 1U) { + src++; + mask = 128U; + } + else { + mask = mask >> 1; + } + } + + /* get ready for next row */ + if (mask != 128) + src++; + } + + srcRow += srcStride; + } /* row */ + +#undef SET_PIXEL +} + + + + +/** + * Convert an array of RGBA colors from one datatype to another. + * NOTE: src may equal dst. In that case, we use a temporary buffer. + */ +void +_mesa_convert_colors(GLenum srcType, const GLvoid *src, + GLenum dstType, GLvoid *dst, + GLuint count, const GLubyte mask[]) +{ + GLuint tempBuffer[MAX_WIDTH][4]; + const GLboolean useTemp = (src == dst); + + ASSERT(srcType != dstType); + + switch (srcType) { + case GL_UNSIGNED_BYTE: + if (dstType == GL_UNSIGNED_SHORT) { + const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; + GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]); + dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]); + dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]); + dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); + } + else { + const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; + GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + ASSERT(dstType == GL_FLOAT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]); + dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]); + dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]); + dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); + } + break; + case GL_UNSIGNED_SHORT: + if (dstType == GL_UNSIGNED_BYTE) { + const GLushort (*src2)[4] = (const GLushort (*)[4]) src; + GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]); + dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]); + dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]); + dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); + } + else { + const GLushort (*src2)[4] = (const GLushort (*)[4]) src; + GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + ASSERT(dstType == GL_FLOAT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]); + dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]); + dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]); + dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); + } + break; + case GL_FLOAT: + if (dstType == GL_UNSIGNED_BYTE) { + const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; + GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][RCOMP], src4[i][RCOMP]); + UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][GCOMP], src4[i][GCOMP]); + UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][BCOMP], src4[i][BCOMP]); + UNCLAMPED_FLOAT_TO_UBYTE(dst1[i][ACOMP], src4[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); + } + else { + const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; + GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); + GLuint i; + ASSERT(dstType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]); + } + } + if (useTemp) + memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); + } + break; + default: + _mesa_problem(NULL, "Invalid datatype in _mesa_convert_colors"); + } +} + + + + +/** + * Perform basic clipping for glDrawPixels. The image's position and size + * and the unpack SkipPixels and SkipRows are adjusted so that the image + * region is entirely within the window and scissor bounds. + * NOTE: this will only work when glPixelZoom is (1, 1) or (1, -1). + * If Pixel.ZoomY is -1, *destY will be changed to be the first row which + * we'll actually write. Beforehand, *destY-1 is the first drawing row. + * + * \return GL_TRUE if image is ready for drawing or + * GL_FALSE if image was completely clipped away (draw nothing) + */ +GLboolean +_mesa_clip_drawpixels(const struct gl_context *ctx, + GLint *destX, GLint *destY, + GLsizei *width, GLsizei *height, + struct gl_pixelstore_attrib *unpack) +{ + const struct gl_framebuffer *buffer = ctx->DrawBuffer; + + if (unpack->RowLength == 0) { + unpack->RowLength = *width; + } + + ASSERT(ctx->Pixel.ZoomX == 1.0F); + ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F); + + /* left clipping */ + if (*destX < buffer->_Xmin) { + unpack->SkipPixels += (buffer->_Xmin - *destX); + *width -= (buffer->_Xmin - *destX); + *destX = buffer->_Xmin; + } + /* right clipping */ + if (*destX + *width > buffer->_Xmax) + *width -= (*destX + *width - buffer->_Xmax); + + if (*width <= 0) + return GL_FALSE; + + if (ctx->Pixel.ZoomY == 1.0F) { + /* bottom clipping */ + if (*destY < buffer->_Ymin) { + unpack->SkipRows += (buffer->_Ymin - *destY); + *height -= (buffer->_Ymin - *destY); + *destY = buffer->_Ymin; + } + /* top clipping */ + if (*destY + *height > buffer->_Ymax) + *height -= (*destY + *height - buffer->_Ymax); + } + else { /* upside down */ + /* top clipping */ + if (*destY > buffer->_Ymax) { + unpack->SkipRows += (*destY - buffer->_Ymax); + *height -= (*destY - buffer->_Ymax); + *destY = buffer->_Ymax; + } + /* bottom clipping */ + if (*destY - *height < buffer->_Ymin) + *height -= (buffer->_Ymin - (*destY - *height)); + /* adjust destY so it's the first row to write to */ + (*destY)--; + } + + if (*height <= 0) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Perform clipping for glReadPixels. The image's window position + * and size, and the pack skipPixels, skipRows and rowLength are adjusted + * so that the image region is entirely within the window bounds. + * Note: this is different from _mesa_clip_drawpixels() in that the + * scissor box is ignored, and we use the bounds of the current readbuffer + * surface. + * + * \return GL_TRUE if image is ready for drawing or + * GL_FALSE if image was completely clipped away (draw nothing) + */ +GLboolean +_mesa_clip_readpixels(const struct gl_context *ctx, + GLint *srcX, GLint *srcY, + GLsizei *width, GLsizei *height, + struct gl_pixelstore_attrib *pack) +{ + const struct gl_framebuffer *buffer = ctx->ReadBuffer; + + if (pack->RowLength == 0) { + pack->RowLength = *width; + } + + /* left clipping */ + if (*srcX < 0) { + pack->SkipPixels += (0 - *srcX); + *width -= (0 - *srcX); + *srcX = 0; + } + /* right clipping */ + if (*srcX + *width > (GLsizei) buffer->Width) + *width -= (*srcX + *width - buffer->Width); + + if (*width <= 0) + return GL_FALSE; + + /* bottom clipping */ + if (*srcY < 0) { + pack->SkipRows += (0 - *srcY); + *height -= (0 - *srcY); + *srcY = 0; + } + /* top clipping */ + if (*srcY + *height > (GLsizei) buffer->Height) + *height -= (*srcY + *height - buffer->Height); + + if (*height <= 0) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Do clipping for a glCopyTexSubImage call. + * The framebuffer source region might extend outside the framebuffer + * bounds. Clip the source region against the framebuffer bounds and + * adjust the texture/dest position and size accordingly. + * + * \return GL_FALSE if region is totally clipped, GL_TRUE otherwise. + */ +GLboolean +_mesa_clip_copytexsubimage(const struct gl_context *ctx, + GLint *destX, GLint *destY, + GLint *srcX, GLint *srcY, + GLsizei *width, GLsizei *height) +{ + const struct gl_framebuffer *fb = ctx->ReadBuffer; + const GLint srcX0 = *srcX, srcY0 = *srcY; + + if (_mesa_clip_to_region(0, 0, fb->Width, fb->Height, + srcX, srcY, width, height)) { + *destX = *destX + *srcX - srcX0; + *destY = *destY + *srcY - srcY0; + + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/** + * Clip the rectangle defined by (x, y, width, height) against the bounds + * specified by [xmin, xmax) and [ymin, ymax). + * \return GL_FALSE if rect is totally clipped, GL_TRUE otherwise. + */ +GLboolean +_mesa_clip_to_region(GLint xmin, GLint ymin, + GLint xmax, GLint ymax, + GLint *x, GLint *y, + GLsizei *width, GLsizei *height ) +{ + /* left clipping */ + if (*x < xmin) { + *width -= (xmin - *x); + *x = xmin; + } + + /* right clipping */ + if (*x + *width > xmax) + *width -= (*x + *width - xmax); + + if (*width <= 0) + return GL_FALSE; + + /* bottom (or top) clipping */ + if (*y < ymin) { + *height -= (ymin - *y); + *y = ymin; + } + + /* top (or bottom) clipping */ + if (*y + *height > ymax) + *height -= (*y + *height - ymax); + + if (*height <= 0) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Clip dst coords against Xmax (or Ymax). + */ +static INLINE void +clip_right_or_top(GLint *srcX0, GLint *srcX1, + GLint *dstX0, GLint *dstX1, + GLint maxValue) +{ + GLfloat t, bias; + + if (*dstX1 > maxValue) { + /* X1 outside right edge */ + ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */ + t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); + /* chop off [t, 1] part */ + ASSERT(t >= 0.0 && t <= 1.0); + *dstX1 = maxValue; + bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; + *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); + } + else if (*dstX0 > maxValue) { + /* X0 outside right edge */ + ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */ + t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); + /* chop off [t, 1] part */ + ASSERT(t >= 0.0 && t <= 1.0); + *dstX0 = maxValue; + bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; + *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); + } +} + + +/** + * Clip dst coords against Xmin (or Ymin). + */ +static INLINE void +clip_left_or_bottom(GLint *srcX0, GLint *srcX1, + GLint *dstX0, GLint *dstX1, + GLint minValue) +{ + GLfloat t, bias; + + if (*dstX0 < minValue) { + /* X0 outside left edge */ + ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */ + t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); + /* chop off [0, t] part */ + ASSERT(t >= 0.0 && t <= 1.0); + *dstX0 = minValue; + bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */ + *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); + } + else if (*dstX1 < minValue) { + /* X1 outside left edge */ + ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */ + t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); + /* chop off [0, t] part */ + ASSERT(t >= 0.0 && t <= 1.0); + *dstX1 = minValue; + bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; + *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); + } +} + + +/** + * Do clipping of blit src/dest rectangles. + * The dest rect is clipped against both the buffer bounds and scissor bounds. + * The src rect is just clipped against the buffer bounds. + * + * When either the src or dest rect is clipped, the other is also clipped + * proportionately! + * + * Note that X0 need not be less than X1 (same for Y) for either the source + * and dest rects. That makes the clipping a little trickier. + * + * \return GL_TRUE if anything is left to draw, GL_FALSE if totally clipped + */ +GLboolean +_mesa_clip_blit(struct gl_context *ctx, + GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, + GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1) +{ + const GLint srcXmin = 0; + const GLint srcXmax = ctx->ReadBuffer->Width; + const GLint srcYmin = 0; + const GLint srcYmax = ctx->ReadBuffer->Height; + + /* these include scissor bounds */ + const GLint dstXmin = ctx->DrawBuffer->_Xmin; + const GLint dstXmax = ctx->DrawBuffer->_Xmax; + const GLint dstYmin = ctx->DrawBuffer->_Ymin; + const GLint dstYmax = ctx->DrawBuffer->_Ymax; + + /* + printf("PreClipX: src: %d .. %d dst: %d .. %d\n", + *srcX0, *srcX1, *dstX0, *dstX1); + printf("PreClipY: src: %d .. %d dst: %d .. %d\n", + *srcY0, *srcY1, *dstY0, *dstY1); + */ + + /* trivial rejection tests */ + if (*dstX0 == *dstX1) + return GL_FALSE; /* no width */ + if (*dstX0 <= dstXmin && *dstX1 <= dstXmin) + return GL_FALSE; /* totally out (left) of bounds */ + if (*dstX0 >= dstXmax && *dstX1 >= dstXmax) + return GL_FALSE; /* totally out (right) of bounds */ + + if (*dstY0 == *dstY1) + return GL_FALSE; + if (*dstY0 <= dstYmin && *dstY1 <= dstYmin) + return GL_FALSE; + if (*dstY0 >= dstYmax && *dstY1 >= dstYmax) + return GL_FALSE; + + if (*srcX0 == *srcX1) + return GL_FALSE; + if (*srcX0 <= srcXmin && *srcX1 <= srcXmin) + return GL_FALSE; + if (*srcX0 >= srcXmax && *srcX1 >= srcXmax) + return GL_FALSE; + + if (*srcY0 == *srcY1) + return GL_FALSE; + if (*srcY0 <= srcYmin && *srcY1 <= srcYmin) + return GL_FALSE; + if (*srcY0 >= srcYmax && *srcY1 >= srcYmax) + return GL_FALSE; + + /* + * dest clip + */ + clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax); + clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax); + clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin); + clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin); + + /* + * src clip (just swap src/dst values from above) + */ + clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax); + clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax); + clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin); + clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin); + + /* + printf("PostClipX: src: %d .. %d dst: %d .. %d\n", + *srcX0, *srcX1, *dstX0, *dstX1); + printf("PostClipY: src: %d .. %d dst: %d .. %d\n", + *srcY0, *srcY1, *dstY0, *dstY1); + */ + + ASSERT(*dstX0 >= dstXmin); + ASSERT(*dstX0 <= dstXmax); + ASSERT(*dstX1 >= dstXmin); + ASSERT(*dstX1 <= dstXmax); + + ASSERT(*dstY0 >= dstYmin); + ASSERT(*dstY0 <= dstYmax); + ASSERT(*dstY1 >= dstYmin); + ASSERT(*dstY1 <= dstYmax); + + ASSERT(*srcX0 >= srcXmin); + ASSERT(*srcX0 <= srcXmax); + ASSERT(*srcX1 >= srcXmin); + ASSERT(*srcX1 <= srcXmax); + + ASSERT(*srcY0 >= srcYmin); + ASSERT(*srcY0 <= srcYmax); + ASSERT(*srcY1 >= srcYmin); + ASSERT(*srcY1 <= srcYmax); + + return GL_TRUE; +} diff --git a/mesalib/src/mesa/main/image.h b/mesalib/src/mesa/main/image.h index 8b180d6bf..6fa93924c 100644 --- a/mesalib/src/mesa/main/image.h +++ b/mesalib/src/mesa/main/image.h @@ -1,336 +1,176 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef IMAGE_H -#define IMAGE_H - - -#include "mtypes.h" - - -extern void -_mesa_swap2( GLushort *p, GLuint n ); - -extern void -_mesa_swap4( GLuint *p, GLuint n ); - -extern GLboolean -_mesa_type_is_packed(GLenum type); - -extern GLint -_mesa_sizeof_type( GLenum type ); - -extern GLint -_mesa_sizeof_packed_type( GLenum type ); - -extern GLint -_mesa_components_in_format( GLenum format ); - -extern GLint -_mesa_bytes_per_pixel( GLenum format, GLenum type ); - -extern GLboolean -_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ); - -extern GLboolean -_mesa_is_color_format(GLenum format); - -extern GLboolean -_mesa_is_index_format(GLenum format); - -extern GLboolean -_mesa_is_depth_format(GLenum format); - -extern GLboolean -_mesa_is_stencil_format(GLenum format); - -extern GLboolean -_mesa_is_ycbcr_format(GLenum format); - -extern GLboolean -_mesa_is_depthstencil_format(GLenum format); - -extern GLboolean -_mesa_is_depth_or_stencil_format(GLenum format); - -extern GLboolean -_mesa_is_dudv_format(GLenum format); - -extern GLboolean -_mesa_is_integer_format(GLenum format); - -extern GLboolean -_mesa_is_compressed_format(GLcontext *ctx, GLenum format); - -extern GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ); - -extern GLvoid * -_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, - GLenum format, GLenum type, - GLint column ); - -extern GLvoid * -_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint row, GLint column ); - -extern GLvoid * -_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ); - - -extern GLint -_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLenum format, GLenum type ); - - -extern GLint -_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, - GLint width, GLint height, - GLenum format, GLenum type ); - -extern void -_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], - const struct gl_pixelstore_attrib *unpacking ); - - -extern void -_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, - const struct gl_pixelstore_attrib *packing ); - - -extern GLvoid * -_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, - const struct gl_pixelstore_attrib *packing ); - -extern void -_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, - GLubyte *dest, const struct gl_pixelstore_attrib *packing ); - -extern void -_mesa_expand_bitmap(GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap, - GLubyte *destBuffer, GLint destStride, - GLubyte onValue); - - -/** \name Pixel processing functions */ -/*@{*/ - -extern void -_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], - GLfloat rScale, GLfloat gScale, - GLfloat bScale, GLfloat aScale, - GLfloat rBias, GLfloat gBias, - GLfloat bBias, GLfloat aBias); - -extern void -_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); - - -extern void -_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); - - -extern void -_mesa_lookup_rgba_float(const struct gl_color_table *table, - GLuint n, GLfloat rgba[][4]); - -extern void -_mesa_lookup_rgba_ubyte(const struct gl_color_table *table, - GLuint n, GLubyte rgba[][4]); - - -extern void -_mesa_map_ci_to_rgba(const GLcontext *ctx, - GLuint n, const GLuint index[], GLfloat rgba[][4]); - - -extern void -_mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[], - GLubyte rgba[][4]); - - -extern void -_mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n, - GLfloat depthValues[]); - -extern void -_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n, - GLuint depthValues[]); - -extern void -_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, - GLuint n, GLfloat rgba[][4]); - - -extern void -_mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps, - GLuint n, GLuint indexes[]); - - -extern void -_mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, - GLstencil stencil[]); - - -extern void -_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4], - GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps ); - - -extern void -_mesa_unpack_color_span_chan( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLchan dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ); - - -extern void -_mesa_unpack_color_span_float( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLfloat dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ); - -extern void -_mesa_unpack_dudv_span_byte( GLcontext *ctx, - GLuint n, GLenum dstFormat, GLbyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ); - -extern void -_mesa_unpack_index_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ); - - -extern void -_mesa_pack_index_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLuint *source, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps ); - - -extern void -_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ); - -extern void -_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLstencil *source, - const struct gl_pixelstore_attrib *dstPacking ); - - -extern void -_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLuint depthMax, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking ); - -extern void -_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest, - GLenum dstType, const GLfloat *depthSpan, - const struct gl_pixelstore_attrib *dstPacking ); - - -extern void -_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest, - const GLfloat *depthVals, - const GLstencil *stencilVals, - const struct gl_pixelstore_attrib *dstPacking); - - -extern void * -_mesa_unpack_image( GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack ); - - -extern void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]); - - -extern GLboolean -_mesa_clip_drawpixels(const GLcontext *ctx, - GLint *destX, GLint *destY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *unpack); - - -extern GLboolean -_mesa_clip_readpixels(const GLcontext *ctx, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height, - struct gl_pixelstore_attrib *pack); - -extern GLboolean -_mesa_clip_copytexsubimage(const GLcontext *ctx, - GLint *destX, GLint *destY, - GLint *srcX, GLint *srcY, - GLsizei *width, GLsizei *height); - -extern GLboolean -_mesa_clip_to_region(GLint xmin, GLint ymin, - GLint xmax, GLint ymax, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - -extern GLboolean -_mesa_clip_blit(GLcontext *ctx, - GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, - GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef IMAGE_H +#define IMAGE_H + + +#include "glheader.h" + +struct gl_context; +struct gl_pixelstore_attrib; + +extern void +_mesa_swap2( GLushort *p, GLuint n ); + +extern void +_mesa_swap4( GLuint *p, GLuint n ); + +extern GLboolean +_mesa_type_is_packed(GLenum type); + +extern GLint +_mesa_sizeof_type( GLenum type ); + +extern GLint +_mesa_sizeof_packed_type( GLenum type ); + +extern GLint +_mesa_components_in_format( GLenum format ); + +extern GLint +_mesa_bytes_per_pixel( GLenum format, GLenum type ); + +extern GLboolean +_mesa_is_legal_format_and_type(const struct gl_context *ctx, + GLenum format, GLenum type); + +extern GLboolean +_mesa_is_color_format(GLenum format); + +extern GLboolean +_mesa_is_index_format(GLenum format); + +extern GLboolean +_mesa_is_depth_format(GLenum format); + +extern GLboolean +_mesa_is_stencil_format(GLenum format); + +extern GLboolean +_mesa_is_ycbcr_format(GLenum format); + +extern GLboolean +_mesa_is_depthstencil_format(GLenum format); + +extern GLboolean +_mesa_is_depth_or_stencil_format(GLenum format); + +extern GLboolean +_mesa_is_dudv_format(GLenum format); + +extern GLboolean +_mesa_is_integer_format(GLenum format); + +extern GLboolean +_mesa_is_compressed_format(struct gl_context *ctx, GLenum format); + +extern GLvoid * +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ); + +extern GLvoid * +_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, + GLenum format, GLenum type, + GLint column ); + +extern GLvoid * +_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint row, GLint column ); + +extern GLvoid * +_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ); + + +extern GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ); + + +extern GLint +_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLint height, + GLenum format, GLenum type ); + + +extern void +_mesa_expand_bitmap(GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap, + GLubyte *destBuffer, GLint destStride, + GLubyte onValue); + + +extern void +_mesa_convert_colors(GLenum srcType, const GLvoid *src, + GLenum dstType, GLvoid *dst, + GLuint count, const GLubyte mask[]); + + +extern GLboolean +_mesa_clip_drawpixels(const struct gl_context *ctx, + GLint *destX, GLint *destY, + GLsizei *width, GLsizei *height, + struct gl_pixelstore_attrib *unpack); + + +extern GLboolean +_mesa_clip_readpixels(const struct gl_context *ctx, + GLint *srcX, GLint *srcY, + GLsizei *width, GLsizei *height, + struct gl_pixelstore_attrib *pack); + +extern GLboolean +_mesa_clip_copytexsubimage(const struct gl_context *ctx, + GLint *destX, GLint *destY, + GLint *srcX, GLint *srcY, + GLsizei *width, GLsizei *height); + +extern GLboolean +_mesa_clip_to_region(GLint xmin, GLint ymin, + GLint xmax, GLint ymax, + GLint *x, GLint *y, + GLsizei *width, GLsizei *height ); + +extern GLboolean +_mesa_clip_blit(struct gl_context *ctx, + GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, + GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1); + + +#endif diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c index 46e5c932d..6bfa734b8 100644 --- a/mesalib/src/mesa/main/imports.c +++ b/mesalib/src/mesa/main/imports.c @@ -1,1031 +1,1032 @@ -/** - * \file imports.c - * Standard C library function wrappers. - * - * Imports are services which the device driver or window system or - * operating system provides to the core renderer. The core renderer (Mesa) - * will call these functions in order to do memory allocation, simple I/O, - * etc. - * - * Some drivers will want to override/replace this file with something - * specialized, but that'll be rare. - * - * Eventually, I want to move roll the glheader.h file into this. - * - * \todo Functions still needed: - * - scanf - * - qsort - * - rand and RAND_MAX - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#include "imports.h" -#include "context.h" -#include "version.h" - -#ifdef _GNU_SOURCE -#include -#ifdef __APPLE__ -#include -#endif -#endif - - -#define MAXSTRING 4000 /* for vsnprintf() */ - -#ifdef WIN32 -#define vsnprintf _vsnprintf -#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 ) -extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); -#ifdef __VMS -#include "vsnprintf.c" -#endif -#endif - -/**********************************************************************/ -/** \name Memory */ -/*@{*/ - -/** - * Allocate aligned memory. - * - * \param bytes number of bytes to allocate. - * \param alignment alignment (must be greater than zero). - * - * Allocates extra memory to accommodate rounding up the address for - * alignment and to record the real malloc address. - * - * \sa _mesa_align_free(). - */ -void * -_mesa_align_malloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - int err = posix_memalign(& mem, alignment, bytes); - (void) err; - return mem; -#elif defined(_WIN32) && defined(_MSC_VER) - return _aligned_malloc(bytes, alignment); -#else - uintptr_t ptr, buf; - - ASSERT( alignment > 0 ); - - ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifdef DEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *) buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Same as _mesa_align_malloc(), but using calloc(1, ) instead of - * malloc() - */ -void * -_mesa_align_calloc(size_t bytes, unsigned long alignment) -{ -#if defined(HAVE_POSIX_MEMALIGN) - void *mem; - - mem = _mesa_align_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#elif defined(_WIN32) && defined(_MSC_VER) - void *mem; - - mem = _aligned_malloc(bytes, alignment); - if (mem != NULL) { - (void) memset(mem, 0, bytes); - } - - return mem; -#else - uintptr_t ptr, buf; - - ASSERT( alignment > 0 ); - - ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *)); - if (!ptr) - return NULL; - - buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); - *(uintptr_t *)(buf - sizeof(void *)) = ptr; - -#ifdef DEBUG - /* mark the non-aligned area */ - while ( ptr < buf - sizeof(void *) ) { - *(unsigned long *)ptr = 0xcdcdcdcd; - ptr += sizeof(unsigned long); - } -#endif - - return (void *)buf; -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Free memory which was allocated with either _mesa_align_malloc() - * or _mesa_align_calloc(). - * \param ptr pointer to the memory to be freed. - * The actual address to free is stored in the word immediately before the - * address the client sees. - */ -void -_mesa_align_free(void *ptr) -{ -#if defined(HAVE_POSIX_MEMALIGN) - free(ptr); -#elif defined(_WIN32) && defined(_MSC_VER) - _aligned_free(ptr); -#else - void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); - void *realAddr = *cubbyHole; - free(realAddr); -#endif /* defined(HAVE_POSIX_MEMALIGN) */ -} - -/** - * Reallocate memory, with alignment. - */ -void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment) -{ -#if defined(_WIN32) && defined(_MSC_VER) - (void) oldSize; - return _aligned_realloc(oldBuffer, newSize, alignment); -#else - const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuf = _mesa_align_malloc(newSize, alignment); - if (newBuf && oldBuffer && copySize > 0) { - memcpy(newBuf, oldBuffer, copySize); - } - if (oldBuffer) - _mesa_align_free(oldBuffer); - return newBuf; -#endif -} - - - -/** Reallocate memory */ -void * -_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) -{ - const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuffer = malloc(newSize); - if (newBuffer && oldBuffer && copySize > 0) - memcpy(newBuffer, oldBuffer, copySize); - if (oldBuffer) - free(oldBuffer); - return newBuffer; -} - -/** - * Fill memory with a constant 16bit word. - * \param dst destination pointer. - * \param val value. - * \param n number of words. - */ -void -_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) -{ - while (n-- > 0) - *dst++ = val; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Math */ -/*@{*/ - -/** Wrapper around sqrt() */ -double -_mesa_sqrtd(double x) -{ - return sqrt(x); -} - - -/* - * A High Speed, Low Precision Square Root - * by Paul Lalonde and Robert Dawson - * from "Graphics Gems", Academic Press, 1990 - * - * SPARC implementation of a fast square root by table - * lookup. - * SPARC floating point format is as follows: - * - * BIT 31 30 23 22 0 - * sign exponent mantissa - */ -static short sqrttab[0x100]; /* declare table of square roots */ - -void -_mesa_init_sqrt_table(void) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - unsigned short i; - fi_type fi; /* to access the bits of a float in C quickly */ - /* we use a union defined in glheader.h */ - - for(i=0; i<= 0x7f; i++) { - fi.i = 0; - - /* - * Build a float with the bit pattern i as mantissa - * and an exponent of 0, stored as 127 - */ - - fi.i = (i << 16) | (127 << 23); - fi.f = _mesa_sqrtd(fi.f); - - /* - * Take the square root then strip the first 7 bits of - * the mantissa into the table - */ - - sqrttab[i] = (fi.i & 0x7fffff) >> 16; - - /* - * Repeat the process, this time with an exponent of - * 1, stored as 128 - */ - - fi.i = 0; - fi.i = (i << 16) | (128 << 23); - fi.f = sqrt(fi.f); - sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16; - } -#else - (void) sqrttab; /* silence compiler warnings */ -#endif /*HAVE_FAST_MATH*/ -} - - -/** - * Single precision square root. - */ -float -_mesa_sqrtf( float x ) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - fi_type num; - /* to access the bits of a float in C - * we use a union from glheader.h */ - - short e; /* the exponent */ - if (x == 0.0F) return 0.0F; /* check for square root of 0 */ - num.f = x; - e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */ - /* exponent is stored with 127 added */ - num.i &= 0x7fffff; /* leave only the mantissa */ - if (e & 0x01) num.i |= 0x800000; - /* the exponent is odd so we have to */ - /* look it up in the second half of */ - /* the lookup table, so we set the */ - /* high bit */ - e >>= 1; /* divide the exponent by two */ - /* note that in C the shift */ - /* operators are sign preserving */ - /* for signed operands */ - /* Do the table lookup, based on the quaternary mantissa, - * then reconstruct the result back into a float - */ - num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23); - - return num.f; -#else - return (float) _mesa_sqrtd((double) x); -#endif -} - - -/** - inv_sqrt - A single precision 1/sqrt routine for IEEE format floats. - written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk - and Vesa Karvonen. -*/ -float -_mesa_inv_sqrtf(float n) -{ -#if defined(USE_IEEE) && !defined(DEBUG) - float r0, x0, y0; - float r1, x1, y1; - float r2, x2, y2; -#if 0 /* not used, see below -BP */ - float r3, x3, y3; -#endif - fi_type u; - unsigned int magic; - - /* - Exponent part of the magic number - - - We want to: - 1. subtract the bias from the exponent, - 2. negate it - 3. divide by two (rounding towards -inf) - 4. add the bias back - - Which is the same as subtracting the exponent from 381 and dividing - by 2. - - floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2) - */ - - magic = 381 << 23; - - /* - Significand part of magic number - - - With the current magic number, "(magic - u.i) >> 1" will give you: - - for 1 <= u.f <= 2: 1.25 - u.f / 4 - for 2 <= u.f <= 4: 1.00 - u.f / 8 - - This isn't a bad approximation of 1/sqrt. The maximum difference from - 1/sqrt will be around .06. After three Newton-Raphson iterations, the - maximum difference is less than 4.5e-8. (Which is actually close - enough to make the following bias academic...) - - To get a better approximation you can add a bias to the magic - number. For example, if you subtract 1/2 of the maximum difference in - the first approximation (.03), you will get the following function: - - for 1 <= u.f <= 2: 1.22 - u.f / 4 - for 2 <= u.f <= 3.76: 0.97 - u.f / 8 - for 3.76 <= u.f <= 4: 0.72 - u.f / 16 - (The 3.76 to 4 range is where the result is < .5.) - - This is the closest possible initial approximation, but with a maximum - error of 8e-11 after three NR iterations, it is still not perfect. If - you subtract 0.0332281 instead of .03, the maximum error will be - 2.5e-11 after three NR iterations, which should be about as close as - is possible. - - for 1 <= u.f <= 2: 1.2167719 - u.f / 4 - for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8 - for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16 - - */ - - magic -= (int)(0.0332281 * (1 << 25)); - - u.f = n; - u.i = (magic - u.i) >> 1; - - /* - Instead of Newton-Raphson, we use Goldschmidt's algorithm, which - allows more parallelism. From what I understand, the parallelism - comes at the cost of less precision, because it lets error - accumulate across iterations. - */ - x0 = 1.0f; - y0 = 0.5f * n; - r0 = u.f; - - x1 = x0 * r0; - y1 = y0 * r0 * r0; - r1 = 1.5f - y1; - - x2 = x1 * r1; - y2 = y1 * r1 * r1; - r2 = 1.5f - y2; - -#if 1 - return x2 * r2; /* we can stop here, and be conformant -BP */ -#else - x3 = x2 * r2; - y3 = y2 * r2 * r2; - r3 = 1.5f - y3; - - return x3 * r3; -#endif -#else - return (float) (1.0 / sqrt(n)); -#endif -} - -/** - * Find the first bit set in a word. - */ -int -_mesa_ffs(int32_t i) -{ -#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__) - register int bit = 0; - if (i != 0) { - if ((i & 0xffff) == 0) { - bit += 16; - i >>= 16; - } - if ((i & 0xff) == 0) { - bit += 8; - i >>= 8; - } - if ((i & 0xf) == 0) { - bit += 4; - i >>= 4; - } - while ((i & 1) == 0) { - bit++; - i >>= 1; - } - bit++; - } - return bit; -#else - return ffs(i); -#endif -} - - -/** - * Find position of first bit set in given value. - * XXX Warning: this function can only be used on 64-bit systems! - * \return position of least-significant bit set, starting at 1, return zero - * if no bits set. - */ -int -_mesa_ffsll(int64_t val) -{ -#ifdef ffsll - return ffsll(val); -#else - int bit; - - assert(sizeof(val) == 8); - - bit = _mesa_ffs((int32_t)val); - if (bit != 0) - return bit; - - bit = _mesa_ffs((int32_t)(val >> 32)); - if (bit != 0) - return 32 + bit; - - return 0; -#endif -} - - -/** - * Return number of bits set in given GLuint. - */ -unsigned int -_mesa_bitcount(unsigned int n) -{ -#if defined(__GNUC__) && \ - ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - return __builtin_popcount(n); -#else - unsigned int bits; - for (bits = 0; n > 0; n = n >> 1) { - bits += (n & 1); - } - return bits; -#endif -} - - -/** - * Convert a 4-byte float to a 2-byte half float. - * Based on code from: - * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html - */ -GLhalfARB -_mesa_float_to_half(float val) -{ - const fi_type fi = {val}; - const int flt_m = fi.i & 0x7fffff; - const int flt_e = (fi.i >> 23) & 0xff; - const int flt_s = (fi.i >> 31) & 0x1; - int s, e, m = 0; - GLhalfARB result; - - /* sign bit */ - s = flt_s; - - /* handle special cases */ - if ((flt_e == 0) && (flt_m == 0)) { - /* zero */ - /* m = 0; - already set */ - e = 0; - } - else if ((flt_e == 0) && (flt_m != 0)) { - /* denorm -- denorm float maps to 0 half */ - /* m = 0; - already set */ - e = 0; - } - else if ((flt_e == 0xff) && (flt_m == 0)) { - /* infinity */ - /* m = 0; - already set */ - e = 31; - } - else if ((flt_e == 0xff) && (flt_m != 0)) { - /* NaN */ - m = 1; - e = 31; - } - else { - /* regular number */ - const int new_exp = flt_e - 127; - if (new_exp < -24) { - /* this maps to 0 */ - /* m = 0; - already set */ - e = 0; - } - else if (new_exp < -14) { - /* this maps to a denorm */ - unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/ - e = 0; - switch (exp_val) { - case 0: - _mesa_warning(NULL, - "float_to_half: logical error in denorm creation!\n"); - /* m = 0; - already set */ - break; - case 1: m = 512 + (flt_m >> 14); break; - case 2: m = 256 + (flt_m >> 15); break; - case 3: m = 128 + (flt_m >> 16); break; - case 4: m = 64 + (flt_m >> 17); break; - case 5: m = 32 + (flt_m >> 18); break; - case 6: m = 16 + (flt_m >> 19); break; - case 7: m = 8 + (flt_m >> 20); break; - case 8: m = 4 + (flt_m >> 21); break; - case 9: m = 2 + (flt_m >> 22); break; - case 10: m = 1; break; - } - } - else if (new_exp > 15) { - /* map this value to infinity */ - /* m = 0; - already set */ - e = 31; - } - else { - /* regular */ - e = new_exp + 15; - m = flt_m >> 13; - } - } - - result = (s << 15) | (e << 10) | m; - return result; -} - - -/** - * Convert a 2-byte half float to a 4-byte float. - * Based on code from: - * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html - */ -float -_mesa_half_to_float(GLhalfARB val) -{ - /* XXX could also use a 64K-entry lookup table */ - const int m = val & 0x3ff; - const int e = (val >> 10) & 0x1f; - const int s = (val >> 15) & 0x1; - int flt_m, flt_e, flt_s; - fi_type fi; - float result; - - /* sign bit */ - flt_s = s; - - /* handle special cases */ - if ((e == 0) && (m == 0)) { - /* zero */ - flt_m = 0; - flt_e = 0; - } - else if ((e == 0) && (m != 0)) { - /* denorm -- denorm half will fit in non-denorm single */ - const float half_denorm = 1.0f / 16384.0f; /* 2^-14 */ - float mantissa = ((float) (m)) / 1024.0f; - float sign = s ? -1.0f : 1.0f; - return sign * mantissa * half_denorm; - } - else if ((e == 31) && (m == 0)) { - /* infinity */ - flt_e = 0xff; - flt_m = 0; - } - else if ((e == 31) && (m != 0)) { - /* NaN */ - flt_e = 0xff; - flt_m = 1; - } - else { - /* regular */ - flt_e = e + 112; - flt_m = m << 13; - } - - fi.i = (flt_s << 31) | (flt_e << 23) | flt_m; - result = fi.f; - return result; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Sort & Search */ -/*@{*/ - -/** - * Wrapper for bsearch(). - */ -void * -_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *) ) -{ -#if defined(_WIN32_WCE) - void *mid; - int cmp; - while (nmemb) { - nmemb >>= 1; - mid = (char *)base + nmemb * size; - cmp = (*compar)(key, mid); - if (cmp == 0) - return mid; - if (cmp > 0) { - base = (char *)mid + size; - --nmemb; - } - } - return NULL; -#else - return bsearch(key, base, nmemb, size, compar); -#endif -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Environment vars */ -/*@{*/ - -/** - * Wrapper for getenv(). - */ -char * -_mesa_getenv( const char *var ) -{ -#if defined(_XBOX) || defined(_WIN32_WCE) - return NULL; -#else - return getenv(var); -#endif -} - -/*@}*/ - - -/**********************************************************************/ -/** \name String */ -/*@{*/ - -/** - * Implemented using malloc() and strcpy. - * Note that NULL is handled accordingly. - */ -char * -_mesa_strdup( const char *s ) -{ - if (s) { - size_t l = strlen(s); - char *s2 = (char *) malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - else { - return NULL; - } -} - -/** Wrapper around strtof() */ -float -_mesa_strtof( const char *s, char **end ) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); -#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) - return strtof(s, end); -#else - return (float)strtod(s, end); -#endif -} - -/** Compute simple checksum/hash for a string */ -unsigned int -_mesa_str_checksum(const char *str) -{ - /* This could probably be much better */ - unsigned int sum, i; - const char *c; - sum = i = 1; - for (c = str; *c; c++, i++) - sum += *c * (i % 100); - return sum + i; -} - - -/*@}*/ - - -/** Wrapper around vsnprintf() */ -int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsnprintf( str, size, fmt, args ); - va_end( args ); - return r; -} - - -/**********************************************************************/ -/** \name Diagnostics */ -/*@{*/ - -static void -output_if_debug(const char *prefixString, const char *outputString, - GLboolean newline) -{ - static int debug = -1; - - /* Check the MESA_DEBUG environment variable if it hasn't - * been checked yet. We only have to check it once... - */ - if (debug == -1) { - char *env = _mesa_getenv("MESA_DEBUG"); - - /* In a debug build, we print warning messages *unless* - * MESA_DEBUG is 0. In a non-debug build, we don't - * print warning messages *unless* MESA_DEBUG is - * set *to any value*. - */ -#ifdef DEBUG - debug = (env != NULL && atoi(env) == 0) ? 0 : 1; -#else - debug = (env != NULL) ? 1 : 0; -#endif - } - - /* Now only print the string if we're required to do so. */ - if (debug) { - fprintf(stderr, "%s: %s", prefixString, outputString); - if (newline) - fprintf(stderr, "\n"); - -#if defined(_WIN32) && !defined(_WIN32_WCE) - /* stderr from windows applications without console is not usually - * visible, so communicate with the debugger instead */ - { - char buf[4096]; - _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); - OutputDebugStringA(buf); - } -#endif - } -} - - -/** - * Return string version of GL error code. - */ -static const char * -error_string( GLenum error ) -{ - switch (error) { - case GL_NO_ERROR: - return "GL_NO_ERROR"; - case GL_INVALID_VALUE: - return "GL_INVALID_VALUE"; - case GL_INVALID_ENUM: - return "GL_INVALID_ENUM"; - case GL_INVALID_OPERATION: - return "GL_INVALID_OPERATION"; - case GL_STACK_OVERFLOW: - return "GL_STACK_OVERFLOW"; - case GL_STACK_UNDERFLOW: - return "GL_STACK_UNDERFLOW"; - case GL_OUT_OF_MEMORY: - return "GL_OUT_OF_MEMORY"; - case GL_TABLE_TOO_LARGE: - return "GL_TABLE_TOO_LARGE"; - case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: - return "GL_INVALID_FRAMEBUFFER_OPERATION"; - default: - return "unknown"; - } -} - - -/** - * When a new type of error is recorded, print a message describing - * previous errors which were accumulated. - */ -static void -flush_delayed_errors( GLcontext *ctx ) -{ - char s[MAXSTRING]; - - if (ctx->ErrorDebugCount) { - _mesa_snprintf(s, MAXSTRING, "%d similar %s errors", - ctx->ErrorDebugCount, - error_string(ctx->ErrorValue)); - - output_if_debug("Mesa", s, GL_TRUE); - - ctx->ErrorDebugCount = 0; - } -} - - -/** - * Report a warning (a recoverable error condition) to stderr if - * either DEBUG is defined or the MESA_DEBUG env var is set. - * - * \param ctx GL context. - * \param fmtString printf()-like format string. - */ -void -_mesa_warning( GLcontext *ctx, const char *fmtString, ... ) -{ - char str[MAXSTRING]; - va_list args; - va_start( args, fmtString ); - (void) vsnprintf( str, MAXSTRING, fmtString, args ); - va_end( args ); - - if (ctx) - flush_delayed_errors( ctx ); - - output_if_debug("Mesa warning", str, GL_TRUE); -} - - -/** - * Report an internal implementation problem. - * Prints the message to stderr via fprintf(). - * - * \param ctx GL context. - * \param fmtString problem description string. - */ -void -_mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) -{ - va_list args; - char str[MAXSTRING]; - (void) ctx; - - va_start( args, fmtString ); - vsnprintf( str, MAXSTRING, fmtString, args ); - va_end( args ); - - fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str); - fprintf(stderr, "Please report at bugzilla.freedesktop.org\n"); -} - - -/** - * Record an OpenGL state error. These usually occur when the user - * passes invalid parameters to a GL function. - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), report the error with - * _mesa_debug(). - * - * \param ctx the GL context. - * \param error the error value. - * \param fmtString printf() style format string, followed by optional args - */ -void -_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) -{ - static GLint debug = -1; - - /* Check debug environment variable only once: - */ - if (debug == -1) { - const char *debugEnv = _mesa_getenv("MESA_DEBUG"); - -#ifdef DEBUG - if (debugEnv && strstr(debugEnv, "silent")) - debug = GL_FALSE; - else - debug = GL_TRUE; -#else - if (debugEnv) - debug = GL_TRUE; - else - debug = GL_FALSE; -#endif - } - - if (debug) { - if (ctx->ErrorValue == error && - ctx->ErrorDebugFmtString == fmtString) { - ctx->ErrorDebugCount++; - } - else { - char s[MAXSTRING], s2[MAXSTRING]; - va_list args; - - flush_delayed_errors( ctx ); - - va_start(args, fmtString); - vsnprintf(s, MAXSTRING, fmtString, args); - va_end(args); - - _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); - output_if_debug("Mesa: User error", s2, GL_TRUE); - - ctx->ErrorDebugFmtString = fmtString; - ctx->ErrorDebugCount = 0; - } - } - - _mesa_record_error(ctx, error); -} - - -/** - * Report debug information. Print error message to stderr via fprintf(). - * No-op if DEBUG mode not enabled. - * - * \param ctx GL context. - * \param fmtString printf()-style format string, followed by optional args. - */ -void -_mesa_debug( const GLcontext *ctx, const char *fmtString, ... ) -{ -#ifdef DEBUG - char s[MAXSTRING]; - va_list args; - va_start(args, fmtString); - vsnprintf(s, MAXSTRING, fmtString, args); - va_end(args); - output_if_debug("Mesa", s, GL_FALSE); -#endif /* DEBUG */ - (void) ctx; - (void) fmtString; -} - -/*@}*/ +/** + * \file imports.c + * Standard C library function wrappers. + * + * Imports are services which the device driver or window system or + * operating system provides to the core renderer. The core renderer (Mesa) + * will call these functions in order to do memory allocation, simple I/O, + * etc. + * + * Some drivers will want to override/replace this file with something + * specialized, but that'll be rare. + * + * Eventually, I want to move roll the glheader.h file into this. + * + * \todo Functions still needed: + * - scanf + * - qsort + * - rand and RAND_MAX + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#include "imports.h" +#include "context.h" +#include "version.h" + +#ifdef _GNU_SOURCE +#include +#ifdef __APPLE__ +#include +#endif +#endif + + +#define MAXSTRING 4000 /* for vsnprintf() */ + +#ifdef WIN32 +#define vsnprintf _vsnprintf +#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 ) +extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); +#ifdef __VMS +#include "vsnprintf.c" +#endif +#endif + +/**********************************************************************/ +/** \name Memory */ +/*@{*/ + +/** + * Allocate aligned memory. + * + * \param bytes number of bytes to allocate. + * \param alignment alignment (must be greater than zero). + * + * Allocates extra memory to accommodate rounding up the address for + * alignment and to record the real malloc address. + * + * \sa _mesa_align_free(). + */ +void * +_mesa_align_malloc(size_t bytes, unsigned long alignment) +{ +#if defined(HAVE_POSIX_MEMALIGN) + void *mem; + int err = posix_memalign(& mem, alignment, bytes); + if (err) + return NULL; + return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + return _aligned_malloc(bytes, alignment); +#else + uintptr_t ptr, buf; + + ASSERT( alignment > 0 ); + + ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *)); + if (!ptr) + return NULL; + + buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); + *(uintptr_t *)(buf - sizeof(void *)) = ptr; + +#ifdef DEBUG + /* mark the non-aligned area */ + while ( ptr < buf - sizeof(void *) ) { + *(unsigned long *)ptr = 0xcdcdcdcd; + ptr += sizeof(unsigned long); + } +#endif + + return (void *) buf; +#endif /* defined(HAVE_POSIX_MEMALIGN) */ +} + +/** + * Same as _mesa_align_malloc(), but using calloc(1, ) instead of + * malloc() + */ +void * +_mesa_align_calloc(size_t bytes, unsigned long alignment) +{ +#if defined(HAVE_POSIX_MEMALIGN) + void *mem; + + mem = _mesa_align_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + void *mem; + + mem = _aligned_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; +#else + uintptr_t ptr, buf; + + ASSERT( alignment > 0 ); + + ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *)); + if (!ptr) + return NULL; + + buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); + *(uintptr_t *)(buf - sizeof(void *)) = ptr; + +#ifdef DEBUG + /* mark the non-aligned area */ + while ( ptr < buf - sizeof(void *) ) { + *(unsigned long *)ptr = 0xcdcdcdcd; + ptr += sizeof(unsigned long); + } +#endif + + return (void *)buf; +#endif /* defined(HAVE_POSIX_MEMALIGN) */ +} + +/** + * Free memory which was allocated with either _mesa_align_malloc() + * or _mesa_align_calloc(). + * \param ptr pointer to the memory to be freed. + * The actual address to free is stored in the word immediately before the + * address the client sees. + */ +void +_mesa_align_free(void *ptr) +{ +#if defined(HAVE_POSIX_MEMALIGN) + free(ptr); +#elif defined(_WIN32) && defined(_MSC_VER) + _aligned_free(ptr); +#else + void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); + void *realAddr = *cubbyHole; + free(realAddr); +#endif /* defined(HAVE_POSIX_MEMALIGN) */ +} + +/** + * Reallocate memory, with alignment. + */ +void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment) +{ +#if defined(_WIN32) && defined(_MSC_VER) + (void) oldSize; + return _aligned_realloc(oldBuffer, newSize, alignment); +#else + const size_t copySize = (oldSize < newSize) ? oldSize : newSize; + void *newBuf = _mesa_align_malloc(newSize, alignment); + if (newBuf && oldBuffer && copySize > 0) { + memcpy(newBuf, oldBuffer, copySize); + } + if (oldBuffer) + _mesa_align_free(oldBuffer); + return newBuf; +#endif +} + + + +/** Reallocate memory */ +void * +_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) +{ + const size_t copySize = (oldSize < newSize) ? oldSize : newSize; + void *newBuffer = malloc(newSize); + if (newBuffer && oldBuffer && copySize > 0) + memcpy(newBuffer, oldBuffer, copySize); + if (oldBuffer) + free(oldBuffer); + return newBuffer; +} + +/** + * Fill memory with a constant 16bit word. + * \param dst destination pointer. + * \param val value. + * \param n number of words. + */ +void +_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) +{ + while (n-- > 0) + *dst++ = val; +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Math */ +/*@{*/ + +/** Wrapper around sqrt() */ +double +_mesa_sqrtd(double x) +{ + return sqrt(x); +} + + +/* + * A High Speed, Low Precision Square Root + * by Paul Lalonde and Robert Dawson + * from "Graphics Gems", Academic Press, 1990 + * + * SPARC implementation of a fast square root by table + * lookup. + * SPARC floating point format is as follows: + * + * BIT 31 30 23 22 0 + * sign exponent mantissa + */ +static short sqrttab[0x100]; /* declare table of square roots */ + +void +_mesa_init_sqrt_table(void) +{ +#if defined(USE_IEEE) && !defined(DEBUG) + unsigned short i; + fi_type fi; /* to access the bits of a float in C quickly */ + /* we use a union defined in glheader.h */ + + for(i=0; i<= 0x7f; i++) { + fi.i = 0; + + /* + * Build a float with the bit pattern i as mantissa + * and an exponent of 0, stored as 127 + */ + + fi.i = (i << 16) | (127 << 23); + fi.f = _mesa_sqrtd(fi.f); + + /* + * Take the square root then strip the first 7 bits of + * the mantissa into the table + */ + + sqrttab[i] = (fi.i & 0x7fffff) >> 16; + + /* + * Repeat the process, this time with an exponent of + * 1, stored as 128 + */ + + fi.i = 0; + fi.i = (i << 16) | (128 << 23); + fi.f = sqrt(fi.f); + sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16; + } +#else + (void) sqrttab; /* silence compiler warnings */ +#endif /*HAVE_FAST_MATH*/ +} + + +/** + * Single precision square root. + */ +float +_mesa_sqrtf( float x ) +{ +#if defined(USE_IEEE) && !defined(DEBUG) + fi_type num; + /* to access the bits of a float in C + * we use a union from glheader.h */ + + short e; /* the exponent */ + if (x == 0.0F) return 0.0F; /* check for square root of 0 */ + num.f = x; + e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */ + /* exponent is stored with 127 added */ + num.i &= 0x7fffff; /* leave only the mantissa */ + if (e & 0x01) num.i |= 0x800000; + /* the exponent is odd so we have to */ + /* look it up in the second half of */ + /* the lookup table, so we set the */ + /* high bit */ + e >>= 1; /* divide the exponent by two */ + /* note that in C the shift */ + /* operators are sign preserving */ + /* for signed operands */ + /* Do the table lookup, based on the quaternary mantissa, + * then reconstruct the result back into a float + */ + num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23); + + return num.f; +#else + return (float) _mesa_sqrtd((double) x); +#endif +} + + +/** + inv_sqrt - A single precision 1/sqrt routine for IEEE format floats. + written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk + and Vesa Karvonen. +*/ +float +_mesa_inv_sqrtf(float n) +{ +#if defined(USE_IEEE) && !defined(DEBUG) + float r0, x0, y0; + float r1, x1, y1; + float r2, x2, y2; +#if 0 /* not used, see below -BP */ + float r3, x3, y3; +#endif + fi_type u; + unsigned int magic; + + /* + Exponent part of the magic number - + + We want to: + 1. subtract the bias from the exponent, + 2. negate it + 3. divide by two (rounding towards -inf) + 4. add the bias back + + Which is the same as subtracting the exponent from 381 and dividing + by 2. + + floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2) + */ + + magic = 381 << 23; + + /* + Significand part of magic number - + + With the current magic number, "(magic - u.i) >> 1" will give you: + + for 1 <= u.f <= 2: 1.25 - u.f / 4 + for 2 <= u.f <= 4: 1.00 - u.f / 8 + + This isn't a bad approximation of 1/sqrt. The maximum difference from + 1/sqrt will be around .06. After three Newton-Raphson iterations, the + maximum difference is less than 4.5e-8. (Which is actually close + enough to make the following bias academic...) + + To get a better approximation you can add a bias to the magic + number. For example, if you subtract 1/2 of the maximum difference in + the first approximation (.03), you will get the following function: + + for 1 <= u.f <= 2: 1.22 - u.f / 4 + for 2 <= u.f <= 3.76: 0.97 - u.f / 8 + for 3.76 <= u.f <= 4: 0.72 - u.f / 16 + (The 3.76 to 4 range is where the result is < .5.) + + This is the closest possible initial approximation, but with a maximum + error of 8e-11 after three NR iterations, it is still not perfect. If + you subtract 0.0332281 instead of .03, the maximum error will be + 2.5e-11 after three NR iterations, which should be about as close as + is possible. + + for 1 <= u.f <= 2: 1.2167719 - u.f / 4 + for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8 + for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16 + + */ + + magic -= (int)(0.0332281 * (1 << 25)); + + u.f = n; + u.i = (magic - u.i) >> 1; + + /* + Instead of Newton-Raphson, we use Goldschmidt's algorithm, which + allows more parallelism. From what I understand, the parallelism + comes at the cost of less precision, because it lets error + accumulate across iterations. + */ + x0 = 1.0f; + y0 = 0.5f * n; + r0 = u.f; + + x1 = x0 * r0; + y1 = y0 * r0 * r0; + r1 = 1.5f - y1; + + x2 = x1 * r1; + y2 = y1 * r1 * r1; + r2 = 1.5f - y2; + +#if 1 + return x2 * r2; /* we can stop here, and be conformant -BP */ +#else + x3 = x2 * r2; + y3 = y2 * r2 * r2; + r3 = 1.5f - y3; + + return x3 * r3; +#endif +#else + return (float) (1.0 / sqrt(n)); +#endif +} + +/** + * Find the first bit set in a word. + */ +int +_mesa_ffs(int32_t i) +{ +#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__) + register int bit = 0; + if (i != 0) { + if ((i & 0xffff) == 0) { + bit += 16; + i >>= 16; + } + if ((i & 0xff) == 0) { + bit += 8; + i >>= 8; + } + if ((i & 0xf) == 0) { + bit += 4; + i >>= 4; + } + while ((i & 1) == 0) { + bit++; + i >>= 1; + } + bit++; + } + return bit; +#else + return ffs(i); +#endif +} + + +/** + * Find position of first bit set in given value. + * XXX Warning: this function can only be used on 64-bit systems! + * \return position of least-significant bit set, starting at 1, return zero + * if no bits set. + */ +int +_mesa_ffsll(int64_t val) +{ +#ifdef ffsll + return ffsll(val); +#else + int bit; + + assert(sizeof(val) == 8); + + bit = _mesa_ffs((int32_t)val); + if (bit != 0) + return bit; + + bit = _mesa_ffs((int32_t)(val >> 32)); + if (bit != 0) + return 32 + bit; + + return 0; +#endif +} + + +/** + * Return number of bits set in given GLuint. + */ +unsigned int +_mesa_bitcount(unsigned int n) +{ +#if defined(__GNUC__) && \ + ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + return __builtin_popcount(n); +#else + unsigned int bits; + for (bits = 0; n > 0; n = n >> 1) { + bits += (n & 1); + } + return bits; +#endif +} + + +/** + * Convert a 4-byte float to a 2-byte half float. + * Based on code from: + * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html + */ +GLhalfARB +_mesa_float_to_half(float val) +{ + const fi_type fi = {val}; + const int flt_m = fi.i & 0x7fffff; + const int flt_e = (fi.i >> 23) & 0xff; + const int flt_s = (fi.i >> 31) & 0x1; + int s, e, m = 0; + GLhalfARB result; + + /* sign bit */ + s = flt_s; + + /* handle special cases */ + if ((flt_e == 0) && (flt_m == 0)) { + /* zero */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0) && (flt_m != 0)) { + /* denorm -- denorm float maps to 0 half */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0xff) && (flt_m == 0)) { + /* infinity */ + /* m = 0; - already set */ + e = 31; + } + else if ((flt_e == 0xff) && (flt_m != 0)) { + /* NaN */ + m = 1; + e = 31; + } + else { + /* regular number */ + const int new_exp = flt_e - 127; + if (new_exp < -24) { + /* this maps to 0 */ + /* m = 0; - already set */ + e = 0; + } + else if (new_exp < -14) { + /* this maps to a denorm */ + unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/ + e = 0; + switch (exp_val) { + case 0: + _mesa_warning(NULL, + "float_to_half: logical error in denorm creation!\n"); + /* m = 0; - already set */ + break; + case 1: m = 512 + (flt_m >> 14); break; + case 2: m = 256 + (flt_m >> 15); break; + case 3: m = 128 + (flt_m >> 16); break; + case 4: m = 64 + (flt_m >> 17); break; + case 5: m = 32 + (flt_m >> 18); break; + case 6: m = 16 + (flt_m >> 19); break; + case 7: m = 8 + (flt_m >> 20); break; + case 8: m = 4 + (flt_m >> 21); break; + case 9: m = 2 + (flt_m >> 22); break; + case 10: m = 1; break; + } + } + else if (new_exp > 15) { + /* map this value to infinity */ + /* m = 0; - already set */ + e = 31; + } + else { + /* regular */ + e = new_exp + 15; + m = flt_m >> 13; + } + } + + result = (s << 15) | (e << 10) | m; + return result; +} + + +/** + * Convert a 2-byte half float to a 4-byte float. + * Based on code from: + * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html + */ +float +_mesa_half_to_float(GLhalfARB val) +{ + /* XXX could also use a 64K-entry lookup table */ + const int m = val & 0x3ff; + const int e = (val >> 10) & 0x1f; + const int s = (val >> 15) & 0x1; + int flt_m, flt_e, flt_s; + fi_type fi; + float result; + + /* sign bit */ + flt_s = s; + + /* handle special cases */ + if ((e == 0) && (m == 0)) { + /* zero */ + flt_m = 0; + flt_e = 0; + } + else if ((e == 0) && (m != 0)) { + /* denorm -- denorm half will fit in non-denorm single */ + const float half_denorm = 1.0f / 16384.0f; /* 2^-14 */ + float mantissa = ((float) (m)) / 1024.0f; + float sign = s ? -1.0f : 1.0f; + return sign * mantissa * half_denorm; + } + else if ((e == 31) && (m == 0)) { + /* infinity */ + flt_e = 0xff; + flt_m = 0; + } + else if ((e == 31) && (m != 0)) { + /* NaN */ + flt_e = 0xff; + flt_m = 1; + } + else { + /* regular */ + flt_e = e + 112; + flt_m = m << 13; + } + + fi.i = (flt_s << 31) | (flt_e << 23) | flt_m; + result = fi.f; + return result; +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Sort & Search */ +/*@{*/ + +/** + * Wrapper for bsearch(). + */ +void * +_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *) ) +{ +#if defined(_WIN32_WCE) + void *mid; + int cmp; + while (nmemb) { + nmemb >>= 1; + mid = (char *)base + nmemb * size; + cmp = (*compar)(key, mid); + if (cmp == 0) + return mid; + if (cmp > 0) { + base = (char *)mid + size; + --nmemb; + } + } + return NULL; +#else + return bsearch(key, base, nmemb, size, compar); +#endif +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Environment vars */ +/*@{*/ + +/** + * Wrapper for getenv(). + */ +char * +_mesa_getenv( const char *var ) +{ +#if defined(_XBOX) || defined(_WIN32_WCE) + return NULL; +#else + return getenv(var); +#endif +} + +/*@}*/ + + +/**********************************************************************/ +/** \name String */ +/*@{*/ + +/** + * Implemented using malloc() and strcpy. + * Note that NULL is handled accordingly. + */ +char * +_mesa_strdup( const char *s ) +{ + if (s) { + size_t l = strlen(s); + char *s2 = (char *) malloc(l + 1); + if (s2) + strcpy(s2, s); + return s2; + } + else { + return NULL; + } +} + +/** Wrapper around strtof() */ +float +_mesa_strtof( const char *s, char **end ) +{ +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) + static locale_t loc = NULL; + if (!loc) { + loc = newlocale(LC_CTYPE_MASK, "C", NULL); + } + return strtof_l(s, end, loc); +#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) + return strtof(s, end); +#else + return (float)strtod(s, end); +#endif +} + +/** Compute simple checksum/hash for a string */ +unsigned int +_mesa_str_checksum(const char *str) +{ + /* This could probably be much better */ + unsigned int sum, i; + const char *c; + sum = i = 1; + for (c = str; *c; c++, i++) + sum += *c * (i % 100); + return sum + i; +} + + +/*@}*/ + + +/** Wrapper around vsnprintf() */ +int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) +{ + int r; + va_list args; + va_start( args, fmt ); + r = vsnprintf( str, size, fmt, args ); + va_end( args ); + return r; +} + + +/**********************************************************************/ +/** \name Diagnostics */ +/*@{*/ + +static void +output_if_debug(const char *prefixString, const char *outputString, + GLboolean newline) +{ + static int debug = -1; + + /* Check the MESA_DEBUG environment variable if it hasn't + * been checked yet. We only have to check it once... + */ + if (debug == -1) { + char *env = _mesa_getenv("MESA_DEBUG"); + + /* In a debug build, we print warning messages *unless* + * MESA_DEBUG is 0. In a non-debug build, we don't + * print warning messages *unless* MESA_DEBUG is + * set *to any value*. + */ +#ifdef DEBUG + debug = (env != NULL && atoi(env) == 0) ? 0 : 1; +#else + debug = (env != NULL) ? 1 : 0; +#endif + } + + /* Now only print the string if we're required to do so. */ + if (debug) { + fprintf(stderr, "%s: %s", prefixString, outputString); + if (newline) + fprintf(stderr, "\n"); + +#if defined(_WIN32) && !defined(_WIN32_WCE) + /* stderr from windows applications without console is not usually + * visible, so communicate with the debugger instead */ + { + char buf[4096]; + _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); + OutputDebugStringA(buf); + } +#endif + } +} + + +/** + * Return string version of GL error code. + */ +static const char * +error_string( GLenum error ) +{ + switch (error) { + case GL_NO_ERROR: + return "GL_NO_ERROR"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE"; + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION"; + case GL_STACK_OVERFLOW: + return "GL_STACK_OVERFLOW"; + case GL_STACK_UNDERFLOW: + return "GL_STACK_UNDERFLOW"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY"; + case GL_TABLE_TOO_LARGE: + return "GL_TABLE_TOO_LARGE"; + case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: + return "GL_INVALID_FRAMEBUFFER_OPERATION"; + default: + return "unknown"; + } +} + + +/** + * When a new type of error is recorded, print a message describing + * previous errors which were accumulated. + */ +static void +flush_delayed_errors( struct gl_context *ctx ) +{ + char s[MAXSTRING]; + + if (ctx->ErrorDebugCount) { + _mesa_snprintf(s, MAXSTRING, "%d similar %s errors", + ctx->ErrorDebugCount, + error_string(ctx->ErrorValue)); + + output_if_debug("Mesa", s, GL_TRUE); + + ctx->ErrorDebugCount = 0; + } +} + + +/** + * Report a warning (a recoverable error condition) to stderr if + * either DEBUG is defined or the MESA_DEBUG env var is set. + * + * \param ctx GL context. + * \param fmtString printf()-like format string. + */ +void +_mesa_warning( struct gl_context *ctx, const char *fmtString, ... ) +{ + char str[MAXSTRING]; + va_list args; + va_start( args, fmtString ); + (void) vsnprintf( str, MAXSTRING, fmtString, args ); + va_end( args ); + + if (ctx) + flush_delayed_errors( ctx ); + + output_if_debug("Mesa warning", str, GL_TRUE); +} + + +/** + * Report an internal implementation problem. + * Prints the message to stderr via fprintf(). + * + * \param ctx GL context. + * \param fmtString problem description string. + */ +void +_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) +{ + va_list args; + char str[MAXSTRING]; + (void) ctx; + + va_start( args, fmtString ); + vsnprintf( str, MAXSTRING, fmtString, args ); + va_end( args ); + + fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str); + fprintf(stderr, "Please report at bugzilla.freedesktop.org\n"); +} + + +/** + * Record an OpenGL state error. These usually occur when the user + * passes invalid parameters to a GL function. + * + * If debugging is enabled (either at compile-time via the DEBUG macro, or + * run-time via the MESA_DEBUG environment variable), report the error with + * _mesa_debug(). + * + * \param ctx the GL context. + * \param error the error value. + * \param fmtString printf() style format string, followed by optional args + */ +void +_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) +{ + static GLint debug = -1; + + /* Check debug environment variable only once: + */ + if (debug == -1) { + const char *debugEnv = _mesa_getenv("MESA_DEBUG"); + +#ifdef DEBUG + if (debugEnv && strstr(debugEnv, "silent")) + debug = GL_FALSE; + else + debug = GL_TRUE; +#else + if (debugEnv) + debug = GL_TRUE; + else + debug = GL_FALSE; +#endif + } + + if (debug) { + if (ctx->ErrorValue == error && + ctx->ErrorDebugFmtString == fmtString) { + ctx->ErrorDebugCount++; + } + else { + char s[MAXSTRING], s2[MAXSTRING]; + va_list args; + + flush_delayed_errors( ctx ); + + va_start(args, fmtString); + vsnprintf(s, MAXSTRING, fmtString, args); + va_end(args); + + _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); + output_if_debug("Mesa: User error", s2, GL_TRUE); + + ctx->ErrorDebugFmtString = fmtString; + ctx->ErrorDebugCount = 0; + } + } + + _mesa_record_error(ctx, error); +} + + +/** + * Report debug information. Print error message to stderr via fprintf(). + * No-op if DEBUG mode not enabled. + * + * \param ctx GL context. + * \param fmtString printf()-style format string, followed by optional args. + */ +void +_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) +{ +#ifdef DEBUG + char s[MAXSTRING]; + va_list args; + va_start(args, fmtString); + vsnprintf(s, MAXSTRING, fmtString, args); + va_end(args); + output_if_debug("Mesa", s, GL_FALSE); +#endif /* DEBUG */ + (void) ctx; + (void) fmtString; +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index 751f20650..af7a8cc00 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -1,594 +1,602 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file imports.h - * Standard C library function wrappers. - * - * This file provides wrappers for all the standard C library functions - * like malloc(), free(), printf(), getenv(), etc. - */ - - -#ifndef IMPORTS_H -#define IMPORTS_H - - -#include "compiler.h" -#include "glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/**********************************************************************/ -/** Memory macros */ -/*@{*/ - -/** Allocate \p BYTES bytes */ -#define MALLOC(BYTES) malloc(BYTES) -/** Allocate and zero \p BYTES bytes */ -#define CALLOC(BYTES) calloc(1, BYTES) -/** Allocate a structure of type \p T */ -#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) -/** Allocate and zero a structure of type \p T */ -#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) -/** Free memory */ -#define FREE(PTR) free(PTR) - -/*@}*/ - - -/* - * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers - * as offsets into buffer stores. Since the vertex array pointer and - * buffer store pointer are both pointers and we need to add them, we use - * this macro. - * Both pointers/offsets are expressed in bytes. - */ -#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) - - -/** - * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float - * as a int (thereby using integer registers instead of FP registers) is - * a performance win. Typically, this can be done with ordinary casts. - * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) - * these casts generate warnings. - * The following union typedef is used to solve that. - */ -typedef union { GLfloat f; GLint i; } fi_type; - - - -/********************************************************************** - * Math macros - */ - -#define MAX_GLUSHORT 0xffff -#define MAX_GLUINT 0xffffffff - -/* Degrees to radians conversion: */ -#define DEG2RAD (M_PI/180.0) - - -/*** - *** SQRTF: single-precision square root - ***/ -#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ -# define SQRTF(X) _mesa_sqrtf(X) -#else -# define SQRTF(X) (float) sqrt((float) (X)) -#endif - - -/*** - *** INV_SQRTF: single-precision inverse square root - ***/ -#if 0 -#define INV_SQRTF(X) _mesa_inv_sqrt(X) -#else -#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ -#endif - - -/** - * \name Work-arounds for platforms that lack C99 math functions - */ -/*@{*/ -#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ - && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ - && (!defined(_MSC_VER) || (_MSC_VER < 1400)) -#define acosf(f) ((float) acos(f)) -#define asinf(f) ((float) asin(f)) -#define atan2f(x,y) ((float) atan2(x,y)) -#define atanf(f) ((float) atan(f)) -#define cielf(f) ((float) ciel(f)) -#define cosf(f) ((float) cos(f)) -#define coshf(f) ((float) cosh(f)) -#define expf(f) ((float) exp(f)) -#define exp2f(f) ((float) exp2(f)) -#define floorf(f) ((float) floor(f)) -#define logf(f) ((float) log(f)) -#define log2f(f) ((float) log2(f)) -#define powf(x,y) ((float) pow(x,y)) -#define sinf(f) ((float) sin(f)) -#define sinhf(f) ((float) sinh(f)) -#define sqrtf(f) ((float) sqrt(f)) -#define tanf(f) ((float) tan(f)) -#define tanhf(f) ((float) tanh(f)) -#endif - -#if defined(_MSC_VER) -static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } -static INLINE float exp2f(float x) { return powf(2.0f, x); } -static INLINE float log2f(float x) { return logf(x) * 1.442695041f; } -static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; } -#define strtoll(p, e, b) _strtoi64(p, e, b) -#endif -/*@}*/ - -/*** - *** LOG2: Log base 2 of float - ***/ -#ifdef USE_IEEE -#if 0 -/* This is pretty fast, but not accurate enough (only 2 fractional bits). - * Based on code from http://www.stereopsis.com/log2.html - */ -static INLINE GLfloat LOG2(GLfloat x) -{ - const GLfloat y = x * x * x * x; - const GLuint ix = *((GLuint *) &y); - const GLuint exp = (ix >> 23) & 0xFF; - const GLint log2 = ((GLint) exp) - 127; - return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ -} -#endif -/* Pretty fast, and accurate. - * Based on code from http://www.flipcode.com/totd/ - */ -static INLINE GLfloat LOG2(GLfloat val) -{ - fi_type num; - GLint log_2; - num.f = val; - log_2 = ((num.i >> 23) & 255) - 128; - num.i &= ~(255 << 23); - num.i += 127 << 23; - num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; - return num.f + log_2; -} -#else -/* - * NOTE: log_base_2(x) = log(x) / log(2) - * NOTE: 1.442695 = 1/log(2). - */ -#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) -#endif - - -/*** - *** IS_INF_OR_NAN: test if float is infinite or NaN - ***/ -#ifdef USE_IEEE -static INLINE int IS_INF_OR_NAN( float x ) -{ - fi_type tmp; - tmp.f = x; - return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); -} -#elif defined(isfinite) -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#elif defined(finite) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__VMS) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#else -#define IS_INF_OR_NAN(x) (!finite(x)) -#endif - - -/*** - *** IS_NEGATIVE: test if float is negative - ***/ -#if defined(USE_IEEE) -static INLINE int GET_FLOAT_BITS( float x ) -{ - fi_type fi; - fi.f = x; - return fi.i; -} -#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) -#else -#define IS_NEGATIVE(x) (x < 0.0F) -#endif - - -/*** - *** DIFFERENT_SIGNS: test if two floats have opposite signs - ***/ -#if defined(USE_IEEE) -#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) -#else -/* Could just use (x*y<0) except for the flatshading requirements. - * Maybe there's a better way? - */ -#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) -#endif - - -/*** - *** CEILF: ceiling of float - *** FLOORF: floor of float - *** FABSF: absolute value of float - *** LOGF: the natural logarithm (base e) of the value - *** EXPF: raise e to the value - *** LDEXPF: multiply value by an integral power of two - *** FREXPF: extract mantissa and exponent from value - ***/ -#if defined(__gnu_linux__) -/* C99 functions */ -#define CEILF(x) ceilf(x) -#define FLOORF(x) floorf(x) -#define FABSF(x) fabsf(x) -#define LOGF(x) logf(x) -#define EXPF(x) expf(x) -#define LDEXPF(x,y) ldexpf(x,y) -#define FREXPF(x,y) frexpf(x,y) -#else -#define CEILF(x) ((GLfloat) ceil(x)) -#define FLOORF(x) ((GLfloat) floor(x)) -#define FABSF(x) ((GLfloat) fabs(x)) -#define LOGF(x) ((GLfloat) log(x)) -#define EXPF(x) ((GLfloat) exp(x)) -#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) -#define FREXPF(x,y) ((GLfloat) frexp(x,y)) -#endif - - -/*** - *** IROUND: return (as an integer) float rounded to nearest integer - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -static INLINE int iround(float f) -{ - int r; - __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); - return r; -} -#define IROUND(x) iround(x) -#elif defined(USE_X86_ASM) && defined(_MSC_VER) -static INLINE int iround(float f) -{ - int r; - _asm { - fld f - fistp r - } - return r; -} -#define IROUND(x) iround(x) -#elif defined(__WATCOMC__) && defined(__386__) -long iround(float f); -#pragma aux iround = \ - "push eax" \ - "fistp dword ptr [esp]" \ - "pop eax" \ - parm [8087] \ - value [eax] \ - modify exact [eax]; -#define IROUND(x) iround(x) -#else -#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) -#endif - -#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) - -/*** - *** IROUND_POS: return (as an integer) positive float rounded to nearest int - ***/ -#ifdef DEBUG -#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) -#else -#define IROUND_POS(f) (IROUND(f)) -#endif - - -/*** - *** IFLOOR: return (as an integer) floor of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE floor for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static INLINE int ifloor(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#elif defined(USE_IEEE) -static INLINE int ifloor(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#else -static INLINE int ifloor(float f) -{ - int i = IROUND(f); - return (i > f) ? i - 1 : i; -} -#define IFLOOR(x) ifloor(x) -#endif - - -/*** - *** ICEIL: return (as an integer) ceiling of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE ceil for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static INLINE int iceil(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#elif defined(USE_IEEE) -static INLINE int iceil(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#else -static INLINE int iceil(float f) -{ - int i = IROUND(f); - return (i < f) ? i + 1 : i; -} -#define ICEIL(x) iceil(x) -#endif - - -/** - * Is x a power of two? - */ -static INLINE int -_mesa_is_pow_two(int x) -{ - return !(x & (x - 1)); -} - -/** - * Round given integer to next higer power of two - * If X is zero result is undefined. - * - * Source for the fallback implementation is - * Sean Eron Anderson's webpage "Bit Twiddling Hacks" - * http://graphics.stanford.edu/~seander/bithacks.html - * - * When using builtin function have to do some work - * for case when passed values 1 to prevent hiting - * undefined result from __builtin_clz. Undefined - * results would be different depending on optimization - * level used for build. - */ -static INLINE int32_t -_mesa_next_pow_two_32(uint32_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - uint32_t y = (x != 1); - return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x++; - return x; -#endif -} - -static INLINE int64_t -_mesa_next_pow_two_64(uint64_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - uint64_t y = (x != 1); - if (sizeof(x) == sizeof(long)) - return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); - else - return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x |= x >> 32; - x++; - return x; -#endif -} - - -/** - * Return 1 if this is a little endian machine, 0 if big endian. - */ -static INLINE GLboolean -_mesa_little_endian(void) -{ - const GLuint ui = 1; /* intentionally not static */ - return *((const GLubyte *) &ui); -} - - - -/********************************************************************** - * Functions - */ - -extern void * -_mesa_align_malloc( size_t bytes, unsigned long alignment ); - -extern void * -_mesa_align_calloc( size_t bytes, unsigned long alignment ); - -extern void -_mesa_align_free( void *ptr ); - -extern void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment); - -extern void * -_mesa_exec_malloc( GLuint size ); - -extern void -_mesa_exec_free( void *addr ); - -extern void * -_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); - -extern void -_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); - -extern double -_mesa_sqrtd(double x); - -extern float -_mesa_sqrtf(float x); - -extern float -_mesa_inv_sqrtf(float x); - -extern void -_mesa_init_sqrt_table(void); - -extern int -_mesa_ffs(int32_t i); - -extern int -_mesa_ffsll(int64_t i); - -extern unsigned int -_mesa_bitcount(unsigned int n); - -extern GLhalfARB -_mesa_float_to_half(float f); - -extern float -_mesa_half_to_float(GLhalfARB h); - - -extern void * -_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *) ); - -extern char * -_mesa_getenv( const char *var ); - -extern char * -_mesa_strdup( const char *s ); - -extern float -_mesa_strtof( const char *s, char **end ); - -extern unsigned int -_mesa_str_checksum(const char *str); - -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); - -extern void -_mesa_warning( __GLcontext *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); - -extern void -_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - - -#if defined(_MSC_VER) && !defined(snprintf) -#define snprintf _snprintf -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* IMPORTS_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file imports.h + * Standard C library function wrappers. + * + * This file provides wrappers for all the standard C library functions + * like malloc(), free(), printf(), getenv(), etc. + */ + + +#ifndef IMPORTS_H +#define IMPORTS_H + + +#include "compiler.h" +#include "glheader.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/**********************************************************************/ +/** Memory macros */ +/*@{*/ + +/** Allocate \p BYTES bytes */ +#define MALLOC(BYTES) malloc(BYTES) +/** Allocate and zero \p BYTES bytes */ +#define CALLOC(BYTES) calloc(1, BYTES) +/** Allocate a structure of type \p T */ +#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) +/** Allocate and zero a structure of type \p T */ +#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) +/** Free memory */ +#define FREE(PTR) free(PTR) + +/*@}*/ + + +/* + * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers + * as offsets into buffer stores. Since the vertex array pointer and + * buffer store pointer are both pointers and we need to add them, we use + * this macro. + * Both pointers/offsets are expressed in bytes. + */ +#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) + + +/** + * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float + * as a int (thereby using integer registers instead of FP registers) is + * a performance win. Typically, this can be done with ordinary casts. + * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) + * these casts generate warnings. + * The following union typedef is used to solve that. + */ +typedef union { GLfloat f; GLint i; } fi_type; + + + +/********************************************************************** + * Math macros + */ + +#define MAX_GLUSHORT 0xffff +#define MAX_GLUINT 0xffffffff + +/* Degrees to radians conversion: */ +#define DEG2RAD (M_PI/180.0) + + +/*** + *** SQRTF: single-precision square root + ***/ +#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ +# define SQRTF(X) _mesa_sqrtf(X) +#else +# define SQRTF(X) (float) sqrt((float) (X)) +#endif + + +/*** + *** INV_SQRTF: single-precision inverse square root + ***/ +#if 0 +#define INV_SQRTF(X) _mesa_inv_sqrt(X) +#else +#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ +#endif + + +/** + * \name Work-arounds for platforms that lack C99 math functions + */ +/*@{*/ +#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ + && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ + && (!defined(_MSC_VER) || (_MSC_VER < 1400)) +#define acosf(f) ((float) acos(f)) +#define asinf(f) ((float) asin(f)) +#define atan2f(x,y) ((float) atan2(x,y)) +#define atanf(f) ((float) atan(f)) +#define cielf(f) ((float) ciel(f)) +#define cosf(f) ((float) cos(f)) +#define coshf(f) ((float) cosh(f)) +#define expf(f) ((float) exp(f)) +#define exp2f(f) ((float) exp2(f)) +#define floorf(f) ((float) floor(f)) +#define logf(f) ((float) log(f)) +#define log2f(f) ((float) log2(f)) +#define powf(x,y) ((float) pow(x,y)) +#define sinf(f) ((float) sin(f)) +#define sinhf(f) ((float) sinh(f)) +#define sqrtf(f) ((float) sqrt(f)) +#define tanf(f) ((float) tan(f)) +#define tanhf(f) ((float) tanh(f)) +#define acoshf(f) ((float) acosh(f)) +#define asinhf(f) ((float) asinh(f)) +#define atanhf(f) ((float) atanh(f)) +#endif + +#if defined(_MSC_VER) +static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } +static INLINE float exp2f(float x) { return powf(2.0f, x); } +static INLINE float log2f(float x) { return logf(x) * 1.442695041f; } +static INLINE float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } +static INLINE float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } +static INLINE float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } +static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; } +#define strtoll(p, e, b) _strtoi64(p, e, b) +#endif +/*@}*/ + +/*** + *** LOG2: Log base 2 of float + ***/ +#ifdef USE_IEEE +#if 0 +/* This is pretty fast, but not accurate enough (only 2 fractional bits). + * Based on code from http://www.stereopsis.com/log2.html + */ +static INLINE GLfloat LOG2(GLfloat x) +{ + const GLfloat y = x * x * x * x; + const GLuint ix = *((GLuint *) &y); + const GLuint exp = (ix >> 23) & 0xFF; + const GLint log2 = ((GLint) exp) - 127; + return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ +} +#endif +/* Pretty fast, and accurate. + * Based on code from http://www.flipcode.com/totd/ + */ +static INLINE GLfloat LOG2(GLfloat val) +{ + fi_type num; + GLint log_2; + num.f = val; + log_2 = ((num.i >> 23) & 255) - 128; + num.i &= ~(255 << 23); + num.i += 127 << 23; + num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; + return num.f + log_2; +} +#else +/* + * NOTE: log_base_2(x) = log(x) / log(2) + * NOTE: 1.442695 = 1/log(2). + */ +#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) +#endif + + +/*** + *** IS_INF_OR_NAN: test if float is infinite or NaN + ***/ +#ifdef USE_IEEE +static INLINE int IS_INF_OR_NAN( float x ) +{ + fi_type tmp; + tmp.f = x; + return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); +} +#elif defined(isfinite) +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#elif defined(finite) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__VMS) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#else +#define IS_INF_OR_NAN(x) (!finite(x)) +#endif + + +/*** + *** IS_NEGATIVE: test if float is negative + ***/ +#if defined(USE_IEEE) +static INLINE int GET_FLOAT_BITS( float x ) +{ + fi_type fi; + fi.f = x; + return fi.i; +} +#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) +#else +#define IS_NEGATIVE(x) (x < 0.0F) +#endif + + +/*** + *** DIFFERENT_SIGNS: test if two floats have opposite signs + ***/ +#if defined(USE_IEEE) +#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) +#else +/* Could just use (x*y<0) except for the flatshading requirements. + * Maybe there's a better way? + */ +#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) +#endif + + +/*** + *** CEILF: ceiling of float + *** FLOORF: floor of float + *** FABSF: absolute value of float + *** LOGF: the natural logarithm (base e) of the value + *** EXPF: raise e to the value + *** LDEXPF: multiply value by an integral power of two + *** FREXPF: extract mantissa and exponent from value + ***/ +#if defined(__gnu_linux__) +/* C99 functions */ +#define CEILF(x) ceilf(x) +#define FLOORF(x) floorf(x) +#define FABSF(x) fabsf(x) +#define LOGF(x) logf(x) +#define EXPF(x) expf(x) +#define LDEXPF(x,y) ldexpf(x,y) +#define FREXPF(x,y) frexpf(x,y) +#else +#define CEILF(x) ((GLfloat) ceil(x)) +#define FLOORF(x) ((GLfloat) floor(x)) +#define FABSF(x) ((GLfloat) fabs(x)) +#define LOGF(x) ((GLfloat) log(x)) +#define EXPF(x) ((GLfloat) exp(x)) +#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) +#define FREXPF(x,y) ((GLfloat) frexp(x,y)) +#endif + + +/*** + *** IROUND: return (as an integer) float rounded to nearest integer + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +static INLINE int iround(float f) +{ + int r; + __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); + return r; +} +#define IROUND(x) iround(x) +#elif defined(USE_X86_ASM) && defined(_MSC_VER) +static INLINE int iround(float f) +{ + int r; + _asm { + fld f + fistp r + } + return r; +} +#define IROUND(x) iround(x) +#elif defined(__WATCOMC__) && defined(__386__) +long iround(float f); +#pragma aux iround = \ + "push eax" \ + "fistp dword ptr [esp]" \ + "pop eax" \ + parm [8087] \ + value [eax] \ + modify exact [eax]; +#define IROUND(x) iround(x) +#else +#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) +#endif + +#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) + +/*** + *** IROUND_POS: return (as an integer) positive float rounded to nearest int + ***/ +#ifdef DEBUG +#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) +#else +#define IROUND_POS(f) (IROUND(f)) +#endif + + +/*** + *** IFLOOR: return (as an integer) floor of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE floor for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#elif defined(USE_IEEE) +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#else +static INLINE int ifloor(float f) +{ + int i = IROUND(f); + return (i > f) ? i - 1 : i; +} +#define IFLOOR(x) ifloor(x) +#endif + + +/*** + *** ICEIL: return (as an integer) ceiling of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE ceil for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#elif defined(USE_IEEE) +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#else +static INLINE int iceil(float f) +{ + int i = IROUND(f); + return (i < f) ? i + 1 : i; +} +#define ICEIL(x) iceil(x) +#endif + + +/** + * Is x a power of two? + */ +static INLINE int +_mesa_is_pow_two(int x) +{ + return !(x & (x - 1)); +} + +/** + * Round given integer to next higer power of two + * If X is zero result is undefined. + * + * Source for the fallback implementation is + * Sean Eron Anderson's webpage "Bit Twiddling Hacks" + * http://graphics.stanford.edu/~seander/bithacks.html + * + * When using builtin function have to do some work + * for case when passed values 1 to prevent hiting + * undefined result from __builtin_clz. Undefined + * results would be different depending on optimization + * level used for build. + */ +static INLINE int32_t +_mesa_next_pow_two_32(uint32_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint32_t y = (x != 1); + return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x++; + return x; +#endif +} + +static INLINE int64_t +_mesa_next_pow_two_64(uint64_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint64_t y = (x != 1); + if (sizeof(x) == sizeof(long)) + return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); + else + return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x |= x >> 32; + x++; + return x; +#endif +} + + +/** + * Return 1 if this is a little endian machine, 0 if big endian. + */ +static INLINE GLboolean +_mesa_little_endian(void) +{ + const GLuint ui = 1; /* intentionally not static */ + return *((const GLubyte *) &ui); +} + + + +/********************************************************************** + * Functions + */ + +extern void * +_mesa_align_malloc( size_t bytes, unsigned long alignment ); + +extern void * +_mesa_align_calloc( size_t bytes, unsigned long alignment ); + +extern void +_mesa_align_free( void *ptr ); + +extern void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment); + +extern void * +_mesa_exec_malloc( GLuint size ); + +extern void +_mesa_exec_free( void *addr ); + +extern void * +_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); + +extern void +_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); + +extern double +_mesa_sqrtd(double x); + +extern float +_mesa_sqrtf(float x); + +extern float +_mesa_inv_sqrtf(float x); + +extern void +_mesa_init_sqrt_table(void); + +extern int +_mesa_ffs(int32_t i); + +extern int +_mesa_ffsll(int64_t i); + +extern unsigned int +_mesa_bitcount(unsigned int n); + +extern GLhalfARB +_mesa_float_to_half(float f); + +extern float +_mesa_half_to_float(GLhalfARB h); + + +extern void * +_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *) ); + +extern char * +_mesa_getenv( const char *var ); + +extern char * +_mesa_strdup( const char *s ); + +extern float +_mesa_strtof( const char *s, char **end ); + +extern unsigned int +_mesa_str_checksum(const char *str); + +extern int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); + +struct gl_context; + +extern void +_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); + +extern void +_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + + +#if defined(_MSC_VER) && !defined(snprintf) +#define snprintf _snprintf +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* IMPORTS_H */ diff --git a/mesalib/src/mesa/main/light.c b/mesalib/src/mesa/main/light.c index 43ae28c25..888e5622e 100644 --- a/mesalib/src/mesa/main/light.c +++ b/mesalib/src/mesa/main/light.c @@ -1,1430 +1,1430 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "enums.h" -#include "light.h" -#include "macros.h" -#include "simple_list.h" -#include "mtypes.h" -#include "math/m_matrix.h" - - -void GLAPIENTRY -_mesa_ShadeModel( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode != GL_FLAT && mode != GL_SMOOTH) { - _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel"); - return; - } - - if (ctx->Light.ShadeModel == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.ShadeModel = mode; - if (mode == GL_FLAT) - ctx->_TriangleCaps |= DD_FLATSHADE; - else - ctx->_TriangleCaps &= ~DD_FLATSHADE; - - if (ctx->Driver.ShadeModel) - ctx->Driver.ShadeModel( ctx, mode ); -} - - -/** - * Set the provoking vertex (the vertex which specifies the prim's - * color when flat shading) to either the first or last vertex of the - * triangle or line. - */ -void GLAPIENTRY -_mesa_ProvokingVertexEXT(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glProvokingVertexEXT 0x%x\n", mode); - - switch (mode) { - case GL_FIRST_VERTEX_CONVENTION_EXT: - case GL_LAST_VERTEX_CONVENTION_EXT: - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glProvokingVertexEXT(0x%x)", mode); - return; - } - - if (ctx->Light.ProvokingVertex == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.ProvokingVertex = mode; -} - - -/** - * Helper function called by _mesa_Lightfv and _mesa_PopAttrib to set - * per-light state. - * For GL_POSITION and GL_SPOT_DIRECTION the params position/direction - * will have already been transformed by the modelview matrix! - * Also, all error checking should have already been done. - */ -void -_mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params) -{ - struct gl_light *light; - - ASSERT(lnum < MAX_LIGHTS); - light = &ctx->Light.Light[lnum]; - - switch (pname) { - case GL_AMBIENT: - if (TEST_EQ_4V(light->Ambient, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Ambient, params ); - break; - case GL_DIFFUSE: - if (TEST_EQ_4V(light->Diffuse, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Diffuse, params ); - break; - case GL_SPECULAR: - if (TEST_EQ_4V(light->Specular, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( light->Specular, params ); - break; - case GL_POSITION: - /* NOTE: position has already been transformed by ModelView! */ - if (TEST_EQ_4V(light->EyePosition, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V(light->EyePosition, params); - if (light->EyePosition[3] != 0.0F) - light->_Flags |= LIGHT_POSITIONAL; - else - light->_Flags &= ~LIGHT_POSITIONAL; - break; - case GL_SPOT_DIRECTION: - /* NOTE: Direction already transformed by inverse ModelView! */ - if (TEST_EQ_3V(light->SpotDirection, params)) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_3V(light->SpotDirection, params); - break; - case GL_SPOT_EXPONENT: - ASSERT(params[0] >= 0.0); - ASSERT(params[0] <= ctx->Const.MaxSpotExponent); - if (light->SpotExponent == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->SpotExponent = params[0]; - _mesa_invalidate_spot_exp_table(light); - break; - case GL_SPOT_CUTOFF: - ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); - if (light->SpotCutoff == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->SpotCutoff = params[0]; - light->_CosCutoffNeg = (GLfloat) (cos(light->SpotCutoff * DEG2RAD)); - if (light->_CosCutoffNeg < 0) - light->_CosCutoff = 0; - else - light->_CosCutoff = light->_CosCutoffNeg; - if (light->SpotCutoff != 180.0F) - light->_Flags |= LIGHT_SPOT; - else - light->_Flags &= ~LIGHT_SPOT; - break; - case GL_CONSTANT_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->ConstantAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->ConstantAttenuation = params[0]; - break; - case GL_LINEAR_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->LinearAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->LinearAttenuation = params[0]; - break; - case GL_QUADRATIC_ATTENUATION: - ASSERT(params[0] >= 0.0); - if (light->QuadraticAttenuation == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - light->QuadraticAttenuation = params[0]; - break; - default: - _mesa_problem(ctx, "Unexpected pname in _mesa_light()"); - return; - } - - if (ctx->Driver.Lightfv) - ctx->Driver.Lightfv( ctx, GL_LIGHT0 + lnum, pname, params ); -} - - -void GLAPIENTRY -_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Lightfv( light, pname, fparam ); -} - - -void GLAPIENTRY -_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i = (GLint) (light - GL_LIGHT0); - GLfloat temp[4]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (i < 0 || i >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light ); - return; - } - - /* do particular error checks, transformations */ - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - /* nothing */ - break; - case GL_POSITION: - /* transform position by ModelView matrix */ - TRANSFORM_POINT(temp, ctx->ModelviewMatrixStack.Top->m, params); - params = temp; - break; - case GL_SPOT_DIRECTION: - /* transform direction by inverse modelview */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); - } - TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m); - params = temp; - break; - case GL_SPOT_EXPONENT: - if (params[0] < 0.0 || params[0] > ctx->Const.MaxSpotExponent) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_SPOT_CUTOFF: - if ((params[0] < 0.0 || params[0] > 90.0) && params[0] != 180.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_CONSTANT_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_LINEAR_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - case GL_QUADRATIC_ATTENUATION: - if (params[0] < 0.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glLight(pname=0x%x)", pname); - return; - } - - _mesa_light(ctx, i, pname, params); -} - - -void GLAPIENTRY -_mesa_Lighti( GLenum light, GLenum pname, GLint param ) -{ - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - _mesa_Lightiv( light, pname, iparam ); -} - - -void GLAPIENTRY -_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - - _mesa_Lightfv( light, pname, fparam ); -} - - - -void GLAPIENTRY -_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint l = (GLint) (light - GL_LIGHT0); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - COPY_4V( params, ctx->Light.Light[l].Ambient ); - break; - case GL_DIFFUSE: - COPY_4V( params, ctx->Light.Light[l].Diffuse ); - break; - case GL_SPECULAR: - COPY_4V( params, ctx->Light.Light[l].Specular ); - break; - case GL_POSITION: - COPY_4V( params, ctx->Light.Light[l].EyePosition ); - break; - case GL_SPOT_DIRECTION: - COPY_3V( params, ctx->Light.Light[l].SpotDirection ); - break; - case GL_SPOT_EXPONENT: - params[0] = ctx->Light.Light[l].SpotExponent; - break; - case GL_SPOT_CUTOFF: - params[0] = ctx->Light.Light[l].SpotCutoff; - break; - case GL_CONSTANT_ATTENUATION: - params[0] = ctx->Light.Light[l].ConstantAttenuation; - break; - case GL_LINEAR_ATTENUATION: - params[0] = ctx->Light.Light[l].LinearAttenuation; - break; - case GL_QUADRATIC_ATTENUATION: - params[0] = ctx->Light.Light[l].QuadraticAttenuation; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); - break; - } -} - - -void GLAPIENTRY -_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint l = (GLint) (light - GL_LIGHT0); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]); - break; - case GL_DIFFUSE: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]); - break; - case GL_SPECULAR: - params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]); - break; - case GL_POSITION: - params[0] = (GLint) ctx->Light.Light[l].EyePosition[0]; - params[1] = (GLint) ctx->Light.Light[l].EyePosition[1]; - params[2] = (GLint) ctx->Light.Light[l].EyePosition[2]; - params[3] = (GLint) ctx->Light.Light[l].EyePosition[3]; - break; - case GL_SPOT_DIRECTION: - params[0] = (GLint) ctx->Light.Light[l].SpotDirection[0]; - params[1] = (GLint) ctx->Light.Light[l].SpotDirection[1]; - params[2] = (GLint) ctx->Light.Light[l].SpotDirection[2]; - break; - case GL_SPOT_EXPONENT: - params[0] = (GLint) ctx->Light.Light[l].SpotExponent; - break; - case GL_SPOT_CUTOFF: - params[0] = (GLint) ctx->Light.Light[l].SpotCutoff; - break; - case GL_CONSTANT_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation; - break; - case GL_LINEAR_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation; - break; - case GL_QUADRATIC_ATTENUATION: - params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); - break; - } -} - - - -/**********************************************************************/ -/*** Light Model ***/ -/**********************************************************************/ - - -void GLAPIENTRY -_mesa_LightModelfv( GLenum pname, const GLfloat *params ) -{ - GLenum newenum; - GLboolean newbool; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - if (TEST_EQ_4V( ctx->Light.Model.Ambient, params )) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - COPY_4V( ctx->Light.Model.Ambient, params ); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - newbool = (params[0]!=0.0); - if (ctx->Light.Model.LocalViewer == newbool) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Model.LocalViewer = newbool; - break; - case GL_LIGHT_MODEL_TWO_SIDE: - newbool = (params[0]!=0.0); - if (ctx->Light.Model.TwoSide == newbool) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Model.TwoSide = newbool; - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; - case GL_LIGHT_MODEL_COLOR_CONTROL: - if (params[0] == (GLfloat) GL_SINGLE_COLOR) - newenum = GL_SINGLE_COLOR; - else if (params[0] == (GLfloat) GL_SEPARATE_SPECULAR_COLOR) - newenum = GL_SEPARATE_SPECULAR_COLOR; - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(param=0x0%x)", - (GLint) params[0] ); - return; - } - if (ctx->Light.Model.ColorControl == newenum) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Model.ColorControl = newenum; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname ); - break; - } - - if (ctx->Driver.LightModelfv) - ctx->Driver.LightModelfv( ctx, pname, params ); -} - - -void GLAPIENTRY -_mesa_LightModeliv( GLenum pname, const GLint *params ) -{ - GLfloat fparam[4]; - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT( params[0] ); - fparam[1] = INT_TO_FLOAT( params[1] ); - fparam[2] = INT_TO_FLOAT( params[2] ); - fparam[3] = INT_TO_FLOAT( params[3] ); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - _mesa_LightModelfv( pname, fparam ); -} - - -void GLAPIENTRY -_mesa_LightModeli( GLenum pname, GLint param ) -{ - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - _mesa_LightModeliv( pname, iparam ); -} - - -void GLAPIENTRY -_mesa_LightModelf( GLenum pname, GLfloat param ) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_LightModelfv( pname, fparam ); -} - - - -/********** MATERIAL **********/ - - -/* - * Given a face and pname value (ala glColorMaterial), compute a bitmask - * of the targeted material values. - */ -GLuint -_mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, - GLuint legal, const char *where ) -{ - GLuint bitmask = 0; - - /* Make a bitmask indicating what material attribute(s) we're updating */ - switch (pname) { - case GL_EMISSION: - bitmask |= MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION; - break; - case GL_AMBIENT: - bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; - break; - case GL_DIFFUSE: - bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; - break; - case GL_SPECULAR: - bitmask |= MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR; - break; - case GL_SHININESS: - bitmask |= MAT_BIT_FRONT_SHININESS | MAT_BIT_BACK_SHININESS; - break; - case GL_AMBIENT_AND_DIFFUSE: - bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; - bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; - break; - case GL_COLOR_INDEXES: - bitmask |= MAT_BIT_FRONT_INDEXES | MAT_BIT_BACK_INDEXES; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - if (face==GL_FRONT) { - bitmask &= FRONT_MATERIAL_BITS; - } - else if (face==GL_BACK) { - bitmask &= BACK_MATERIAL_BITS; - } - else if (face != GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - if (bitmask & ~legal) { - _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); - return 0; - } - - return bitmask; -} - - - -/* Perform a straight copy between materials. - */ -void -_mesa_copy_materials( struct gl_material *dst, - const struct gl_material *src, - GLuint bitmask ) -{ - int i; - - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<Attrib[i], src->Attrib[i] ); -} - - - -/* Update derived values following a change in ctx->Light.Material - */ -void -_mesa_update_material( GLcontext *ctx, GLuint bitmask ) -{ - struct gl_light *light, *list = &ctx->Light.EnabledList; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - - if (MESA_VERBOSE & VERBOSE_MATERIAL) - _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask); - - if (!bitmask) - return; - - /* update material ambience */ - if (bitmask & MAT_BIT_FRONT_AMBIENT) { - foreach (light, list) { - SCALE_3V( light->_MatAmbient[0], light->Ambient, - mat[MAT_ATTRIB_FRONT_AMBIENT]); - } - } - - if (bitmask & MAT_BIT_BACK_AMBIENT) { - foreach (light, list) { - SCALE_3V( light->_MatAmbient[1], light->Ambient, - mat[MAT_ATTRIB_BACK_AMBIENT]); - } - } - - /* update BaseColor = emission + scene's ambience * material's ambience */ - if (bitmask & (MAT_BIT_FRONT_EMISSION | MAT_BIT_FRONT_AMBIENT)) { - COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] ); - ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT], - ctx->Light.Model.Ambient ); - } - - if (bitmask & (MAT_BIT_BACK_EMISSION | MAT_BIT_BACK_AMBIENT)) { - COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] ); - ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT], - ctx->Light.Model.Ambient ); - } - - /* update material diffuse values */ - if (bitmask & MAT_BIT_FRONT_DIFFUSE) { - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[0], light->Diffuse, - mat[MAT_ATTRIB_FRONT_DIFFUSE] ); - } - } - - if (bitmask & MAT_BIT_BACK_DIFFUSE) { - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[1], light->Diffuse, - mat[MAT_ATTRIB_BACK_DIFFUSE] ); - } - } - - /* update material specular values */ - if (bitmask & MAT_BIT_FRONT_SPECULAR) { - foreach (light, list) { - SCALE_3V( light->_MatSpecular[0], light->Specular, - mat[MAT_ATTRIB_FRONT_SPECULAR]); - } - } - - if (bitmask & MAT_BIT_BACK_SPECULAR) { - foreach (light, list) { - SCALE_3V( light->_MatSpecular[1], light->Specular, - mat[MAT_ATTRIB_BACK_SPECULAR]); - } - } - - if (bitmask & MAT_BIT_FRONT_SHININESS) { - _mesa_invalidate_shine_table( ctx, 0 ); - } - - if (bitmask & MAT_BIT_BACK_SHININESS) { - _mesa_invalidate_shine_table( ctx, 1 ); - } -} - - -/* - * Update the current materials from the given rgba color - * according to the bitmask in ColorMaterialBitmask, which is - * set by glColorMaterial(). - */ -void -_mesa_update_color_material( GLcontext *ctx, const GLfloat color[4] ) -{ - GLuint bitmask = ctx->Light.ColorMaterialBitmask; - struct gl_material *mat = &ctx->Light.Material; - int i; - - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<Attrib[i], color ); - - _mesa_update_material( ctx, bitmask ); -} - - -void GLAPIENTRY -_mesa_ColorMaterial( GLenum face, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint bitmask; - GLuint legal = (MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION | - MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR | - MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE | - MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glColorMaterial %s %s\n", - _mesa_lookup_enum_by_nr(face), - _mesa_lookup_enum_by_nr(mode)); - - bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial"); - - if (ctx->Light.ColorMaterialBitmask == bitmask && - ctx->Light.ColorMaterialFace == face && - ctx->Light.ColorMaterialMode == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.ColorMaterialBitmask = bitmask; - ctx->Light.ColorMaterialFace = face; - ctx->Light.ColorMaterialMode = mode; - - if (ctx->Light.ColorMaterialEnabled) { - FLUSH_CURRENT( ctx, 0 ); - _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); - } - - if (ctx->Driver.ColorMaterial) - ctx->Driver.ColorMaterial( ctx, face, mode ); -} - - -void GLAPIENTRY -_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint f; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ - - FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ - - if (face==GL_FRONT) { - f = 0; - } - else if (face==GL_BACK) { - f = 1; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" ); - return; - } - - switch (pname) { - case GL_AMBIENT: - COPY_4FV( params, mat[MAT_ATTRIB_AMBIENT(f)] ); - break; - case GL_DIFFUSE: - COPY_4FV( params, mat[MAT_ATTRIB_DIFFUSE(f)] ); - break; - case GL_SPECULAR: - COPY_4FV( params, mat[MAT_ATTRIB_SPECULAR(f)] ); - break; - case GL_EMISSION: - COPY_4FV( params, mat[MAT_ATTRIB_EMISSION(f)] ); - break; - case GL_SHININESS: - *params = mat[MAT_ATTRIB_SHININESS(f)][0]; - break; - case GL_COLOR_INDEXES: - params[0] = mat[MAT_ATTRIB_INDEXES(f)][0]; - params[1] = mat[MAT_ATTRIB_INDEXES(f)][1]; - params[2] = mat[MAT_ATTRIB_INDEXES(f)][2]; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); - } -} - - -void GLAPIENTRY -_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint f; - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ - - FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ - - if (face==GL_FRONT) { - f = 0; - } - else if (face==GL_BACK) { - f = 1; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" ); - return; - } - switch (pname) { - case GL_AMBIENT: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][3] ); - break; - case GL_DIFFUSE: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][3] ); - break; - case GL_SPECULAR: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][3] ); - break; - case GL_EMISSION: - params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][0] ); - params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][1] ); - params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][2] ); - params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] ); - break; - case GL_SHININESS: - *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] ); - break; - case GL_COLOR_INDEXES: - params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] ); - params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] ); - params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] ); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); - } -} - - - -/**********************************************************************/ -/***** Lighting computation *****/ -/**********************************************************************/ - - -/* - * Notes: - * When two-sided lighting is enabled we compute the color (or index) - * for both the front and back side of the primitive. Then, when the - * orientation of the facet is later learned, we can determine which - * color (or index) to use for rendering. - * - * KW: We now know orientation in advance and only shade for - * the side or sides which are actually required. - * - * Variables: - * n = normal vector - * V = vertex position - * P = light source position - * Pe = (0,0,0,1) - * - * Precomputed: - * IF P[3]==0 THEN - * // light at infinity - * IF local_viewer THEN - * _VP_inf_norm = unit vector from V to P // Precompute - * ELSE - * // eye at infinity - * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute - * ENDIF - * ENDIF - * - * Functions: - * Normalize( v ) = normalized vector v - * Magnitude( v ) = length of vector v - */ - - - -/* - * Whenever the spotlight exponent for a light changes we must call - * this function to recompute the exponent lookup table. - */ -void -_mesa_invalidate_spot_exp_table( struct gl_light *l ) -{ - l->_SpotExpTable[0][0] = -1; -} - - -static void -validate_spot_exp_table( struct gl_light *l ) -{ - GLint i; - GLdouble exponent = l->SpotExponent; - GLdouble tmp = 0; - GLint clamp = 0; - - l->_SpotExpTable[0][0] = 0.0; - - for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { - if (clamp == 0) { - tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); - if (tmp < FLT_MIN * 100.0) { - tmp = 0.0; - clamp = 1; - } - } - l->_SpotExpTable[i][0] = (GLfloat) tmp; - } - for (i = 0; i < EXP_TABLE_SIZE - 1; i++) { - l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] - - l->_SpotExpTable[i][0]); - } - l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0; -} - - - -/* Calculate a new shine table. Doing this here saves a branch in - * lighting, and the cost of doing it early may be partially offset - * by keeping a MRU cache of shine tables for various shine values. - */ -void -_mesa_invalidate_shine_table( GLcontext *ctx, GLuint side ) -{ - ASSERT(side < 2); - if (ctx->_ShineTable[side]) - ctx->_ShineTable[side]->refcount--; - ctx->_ShineTable[side] = NULL; -} - - -static void -validate_shine_table( GLcontext *ctx, GLuint side, GLfloat shininess ) -{ - struct gl_shine_tab *list = ctx->_ShineTabList; - struct gl_shine_tab *s; - - ASSERT(side < 2); - - foreach(s, list) - if ( s->shininess == shininess ) - break; - - if (s == list) { - GLint j; - GLfloat *m; - - foreach(s, list) - if (s->refcount == 0) - break; - - m = s->tab; - m[0] = 0.0; - if (shininess == 0.0) { - for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++) - m[j] = 1.0; - } - else { - for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) { - GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); - if (x < 0.005) /* underflow check */ - x = 0.005; - t = pow(x, shininess); - if (t > 1e-20) - m[j] = (GLfloat) t; - else - m[j] = 0.0; - } - m[SHINE_TABLE_SIZE] = 1.0; - } - - s->shininess = shininess; - } - - if (ctx->_ShineTable[side]) - ctx->_ShineTable[side]->refcount--; - - ctx->_ShineTable[side] = s; - move_to_tail( list, s ); - s->refcount++; -} - - -void -_mesa_validate_all_lighting_tables( GLcontext *ctx ) -{ - GLuint i; - GLfloat shininess; - - shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0]; - if (!ctx->_ShineTable[0] || ctx->_ShineTable[0]->shininess != shininess) - validate_shine_table( ctx, 0, shininess ); - - shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0]; - if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess) - validate_shine_table( ctx, 1, shininess ); - - for (i = 0; i < ctx->Const.MaxLights; i++) - if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1) - validate_spot_exp_table( &ctx->Light.Light[i] ); -} - - -/** - * Examine current lighting parameters to determine if the optimized lighting - * function can be used. - * Also, precompute some lighting values such as the products of light - * source and material ambient, diffuse and specular coefficients. - */ -void -_mesa_update_lighting( GLcontext *ctx ) -{ - struct gl_light *light; - ctx->Light._NeedEyeCoords = GL_FALSE; - ctx->Light._Flags = 0; - - if (!ctx->Light.Enabled) - return; - - foreach(light, &ctx->Light.EnabledList) { - ctx->Light._Flags |= light->_Flags; - } - - ctx->Light._NeedVertices = - ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) || - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR || - ctx->Light.Model.LocalViewer); - - ctx->Light._NeedEyeCoords = ((ctx->Light._Flags & LIGHT_POSITIONAL) || - ctx->Light.Model.LocalViewer); - - /* XXX: This test is overkill & needs to be fixed both for software and - * hardware t&l drivers. The above should be sufficient & should - * be tested to verify this. - */ - if (ctx->Light._NeedVertices) - ctx->Light._NeedEyeCoords = GL_TRUE; - - /* Precompute some shading values. Although we reference - * Light.Material here, we can get away without flushing - * FLUSH_UPDATE_CURRENT, as when any outstanding material changes - * are flushed, they will update the derived state at that time. - */ - if (ctx->Light.Model.TwoSide) - _mesa_update_material(ctx, - MAT_BIT_FRONT_EMISSION | - MAT_BIT_FRONT_AMBIENT | - MAT_BIT_FRONT_DIFFUSE | - MAT_BIT_FRONT_SPECULAR | - MAT_BIT_BACK_EMISSION | - MAT_BIT_BACK_AMBIENT | - MAT_BIT_BACK_DIFFUSE | - MAT_BIT_BACK_SPECULAR); - else - _mesa_update_material(ctx, - MAT_BIT_FRONT_EMISSION | - MAT_BIT_FRONT_AMBIENT | - MAT_BIT_FRONT_DIFFUSE | - MAT_BIT_FRONT_SPECULAR); -} - - -/** - * Update state derived from light position, spot direction. - * Called upon: - * _NEW_MODELVIEW - * _NEW_LIGHT - * _TNL_NEW_NEED_EYE_COORDS - * - * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled. - * Also update on lighting space changes. - */ -static void -compute_light_positions( GLcontext *ctx ) -{ - struct gl_light *light; - static const GLfloat eye_z[3] = { 0, 0, 1 }; - - if (!ctx->Light.Enabled) - return; - - if (ctx->_NeedEyeCoords) { - COPY_3V( ctx->_EyeZDir, eye_z ); - } - else { - TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m ); - } - - foreach (light, &ctx->Light.EnabledList) { - - if (ctx->_NeedEyeCoords) { - /* _Position is in eye coordinate space */ - COPY_4FV( light->_Position, light->EyePosition ); - } - else { - /* _Position is in object coordinate space */ - TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv, - light->EyePosition ); - } - - if (!(light->_Flags & LIGHT_POSITIONAL)) { - /* VP (VP) = Normalize( Position ) */ - COPY_3V( light->_VP_inf_norm, light->_Position ); - NORMALIZE_3FV( light->_VP_inf_norm ); - - if (!ctx->Light.Model.LocalViewer) { - /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */ - ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir); - NORMALIZE_3FV( light->_h_inf_norm ); - } - light->_VP_inf_spot_attenuation = 1.0; - } - else { - /* positional light w/ homogeneous coordinate, divide by W */ - GLfloat wInv = (GLfloat)1.0 / light->_Position[3]; - light->_Position[0] *= wInv; - light->_Position[1] *= wInv; - light->_Position[2] *= wInv; - } - - if (light->_Flags & LIGHT_SPOT) { - /* Note: we normalize the spot direction now */ - - if (ctx->_NeedEyeCoords) { - COPY_3V( light->_NormSpotDirection, light->SpotDirection ); - NORMALIZE_3FV( light->_NormSpotDirection ); - } - else { - GLfloat spotDir[3]; - COPY_3V(spotDir, light->SpotDirection); - NORMALIZE_3FV(spotDir); - TRANSFORM_NORMAL( light->_NormSpotDirection, - spotDir, - ctx->ModelviewMatrixStack.Top->m); - } - - NORMALIZE_3FV( light->_NormSpotDirection ); - - if (!(light->_Flags & LIGHT_POSITIONAL)) { - GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm, - light->_NormSpotDirection); - - if (PV_dot_dir > light->_CosCutoff) { - double x = PV_dot_dir * (EXP_TABLE_SIZE-1); - int k = (int) x; - light->_VP_inf_spot_attenuation = - (GLfloat) (light->_SpotExpTable[k][0] + - (x-k)*light->_SpotExpTable[k][1]); - } - else { - light->_VP_inf_spot_attenuation = 0; - } - } - } - } -} - - - -static void -update_modelview_scale( GLcontext *ctx ) -{ - ctx->_ModelViewInvScale = 1.0F; - if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) { - const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv; - GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; - if (f < 1e-12) f = 1.0; - if (ctx->_NeedEyeCoords) - ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f); - else - ctx->_ModelViewInvScale = (GLfloat) SQRTF(f); - } -} - - -/** - * Bring up to date any state that relies on _NeedEyeCoords. - */ -void -_mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state ) -{ - const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; - - (void) new_state; - ctx->_NeedEyeCoords = GL_FALSE; - - if (ctx->_ForceEyeCoords || - (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) || - ctx->Point._Attenuated || - ctx->Light._NeedEyeCoords) - ctx->_NeedEyeCoords = GL_TRUE; - - if (ctx->Light.Enabled && - !_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) - ctx->_NeedEyeCoords = GL_TRUE; - - /* Check if the truth-value interpretations of the bitfields have - * changed: - */ - if (oldneedeyecoords != ctx->_NeedEyeCoords) { - /* Recalculate all state that depends on _NeedEyeCoords. - */ - update_modelview_scale(ctx); - compute_light_positions( ctx ); - - if (ctx->Driver.LightingSpaceChange) - ctx->Driver.LightingSpaceChange( ctx ); - } - else { - GLuint new_state2 = ctx->NewState; - - /* Recalculate that same state only if it has been invalidated - * by other statechanges. - */ - if (new_state2 & _NEW_MODELVIEW) - update_modelview_scale(ctx); - - if (new_state2 & (_NEW_LIGHT|_NEW_MODELVIEW)) - compute_light_positions( ctx ); - } -} - - -/** - * Drivers may need this if the hardware tnl unit doesn't support the - * light-in-modelspace optimization. It's also useful for debugging. - */ -void -_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag ) -{ - ctx->_ForceEyeCoords = !flag; - ctx->NewState |= _NEW_POINT; /* one of the bits from - * _MESA_NEW_NEED_EYE_COORDS. - */ -} - - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Initialize the n-th light data structure. - * - * \param l pointer to the gl_light structure to be initialized. - * \param n number of the light. - * \note The defaults for light 0 are different than the other lights. - */ -static void -init_light( struct gl_light *l, GLuint n ) -{ - make_empty_list( l ); - - ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 ); - if (n==0) { - ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 ); - } - else { - ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 ); - ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 ); - } - ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 ); - ASSIGN_3V( l->SpotDirection, 0.0, 0.0, -1.0 ); - l->SpotExponent = 0.0; - _mesa_invalidate_spot_exp_table( l ); - l->SpotCutoff = 180.0; - l->_CosCutoffNeg = -1.0f; - l->_CosCutoff = 0.0; /* KW: -ve values not admitted */ - l->ConstantAttenuation = 1.0; - l->LinearAttenuation = 0.0; - l->QuadraticAttenuation = 0.0; - l->Enabled = GL_FALSE; -} - - -/** - * Initialize the light model data structure. - * - * \param lm pointer to the gl_lightmodel structure to be initialized. - */ -static void -init_lightmodel( struct gl_lightmodel *lm ) -{ - ASSIGN_4V( lm->Ambient, 0.2F, 0.2F, 0.2F, 1.0F ); - lm->LocalViewer = GL_FALSE; - lm->TwoSide = GL_FALSE; - lm->ColorControl = GL_SINGLE_COLOR; -} - - -/** - * Initialize the material data structure. - * - * \param m pointer to the gl_material structure to be initialized. - */ -static void -init_material( struct gl_material *m ) -{ - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); - - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); - ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); -} - - -/** - * Initialize all lighting state for the given context. - */ -void -_mesa_init_lighting( GLcontext *ctx ) -{ - GLuint i; - - /* Lighting group */ - for (i = 0; i < MAX_LIGHTS; i++) { - init_light( &ctx->Light.Light[i], i ); - } - make_empty_list( &ctx->Light.EnabledList ); - - init_lightmodel( &ctx->Light.Model ); - init_material( &ctx->Light.Material ); - ctx->Light.ShadeModel = GL_SMOOTH; - ctx->Light.ProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT; - ctx->Light.Enabled = GL_FALSE; - ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK; - ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE; - ctx->Light.ColorMaterialBitmask = _mesa_material_bitmask( ctx, - GL_FRONT_AND_BACK, - GL_AMBIENT_AND_DIFFUSE, ~0, - NULL ); - - ctx->Light.ColorMaterialEnabled = GL_FALSE; - ctx->Light.ClampVertexColor = GL_TRUE; - - /* Lighting miscellaneous */ - ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab ); - make_empty_list( ctx->_ShineTabList ); - /* Allocate 10 (arbitrary) shininess lookup tables */ - for (i = 0 ; i < 10 ; i++) { - struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab ); - s->shininess = -1; - s->refcount = 0; - insert_at_tail( ctx->_ShineTabList, s ); - } - - /* Miscellaneous */ - ctx->Light._NeedEyeCoords = GL_FALSE; - ctx->_NeedEyeCoords = GL_FALSE; - ctx->_ForceEyeCoords = GL_FALSE; - ctx->_ModelViewInvScale = 1.0; -} - - -/** - * Deallocate malloc'd lighting state attached to given context. - */ -void -_mesa_free_lighting_data( GLcontext *ctx ) -{ - struct gl_shine_tab *s, *tmps; - - /* Free lighting shininess exponentiation table */ - foreach_s( s, tmps, ctx->_ShineTabList ) { - free( s ); - } - free( ctx->_ShineTabList ); -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "enums.h" +#include "light.h" +#include "macros.h" +#include "simple_list.h" +#include "mtypes.h" +#include "math/m_matrix.h" + + +void GLAPIENTRY +_mesa_ShadeModel( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode)); + + if (mode != GL_FLAT && mode != GL_SMOOTH) { + _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel"); + return; + } + + if (ctx->Light.ShadeModel == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.ShadeModel = mode; + if (mode == GL_FLAT) + ctx->_TriangleCaps |= DD_FLATSHADE; + else + ctx->_TriangleCaps &= ~DD_FLATSHADE; + + if (ctx->Driver.ShadeModel) + ctx->Driver.ShadeModel( ctx, mode ); +} + + +/** + * Set the provoking vertex (the vertex which specifies the prim's + * color when flat shading) to either the first or last vertex of the + * triangle or line. + */ +void GLAPIENTRY +_mesa_ProvokingVertexEXT(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glProvokingVertexEXT 0x%x\n", mode); + + switch (mode) { + case GL_FIRST_VERTEX_CONVENTION_EXT: + case GL_LAST_VERTEX_CONVENTION_EXT: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glProvokingVertexEXT(0x%x)", mode); + return; + } + + if (ctx->Light.ProvokingVertex == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.ProvokingVertex = mode; +} + + +/** + * Helper function called by _mesa_Lightfv and _mesa_PopAttrib to set + * per-light state. + * For GL_POSITION and GL_SPOT_DIRECTION the params position/direction + * will have already been transformed by the modelview matrix! + * Also, all error checking should have already been done. + */ +void +_mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params) +{ + struct gl_light *light; + + ASSERT(lnum < MAX_LIGHTS); + light = &ctx->Light.Light[lnum]; + + switch (pname) { + case GL_AMBIENT: + if (TEST_EQ_4V(light->Ambient, params)) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_4V( light->Ambient, params ); + break; + case GL_DIFFUSE: + if (TEST_EQ_4V(light->Diffuse, params)) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_4V( light->Diffuse, params ); + break; + case GL_SPECULAR: + if (TEST_EQ_4V(light->Specular, params)) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_4V( light->Specular, params ); + break; + case GL_POSITION: + /* NOTE: position has already been transformed by ModelView! */ + if (TEST_EQ_4V(light->EyePosition, params)) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_4V(light->EyePosition, params); + if (light->EyePosition[3] != 0.0F) + light->_Flags |= LIGHT_POSITIONAL; + else + light->_Flags &= ~LIGHT_POSITIONAL; + break; + case GL_SPOT_DIRECTION: + /* NOTE: Direction already transformed by inverse ModelView! */ + if (TEST_EQ_3V(light->SpotDirection, params)) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_3V(light->SpotDirection, params); + break; + case GL_SPOT_EXPONENT: + ASSERT(params[0] >= 0.0); + ASSERT(params[0] <= ctx->Const.MaxSpotExponent); + if (light->SpotExponent == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + light->SpotExponent = params[0]; + _mesa_invalidate_spot_exp_table(light); + break; + case GL_SPOT_CUTOFF: + ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); + if (light->SpotCutoff == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + light->SpotCutoff = params[0]; + light->_CosCutoffNeg = (GLfloat) (cos(light->SpotCutoff * DEG2RAD)); + if (light->_CosCutoffNeg < 0) + light->_CosCutoff = 0; + else + light->_CosCutoff = light->_CosCutoffNeg; + if (light->SpotCutoff != 180.0F) + light->_Flags |= LIGHT_SPOT; + else + light->_Flags &= ~LIGHT_SPOT; + break; + case GL_CONSTANT_ATTENUATION: + ASSERT(params[0] >= 0.0); + if (light->ConstantAttenuation == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + light->ConstantAttenuation = params[0]; + break; + case GL_LINEAR_ATTENUATION: + ASSERT(params[0] >= 0.0); + if (light->LinearAttenuation == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + light->LinearAttenuation = params[0]; + break; + case GL_QUADRATIC_ATTENUATION: + ASSERT(params[0] >= 0.0); + if (light->QuadraticAttenuation == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + light->QuadraticAttenuation = params[0]; + break; + default: + _mesa_problem(ctx, "Unexpected pname in _mesa_light()"); + return; + } + + if (ctx->Driver.Lightfv) + ctx->Driver.Lightfv( ctx, GL_LIGHT0 + lnum, pname, params ); +} + + +void GLAPIENTRY +_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ) +{ + GLfloat fparam[4]; + fparam[0] = param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_Lightfv( light, pname, fparam ); +} + + +void GLAPIENTRY +_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i = (GLint) (light - GL_LIGHT0); + GLfloat temp[4]; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (i < 0 || i >= (GLint) ctx->Const.MaxLights) { + _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light ); + return; + } + + /* do particular error checks, transformations */ + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + /* nothing */ + break; + case GL_POSITION: + /* transform position by ModelView matrix */ + TRANSFORM_POINT(temp, ctx->ModelviewMatrixStack.Top->m, params); + params = temp; + break; + case GL_SPOT_DIRECTION: + /* transform direction by inverse modelview */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); + } + TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m); + params = temp; + break; + case GL_SPOT_EXPONENT: + if (params[0] < 0.0 || params[0] > ctx->Const.MaxSpotExponent) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); + return; + } + break; + case GL_SPOT_CUTOFF: + if ((params[0] < 0.0 || params[0] > 90.0) && params[0] != 180.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); + return; + } + break; + case GL_CONSTANT_ATTENUATION: + if (params[0] < 0.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); + return; + } + break; + case GL_LINEAR_ATTENUATION: + if (params[0] < 0.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); + return; + } + break; + case GL_QUADRATIC_ATTENUATION: + if (params[0] < 0.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLight"); + return; + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glLight(pname=0x%x)", pname); + return; + } + + _mesa_light(ctx, i, pname, params); +} + + +void GLAPIENTRY +_mesa_Lighti( GLenum light, GLenum pname, GLint param ) +{ + GLint iparam[4]; + iparam[0] = param; + iparam[1] = iparam[2] = iparam[3] = 0; + _mesa_Lightiv( light, pname, iparam ); +} + + +void GLAPIENTRY +_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + + _mesa_Lightfv( light, pname, fparam ); +} + + + +void GLAPIENTRY +_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint l = (GLint) (light - GL_LIGHT0); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + COPY_4V( params, ctx->Light.Light[l].Ambient ); + break; + case GL_DIFFUSE: + COPY_4V( params, ctx->Light.Light[l].Diffuse ); + break; + case GL_SPECULAR: + COPY_4V( params, ctx->Light.Light[l].Specular ); + break; + case GL_POSITION: + COPY_4V( params, ctx->Light.Light[l].EyePosition ); + break; + case GL_SPOT_DIRECTION: + COPY_3V( params, ctx->Light.Light[l].SpotDirection ); + break; + case GL_SPOT_EXPONENT: + params[0] = ctx->Light.Light[l].SpotExponent; + break; + case GL_SPOT_CUTOFF: + params[0] = ctx->Light.Light[l].SpotCutoff; + break; + case GL_CONSTANT_ATTENUATION: + params[0] = ctx->Light.Light[l].ConstantAttenuation; + break; + case GL_LINEAR_ATTENUATION: + params[0] = ctx->Light.Light[l].LinearAttenuation; + break; + case GL_QUADRATIC_ATTENUATION: + params[0] = ctx->Light.Light[l].QuadraticAttenuation; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); + break; + } +} + + +void GLAPIENTRY +_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint l = (GLint) (light - GL_LIGHT0); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]); + break; + case GL_DIFFUSE: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]); + break; + case GL_SPECULAR: + params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]); + params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]); + params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]); + params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]); + break; + case GL_POSITION: + params[0] = (GLint) ctx->Light.Light[l].EyePosition[0]; + params[1] = (GLint) ctx->Light.Light[l].EyePosition[1]; + params[2] = (GLint) ctx->Light.Light[l].EyePosition[2]; + params[3] = (GLint) ctx->Light.Light[l].EyePosition[3]; + break; + case GL_SPOT_DIRECTION: + params[0] = (GLint) ctx->Light.Light[l].SpotDirection[0]; + params[1] = (GLint) ctx->Light.Light[l].SpotDirection[1]; + params[2] = (GLint) ctx->Light.Light[l].SpotDirection[2]; + break; + case GL_SPOT_EXPONENT: + params[0] = (GLint) ctx->Light.Light[l].SpotExponent; + break; + case GL_SPOT_CUTOFF: + params[0] = (GLint) ctx->Light.Light[l].SpotCutoff; + break; + case GL_CONSTANT_ATTENUATION: + params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation; + break; + case GL_LINEAR_ATTENUATION: + params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation; + break; + case GL_QUADRATIC_ATTENUATION: + params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" ); + break; + } +} + + + +/**********************************************************************/ +/*** Light Model ***/ +/**********************************************************************/ + + +void GLAPIENTRY +_mesa_LightModelfv( GLenum pname, const GLfloat *params ) +{ + GLenum newenum; + GLboolean newbool; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + if (TEST_EQ_4V( ctx->Light.Model.Ambient, params )) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + COPY_4V( ctx->Light.Model.Ambient, params ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + newbool = (params[0]!=0.0); + if (ctx->Light.Model.LocalViewer == newbool) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Model.LocalViewer = newbool; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + newbool = (params[0]!=0.0); + if (ctx->Light.Model.TwoSide == newbool) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Model.TwoSide = newbool; + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + else + ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; + break; + case GL_LIGHT_MODEL_COLOR_CONTROL: + if (params[0] == (GLfloat) GL_SINGLE_COLOR) + newenum = GL_SINGLE_COLOR; + else if (params[0] == (GLfloat) GL_SEPARATE_SPECULAR_COLOR) + newenum = GL_SEPARATE_SPECULAR_COLOR; + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(param=0x0%x)", + (GLint) params[0] ); + return; + } + if (ctx->Light.Model.ColorControl == newenum) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Model.ColorControl = newenum; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname ); + break; + } + + if (ctx->Driver.LightModelfv) + ctx->Driver.LightModelfv( ctx, pname, params ); +} + + +void GLAPIENTRY +_mesa_LightModeliv( GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); + } + _mesa_LightModelfv( pname, fparam ); +} + + +void GLAPIENTRY +_mesa_LightModeli( GLenum pname, GLint param ) +{ + GLint iparam[4]; + iparam[0] = param; + iparam[1] = iparam[2] = iparam[3] = 0; + _mesa_LightModeliv( pname, iparam ); +} + + +void GLAPIENTRY +_mesa_LightModelf( GLenum pname, GLfloat param ) +{ + GLfloat fparam[4]; + fparam[0] = param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_LightModelfv( pname, fparam ); +} + + + +/********** MATERIAL **********/ + + +/* + * Given a face and pname value (ala glColorMaterial), compute a bitmask + * of the targeted material values. + */ +GLuint +_mesa_material_bitmask( struct gl_context *ctx, GLenum face, GLenum pname, + GLuint legal, const char *where ) +{ + GLuint bitmask = 0; + + /* Make a bitmask indicating what material attribute(s) we're updating */ + switch (pname) { + case GL_EMISSION: + bitmask |= MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION; + break; + case GL_AMBIENT: + bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; + break; + case GL_DIFFUSE: + bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; + break; + case GL_SPECULAR: + bitmask |= MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR; + break; + case GL_SHININESS: + bitmask |= MAT_BIT_FRONT_SHININESS | MAT_BIT_BACK_SHININESS; + break; + case GL_AMBIENT_AND_DIFFUSE: + bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT; + bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE; + break; + case GL_COLOR_INDEXES: + bitmask |= MAT_BIT_FRONT_INDEXES | MAT_BIT_BACK_INDEXES; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); + return 0; + } + + if (face==GL_FRONT) { + bitmask &= FRONT_MATERIAL_BITS; + } + else if (face==GL_BACK) { + bitmask &= BACK_MATERIAL_BITS; + } + else if (face != GL_FRONT_AND_BACK) { + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); + return 0; + } + + if (bitmask & ~legal) { + _mesa_error( ctx, GL_INVALID_ENUM, "%s", where ); + return 0; + } + + return bitmask; +} + + + +/* Perform a straight copy between materials. + */ +void +_mesa_copy_materials( struct gl_material *dst, + const struct gl_material *src, + GLuint bitmask ) +{ + int i; + + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<Attrib[i], src->Attrib[i] ); +} + + + +/* Update derived values following a change in ctx->Light.Material + */ +void +_mesa_update_material( struct gl_context *ctx, GLuint bitmask ) +{ + struct gl_light *light, *list = &ctx->Light.EnabledList; + GLfloat (*mat)[4] = ctx->Light.Material.Attrib; + + if (MESA_VERBOSE & VERBOSE_MATERIAL) + _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask); + + if (!bitmask) + return; + + /* update material ambience */ + if (bitmask & MAT_BIT_FRONT_AMBIENT) { + foreach (light, list) { + SCALE_3V( light->_MatAmbient[0], light->Ambient, + mat[MAT_ATTRIB_FRONT_AMBIENT]); + } + } + + if (bitmask & MAT_BIT_BACK_AMBIENT) { + foreach (light, list) { + SCALE_3V( light->_MatAmbient[1], light->Ambient, + mat[MAT_ATTRIB_BACK_AMBIENT]); + } + } + + /* update BaseColor = emission + scene's ambience * material's ambience */ + if (bitmask & (MAT_BIT_FRONT_EMISSION | MAT_BIT_FRONT_AMBIENT)) { + COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] ); + ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT], + ctx->Light.Model.Ambient ); + } + + if (bitmask & (MAT_BIT_BACK_EMISSION | MAT_BIT_BACK_AMBIENT)) { + COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] ); + ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT], + ctx->Light.Model.Ambient ); + } + + /* update material diffuse values */ + if (bitmask & MAT_BIT_FRONT_DIFFUSE) { + foreach (light, list) { + SCALE_3V( light->_MatDiffuse[0], light->Diffuse, + mat[MAT_ATTRIB_FRONT_DIFFUSE] ); + } + } + + if (bitmask & MAT_BIT_BACK_DIFFUSE) { + foreach (light, list) { + SCALE_3V( light->_MatDiffuse[1], light->Diffuse, + mat[MAT_ATTRIB_BACK_DIFFUSE] ); + } + } + + /* update material specular values */ + if (bitmask & MAT_BIT_FRONT_SPECULAR) { + foreach (light, list) { + SCALE_3V( light->_MatSpecular[0], light->Specular, + mat[MAT_ATTRIB_FRONT_SPECULAR]); + } + } + + if (bitmask & MAT_BIT_BACK_SPECULAR) { + foreach (light, list) { + SCALE_3V( light->_MatSpecular[1], light->Specular, + mat[MAT_ATTRIB_BACK_SPECULAR]); + } + } + + if (bitmask & MAT_BIT_FRONT_SHININESS) { + _mesa_invalidate_shine_table( ctx, 0 ); + } + + if (bitmask & MAT_BIT_BACK_SHININESS) { + _mesa_invalidate_shine_table( ctx, 1 ); + } +} + + +/* + * Update the current materials from the given rgba color + * according to the bitmask in ColorMaterialBitmask, which is + * set by glColorMaterial(). + */ +void +_mesa_update_color_material( struct gl_context *ctx, const GLfloat color[4] ) +{ + GLuint bitmask = ctx->Light.ColorMaterialBitmask; + struct gl_material *mat = &ctx->Light.Material; + int i; + + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<Attrib[i], color ); + + _mesa_update_material( ctx, bitmask ); +} + + +void GLAPIENTRY +_mesa_ColorMaterial( GLenum face, GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint bitmask; + GLuint legal = (MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION | + MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR | + MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE | + MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glColorMaterial %s %s\n", + _mesa_lookup_enum_by_nr(face), + _mesa_lookup_enum_by_nr(mode)); + + bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial"); + + if (ctx->Light.ColorMaterialBitmask == bitmask && + ctx->Light.ColorMaterialFace == face && + ctx->Light.ColorMaterialMode == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.ColorMaterialBitmask = bitmask; + ctx->Light.ColorMaterialFace = face; + ctx->Light.ColorMaterialMode = mode; + + if (ctx->Light.ColorMaterialEnabled) { + FLUSH_CURRENT( ctx, 0 ); + _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + } + + if (ctx->Driver.ColorMaterial) + ctx->Driver.ColorMaterial( ctx, face, mode ); +} + + +void GLAPIENTRY +_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint f; + GLfloat (*mat)[4] = ctx->Light.Material.Attrib; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ + + FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ + + if (face==GL_FRONT) { + f = 0; + } + else if (face==GL_BACK) { + f = 1; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" ); + return; + } + + switch (pname) { + case GL_AMBIENT: + COPY_4FV( params, mat[MAT_ATTRIB_AMBIENT(f)] ); + break; + case GL_DIFFUSE: + COPY_4FV( params, mat[MAT_ATTRIB_DIFFUSE(f)] ); + break; + case GL_SPECULAR: + COPY_4FV( params, mat[MAT_ATTRIB_SPECULAR(f)] ); + break; + case GL_EMISSION: + COPY_4FV( params, mat[MAT_ATTRIB_EMISSION(f)] ); + break; + case GL_SHININESS: + *params = mat[MAT_ATTRIB_SHININESS(f)][0]; + break; + case GL_COLOR_INDEXES: + params[0] = mat[MAT_ATTRIB_INDEXES(f)][0]; + params[1] = mat[MAT_ATTRIB_INDEXES(f)][1]; + params[2] = mat[MAT_ATTRIB_INDEXES(f)][2]; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); + } +} + + +void GLAPIENTRY +_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint f; + GLfloat (*mat)[4] = ctx->Light.Material.Attrib; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ + + FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ + + if (face==GL_FRONT) { + f = 0; + } + else if (face==GL_BACK) { + f = 1; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" ); + return; + } + switch (pname) { + case GL_AMBIENT: + params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][0] ); + params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][1] ); + params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][2] ); + params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][3] ); + break; + case GL_DIFFUSE: + params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][0] ); + params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][1] ); + params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][2] ); + params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][3] ); + break; + case GL_SPECULAR: + params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][0] ); + params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][1] ); + params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][2] ); + params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][3] ); + break; + case GL_EMISSION: + params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][0] ); + params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][1] ); + params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][2] ); + params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] ); + break; + case GL_SHININESS: + *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] ); + break; + case GL_COLOR_INDEXES: + params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] ); + params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] ); + params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] ); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); + } +} + + + +/**********************************************************************/ +/***** Lighting computation *****/ +/**********************************************************************/ + + +/* + * Notes: + * When two-sided lighting is enabled we compute the color (or index) + * for both the front and back side of the primitive. Then, when the + * orientation of the facet is later learned, we can determine which + * color (or index) to use for rendering. + * + * KW: We now know orientation in advance and only shade for + * the side or sides which are actually required. + * + * Variables: + * n = normal vector + * V = vertex position + * P = light source position + * Pe = (0,0,0,1) + * + * Precomputed: + * IF P[3]==0 THEN + * // light at infinity + * IF local_viewer THEN + * _VP_inf_norm = unit vector from V to P // Precompute + * ELSE + * // eye at infinity + * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute + * ENDIF + * ENDIF + * + * Functions: + * Normalize( v ) = normalized vector v + * Magnitude( v ) = length of vector v + */ + + + +/* + * Whenever the spotlight exponent for a light changes we must call + * this function to recompute the exponent lookup table. + */ +void +_mesa_invalidate_spot_exp_table( struct gl_light *l ) +{ + l->_SpotExpTable[0][0] = -1; +} + + +static void +validate_spot_exp_table( struct gl_light *l ) +{ + GLint i; + GLdouble exponent = l->SpotExponent; + GLdouble tmp = 0; + GLint clamp = 0; + + l->_SpotExpTable[0][0] = 0.0; + + for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { + if (clamp == 0) { + tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); + if (tmp < FLT_MIN * 100.0) { + tmp = 0.0; + clamp = 1; + } + } + l->_SpotExpTable[i][0] = (GLfloat) tmp; + } + for (i = 0; i < EXP_TABLE_SIZE - 1; i++) { + l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] - + l->_SpotExpTable[i][0]); + } + l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0; +} + + + +/* Calculate a new shine table. Doing this here saves a branch in + * lighting, and the cost of doing it early may be partially offset + * by keeping a MRU cache of shine tables for various shine values. + */ +void +_mesa_invalidate_shine_table( struct gl_context *ctx, GLuint side ) +{ + ASSERT(side < 2); + if (ctx->_ShineTable[side]) + ctx->_ShineTable[side]->refcount--; + ctx->_ShineTable[side] = NULL; +} + + +static void +validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) +{ + struct gl_shine_tab *list = ctx->_ShineTabList; + struct gl_shine_tab *s; + + ASSERT(side < 2); + + foreach(s, list) + if ( s->shininess == shininess ) + break; + + if (s == list) { + GLint j; + GLfloat *m; + + foreach(s, list) + if (s->refcount == 0) + break; + + m = s->tab; + m[0] = 0.0; + if (shininess == 0.0) { + for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++) + m[j] = 1.0; + } + else { + for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) { + GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); + if (x < 0.005) /* underflow check */ + x = 0.005; + t = pow(x, shininess); + if (t > 1e-20) + m[j] = (GLfloat) t; + else + m[j] = 0.0; + } + m[SHINE_TABLE_SIZE] = 1.0; + } + + s->shininess = shininess; + } + + if (ctx->_ShineTable[side]) + ctx->_ShineTable[side]->refcount--; + + ctx->_ShineTable[side] = s; + move_to_tail( list, s ); + s->refcount++; +} + + +void +_mesa_validate_all_lighting_tables( struct gl_context *ctx ) +{ + GLuint i; + GLfloat shininess; + + shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0]; + if (!ctx->_ShineTable[0] || ctx->_ShineTable[0]->shininess != shininess) + validate_shine_table( ctx, 0, shininess ); + + shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0]; + if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess) + validate_shine_table( ctx, 1, shininess ); + + for (i = 0; i < ctx->Const.MaxLights; i++) + if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1) + validate_spot_exp_table( &ctx->Light.Light[i] ); +} + + +/** + * Examine current lighting parameters to determine if the optimized lighting + * function can be used. + * Also, precompute some lighting values such as the products of light + * source and material ambient, diffuse and specular coefficients. + */ +void +_mesa_update_lighting( struct gl_context *ctx ) +{ + struct gl_light *light; + ctx->Light._NeedEyeCoords = GL_FALSE; + ctx->Light._Flags = 0; + + if (!ctx->Light.Enabled) + return; + + foreach(light, &ctx->Light.EnabledList) { + ctx->Light._Flags |= light->_Flags; + } + + ctx->Light._NeedVertices = + ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) || + ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR || + ctx->Light.Model.LocalViewer); + + ctx->Light._NeedEyeCoords = ((ctx->Light._Flags & LIGHT_POSITIONAL) || + ctx->Light.Model.LocalViewer); + + /* XXX: This test is overkill & needs to be fixed both for software and + * hardware t&l drivers. The above should be sufficient & should + * be tested to verify this. + */ + if (ctx->Light._NeedVertices) + ctx->Light._NeedEyeCoords = GL_TRUE; + + /* Precompute some shading values. Although we reference + * Light.Material here, we can get away without flushing + * FLUSH_UPDATE_CURRENT, as when any outstanding material changes + * are flushed, they will update the derived state at that time. + */ + if (ctx->Light.Model.TwoSide) + _mesa_update_material(ctx, + MAT_BIT_FRONT_EMISSION | + MAT_BIT_FRONT_AMBIENT | + MAT_BIT_FRONT_DIFFUSE | + MAT_BIT_FRONT_SPECULAR | + MAT_BIT_BACK_EMISSION | + MAT_BIT_BACK_AMBIENT | + MAT_BIT_BACK_DIFFUSE | + MAT_BIT_BACK_SPECULAR); + else + _mesa_update_material(ctx, + MAT_BIT_FRONT_EMISSION | + MAT_BIT_FRONT_AMBIENT | + MAT_BIT_FRONT_DIFFUSE | + MAT_BIT_FRONT_SPECULAR); +} + + +/** + * Update state derived from light position, spot direction. + * Called upon: + * _NEW_MODELVIEW + * _NEW_LIGHT + * _TNL_NEW_NEED_EYE_COORDS + * + * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled. + * Also update on lighting space changes. + */ +static void +compute_light_positions( struct gl_context *ctx ) +{ + struct gl_light *light; + static const GLfloat eye_z[3] = { 0, 0, 1 }; + + if (!ctx->Light.Enabled) + return; + + if (ctx->_NeedEyeCoords) { + COPY_3V( ctx->_EyeZDir, eye_z ); + } + else { + TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m ); + } + + foreach (light, &ctx->Light.EnabledList) { + + if (ctx->_NeedEyeCoords) { + /* _Position is in eye coordinate space */ + COPY_4FV( light->_Position, light->EyePosition ); + } + else { + /* _Position is in object coordinate space */ + TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv, + light->EyePosition ); + } + + if (!(light->_Flags & LIGHT_POSITIONAL)) { + /* VP (VP) = Normalize( Position ) */ + COPY_3V( light->_VP_inf_norm, light->_Position ); + NORMALIZE_3FV( light->_VP_inf_norm ); + + if (!ctx->Light.Model.LocalViewer) { + /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */ + ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir); + NORMALIZE_3FV( light->_h_inf_norm ); + } + light->_VP_inf_spot_attenuation = 1.0; + } + else { + /* positional light w/ homogeneous coordinate, divide by W */ + GLfloat wInv = (GLfloat)1.0 / light->_Position[3]; + light->_Position[0] *= wInv; + light->_Position[1] *= wInv; + light->_Position[2] *= wInv; + } + + if (light->_Flags & LIGHT_SPOT) { + /* Note: we normalize the spot direction now */ + + if (ctx->_NeedEyeCoords) { + COPY_3V( light->_NormSpotDirection, light->SpotDirection ); + NORMALIZE_3FV( light->_NormSpotDirection ); + } + else { + GLfloat spotDir[3]; + COPY_3V(spotDir, light->SpotDirection); + NORMALIZE_3FV(spotDir); + TRANSFORM_NORMAL( light->_NormSpotDirection, + spotDir, + ctx->ModelviewMatrixStack.Top->m); + } + + NORMALIZE_3FV( light->_NormSpotDirection ); + + if (!(light->_Flags & LIGHT_POSITIONAL)) { + GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm, + light->_NormSpotDirection); + + if (PV_dot_dir > light->_CosCutoff) { + double x = PV_dot_dir * (EXP_TABLE_SIZE-1); + int k = (int) x; + light->_VP_inf_spot_attenuation = + (GLfloat) (light->_SpotExpTable[k][0] + + (x-k)*light->_SpotExpTable[k][1]); + } + else { + light->_VP_inf_spot_attenuation = 0; + } + } + } + } +} + + + +static void +update_modelview_scale( struct gl_context *ctx ) +{ + ctx->_ModelViewInvScale = 1.0F; + if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) { + const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv; + GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; + if (f < 1e-12) f = 1.0; + if (ctx->_NeedEyeCoords) + ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f); + else + ctx->_ModelViewInvScale = (GLfloat) SQRTF(f); + } +} + + +/** + * Bring up to date any state that relies on _NeedEyeCoords. + */ +void +_mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ) +{ + const GLuint oldneedeyecoords = ctx->_NeedEyeCoords; + + (void) new_state; + ctx->_NeedEyeCoords = GL_FALSE; + + if (ctx->_ForceEyeCoords || + (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) || + ctx->Point._Attenuated || + ctx->Light._NeedEyeCoords) + ctx->_NeedEyeCoords = GL_TRUE; + + if (ctx->Light.Enabled && + !_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) + ctx->_NeedEyeCoords = GL_TRUE; + + /* Check if the truth-value interpretations of the bitfields have + * changed: + */ + if (oldneedeyecoords != ctx->_NeedEyeCoords) { + /* Recalculate all state that depends on _NeedEyeCoords. + */ + update_modelview_scale(ctx); + compute_light_positions( ctx ); + + if (ctx->Driver.LightingSpaceChange) + ctx->Driver.LightingSpaceChange( ctx ); + } + else { + GLuint new_state2 = ctx->NewState; + + /* Recalculate that same state only if it has been invalidated + * by other statechanges. + */ + if (new_state2 & _NEW_MODELVIEW) + update_modelview_scale(ctx); + + if (new_state2 & (_NEW_LIGHT|_NEW_MODELVIEW)) + compute_light_positions( ctx ); + } +} + + +/** + * Drivers may need this if the hardware tnl unit doesn't support the + * light-in-modelspace optimization. It's also useful for debugging. + */ +void +_mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ) +{ + ctx->_ForceEyeCoords = !flag; + ctx->NewState |= _NEW_POINT; /* one of the bits from + * _MESA_NEW_NEED_EYE_COORDS. + */ +} + + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +/** + * Initialize the n-th light data structure. + * + * \param l pointer to the gl_light structure to be initialized. + * \param n number of the light. + * \note The defaults for light 0 are different than the other lights. + */ +static void +init_light( struct gl_light *l, GLuint n ) +{ + make_empty_list( l ); + + ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 ); + if (n==0) { + ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 ); + ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 ); + } + else { + ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 ); + } + ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 ); + ASSIGN_3V( l->SpotDirection, 0.0, 0.0, -1.0 ); + l->SpotExponent = 0.0; + _mesa_invalidate_spot_exp_table( l ); + l->SpotCutoff = 180.0; + l->_CosCutoffNeg = -1.0f; + l->_CosCutoff = 0.0; /* KW: -ve values not admitted */ + l->ConstantAttenuation = 1.0; + l->LinearAttenuation = 0.0; + l->QuadraticAttenuation = 0.0; + l->Enabled = GL_FALSE; +} + + +/** + * Initialize the light model data structure. + * + * \param lm pointer to the gl_lightmodel structure to be initialized. + */ +static void +init_lightmodel( struct gl_lightmodel *lm ) +{ + ASSIGN_4V( lm->Ambient, 0.2F, 0.2F, 0.2F, 1.0F ); + lm->LocalViewer = GL_FALSE; + lm->TwoSide = GL_FALSE; + lm->ColorControl = GL_SINGLE_COLOR; +} + + +/** + * Initialize the material data structure. + * + * \param m pointer to the gl_material structure to be initialized. + */ +static void +init_material( struct gl_material *m ) +{ + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); + + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F ); + ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F ); +} + + +/** + * Initialize all lighting state for the given context. + */ +void +_mesa_init_lighting( struct gl_context *ctx ) +{ + GLuint i; + + /* Lighting group */ + for (i = 0; i < MAX_LIGHTS; i++) { + init_light( &ctx->Light.Light[i], i ); + } + make_empty_list( &ctx->Light.EnabledList ); + + init_lightmodel( &ctx->Light.Model ); + init_material( &ctx->Light.Material ); + ctx->Light.ShadeModel = GL_SMOOTH; + ctx->Light.ProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT; + ctx->Light.Enabled = GL_FALSE; + ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK; + ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE; + ctx->Light.ColorMaterialBitmask = _mesa_material_bitmask( ctx, + GL_FRONT_AND_BACK, + GL_AMBIENT_AND_DIFFUSE, ~0, + NULL ); + + ctx->Light.ColorMaterialEnabled = GL_FALSE; + ctx->Light.ClampVertexColor = GL_TRUE; + + /* Lighting miscellaneous */ + ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab ); + make_empty_list( ctx->_ShineTabList ); + /* Allocate 10 (arbitrary) shininess lookup tables */ + for (i = 0 ; i < 10 ; i++) { + struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab ); + s->shininess = -1; + s->refcount = 0; + insert_at_tail( ctx->_ShineTabList, s ); + } + + /* Miscellaneous */ + ctx->Light._NeedEyeCoords = GL_FALSE; + ctx->_NeedEyeCoords = GL_FALSE; + ctx->_ForceEyeCoords = GL_FALSE; + ctx->_ModelViewInvScale = 1.0; +} + + +/** + * Deallocate malloc'd lighting state attached to given context. + */ +void +_mesa_free_lighting_data( struct gl_context *ctx ) +{ + struct gl_shine_tab *s, *tmps; + + /* Free lighting shininess exponentiation table */ + foreach_s( s, tmps, ctx->_ShineTabList ) { + free( s ); + } + free( ctx->_ShineTabList ); +} diff --git a/mesalib/src/mesa/main/light.h b/mesalib/src/mesa/main/light.h index b3436114d..cd8aeaeb6 100644 --- a/mesalib/src/mesa/main/light.h +++ b/mesalib/src/mesa/main/light.h @@ -1,146 +1,151 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef LIGHT_H -#define LIGHT_H - - -#include "mtypes.h" - -extern void GLAPIENTRY -_mesa_ShadeModel( GLenum mode ); - -extern void GLAPIENTRY -_mesa_ProvokingVertexEXT(GLenum mode); - - -#if _HAVE_FULL_GL -extern void GLAPIENTRY -_mesa_ColorMaterial( GLenum face, GLenum mode ); - -extern void GLAPIENTRY -_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_Lighti( GLenum light, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_LightModelf( GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_LightModelfv( GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_LightModeli( GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_LightModeliv( GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ); - - -extern void -_mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params); - - -/* Lerp between adjacent values in the f(x) lookup table, giving a - * continuous function, with adequeate overall accuracy. (Though - * still pretty good compared to a straight lookup). - * Result should be a GLfloat. - */ -#define GET_SHINE_TAB_ENTRY( table, dp, result ) \ -do { \ - struct gl_shine_tab *_tab = table; \ - float f = (dp * (SHINE_TABLE_SIZE-1)); \ - int k = (int) f; \ - if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \ - || k > SHINE_TABLE_SIZE-2) \ - result = (GLfloat) pow( dp, _tab->shininess ); \ - else \ - result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ -} while (0) - - -extern GLuint _mesa_material_bitmask( GLcontext *ctx, - GLenum face, GLenum pname, - GLuint legal, - const char * ); - -extern void _mesa_invalidate_spot_exp_table( struct gl_light *l ); - -extern void _mesa_invalidate_shine_table( GLcontext *ctx, GLuint i ); - -extern void _mesa_validate_all_lighting_tables( GLcontext *ctx ); - -extern void _mesa_update_lighting( GLcontext *ctx ); - -extern void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state ); - -extern void _mesa_update_material( GLcontext *ctx, - GLuint bitmask ); - -extern void _mesa_copy_materials( struct gl_material *dst, - const struct gl_material *src, - GLuint bitmask ); - -extern void _mesa_update_color_material( GLcontext *ctx, - const GLfloat rgba[4] ); - -extern void _mesa_init_lighting( GLcontext *ctx ); - -extern void _mesa_free_lighting_data( GLcontext *ctx ); - -extern void _mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag ); - -#else -#define _mesa_update_color_material( c, r ) ((void)0) -#define _mesa_validate_all_lighting_tables( c ) ((void)0) -#define _mesa_invalidate_spot_exp_table( l ) ((void)0) -#define _mesa_material_bitmask( c, f, p, l, s ) 0 -#define _mesa_init_lighting( c ) ((void)0) -#define _mesa_free_lighting_data( c ) ((void)0) -#define _mesa_update_lighting( c ) ((void)0) -#define _mesa_update_tnl_spaces( c, n ) ((void)0) -#define GET_SHINE_TAB_ENTRY( table, dp, result ) ((result)=0) -#endif - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef LIGHT_H +#define LIGHT_H + + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; +struct gl_light; +struct gl_material; + +extern void GLAPIENTRY +_mesa_ShadeModel( GLenum mode ); + +extern void GLAPIENTRY +_mesa_ProvokingVertexEXT(GLenum mode); + + +#if _HAVE_FULL_GL +extern void GLAPIENTRY +_mesa_ColorMaterial( GLenum face, GLenum mode ); + +extern void GLAPIENTRY +_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ); + +extern void GLAPIENTRY +_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ); + +extern void GLAPIENTRY +_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ); + +extern void GLAPIENTRY +_mesa_Lighti( GLenum light, GLenum pname, GLint param ); + +extern void GLAPIENTRY +_mesa_LightModelf( GLenum pname, GLfloat param ); + +extern void GLAPIENTRY +_mesa_LightModelfv( GLenum pname, const GLfloat *params ); + +extern void GLAPIENTRY +_mesa_LightModeli( GLenum pname, GLint param ); + +extern void GLAPIENTRY +_mesa_LightModeliv( GLenum pname, const GLint *params ); + +extern void GLAPIENTRY +_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ); + +extern void GLAPIENTRY +_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ); + +extern void GLAPIENTRY +_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); + +extern void GLAPIENTRY +_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ); + + +extern void +_mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params); + + +/* Lerp between adjacent values in the f(x) lookup table, giving a + * continuous function, with adequeate overall accuracy. (Though + * still pretty good compared to a straight lookup). + * Result should be a GLfloat. + */ +#define GET_SHINE_TAB_ENTRY( table, dp, result ) \ +do { \ + struct gl_shine_tab *_tab = table; \ + float f = (dp * (SHINE_TABLE_SIZE-1)); \ + int k = (int) f; \ + if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \ + || k > SHINE_TABLE_SIZE-2) \ + result = (GLfloat) pow( dp, _tab->shininess ); \ + else \ + result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ +} while (0) + + +extern GLuint _mesa_material_bitmask( struct gl_context *ctx, + GLenum face, GLenum pname, + GLuint legal, + const char * ); + +extern void _mesa_invalidate_spot_exp_table( struct gl_light *l ); + +extern void _mesa_invalidate_shine_table( struct gl_context *ctx, GLuint i ); + +extern void _mesa_validate_all_lighting_tables( struct gl_context *ctx ); + +extern void _mesa_update_lighting( struct gl_context *ctx ); + +extern void _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ); + +extern void _mesa_update_material( struct gl_context *ctx, + GLuint bitmask ); + +extern void _mesa_copy_materials( struct gl_material *dst, + const struct gl_material *src, + GLuint bitmask ); + +extern void _mesa_update_color_material( struct gl_context *ctx, + const GLfloat rgba[4] ); + +extern void _mesa_init_lighting( struct gl_context *ctx ); + +extern void _mesa_free_lighting_data( struct gl_context *ctx ); + +extern void _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ); + +#else +#define _mesa_update_color_material( c, r ) ((void)0) +#define _mesa_validate_all_lighting_tables( c ) ((void)0) +#define _mesa_invalidate_spot_exp_table( l ) ((void)0) +#define _mesa_material_bitmask( c, f, p, l, s ) 0 +#define _mesa_init_lighting( c ) ((void)0) +#define _mesa_free_lighting_data( c ) ((void)0) +#define _mesa_update_lighting( c ) ((void)0) +#define _mesa_update_tnl_spaces( c, n ) ((void)0) +#define GET_SHINE_TAB_ENTRY( table, dp, result ) ((result)=0) +#endif + +#endif diff --git a/mesalib/src/mesa/main/lines.c b/mesalib/src/mesa/main/lines.c index cc63a759e..79385cd75 100644 --- a/mesalib/src/mesa/main/lines.c +++ b/mesalib/src/mesa/main/lines.c @@ -1,116 +1,111 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "context.h" -#include "lines.h" -#include "macros.h" -#include "mtypes.h" - - -/** - * Set the line width. - * - * \param width line width in pixels. - * - * \sa glLineWidth(). - */ -void GLAPIENTRY -_mesa_LineWidth( GLfloat width ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (width<=0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); - return; - } - - if (ctx->Line.Width == width) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.Width = width; - - if (width != 1.0F) - ctx->_TriangleCaps |= DD_LINE_WIDTH; - else - ctx->_TriangleCaps &= ~DD_LINE_WIDTH; - - if (ctx->Driver.LineWidth) - ctx->Driver.LineWidth(ctx, width); -} - - -/** - * Set the line stipple pattern. - * - * \param factor pattern scale factor. - * \param pattern bit pattern. - * - * \sa glLineStipple(). - * - * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On - * change flushes the vertices and notifies the driver via - * the dd_function_table::LineStipple callback. - */ -void GLAPIENTRY -_mesa_LineStipple( GLint factor, GLushort pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - factor = CLAMP( factor, 1, 256 ); - - if (ctx->Line.StippleFactor == factor && - ctx->Line.StipplePattern == pattern) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFactor = factor; - ctx->Line.StipplePattern = pattern; - - if (ctx->Driver.LineStipple) - ctx->Driver.LineStipple( ctx, factor, pattern ); -} - - -/** - * Initialize the context line state. - * - * \param ctx GL context. - * - * Initializes __GLcontextRec::Line and line related constants in - * __GLcontextRec::Const. - */ -void GLAPIENTRY -_mesa_init_line( GLcontext * ctx ) -{ - ctx->Line.SmoothFlag = GL_FALSE; - ctx->Line.StippleFlag = GL_FALSE; - ctx->Line.Width = 1.0; - ctx->Line.StipplePattern = 0xffff; - ctx->Line.StippleFactor = 1; -} +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "context.h" +#include "lines.h" +#include "macros.h" +#include "mtypes.h" + + +/** + * Set the line width. + * + * \param width line width in pixels. + * + * \sa glLineWidth(). + */ +void GLAPIENTRY +_mesa_LineWidth( GLfloat width ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (width<=0.0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); + return; + } + + if (ctx->Line.Width == width) + return; + + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.Width = width; + + if (ctx->Driver.LineWidth) + ctx->Driver.LineWidth(ctx, width); +} + + +/** + * Set the line stipple pattern. + * + * \param factor pattern scale factor. + * \param pattern bit pattern. + * + * \sa glLineStipple(). + * + * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On + * change flushes the vertices and notifies the driver via + * the dd_function_table::LineStipple callback. + */ +void GLAPIENTRY +_mesa_LineStipple( GLint factor, GLushort pattern ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + factor = CLAMP( factor, 1, 256 ); + + if (ctx->Line.StippleFactor == factor && + ctx->Line.StipplePattern == pattern) + return; + + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.StippleFactor = factor; + ctx->Line.StipplePattern = pattern; + + if (ctx->Driver.LineStipple) + ctx->Driver.LineStipple( ctx, factor, pattern ); +} + + +/** + * Initialize the context line state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Line and line related constants in + * __struct gl_contextRec::Const. + */ +void GLAPIENTRY +_mesa_init_line( struct gl_context * ctx ) +{ + ctx->Line.SmoothFlag = GL_FALSE; + ctx->Line.StippleFlag = GL_FALSE; + ctx->Line.Width = 1.0; + ctx->Line.StipplePattern = 0xffff; + ctx->Line.StippleFactor = 1; +} diff --git a/mesalib/src/mesa/main/lines.h b/mesalib/src/mesa/main/lines.h index 5a47e9858..c882fc679 100644 --- a/mesalib/src/mesa/main/lines.h +++ b/mesalib/src/mesa/main/lines.h @@ -1,48 +1,49 @@ -/** - * \file lines.h - * Line operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - - -#ifndef LINES_H -#define LINES_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_LineWidth( GLfloat width ); - -extern void GLAPIENTRY -_mesa_LineStipple( GLint factor, GLushort pattern ); - -extern void GLAPIENTRY -_mesa_init_line( GLcontext * ctx ); - -#endif +/** + * \file lines.h + * Line operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + + +#ifndef LINES_H +#define LINES_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_LineWidth( GLfloat width ); + +extern void GLAPIENTRY +_mesa_LineStipple( GLint factor, GLushort pattern ); + +extern void GLAPIENTRY +_mesa_init_line( struct gl_context * ctx ); + +#endif diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c index 4b8c00b5b..3fae85cad 100644 --- a/mesalib/src/mesa/main/matrix.c +++ b/mesalib/src/mesa/main/matrix.c @@ -1,793 +1,787 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file matrix.c - * Matrix operations. - * - * \note - * -# 4x4 transformation matrices are stored in memory in column major order. - * -# Points/vertices are to be thought of as column vectors. - * -# Transformation of a point p by a matrix M is: p' = M * p - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "enums.h" -#include "macros.h" -#include "matrix.h" -#include "mtypes.h" -#include "math/m_matrix.h" - - -/** - * Apply a perspective projection matrix. - * - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * \sa glFrustum(). - * - * Flushes vertices and validates parameters. Calls _math_matrix_frustum() with - * the top matrix of the current matrix stack and sets - * __GLcontextRec::NewState. - */ -void GLAPIENTRY -_mesa_Frustum( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (nearval <= 0.0 || - farval <= 0.0 || - nearval == farval || - left == right || - top == bottom) - { - _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" ); - return; - } - - _math_matrix_frustum( ctx->CurrentStack->Top, - (GLfloat) left, (GLfloat) right, - (GLfloat) bottom, (GLfloat) top, - (GLfloat) nearval, (GLfloat) farval ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Apply an orthographic projection matrix. - * - * \param left left clipping plane coordinate. - * \param right right clipping plane coordinate. - * \param bottom bottom clipping plane coordinate. - * \param top top clipping plane coordinate. - * \param nearval distance to the near clipping plane. - * \param farval distance to the far clipping plane. - * - * \sa glOrtho(). - * - * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with - * the top matrix of the current matrix stack and sets - * __GLcontextRec::NewState. - */ -void GLAPIENTRY -_mesa_Ortho( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n", - left, right, bottom, top, nearval, farval); - - if (left == right || - bottom == top || - nearval == farval) - { - _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" ); - return; - } - - _math_matrix_ortho( ctx->CurrentStack->Top, - (GLfloat) left, (GLfloat) right, - (GLfloat) bottom, (GLfloat) top, - (GLfloat) nearval, (GLfloat) farval ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Set the current matrix stack. - * - * \param mode matrix stack. - * - * \sa glMatrixMode(). - * - * Flushes the vertices, validates the parameter and updates - * __GLcontextRec::CurrentStack and gl_transform_attrib::MatrixMode with the - * specified matrix stack. - */ -void GLAPIENTRY -_mesa_MatrixMode( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - switch (mode) { - case GL_MODELVIEW: - ctx->CurrentStack = &ctx->ModelviewMatrixStack; - break; - case GL_PROJECTION: - ctx->CurrentStack = &ctx->ProjectionMatrixStack; - break; - case GL_TEXTURE: - /* This error check is disabled because if we're called from - * glPopAttrib() when the active texture unit is >= MaxTextureCoordUnits - * we'll generate an unexpected error. - * From the GL_ARB_vertex_shader spec it sounds like we should instead - * do error checking in other places when we actually try to access - * texture matrices beyond MaxTextureCoordUnits. - */ -#if 0 - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(invalid tex unit %d)", - ctx->Texture.CurrentUnit); - return; - } -#endif - ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); - ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; - break; - case GL_COLOR: - ctx->CurrentStack = &ctx->ColorMatrixStack; - break; - case GL_MATRIX0_NV: - case GL_MATRIX1_NV: - case GL_MATRIX2_NV: - case GL_MATRIX3_NV: - case GL_MATRIX4_NV: - case GL_MATRIX5_NV: - case GL_MATRIX6_NV: - case GL_MATRIX7_NV: - if (ctx->Extensions.NV_vertex_program) { - ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - break; - case GL_MATRIX0_ARB: - case GL_MATRIX1_ARB: - case GL_MATRIX2_ARB: - case GL_MATRIX3_ARB: - case GL_MATRIX4_ARB: - case GL_MATRIX5_ARB: - case GL_MATRIX6_ARB: - case GL_MATRIX7_ARB: - if (ctx->Extensions.ARB_vertex_program || - ctx->Extensions.ARB_fragment_program) { - const GLuint m = mode - GL_MATRIX0_ARB; - if (m > ctx->Const.MaxProgramMatrices) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glMatrixMode(GL_MATRIX%d_ARB)", m); - return; - } - ctx->CurrentStack = &ctx->ProgramMatrixStack[m]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - - ctx->Transform.MatrixMode = mode; -} - - -/** - * Push the current matrix stack. - * - * \sa glPushMatrix(). - * - * Verifies the current matrix stack is not full, and duplicates the top-most - * matrix in the stack. Marks __GLcontextRec::NewState with the stack dirty - * flag. - */ -void GLAPIENTRY -_mesa_PushMatrix( void ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_matrix_stack *stack = ctx->CurrentStack; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPushMatrix %s\n", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - - if (stack->Depth + 1 >= stack->MaxDepth) { - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - _mesa_error(ctx, GL_STACK_OVERFLOW, - "glPushMatrix(mode=GL_TEXTURE, unit=%d)", - ctx->Texture.CurrentUnit); - } - else { - _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - } - return; - } - _math_matrix_copy( &stack->Stack[stack->Depth + 1], - &stack->Stack[stack->Depth] ); - stack->Depth++; - stack->Top = &(stack->Stack[stack->Depth]); - ctx->NewState |= stack->DirtyFlag; -} - - -/** - * Pop the current matrix stack. - * - * \sa glPopMatrix(). - * - * Flushes the vertices, verifies the current matrix stack is not empty, and - * moves the stack head down. Marks __GLcontextRec::NewState with the dirty - * stack flag. - */ -void GLAPIENTRY -_mesa_PopMatrix( void ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_matrix_stack *stack = ctx->CurrentStack; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPopMatrix %s\n", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - - if (stack->Depth == 0) { - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - _mesa_error(ctx, GL_STACK_UNDERFLOW, - "glPopMatrix(mode=GL_TEXTURE, unit=%d)", - ctx->Texture.CurrentUnit); - } - else { - _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)", - _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); - } - return; - } - stack->Depth--; - stack->Top = &(stack->Stack[stack->Depth]); - ctx->NewState |= stack->DirtyFlag; -} - - -/** - * Replace the current matrix with the identity matrix. - * - * \sa glLoadIdentity(). - * - * Flushes the vertices and calls _math_matrix_set_identity() with the top-most - * matrix in the current stack. Marks __GLcontextRec::NewState with the stack - * dirty flag. - */ -void GLAPIENTRY -_mesa_LoadIdentity( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLoadIdentity()\n"); - - _math_matrix_set_identity( ctx->CurrentStack->Top ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Replace the current matrix with a given matrix. - * - * \param m matrix. - * - * \sa glLoadMatrixf(). - * - * Flushes the vertices and calls _math_matrix_loadf() with the top-most matrix - * in the current stack and the given matrix. Marks __GLcontextRec::NewState - * with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_LoadMatrixf( const GLfloat *m ) -{ - GET_CURRENT_CONTEXT(ctx); - if (!m) return; - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15]); - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_loadf( ctx->CurrentStack->Top, m ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a given matrix. - * - * \param m matrix. - * - * \sa glMultMatrixf(). - * - * Flushes the vertices and calls _math_matrix_mul_floats() with the top-most - * matrix in the current stack and the given matrix. Marks - * __GLcontextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_MultMatrixf( const GLfloat *m ) -{ - GET_CURRENT_CONTEXT(ctx); - if (!m) return; - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15]); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_mul_floats( ctx->CurrentStack->Top, m ); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a rotation matrix. - * - * \param angle angle of rotation, in degrees. - * \param x rotation vector x coordinate. - * \param y rotation vector y coordinate. - * \param z rotation vector z coordinate. - * - * \sa glRotatef(). - * - * Flushes the vertices and calls _math_matrix_rotate() with the top-most - * matrix in the current stack and the given parameters. Marks - * __GLcontextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (angle != 0.0F) { - _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; - } -} - - -/** - * Multiply the current matrix with a general scaling matrix. - * - * \param x x axis scale factor. - * \param y y axis scale factor. - * \param z z axis scale factor. - * - * \sa glScalef(). - * - * Flushes the vertices and calls _math_matrix_scale() with the top-most - * matrix in the current stack and the given parameters. Marks - * __GLcontextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_scale( ctx->CurrentStack->Top, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -/** - * Multiply the current matrix with a translation matrix. - * - * \param x translation vector x coordinate. - * \param y translation vector y coordinate. - * \param z translation vector z coordinate. - * - * \sa glTranslatef(). - * - * Flushes the vertices and calls _math_matrix_translate() with the top-most - * matrix in the current stack and the given parameters. Marks - * __GLcontextRec::NewState with the dirty stack flag. - */ -void GLAPIENTRY -_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _math_matrix_translate( ctx->CurrentStack->Top, x, y, z); - ctx->NewState |= ctx->CurrentStack->DirtyFlag; -} - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_LoadMatrixd( const GLdouble *m ) -{ - GLint i; - GLfloat f[16]; - if (!m) return; - for (i = 0; i < 16; i++) - f[i] = (GLfloat) m[i]; - _mesa_LoadMatrixf(f); -} - -void GLAPIENTRY -_mesa_MultMatrixd( const GLdouble *m ) -{ - GLint i; - GLfloat f[16]; - if (!m) return; - for (i = 0; i < 16; i++) - f[i] = (GLfloat) m[i]; - _mesa_MultMatrixf( f ); -} - - -void GLAPIENTRY -_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -void GLAPIENTRY -_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -void GLAPIENTRY -_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) -{ - _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} -#endif - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_LoadTransposeMatrixfARB( const GLfloat *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposef(tm, m); - _mesa_LoadMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_LoadTransposeMatrixdARB( const GLdouble *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposefd(tm, m); - _mesa_LoadMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_MultTransposeMatrixfARB( const GLfloat *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposef(tm, m); - _mesa_MultMatrixf(tm); -} - - -void GLAPIENTRY -_mesa_MultTransposeMatrixdARB( const GLdouble *m ) -{ - GLfloat tm[16]; - if (!m) return; - _math_transposefd(tm, m); - _mesa_MultMatrixf(tm); -} -#endif - - - -/**********************************************************************/ -/** \name State management */ -/*@{*/ - - -/** - * Update the projection matrix stack. - * - * \param ctx GL context. - * - * Calls _math_matrix_analyse() with the top-matrix of the projection matrix - * stack, and recomputes user clip positions if necessary. - * - * \note This routine references __GLcontextRec::Tranform attribute values to - * compute userclip positions in clip space, but is only called on - * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to - * date across changes to the __GLcontextRec::Transform attributes. - */ -static void -update_projection( GLcontext *ctx ) -{ - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - -#if FEATURE_userclip - /* Recompute clip plane positions in clipspace. This is also done - * in _mesa_ClipPlane(). - */ - if (ctx->Transform.ClipPlanesEnabled) { - GLuint p; - for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { - if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], - ctx->Transform.EyeUserPlane[p], - ctx->ProjectionMatrixStack.Top->inv ); - } - } - } -#endif -} - - -/** - * Calculate the combined modelview-projection matrix. - * - * \param ctx GL context. - * - * Multiplies the top matrices of the projection and model view stacks into - * __GLcontextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() and - * analyzes the resulting matrix via _math_matrix_analyse(). - */ -static void -calculate_model_project_matrix( GLcontext *ctx ) -{ - _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, - ctx->ProjectionMatrixStack.Top, - ctx->ModelviewMatrixStack.Top ); - - _math_matrix_analyse( &ctx->_ModelProjectMatrix ); -} - - -/** - * Updates the combined modelview-projection matrix. - * - * \param ctx GL context. - * \param new_state new state bit mask. - * - * If there is a new model view matrix then analyzes it. If there is a new - * projection matrix, updates it. Finally calls - * calculate_model_project_matrix() to recalculate the modelview-projection - * matrix. - */ -void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state ) -{ - if (new_state & _NEW_MODELVIEW) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - /* Bring cull position uptodate. - */ - TRANSFORM_POINT3( ctx->Transform.CullObjPos, - ctx->ModelviewMatrixStack.Top->inv, - ctx->Transform.CullEyePos ); - } - - - if (new_state & _NEW_PROJECTION) - update_projection( ctx ); - - /* Keep ModelviewProject uptodate always to allow tnl - * implementations that go model->clip even when eye is required. - */ - calculate_model_project_matrix(ctx); -} - -/*@}*/ - - -/**********************************************************************/ -/** Matrix stack initialization */ -/*@{*/ - - -/** - * Initialize a matrix stack. - * - * \param stack matrix stack. - * \param maxDepth maximum stack depth. - * \param dirtyFlag dirty flag. - * - * Allocates an array of \p maxDepth elements for the matrix stack and calls - * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to - * initialize it. - */ -static void -init_matrix_stack( struct gl_matrix_stack *stack, - GLuint maxDepth, GLuint dirtyFlag ) -{ - GLuint i; - - stack->Depth = 0; - stack->MaxDepth = maxDepth; - stack->DirtyFlag = dirtyFlag; - /* The stack */ - stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix)); - for (i = 0; i < maxDepth; i++) { - _math_matrix_ctr(&stack->Stack[i]); - _math_matrix_alloc_inv(&stack->Stack[i]); - } - stack->Top = stack->Stack; -} - -/** - * Free matrix stack. - * - * \param stack matrix stack. - * - * Calls _math_matrix_dtr() for each element of the matrix stack and - * frees the array. - */ -static void -free_matrix_stack( struct gl_matrix_stack *stack ) -{ - GLuint i; - for (i = 0; i < stack->MaxDepth; i++) { - _math_matrix_dtr(&stack->Stack[i]); - } - FREE(stack->Stack); - stack->Stack = stack->Top = NULL; -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - - -/** - * Initialize the context matrix data. - * - * \param ctx GL context. - * - * Initializes each of the matrix stacks and the combined modelview-projection - * matrix. - */ -void _mesa_init_matrix( GLcontext * ctx ) -{ - GLint i; - - /* Initialize matrix stacks */ - init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, - _NEW_MODELVIEW); - init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, - _NEW_PROJECTION); - init_matrix_stack(&ctx->ColorMatrixStack, MAX_COLOR_STACK_DEPTH, - _NEW_COLOR_MATRIX); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) - init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, - _NEW_TEXTURE_MATRIX); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) - init_matrix_stack(&ctx->ProgramMatrixStack[i], - MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); - ctx->CurrentStack = &ctx->ModelviewMatrixStack; - - /* Init combined Modelview*Projection matrix */ - _math_matrix_ctr( &ctx->_ModelProjectMatrix ); -} - - -/** - * Free the context matrix data. - * - * \param ctx GL context. - * - * Frees each of the matrix stacks and the combined modelview-projection - * matrix. - */ -void _mesa_free_matrix_data( GLcontext *ctx ) -{ - GLint i; - - free_matrix_stack(&ctx->ModelviewMatrixStack); - free_matrix_stack(&ctx->ProjectionMatrixStack); - free_matrix_stack(&ctx->ColorMatrixStack); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) - free_matrix_stack(&ctx->TextureMatrixStack[i]); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) - free_matrix_stack(&ctx->ProgramMatrixStack[i]); - /* combined Modelview*Projection matrix */ - _math_matrix_dtr( &ctx->_ModelProjectMatrix ); - -} - - -/** - * Initialize the context transform attribute group. - * - * \param ctx GL context. - * - * \todo Move this to a new file with other 'transform' routines. - */ -void _mesa_init_transform( GLcontext *ctx ) -{ - GLint i; - - /* Transformation group */ - ctx->Transform.MatrixMode = GL_MODELVIEW; - ctx->Transform.Normalize = GL_FALSE; - ctx->Transform.RescaleNormals = GL_FALSE; - ctx->Transform.RasterPositionUnclipped = GL_FALSE; - for (i=0;iTransform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); - } - ctx->Transform.ClipPlanesEnabled = 0; - - ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 ); - ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 ); -} - - -/*@}*/ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file matrix.c + * Matrix operations. + * + * \note + * -# 4x4 transformation matrices are stored in memory in column major order. + * -# Points/vertices are to be thought of as column vectors. + * -# Transformation of a point p by a matrix M is: p' = M * p + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "enums.h" +#include "macros.h" +#include "matrix.h" +#include "mtypes.h" +#include "math/m_matrix.h" + + +/** + * Apply a perspective projection matrix. + * + * \param left left clipping plane coordinate. + * \param right right clipping plane coordinate. + * \param bottom bottom clipping plane coordinate. + * \param top top clipping plane coordinate. + * \param nearval distance to the near clipping plane. + * \param farval distance to the far clipping plane. + * + * \sa glFrustum(). + * + * Flushes vertices and validates parameters. Calls _math_matrix_frustum() with + * the top matrix of the current matrix stack and sets + * __struct gl_contextRec::NewState. + */ +void GLAPIENTRY +_mesa_Frustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (nearval <= 0.0 || + farval <= 0.0 || + nearval == farval || + left == right || + top == bottom) + { + _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" ); + return; + } + + _math_matrix_frustum( ctx->CurrentStack->Top, + (GLfloat) left, (GLfloat) right, + (GLfloat) bottom, (GLfloat) top, + (GLfloat) nearval, (GLfloat) farval ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Apply an orthographic projection matrix. + * + * \param left left clipping plane coordinate. + * \param right right clipping plane coordinate. + * \param bottom bottom clipping plane coordinate. + * \param top top clipping plane coordinate. + * \param nearval distance to the near clipping plane. + * \param farval distance to the far clipping plane. + * + * \sa glOrtho(). + * + * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with + * the top matrix of the current matrix stack and sets + * __struct gl_contextRec::NewState. + */ +void GLAPIENTRY +_mesa_Ortho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n", + left, right, bottom, top, nearval, farval); + + if (left == right || + bottom == top || + nearval == farval) + { + _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" ); + return; + } + + _math_matrix_ortho( ctx->CurrentStack->Top, + (GLfloat) left, (GLfloat) right, + (GLfloat) bottom, (GLfloat) top, + (GLfloat) nearval, (GLfloat) farval ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Set the current matrix stack. + * + * \param mode matrix stack. + * + * \sa glMatrixMode(). + * + * Flushes the vertices, validates the parameter and updates + * __struct gl_contextRec::CurrentStack and gl_transform_attrib::MatrixMode with the + * specified matrix stack. + */ +void GLAPIENTRY +_mesa_MatrixMode( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + + switch (mode) { + case GL_MODELVIEW: + ctx->CurrentStack = &ctx->ModelviewMatrixStack; + break; + case GL_PROJECTION: + ctx->CurrentStack = &ctx->ProjectionMatrixStack; + break; + case GL_TEXTURE: + /* This error check is disabled because if we're called from + * glPopAttrib() when the active texture unit is >= MaxTextureCoordUnits + * we'll generate an unexpected error. + * From the GL_ARB_vertex_shader spec it sounds like we should instead + * do error checking in other places when we actually try to access + * texture matrices beyond MaxTextureCoordUnits. + */ +#if 0 + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(invalid tex unit %d)", + ctx->Texture.CurrentUnit); + return; + } +#endif + ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); + ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; + break; + case GL_MATRIX0_NV: + case GL_MATRIX1_NV: + case GL_MATRIX2_NV: + case GL_MATRIX3_NV: + case GL_MATRIX4_NV: + case GL_MATRIX5_NV: + case GL_MATRIX6_NV: + case GL_MATRIX7_NV: + if (ctx->Extensions.NV_vertex_program) { + ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); + return; + } + break; + case GL_MATRIX0_ARB: + case GL_MATRIX1_ARB: + case GL_MATRIX2_ARB: + case GL_MATRIX3_ARB: + case GL_MATRIX4_ARB: + case GL_MATRIX5_ARB: + case GL_MATRIX6_ARB: + case GL_MATRIX7_ARB: + if (ctx->Extensions.ARB_vertex_program || + ctx->Extensions.ARB_fragment_program) { + const GLuint m = mode - GL_MATRIX0_ARB; + if (m > ctx->Const.MaxProgramMatrices) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glMatrixMode(GL_MATRIX%d_ARB)", m); + return; + } + ctx->CurrentStack = &ctx->ProgramMatrixStack[m]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); + return; + } + + ctx->Transform.MatrixMode = mode; +} + + +/** + * Push the current matrix stack. + * + * \sa glPushMatrix(). + * + * Verifies the current matrix stack is not full, and duplicates the top-most + * matrix in the stack. Marks __struct gl_contextRec::NewState with the stack dirty + * flag. + */ +void GLAPIENTRY +_mesa_PushMatrix( void ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_matrix_stack *stack = ctx->CurrentStack; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPushMatrix %s\n", + _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); + + if (stack->Depth + 1 >= stack->MaxDepth) { + if (ctx->Transform.MatrixMode == GL_TEXTURE) { + _mesa_error(ctx, GL_STACK_OVERFLOW, + "glPushMatrix(mode=GL_TEXTURE, unit=%d)", + ctx->Texture.CurrentUnit); + } + else { + _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", + _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); + } + return; + } + _math_matrix_copy( &stack->Stack[stack->Depth + 1], + &stack->Stack[stack->Depth] ); + stack->Depth++; + stack->Top = &(stack->Stack[stack->Depth]); + ctx->NewState |= stack->DirtyFlag; +} + + +/** + * Pop the current matrix stack. + * + * \sa glPopMatrix(). + * + * Flushes the vertices, verifies the current matrix stack is not empty, and + * moves the stack head down. Marks __struct gl_contextRec::NewState with the dirty + * stack flag. + */ +void GLAPIENTRY +_mesa_PopMatrix( void ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_matrix_stack *stack = ctx->CurrentStack; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPopMatrix %s\n", + _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); + + if (stack->Depth == 0) { + if (ctx->Transform.MatrixMode == GL_TEXTURE) { + _mesa_error(ctx, GL_STACK_UNDERFLOW, + "glPopMatrix(mode=GL_TEXTURE, unit=%d)", + ctx->Texture.CurrentUnit); + } + else { + _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)", + _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); + } + return; + } + stack->Depth--; + stack->Top = &(stack->Stack[stack->Depth]); + ctx->NewState |= stack->DirtyFlag; +} + + +/** + * Replace the current matrix with the identity matrix. + * + * \sa glLoadIdentity(). + * + * Flushes the vertices and calls _math_matrix_set_identity() with the top-most + * matrix in the current stack. Marks __struct gl_contextRec::NewState with the stack + * dirty flag. + */ +void GLAPIENTRY +_mesa_LoadIdentity( void ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glLoadIdentity()\n"); + + _math_matrix_set_identity( ctx->CurrentStack->Top ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Replace the current matrix with a given matrix. + * + * \param m matrix. + * + * \sa glLoadMatrixf(). + * + * Flushes the vertices and calls _math_matrix_loadf() with the top-most matrix + * in the current stack and the given matrix. Marks __struct gl_contextRec::NewState + * with the dirty stack flag. + */ +void GLAPIENTRY +_mesa_LoadMatrixf( const GLfloat *m ) +{ + GET_CURRENT_CONTEXT(ctx); + if (!m) return; + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, + "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", + m[0], m[4], m[8], m[12], + m[1], m[5], m[9], m[13], + m[2], m[6], m[10], m[14], + m[3], m[7], m[11], m[15]); + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _math_matrix_loadf( ctx->CurrentStack->Top, m ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Multiply the current matrix with a given matrix. + * + * \param m matrix. + * + * \sa glMultMatrixf(). + * + * Flushes the vertices and calls _math_matrix_mul_floats() with the top-most + * matrix in the current stack and the given matrix. Marks + * __struct gl_contextRec::NewState with the dirty stack flag. + */ +void GLAPIENTRY +_mesa_MultMatrixf( const GLfloat *m ) +{ + GET_CURRENT_CONTEXT(ctx); + if (!m) return; + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, + "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", + m[0], m[4], m[8], m[12], + m[1], m[5], m[9], m[13], + m[2], m[6], m[10], m[14], + m[3], m[7], m[11], m[15]); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _math_matrix_mul_floats( ctx->CurrentStack->Top, m ); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Multiply the current matrix with a rotation matrix. + * + * \param angle angle of rotation, in degrees. + * \param x rotation vector x coordinate. + * \param y rotation vector y coordinate. + * \param z rotation vector z coordinate. + * + * \sa glRotatef(). + * + * Flushes the vertices and calls _math_matrix_rotate() with the top-most + * matrix in the current stack and the given parameters. Marks + * __struct gl_contextRec::NewState with the dirty stack flag. + */ +void GLAPIENTRY +_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + if (angle != 0.0F) { + _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; + } +} + + +/** + * Multiply the current matrix with a general scaling matrix. + * + * \param x x axis scale factor. + * \param y y axis scale factor. + * \param z z axis scale factor. + * + * \sa glScalef(). + * + * Flushes the vertices and calls _math_matrix_scale() with the top-most + * matrix in the current stack and the given parameters. Marks + * __struct gl_contextRec::NewState with the dirty stack flag. + */ +void GLAPIENTRY +_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _math_matrix_scale( ctx->CurrentStack->Top, x, y, z); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +/** + * Multiply the current matrix with a translation matrix. + * + * \param x translation vector x coordinate. + * \param y translation vector y coordinate. + * \param z translation vector z coordinate. + * + * \sa glTranslatef(). + * + * Flushes the vertices and calls _math_matrix_translate() with the top-most + * matrix in the current stack and the given parameters. Marks + * __struct gl_contextRec::NewState with the dirty stack flag. + */ +void GLAPIENTRY +_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _math_matrix_translate( ctx->CurrentStack->Top, x, y, z); + ctx->NewState |= ctx->CurrentStack->DirtyFlag; +} + + +#if _HAVE_FULL_GL +void GLAPIENTRY +_mesa_LoadMatrixd( const GLdouble *m ) +{ + GLint i; + GLfloat f[16]; + if (!m) return; + for (i = 0; i < 16; i++) + f[i] = (GLfloat) m[i]; + _mesa_LoadMatrixf(f); +} + +void GLAPIENTRY +_mesa_MultMatrixd( const GLdouble *m ) +{ + GLint i; + GLfloat f[16]; + if (!m) return; + for (i = 0; i < 16; i++) + f[i] = (GLfloat) m[i]; + _mesa_MultMatrixf( f ); +} + + +void GLAPIENTRY +_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +void GLAPIENTRY +_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +void GLAPIENTRY +_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} +#endif + + +#if _HAVE_FULL_GL +void GLAPIENTRY +_mesa_LoadTransposeMatrixfARB( const GLfloat *m ) +{ + GLfloat tm[16]; + if (!m) return; + _math_transposef(tm, m); + _mesa_LoadMatrixf(tm); +} + + +void GLAPIENTRY +_mesa_LoadTransposeMatrixdARB( const GLdouble *m ) +{ + GLfloat tm[16]; + if (!m) return; + _math_transposefd(tm, m); + _mesa_LoadMatrixf(tm); +} + + +void GLAPIENTRY +_mesa_MultTransposeMatrixfARB( const GLfloat *m ) +{ + GLfloat tm[16]; + if (!m) return; + _math_transposef(tm, m); + _mesa_MultMatrixf(tm); +} + + +void GLAPIENTRY +_mesa_MultTransposeMatrixdARB( const GLdouble *m ) +{ + GLfloat tm[16]; + if (!m) return; + _math_transposefd(tm, m); + _mesa_MultMatrixf(tm); +} +#endif + + + +/**********************************************************************/ +/** \name State management */ +/*@{*/ + + +/** + * Update the projection matrix stack. + * + * \param ctx GL context. + * + * Calls _math_matrix_analyse() with the top-matrix of the projection matrix + * stack, and recomputes user clip positions if necessary. + * + * \note This routine references __struct gl_contextRec::Tranform attribute values to + * compute userclip positions in clip space, but is only called on + * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to + * date across changes to the __struct gl_contextRec::Transform attributes. + */ +static void +update_projection( struct gl_context *ctx ) +{ + _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); + +#if FEATURE_userclip + /* Recompute clip plane positions in clipspace. This is also done + * in _mesa_ClipPlane(). + */ + if (ctx->Transform.ClipPlanesEnabled) { + GLuint p; + for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { + if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { + _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], + ctx->Transform.EyeUserPlane[p], + ctx->ProjectionMatrixStack.Top->inv ); + } + } + } +#endif +} + + +/** + * Calculate the combined modelview-projection matrix. + * + * \param ctx GL context. + * + * Multiplies the top matrices of the projection and model view stacks into + * __struct gl_contextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() and + * analyzes the resulting matrix via _math_matrix_analyse(). + */ +static void +calculate_model_project_matrix( struct gl_context *ctx ) +{ + _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, + ctx->ProjectionMatrixStack.Top, + ctx->ModelviewMatrixStack.Top ); + + _math_matrix_analyse( &ctx->_ModelProjectMatrix ); +} + + +/** + * Updates the combined modelview-projection matrix. + * + * \param ctx GL context. + * \param new_state new state bit mask. + * + * If there is a new model view matrix then analyzes it. If there is a new + * projection matrix, updates it. Finally calls + * calculate_model_project_matrix() to recalculate the modelview-projection + * matrix. + */ +void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state ) +{ + if (new_state & _NEW_MODELVIEW) { + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + + /* Bring cull position uptodate. + */ + TRANSFORM_POINT3( ctx->Transform.CullObjPos, + ctx->ModelviewMatrixStack.Top->inv, + ctx->Transform.CullEyePos ); + } + + + if (new_state & _NEW_PROJECTION) + update_projection( ctx ); + + /* Keep ModelviewProject uptodate always to allow tnl + * implementations that go model->clip even when eye is required. + */ + calculate_model_project_matrix(ctx); +} + +/*@}*/ + + +/**********************************************************************/ +/** Matrix stack initialization */ +/*@{*/ + + +/** + * Initialize a matrix stack. + * + * \param stack matrix stack. + * \param maxDepth maximum stack depth. + * \param dirtyFlag dirty flag. + * + * Allocates an array of \p maxDepth elements for the matrix stack and calls + * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to + * initialize it. + */ +static void +init_matrix_stack( struct gl_matrix_stack *stack, + GLuint maxDepth, GLuint dirtyFlag ) +{ + GLuint i; + + stack->Depth = 0; + stack->MaxDepth = maxDepth; + stack->DirtyFlag = dirtyFlag; + /* The stack */ + stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix)); + for (i = 0; i < maxDepth; i++) { + _math_matrix_ctr(&stack->Stack[i]); + _math_matrix_alloc_inv(&stack->Stack[i]); + } + stack->Top = stack->Stack; +} + +/** + * Free matrix stack. + * + * \param stack matrix stack. + * + * Calls _math_matrix_dtr() for each element of the matrix stack and + * frees the array. + */ +static void +free_matrix_stack( struct gl_matrix_stack *stack ) +{ + GLuint i; + for (i = 0; i < stack->MaxDepth; i++) { + _math_matrix_dtr(&stack->Stack[i]); + } + FREE(stack->Stack); + stack->Stack = stack->Top = NULL; +} + +/*@}*/ + + +/**********************************************************************/ +/** \name Initialization */ +/*@{*/ + + +/** + * Initialize the context matrix data. + * + * \param ctx GL context. + * + * Initializes each of the matrix stacks and the combined modelview-projection + * matrix. + */ +void _mesa_init_matrix( struct gl_context * ctx ) +{ + GLint i; + + /* Initialize matrix stacks */ + init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, + _NEW_MODELVIEW); + init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, + _NEW_PROJECTION); + for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, + _NEW_TEXTURE_MATRIX); + for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + init_matrix_stack(&ctx->ProgramMatrixStack[i], + MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); + ctx->CurrentStack = &ctx->ModelviewMatrixStack; + + /* Init combined Modelview*Projection matrix */ + _math_matrix_ctr( &ctx->_ModelProjectMatrix ); +} + + +/** + * Free the context matrix data. + * + * \param ctx GL context. + * + * Frees each of the matrix stacks and the combined modelview-projection + * matrix. + */ +void _mesa_free_matrix_data( struct gl_context *ctx ) +{ + GLint i; + + free_matrix_stack(&ctx->ModelviewMatrixStack); + free_matrix_stack(&ctx->ProjectionMatrixStack); + for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + free_matrix_stack(&ctx->TextureMatrixStack[i]); + for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + free_matrix_stack(&ctx->ProgramMatrixStack[i]); + /* combined Modelview*Projection matrix */ + _math_matrix_dtr( &ctx->_ModelProjectMatrix ); + +} + + +/** + * Initialize the context transform attribute group. + * + * \param ctx GL context. + * + * \todo Move this to a new file with other 'transform' routines. + */ +void _mesa_init_transform( struct gl_context *ctx ) +{ + GLint i; + + /* Transformation group */ + ctx->Transform.MatrixMode = GL_MODELVIEW; + ctx->Transform.Normalize = GL_FALSE; + ctx->Transform.RescaleNormals = GL_FALSE; + ctx->Transform.RasterPositionUnclipped = GL_FALSE; + for (i=0;iTransform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); + } + ctx->Transform.ClipPlanesEnabled = 0; + + ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 ); + ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 ); +} + + +/*@}*/ diff --git a/mesalib/src/mesa/main/matrix.h b/mesalib/src/mesa/main/matrix.h index a53d1045c..a4e7f7cfd 100644 --- a/mesalib/src/mesa/main/matrix.h +++ b/mesalib/src/mesa/main/matrix.h @@ -1,112 +1,113 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MATRIX_H -#define MATRIX_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_Frustum( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); - -extern void GLAPIENTRY -_mesa_Ortho( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); - -extern void GLAPIENTRY -_mesa_PushMatrix( void ); - -extern void GLAPIENTRY -_mesa_PopMatrix( void ); - -extern void GLAPIENTRY -_mesa_LoadIdentity( void ); - -extern void GLAPIENTRY -_mesa_LoadMatrixf( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_LoadMatrixd( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_MatrixMode( GLenum mode ); - -extern void GLAPIENTRY -_mesa_MultMatrixf( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_MultMatrixd( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ); - -extern void GLAPIENTRY -_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ); - -extern void GLAPIENTRY -_mesa_LoadTransposeMatrixfARB( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_LoadTransposeMatrixdARB( const GLdouble *m ); - -extern void GLAPIENTRY -_mesa_MultTransposeMatrixfARB( const GLfloat *m ); - -extern void GLAPIENTRY -_mesa_MultTransposeMatrixdARB( const GLdouble *m ); - - -extern void -_mesa_init_matrix( GLcontext * ctx ); - -extern void -_mesa_init_transform( GLcontext *ctx ); - -extern void -_mesa_free_matrix_data( GLcontext *ctx ); - -extern void -_mesa_update_modelview_project( GLcontext *ctx, GLuint newstate ); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef MATRIX_H +#define MATRIX_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_Frustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void GLAPIENTRY +_mesa_Ortho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); + +extern void GLAPIENTRY +_mesa_PushMatrix( void ); + +extern void GLAPIENTRY +_mesa_PopMatrix( void ); + +extern void GLAPIENTRY +_mesa_LoadIdentity( void ); + +extern void GLAPIENTRY +_mesa_LoadMatrixf( const GLfloat *m ); + +extern void GLAPIENTRY +_mesa_LoadMatrixd( const GLdouble *m ); + +extern void GLAPIENTRY +_mesa_MatrixMode( GLenum mode ); + +extern void GLAPIENTRY +_mesa_MultMatrixf( const GLfloat *m ); + +extern void GLAPIENTRY +_mesa_MultMatrixd( const GLdouble *m ); + +extern void GLAPIENTRY +_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); + +extern void GLAPIENTRY +_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); + +extern void GLAPIENTRY +_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ); + +extern void GLAPIENTRY +_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ); + +extern void GLAPIENTRY +_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ); + +extern void GLAPIENTRY +_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ); + +extern void GLAPIENTRY +_mesa_LoadTransposeMatrixfARB( const GLfloat *m ); + +extern void GLAPIENTRY +_mesa_LoadTransposeMatrixdARB( const GLdouble *m ); + +extern void GLAPIENTRY +_mesa_MultTransposeMatrixfARB( const GLfloat *m ); + +extern void GLAPIENTRY +_mesa_MultTransposeMatrixdARB( const GLdouble *m ); + + +extern void +_mesa_init_matrix( struct gl_context * ctx ); + +extern void +_mesa_init_transform( struct gl_context *ctx ); + +extern void +_mesa_free_matrix_data( struct gl_context *ctx ); + +extern void +_mesa_update_modelview_project( struct gl_context *ctx, GLuint newstate ); + + +#endif diff --git a/mesalib/src/mesa/main/mfeatures.h b/mesalib/src/mesa/main/mfeatures.h index 92311ef7f..b549d90bd 100644 --- a/mesalib/src/mesa/main/mfeatures.h +++ b/mesalib/src/mesa/main/mfeatures.h @@ -1,149 +1,145 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file mfeatures.h - * Flags to enable/disable specific parts of the API. - */ - -#ifndef FEATURES_H -#define FEATURES_H - - -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -/* assert that a feature is disabled and should never be used */ -#define ASSERT_NO_FEATURE() ASSERT(0) - -/** - * A feature can be anything. But most of them share certain characteristics. - * - * When a feature defines vtxfmt entries, they can be initialized and - * installed by - * _MESA_INIT__VTXFMT - * _mesa_install__vtxfmt - * - * When a feature defines dispatch entries, they are initialized by - * _mesa_init__dispatch - * - * When a feature has states, they are initialized and freed by - * _mesa_init_ - * _mesa_free__data - * - * Except for states, the others compile to no-op when a feature is disabled. - * - * The GLAPIENTRYs and helper functions defined by a feature should also - * compile to no-op when it is disabled. But to save typings and to catch - * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() - * when the feature is disabled. - * - * A feature following the conventions may be used without knowing if it is - * enabled or not. - */ - -#ifndef FEATURE_ES1 -#define FEATURE_ES1 0 -#endif -#ifndef FEATURE_ES2 -#define FEATURE_ES2 0 -#endif - -#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) - -#ifndef FEATURE_GL -#define FEATURE_GL !FEATURE_ES -#endif - -#ifdef IN_DRI_DRIVER -#define FEATURE_remap_table 1 -#else -#define FEATURE_remap_table 0 -#endif - -#define FEATURE_dispatch 1 -#define FEATURE_texgen 1 -#define FEATURE_userclip 1 - -#define FEATURE_accum FEATURE_GL -#define FEATURE_arrayelt FEATURE_GL -#define FEATURE_attrib_stack FEATURE_GL -/* this disables vtxfmt, api_loopback, and api_noop completely */ -#define FEATURE_beginend FEATURE_GL -#define FEATURE_colortable FEATURE_GL -#define FEATURE_convolve FEATURE_GL -#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) -#define FEATURE_draw_read_buffer FEATURE_GL -#define FEATURE_drawpix FEATURE_GL -#define FEATURE_evaluators FEATURE_GL -#define FEATURE_feedback FEATURE_GL -#define FEATURE_histogram FEATURE_GL -#define FEATURE_pixel_transfer FEATURE_GL -#define FEATURE_queryobj FEATURE_GL -#define FEATURE_rastpos FEATURE_GL -#define FEATURE_texture_fxt1 FEATURE_GL -#define FEATURE_texture_s3tc FEATURE_GL - -#define FEATURE_extra_context_init FEATURE_ES -#define FEATURE_fixedpt FEATURE_ES -#define FEATURE_point_size_array FEATURE_ES -#define FEATURE_vertex_array_byte FEATURE_ES - -#define FEATURE_es2_glsl FEATURE_ES2 - -#define FEATURE_ARB_fragment_program 1 -#define FEATURE_ARB_vertex_program 1 -#define FEATURE_ARB_vertex_shader 1 -#define FEATURE_ARB_fragment_shader 1 -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects -#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects - -#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) -#define FEATURE_ARB_map_buffer_range FEATURE_GL -#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) -#define FEATURE_ARB_sync FEATURE_GL -#define FEATURE_ARB_vertex_buffer_object 1 - -#define FEATURE_EXT_framebuffer_blit FEATURE_GL -#define FEATURE_EXT_framebuffer_object 1 -#define FEATURE_EXT_pixel_buffer_object 1 -#define FEATURE_EXT_texture_sRGB FEATURE_GL -#define FEATURE_EXT_transform_feedback FEATURE_GL - -#define FEATURE_APPLE_object_purgeable FEATURE_GL -#define FEATURE_ATI_fragment_shader FEATURE_GL -#define FEATURE_NV_fence FEATURE_GL -#define FEATURE_NV_fragment_program FEATURE_GL -#define FEATURE_NV_vertex_program FEATURE_GL - -#define FEATURE_OES_EGL_image 1 -#define FEATURE_OES_draw_texture FEATURE_ES1 -#define FEATURE_OES_framebuffer_object FEATURE_ES -#define FEATURE_OES_mapbuffer FEATURE_ES - -#endif /* FEATURES_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file mfeatures.h + * Flags to enable/disable specific parts of the API. + */ + +#ifndef FEATURES_H +#define FEATURES_H + + +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +/* assert that a feature is disabled and should never be used */ +#define ASSERT_NO_FEATURE() ASSERT(0) + +/** + * A feature can be anything. But most of them share certain characteristics. + * + * When a feature defines vtxfmt entries, they can be initialized and + * installed by + * _MESA_INIT__VTXFMT + * _mesa_install__vtxfmt + * + * When a feature defines dispatch entries, they are initialized by + * _mesa_init__dispatch + * + * When a feature has states, they are initialized and freed by + * _mesa_init_ + * _mesa_free__data + * + * Except for states, the others compile to no-op when a feature is disabled. + * + * The GLAPIENTRYs and helper functions defined by a feature should also + * compile to no-op when it is disabled. But to save typings and to catch + * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() + * when the feature is disabled. + * + * A feature following the conventions may be used without knowing if it is + * enabled or not. + */ + +#ifndef FEATURE_ES1 +#define FEATURE_ES1 0 +#endif +#ifndef FEATURE_ES2 +#define FEATURE_ES2 0 +#endif + +#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) + +#ifndef FEATURE_GL +#define FEATURE_GL !FEATURE_ES +#endif + +#if defined(IN_DRI_DRIVER) || (FEATURE_GL + FEATURE_ES1 + FEATURE_ES2 > 1) +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_dispatch 1 +#define FEATURE_texgen 1 +#define FEATURE_userclip 1 + +#define FEATURE_accum FEATURE_GL +#define FEATURE_arrayelt FEATURE_GL +#define FEATURE_attrib_stack FEATURE_GL +/* this disables vtxfmt, api_loopback, and api_noop completely */ +#define FEATURE_beginend FEATURE_GL +#define FEATURE_colortable FEATURE_GL +#define FEATURE_convolve FEATURE_GL +#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) +#define FEATURE_draw_read_buffer FEATURE_GL +#define FEATURE_drawpix FEATURE_GL +#define FEATURE_evaluators FEATURE_GL +#define FEATURE_feedback FEATURE_GL +#define FEATURE_pixel_transfer FEATURE_GL +#define FEATURE_queryobj FEATURE_GL +#define FEATURE_rastpos FEATURE_GL +#define FEATURE_texture_fxt1 FEATURE_GL +#define FEATURE_texture_s3tc FEATURE_GL + +#define FEATURE_extra_context_init FEATURE_ES +#define FEATURE_point_size_array FEATURE_ES + +#define FEATURE_es2_glsl FEATURE_ES2 + +#define FEATURE_ARB_fragment_program 1 +#define FEATURE_ARB_vertex_program 1 +#define FEATURE_ARB_vertex_shader 1 +#define FEATURE_ARB_fragment_shader 1 +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects + +#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) +#define FEATURE_ARB_map_buffer_range FEATURE_GL +#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) +#define FEATURE_ARB_sync FEATURE_GL +#define FEATURE_ARB_vertex_buffer_object 1 + +#define FEATURE_EXT_framebuffer_blit FEATURE_GL +#define FEATURE_EXT_framebuffer_object 1 +#define FEATURE_EXT_pixel_buffer_object 1 +#define FEATURE_EXT_texture_sRGB FEATURE_GL +#define FEATURE_EXT_transform_feedback FEATURE_GL + +#define FEATURE_APPLE_object_purgeable FEATURE_GL +#define FEATURE_ATI_fragment_shader FEATURE_GL +#define FEATURE_NV_fence FEATURE_GL +#define FEATURE_NV_fragment_program FEATURE_GL +#define FEATURE_NV_vertex_program FEATURE_GL + +#define FEATURE_OES_EGL_image 1 +#define FEATURE_OES_draw_texture FEATURE_ES1 +#define FEATURE_OES_framebuffer_object FEATURE_ES +#define FEATURE_OES_mapbuffer FEATURE_ES + +#endif /* FEATURES_H */ diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index 3d1a4c49c..cf85782bc 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -1,1800 +1,1966 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file mipmap.c mipmap generation and teximage resizing functions. - */ - -#include "imports.h" -#include "formats.h" -#include "mipmap.h" -#include "teximage.h" -#include "texstore.h" -#include "image.h" - - - -static GLint -bytes_per_pixel(GLenum datatype, GLuint comps) -{ - GLint b = _mesa_sizeof_packed_type(datatype); - assert(b >= 0); - - if (_mesa_type_is_packed(datatype)) - return b; - else - return b * comps; -} - - -/** - * \name Support macros for do_row and do_row_3d - * - * The macro madness is here for two reasons. First, it compacts the code - * slightly. Second, it makes it much easier to adjust the specifics of the - * filter to tune the rounding characteristics. - */ -/*@{*/ -#define DECLARE_ROW_POINTERS(t, e) \ - const t(*rowA)[e] = (const t(*)[e]) srcRowA; \ - const t(*rowB)[e] = (const t(*)[e]) srcRowB; \ - const t(*rowC)[e] = (const t(*)[e]) srcRowC; \ - const t(*rowD)[e] = (const t(*)[e]) srcRowD; \ - t(*dst)[e] = (t(*)[e]) dstRow - -#define DECLARE_ROW_POINTERS0(t) \ - const t *rowA = (const t *) srcRowA; \ - const t *rowB = (const t *) srcRowB; \ - const t *rowC = (const t *) srcRowC; \ - const t *rowD = (const t *) srcRowD; \ - t *dst = (t *) dstRow - -#define FILTER_SUM_3D(Aj, Ak, Bj, Bk, Cj, Ck, Dj, Dk) \ - ((unsigned) Aj + (unsigned) Ak \ - + (unsigned) Bj + (unsigned) Bk \ - + (unsigned) Cj + (unsigned) Ck \ - + (unsigned) Dj + (unsigned) Dk \ - + 4) >> 3 - -#define FILTER_3D(e) \ - do { \ - dst[i][e] = FILTER_SUM_3D(rowA[j][e], rowA[k][e], \ - rowB[j][e], rowB[k][e], \ - rowC[j][e], rowC[k][e], \ - rowD[j][e], rowD[k][e]); \ - } while(0) - -#define FILTER_SUM_3D_SIGNED(Aj, Ak, Bj, Bk, Cj, Ck, Dj, Dk) \ - (Aj + Ak \ - + Bj + Bk \ - + Cj + Ck \ - + Dj + Dk \ - + 4) / 8 - -#define FILTER_3D_SIGNED(e) \ - do { \ - dst[i][e] = FILTER_SUM_3D_SIGNED(rowA[j][e], rowA[k][e], \ - rowB[j][e], rowB[k][e], \ - rowC[j][e], rowC[k][e], \ - rowD[j][e], rowD[k][e]); \ - } while(0) - -#define FILTER_F_3D(e) \ - do { \ - dst[i][e] = (rowA[j][e] + rowA[k][e] \ - + rowB[j][e] + rowB[k][e] \ - + rowC[j][e] + rowC[k][e] \ - + rowD[j][e] + rowD[k][e]) * 0.125F; \ - } while(0) - -#define FILTER_HF_3D(e) \ - do { \ - const GLfloat aj = _mesa_half_to_float(rowA[j][e]); \ - const GLfloat ak = _mesa_half_to_float(rowA[k][e]); \ - const GLfloat bj = _mesa_half_to_float(rowB[j][e]); \ - const GLfloat bk = _mesa_half_to_float(rowB[k][e]); \ - const GLfloat cj = _mesa_half_to_float(rowC[j][e]); \ - const GLfloat ck = _mesa_half_to_float(rowC[k][e]); \ - const GLfloat dj = _mesa_half_to_float(rowD[j][e]); \ - const GLfloat dk = _mesa_half_to_float(rowD[k][e]); \ - dst[i][e] = _mesa_float_to_half((aj + ak + bj + bk + cj + ck + dj + dk) \ - * 0.125F); \ - } while(0) -/*@}*/ - - -/** - * Average together two rows of a source image to produce a single new - * row in the dest image. It's legal for the two source rows to point - * to the same data. The source width must be equal to either the - * dest width or two times the dest width. - * \param datatype GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_FLOAT, etc. - * \param comps number of components per pixel (1..4) - */ -static void -do_row(GLenum datatype, GLuint comps, GLint srcWidth, - const GLvoid *srcRowA, const GLvoid *srcRowB, - GLint dstWidth, GLvoid *dstRow) -{ - const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1; - const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; - - ASSERT(comps >= 1); - ASSERT(comps <= 4); - - /* This assertion is no longer valid with non-power-of-2 textures - assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth); - */ - - if (datatype == GL_UNSIGNED_BYTE && comps == 4) { - GLuint i, j, k; - const GLubyte(*rowA)[4] = (const GLubyte(*)[4]) srcRowA; - const GLubyte(*rowB)[4] = (const GLubyte(*)[4]) srcRowB; - GLubyte(*dst)[4] = (GLubyte(*)[4]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; - } - } - else if (datatype == GL_UNSIGNED_BYTE && comps == 3) { - GLuint i, j, k; - const GLubyte(*rowA)[3] = (const GLubyte(*)[3]) srcRowA; - const GLubyte(*rowB)[3] = (const GLubyte(*)[3]) srcRowB; - GLubyte(*dst)[3] = (GLubyte(*)[3]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - } - } - else if (datatype == GL_UNSIGNED_BYTE && comps == 2) { - GLuint i, j, k; - const GLubyte(*rowA)[2] = (const GLubyte(*)[2]) srcRowA; - const GLubyte(*rowB)[2] = (const GLubyte(*)[2]) srcRowB; - GLubyte(*dst)[2] = (GLubyte(*)[2]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) >> 2; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) >> 2; - } - } - else if (datatype == GL_UNSIGNED_BYTE && comps == 1) { - GLuint i, j, k; - const GLubyte *rowA = (const GLubyte *) srcRowA; - const GLubyte *rowB = (const GLubyte *) srcRowB; - GLubyte *dst = (GLubyte *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) >> 2; - } - } - - else if (datatype == GL_BYTE && comps == 4) { - GLuint i, j, k; - const GLbyte(*rowA)[4] = (const GLbyte(*)[4]) srcRowA; - const GLbyte(*rowB)[4] = (const GLbyte(*)[4]) srcRowB; - GLbyte(*dst)[4] = (GLbyte(*)[4]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; - } - } - else if (datatype == GL_BYTE && comps == 3) { - GLuint i, j, k; - const GLbyte(*rowA)[3] = (const GLbyte(*)[3]) srcRowA; - const GLbyte(*rowB)[3] = (const GLbyte(*)[3]) srcRowB; - GLbyte(*dst)[3] = (GLbyte(*)[3]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - } - } - else if (datatype == GL_BYTE && comps == 2) { - GLuint i, j, k; - const GLbyte(*rowA)[2] = (const GLbyte(*)[2]) srcRowA; - const GLbyte(*rowB)[2] = (const GLbyte(*)[2]) srcRowB; - GLbyte(*dst)[2] = (GLbyte(*)[2]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - } - } - else if (datatype == GL_BYTE && comps == 1) { - GLuint i, j, k; - const GLbyte *rowA = (const GLbyte *) srcRowA; - const GLbyte *rowB = (const GLbyte *) srcRowB; - GLbyte *dst = (GLbyte *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; - } - } - - else if (datatype == GL_UNSIGNED_SHORT && comps == 4) { - GLuint i, j, k; - const GLushort(*rowA)[4] = (const GLushort(*)[4]) srcRowA; - const GLushort(*rowB)[4] = (const GLushort(*)[4]) srcRowB; - GLushort(*dst)[4] = (GLushort(*)[4]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; - } - } - else if (datatype == GL_UNSIGNED_SHORT && comps == 3) { - GLuint i, j, k; - const GLushort(*rowA)[3] = (const GLushort(*)[3]) srcRowA; - const GLushort(*rowB)[3] = (const GLushort(*)[3]) srcRowB; - GLushort(*dst)[3] = (GLushort(*)[3]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; - } - } - else if (datatype == GL_UNSIGNED_SHORT && comps == 2) { - GLuint i, j, k; - const GLushort(*rowA)[2] = (const GLushort(*)[2]) srcRowA; - const GLushort(*rowB)[2] = (const GLushort(*)[2]) srcRowB; - GLushort(*dst)[2] = (GLushort(*)[2]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; - dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; - } - } - else if (datatype == GL_UNSIGNED_SHORT && comps == 1) { - GLuint i, j, k; - const GLushort *rowA = (const GLushort *) srcRowA; - const GLushort *rowB = (const GLushort *) srcRowB; - GLushort *dst = (GLushort *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; - } - } - else if (datatype == GL_FLOAT && comps == 4) { - GLuint i, j, k; - const GLfloat(*rowA)[4] = (const GLfloat(*)[4]) srcRowA; - const GLfloat(*rowB)[4] = (const GLfloat(*)[4]) srcRowB; - GLfloat(*dst)[4] = (GLfloat(*)[4]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + - rowB[j][0] + rowB[k][0]) * 0.25F; - dst[i][1] = (rowA[j][1] + rowA[k][1] + - rowB[j][1] + rowB[k][1]) * 0.25F; - dst[i][2] = (rowA[j][2] + rowA[k][2] + - rowB[j][2] + rowB[k][2]) * 0.25F; - dst[i][3] = (rowA[j][3] + rowA[k][3] + - rowB[j][3] + rowB[k][3]) * 0.25F; - } - } - else if (datatype == GL_FLOAT && comps == 3) { - GLuint i, j, k; - const GLfloat(*rowA)[3] = (const GLfloat(*)[3]) srcRowA; - const GLfloat(*rowB)[3] = (const GLfloat(*)[3]) srcRowB; - GLfloat(*dst)[3] = (GLfloat(*)[3]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + - rowB[j][0] + rowB[k][0]) * 0.25F; - dst[i][1] = (rowA[j][1] + rowA[k][1] + - rowB[j][1] + rowB[k][1]) * 0.25F; - dst[i][2] = (rowA[j][2] + rowA[k][2] + - rowB[j][2] + rowB[k][2]) * 0.25F; - } - } - else if (datatype == GL_FLOAT && comps == 2) { - GLuint i, j, k; - const GLfloat(*rowA)[2] = (const GLfloat(*)[2]) srcRowA; - const GLfloat(*rowB)[2] = (const GLfloat(*)[2]) srcRowB; - GLfloat(*dst)[2] = (GLfloat(*)[2]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i][0] = (rowA[j][0] + rowA[k][0] + - rowB[j][0] + rowB[k][0]) * 0.25F; - dst[i][1] = (rowA[j][1] + rowA[k][1] + - rowB[j][1] + rowB[k][1]) * 0.25F; - } - } - else if (datatype == GL_FLOAT && comps == 1) { - GLuint i, j, k; - const GLfloat *rowA = (const GLfloat *) srcRowA; - const GLfloat *rowB = (const GLfloat *) srcRowB; - GLfloat *dst = (GLfloat *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F; - } - } - - else if (datatype == GL_HALF_FLOAT_ARB && comps == 4) { - GLuint i, j, k, comp; - const GLhalfARB(*rowA)[4] = (const GLhalfARB(*)[4]) srcRowA; - const GLhalfARB(*rowB)[4] = (const GLhalfARB(*)[4]) srcRowB; - GLhalfARB(*dst)[4] = (GLhalfARB(*)[4]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - for (comp = 0; comp < 4; comp++) { - GLfloat aj, ak, bj, bk; - aj = _mesa_half_to_float(rowA[j][comp]); - ak = _mesa_half_to_float(rowA[k][comp]); - bj = _mesa_half_to_float(rowB[j][comp]); - bk = _mesa_half_to_float(rowB[k][comp]); - dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); - } - } - } - else if (datatype == GL_HALF_FLOAT_ARB && comps == 3) { - GLuint i, j, k, comp; - const GLhalfARB(*rowA)[3] = (const GLhalfARB(*)[3]) srcRowA; - const GLhalfARB(*rowB)[3] = (const GLhalfARB(*)[3]) srcRowB; - GLhalfARB(*dst)[3] = (GLhalfARB(*)[3]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - for (comp = 0; comp < 3; comp++) { - GLfloat aj, ak, bj, bk; - aj = _mesa_half_to_float(rowA[j][comp]); - ak = _mesa_half_to_float(rowA[k][comp]); - bj = _mesa_half_to_float(rowB[j][comp]); - bk = _mesa_half_to_float(rowB[k][comp]); - dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); - } - } - } - else if (datatype == GL_HALF_FLOAT_ARB && comps == 2) { - GLuint i, j, k, comp; - const GLhalfARB(*rowA)[2] = (const GLhalfARB(*)[2]) srcRowA; - const GLhalfARB(*rowB)[2] = (const GLhalfARB(*)[2]) srcRowB; - GLhalfARB(*dst)[2] = (GLhalfARB(*)[2]) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - for (comp = 0; comp < 2; comp++) { - GLfloat aj, ak, bj, bk; - aj = _mesa_half_to_float(rowA[j][comp]); - ak = _mesa_half_to_float(rowA[k][comp]); - bj = _mesa_half_to_float(rowB[j][comp]); - bk = _mesa_half_to_float(rowB[k][comp]); - dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); - } - } - } - else if (datatype == GL_HALF_FLOAT_ARB && comps == 1) { - GLuint i, j, k; - const GLhalfARB *rowA = (const GLhalfARB *) srcRowA; - const GLhalfARB *rowB = (const GLhalfARB *) srcRowB; - GLhalfARB *dst = (GLhalfARB *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - GLfloat aj, ak, bj, bk; - aj = _mesa_half_to_float(rowA[j]); - ak = _mesa_half_to_float(rowA[k]); - bj = _mesa_half_to_float(rowB[j]); - bk = _mesa_half_to_float(rowB[k]); - dst[i] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); - } - } - - else if (datatype == GL_UNSIGNED_INT && comps == 1) { - GLuint i, j, k; - const GLuint *rowA = (const GLuint *) srcRowA; - const GLuint *rowB = (const GLuint *) srcRowB; - GLuint *dst = (GLuint *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - dst[i] = (GLfloat)(rowA[j] / 4 + rowA[k] / 4 + rowB[j] / 4 + rowB[k] / 4); - } - } - - else if (datatype == GL_UNSIGNED_SHORT_5_6_5 && comps == 3) { - GLuint i, j, k; - const GLushort *rowA = (const GLushort *) srcRowA; - const GLushort *rowB = (const GLushort *) srcRowB; - GLushort *dst = (GLushort *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x1f; - const GLint rowAr1 = rowA[k] & 0x1f; - const GLint rowBr0 = rowB[j] & 0x1f; - const GLint rowBr1 = rowB[k] & 0x1f; - const GLint rowAg0 = (rowA[j] >> 5) & 0x3f; - const GLint rowAg1 = (rowA[k] >> 5) & 0x3f; - const GLint rowBg0 = (rowB[j] >> 5) & 0x3f; - const GLint rowBg1 = (rowB[k] >> 5) & 0x3f; - const GLint rowAb0 = (rowA[j] >> 11) & 0x1f; - const GLint rowAb1 = (rowA[k] >> 11) & 0x1f; - const GLint rowBb0 = (rowB[j] >> 11) & 0x1f; - const GLint rowBb1 = (rowB[k] >> 11) & 0x1f; - const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; - const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; - const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; - dst[i] = (blue << 11) | (green << 5) | red; - } - } - else if (datatype == GL_UNSIGNED_SHORT_4_4_4_4 && comps == 4) { - GLuint i, j, k; - const GLushort *rowA = (const GLushort *) srcRowA; - const GLushort *rowB = (const GLushort *) srcRowB; - GLushort *dst = (GLushort *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0xf; - const GLint rowAr1 = rowA[k] & 0xf; - const GLint rowBr0 = rowB[j] & 0xf; - const GLint rowBr1 = rowB[k] & 0xf; - const GLint rowAg0 = (rowA[j] >> 4) & 0xf; - const GLint rowAg1 = (rowA[k] >> 4) & 0xf; - const GLint rowBg0 = (rowB[j] >> 4) & 0xf; - const GLint rowBg1 = (rowB[k] >> 4) & 0xf; - const GLint rowAb0 = (rowA[j] >> 8) & 0xf; - const GLint rowAb1 = (rowA[k] >> 8) & 0xf; - const GLint rowBb0 = (rowB[j] >> 8) & 0xf; - const GLint rowBb1 = (rowB[k] >> 8) & 0xf; - const GLint rowAa0 = (rowA[j] >> 12) & 0xf; - const GLint rowAa1 = (rowA[k] >> 12) & 0xf; - const GLint rowBa0 = (rowB[j] >> 12) & 0xf; - const GLint rowBa1 = (rowB[k] >> 12) & 0xf; - const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; - const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; - const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; - const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2; - dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red; - } - } - else if (datatype == GL_UNSIGNED_SHORT_1_5_5_5_REV && comps == 4) { - GLuint i, j, k; - const GLushort *rowA = (const GLushort *) srcRowA; - const GLushort *rowB = (const GLushort *) srcRowB; - GLushort *dst = (GLushort *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x1f; - const GLint rowAr1 = rowA[k] & 0x1f; - const GLint rowBr0 = rowB[j] & 0x1f; - const GLint rowBr1 = rowB[k] & 0x1f; - const GLint rowAg0 = (rowA[j] >> 5) & 0x1f; - const GLint rowAg1 = (rowA[k] >> 5) & 0x1f; - const GLint rowBg0 = (rowB[j] >> 5) & 0x1f; - const GLint rowBg1 = (rowB[k] >> 5) & 0x1f; - const GLint rowAb0 = (rowA[j] >> 10) & 0x1f; - const GLint rowAb1 = (rowA[k] >> 10) & 0x1f; - const GLint rowBb0 = (rowB[j] >> 10) & 0x1f; - const GLint rowBb1 = (rowB[k] >> 10) & 0x1f; - const GLint rowAa0 = (rowA[j] >> 15) & 0x1; - const GLint rowAa1 = (rowA[k] >> 15) & 0x1; - const GLint rowBa0 = (rowB[j] >> 15) & 0x1; - const GLint rowBa1 = (rowB[k] >> 15) & 0x1; - const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; - const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; - const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; - const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2; - dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red; - } - } - else if (datatype == GL_UNSIGNED_BYTE_3_3_2 && comps == 3) { - GLuint i, j, k; - const GLubyte *rowA = (const GLubyte *) srcRowA; - const GLubyte *rowB = (const GLubyte *) srcRowB; - GLubyte *dst = (GLubyte *) dstRow; - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x3; - const GLint rowAr1 = rowA[k] & 0x3; - const GLint rowBr0 = rowB[j] & 0x3; - const GLint rowBr1 = rowB[k] & 0x3; - const GLint rowAg0 = (rowA[j] >> 2) & 0x7; - const GLint rowAg1 = (rowA[k] >> 2) & 0x7; - const GLint rowBg0 = (rowB[j] >> 2) & 0x7; - const GLint rowBg1 = (rowB[k] >> 2) & 0x7; - const GLint rowAb0 = (rowA[j] >> 5) & 0x7; - const GLint rowAb1 = (rowA[k] >> 5) & 0x7; - const GLint rowBb0 = (rowB[j] >> 5) & 0x7; - const GLint rowBb1 = (rowB[k] >> 5) & 0x7; - const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; - const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; - const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; - dst[i] = (blue << 5) | (green << 2) | red; - } - } - else { - _mesa_problem(NULL, "bad format in do_row()"); - } -} - - -/** - * Average together four rows of a source image to produce a single new - * row in the dest image. It's legal for the two source rows to point - * to the same data. The source width must be equal to either the - * dest width or two times the dest width. - * - * \param datatype GL pixel type \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, - * \c GL_FLOAT, etc. - * \param comps number of components per pixel (1..4) - * \param srcWidth Width of a row in the source data - * \param srcRowA Pointer to one of the rows of source data - * \param srcRowB Pointer to one of the rows of source data - * \param srcRowC Pointer to one of the rows of source data - * \param srcRowD Pointer to one of the rows of source data - * \param dstWidth Width of a row in the destination data - * \param srcRowA Pointer to the row of destination data - */ -static void -do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth, - const GLvoid *srcRowA, const GLvoid *srcRowB, - const GLvoid *srcRowC, const GLvoid *srcRowD, - GLint dstWidth, GLvoid *dstRow) -{ - const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1; - const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; - GLuint i, j, k; - - ASSERT(comps >= 1); - ASSERT(comps <= 4); - - if ((datatype == GL_UNSIGNED_BYTE) && (comps == 4)) { - DECLARE_ROW_POINTERS(GLubyte, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - FILTER_3D(2); - FILTER_3D(3); - } - } - else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 3)) { - DECLARE_ROW_POINTERS(GLubyte, 3); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - FILTER_3D(2); - } - } - else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 2)) { - DECLARE_ROW_POINTERS(GLubyte, 2); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - } - } - else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 1)) { - DECLARE_ROW_POINTERS(GLubyte, 1); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - } - } - if ((datatype == GL_BYTE) && (comps == 4)) { - DECLARE_ROW_POINTERS(GLbyte, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D_SIGNED(0); - FILTER_3D_SIGNED(1); - FILTER_3D_SIGNED(2); - FILTER_3D_SIGNED(3); - } - } - else if ((datatype == GL_BYTE) && (comps == 3)) { - DECLARE_ROW_POINTERS(GLbyte, 3); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D_SIGNED(0); - FILTER_3D_SIGNED(1); - FILTER_3D_SIGNED(2); - } - } - else if ((datatype == GL_BYTE) && (comps == 2)) { - DECLARE_ROW_POINTERS(GLbyte, 2); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D_SIGNED(0); - FILTER_3D_SIGNED(1); - } - } - else if ((datatype == GL_BYTE) && (comps == 1)) { - DECLARE_ROW_POINTERS(GLbyte, 1); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D_SIGNED(0); - } - } - else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 4)) { - DECLARE_ROW_POINTERS(GLushort, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - FILTER_3D(2); - FILTER_3D(3); - } - } - else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 3)) { - DECLARE_ROW_POINTERS(GLushort, 3); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - FILTER_3D(2); - } - } - else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 2)) { - DECLARE_ROW_POINTERS(GLushort, 2); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - FILTER_3D(1); - } - } - else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 1)) { - DECLARE_ROW_POINTERS(GLushort, 1); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_3D(0); - } - } - else if ((datatype == GL_FLOAT) && (comps == 4)) { - DECLARE_ROW_POINTERS(GLfloat, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_F_3D(0); - FILTER_F_3D(1); - FILTER_F_3D(2); - FILTER_F_3D(3); - } - } - else if ((datatype == GL_FLOAT) && (comps == 3)) { - DECLARE_ROW_POINTERS(GLfloat, 3); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_F_3D(0); - FILTER_F_3D(1); - FILTER_F_3D(2); - } - } - else if ((datatype == GL_FLOAT) && (comps == 2)) { - DECLARE_ROW_POINTERS(GLfloat, 2); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_F_3D(0); - FILTER_F_3D(1); - } - } - else if ((datatype == GL_FLOAT) && (comps == 1)) { - DECLARE_ROW_POINTERS(GLfloat, 1); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_F_3D(0); - } - } - else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 4)) { - DECLARE_ROW_POINTERS(GLhalfARB, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_HF_3D(0); - FILTER_HF_3D(1); - FILTER_HF_3D(2); - FILTER_HF_3D(3); - } - } - else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 3)) { - DECLARE_ROW_POINTERS(GLhalfARB, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_HF_3D(0); - FILTER_HF_3D(1); - FILTER_HF_3D(2); - } - } - else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 2)) { - DECLARE_ROW_POINTERS(GLhalfARB, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_HF_3D(0); - FILTER_HF_3D(1); - } - } - else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 1)) { - DECLARE_ROW_POINTERS(GLhalfARB, 4); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - FILTER_HF_3D(0); - } - } - else if ((datatype == GL_UNSIGNED_INT) && (comps == 1)) { - const GLuint *rowA = (const GLuint *) srcRowA; - const GLuint *rowB = (const GLuint *) srcRowB; - const GLuint *rowC = (const GLuint *) srcRowC; - const GLuint *rowD = (const GLuint *) srcRowD; - GLfloat *dst = (GLfloat *) dstRow; - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const uint64_t tmp = (((uint64_t) rowA[j] + (uint64_t) rowA[k]) - + ((uint64_t) rowB[j] + (uint64_t) rowB[k]) - + ((uint64_t) rowC[j] + (uint64_t) rowC[k]) - + ((uint64_t) rowD[j] + (uint64_t) rowD[k])); - dst[i] = (GLfloat)((double) tmp * 0.125); - } - } - else if ((datatype == GL_UNSIGNED_SHORT_5_6_5) && (comps == 3)) { - DECLARE_ROW_POINTERS0(GLushort); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x1f; - const GLint rowAr1 = rowA[k] & 0x1f; - const GLint rowBr0 = rowB[j] & 0x1f; - const GLint rowBr1 = rowB[k] & 0x1f; - const GLint rowCr0 = rowC[j] & 0x1f; - const GLint rowCr1 = rowC[k] & 0x1f; - const GLint rowDr0 = rowD[j] & 0x1f; - const GLint rowDr1 = rowD[k] & 0x1f; - const GLint rowAg0 = (rowA[j] >> 5) & 0x3f; - const GLint rowAg1 = (rowA[k] >> 5) & 0x3f; - const GLint rowBg0 = (rowB[j] >> 5) & 0x3f; - const GLint rowBg1 = (rowB[k] >> 5) & 0x3f; - const GLint rowCg0 = (rowC[j] >> 5) & 0x3f; - const GLint rowCg1 = (rowC[k] >> 5) & 0x3f; - const GLint rowDg0 = (rowD[j] >> 5) & 0x3f; - const GLint rowDg1 = (rowD[k] >> 5) & 0x3f; - const GLint rowAb0 = (rowA[j] >> 11) & 0x1f; - const GLint rowAb1 = (rowA[k] >> 11) & 0x1f; - const GLint rowBb0 = (rowB[j] >> 11) & 0x1f; - const GLint rowBb1 = (rowB[k] >> 11) & 0x1f; - const GLint rowCb0 = (rowC[j] >> 11) & 0x1f; - const GLint rowCb1 = (rowC[k] >> 11) & 0x1f; - const GLint rowDb0 = (rowD[j] >> 11) & 0x1f; - const GLint rowDb1 = (rowD[k] >> 11) & 0x1f; - const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, - rowCr0, rowCr1, rowDr0, rowDr1); - const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, - rowCg0, rowCg1, rowDg0, rowDg1); - const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, - rowCb0, rowCb1, rowDb0, rowDb1); - dst[i] = (b << 11) | (g << 5) | r; - } - } - else if ((datatype == GL_UNSIGNED_SHORT_4_4_4_4) && (comps == 4)) { - DECLARE_ROW_POINTERS0(GLushort); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0xf; - const GLint rowAr1 = rowA[k] & 0xf; - const GLint rowBr0 = rowB[j] & 0xf; - const GLint rowBr1 = rowB[k] & 0xf; - const GLint rowCr0 = rowC[j] & 0xf; - const GLint rowCr1 = rowC[k] & 0xf; - const GLint rowDr0 = rowD[j] & 0xf; - const GLint rowDr1 = rowD[k] & 0xf; - const GLint rowAg0 = (rowA[j] >> 4) & 0xf; - const GLint rowAg1 = (rowA[k] >> 4) & 0xf; - const GLint rowBg0 = (rowB[j] >> 4) & 0xf; - const GLint rowBg1 = (rowB[k] >> 4) & 0xf; - const GLint rowCg0 = (rowC[j] >> 4) & 0xf; - const GLint rowCg1 = (rowC[k] >> 4) & 0xf; - const GLint rowDg0 = (rowD[j] >> 4) & 0xf; - const GLint rowDg1 = (rowD[k] >> 4) & 0xf; - const GLint rowAb0 = (rowA[j] >> 8) & 0xf; - const GLint rowAb1 = (rowA[k] >> 8) & 0xf; - const GLint rowBb0 = (rowB[j] >> 8) & 0xf; - const GLint rowBb1 = (rowB[k] >> 8) & 0xf; - const GLint rowCb0 = (rowC[j] >> 8) & 0xf; - const GLint rowCb1 = (rowC[k] >> 8) & 0xf; - const GLint rowDb0 = (rowD[j] >> 8) & 0xf; - const GLint rowDb1 = (rowD[k] >> 8) & 0xf; - const GLint rowAa0 = (rowA[j] >> 12) & 0xf; - const GLint rowAa1 = (rowA[k] >> 12) & 0xf; - const GLint rowBa0 = (rowB[j] >> 12) & 0xf; - const GLint rowBa1 = (rowB[k] >> 12) & 0xf; - const GLint rowCa0 = (rowC[j] >> 12) & 0xf; - const GLint rowCa1 = (rowC[k] >> 12) & 0xf; - const GLint rowDa0 = (rowD[j] >> 12) & 0xf; - const GLint rowDa1 = (rowD[k] >> 12) & 0xf; - const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, - rowCr0, rowCr1, rowDr0, rowDr1); - const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, - rowCg0, rowCg1, rowDg0, rowDg1); - const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, - rowCb0, rowCb1, rowDb0, rowDb1); - const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1, - rowCa0, rowCa1, rowDa0, rowDa1); - - dst[i] = (a << 12) | (b << 8) | (g << 4) | r; - } - } - else if ((datatype == GL_UNSIGNED_SHORT_1_5_5_5_REV) && (comps == 4)) { - DECLARE_ROW_POINTERS0(GLushort); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x1f; - const GLint rowAr1 = rowA[k] & 0x1f; - const GLint rowBr0 = rowB[j] & 0x1f; - const GLint rowBr1 = rowB[k] & 0x1f; - const GLint rowCr0 = rowC[j] & 0x1f; - const GLint rowCr1 = rowC[k] & 0x1f; - const GLint rowDr0 = rowD[j] & 0x1f; - const GLint rowDr1 = rowD[k] & 0x1f; - const GLint rowAg0 = (rowA[j] >> 5) & 0x1f; - const GLint rowAg1 = (rowA[k] >> 5) & 0x1f; - const GLint rowBg0 = (rowB[j] >> 5) & 0x1f; - const GLint rowBg1 = (rowB[k] >> 5) & 0x1f; - const GLint rowCg0 = (rowC[j] >> 5) & 0x1f; - const GLint rowCg1 = (rowC[k] >> 5) & 0x1f; - const GLint rowDg0 = (rowD[j] >> 5) & 0x1f; - const GLint rowDg1 = (rowD[k] >> 5) & 0x1f; - const GLint rowAb0 = (rowA[j] >> 10) & 0x1f; - const GLint rowAb1 = (rowA[k] >> 10) & 0x1f; - const GLint rowBb0 = (rowB[j] >> 10) & 0x1f; - const GLint rowBb1 = (rowB[k] >> 10) & 0x1f; - const GLint rowCb0 = (rowC[j] >> 10) & 0x1f; - const GLint rowCb1 = (rowC[k] >> 10) & 0x1f; - const GLint rowDb0 = (rowD[j] >> 10) & 0x1f; - const GLint rowDb1 = (rowD[k] >> 10) & 0x1f; - const GLint rowAa0 = (rowA[j] >> 15) & 0x1; - const GLint rowAa1 = (rowA[k] >> 15) & 0x1; - const GLint rowBa0 = (rowB[j] >> 15) & 0x1; - const GLint rowBa1 = (rowB[k] >> 15) & 0x1; - const GLint rowCa0 = (rowC[j] >> 15) & 0x1; - const GLint rowCa1 = (rowC[k] >> 15) & 0x1; - const GLint rowDa0 = (rowD[j] >> 15) & 0x1; - const GLint rowDa1 = (rowD[k] >> 15) & 0x1; - const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, - rowCr0, rowCr1, rowDr0, rowDr1); - const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, - rowCg0, rowCg1, rowDg0, rowDg1); - const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, - rowCb0, rowCb1, rowDb0, rowDb1); - const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1, - rowCa0, rowCa1, rowDa0, rowDa1); - - dst[i] = (a << 15) | (b << 10) | (g << 5) | r; - } - } - else if ((datatype == GL_UNSIGNED_BYTE_3_3_2) && (comps == 3)) { - DECLARE_ROW_POINTERS0(GLushort); - - for (i = j = 0, k = k0; i < (GLuint) dstWidth; - i++, j += colStride, k += colStride) { - const GLint rowAr0 = rowA[j] & 0x3; - const GLint rowAr1 = rowA[k] & 0x3; - const GLint rowBr0 = rowB[j] & 0x3; - const GLint rowBr1 = rowB[k] & 0x3; - const GLint rowCr0 = rowC[j] & 0x3; - const GLint rowCr1 = rowC[k] & 0x3; - const GLint rowDr0 = rowD[j] & 0x3; - const GLint rowDr1 = rowD[k] & 0x3; - const GLint rowAg0 = (rowA[j] >> 2) & 0x7; - const GLint rowAg1 = (rowA[k] >> 2) & 0x7; - const GLint rowBg0 = (rowB[j] >> 2) & 0x7; - const GLint rowBg1 = (rowB[k] >> 2) & 0x7; - const GLint rowCg0 = (rowC[j] >> 2) & 0x7; - const GLint rowCg1 = (rowC[k] >> 2) & 0x7; - const GLint rowDg0 = (rowD[j] >> 2) & 0x7; - const GLint rowDg1 = (rowD[k] >> 2) & 0x7; - const GLint rowAb0 = (rowA[j] >> 5) & 0x7; - const GLint rowAb1 = (rowA[k] >> 5) & 0x7; - const GLint rowBb0 = (rowB[j] >> 5) & 0x7; - const GLint rowBb1 = (rowB[k] >> 5) & 0x7; - const GLint rowCb0 = (rowC[j] >> 5) & 0x7; - const GLint rowCb1 = (rowC[k] >> 5) & 0x7; - const GLint rowDb0 = (rowD[j] >> 5) & 0x7; - const GLint rowDb1 = (rowD[k] >> 5) & 0x7; - const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, - rowCr0, rowCr1, rowDr0, rowDr1); - const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, - rowCg0, rowCg1, rowDg0, rowDg1); - const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, - rowCb0, rowCb1, rowDb0, rowDb1); - dst[i] = (b << 5) | (g << 2) | r; - } - } - else { - _mesa_problem(NULL, "bad format in do_row()"); - } -} - - -/* - * These functions generate a 1/2-size mipmap image from a source image. - * Texture borders are handled by copying or averaging the source image's - * border texels, depending on the scale-down factor. - */ - -static void -make_1d_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, const GLubyte *srcPtr, - GLint dstWidth, GLubyte *dstPtr) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLubyte *src; - GLubyte *dst; - - /* skip the border pixel, if any */ - src = srcPtr + border * bpt; - dst = dstPtr + border * bpt; - - /* we just duplicate the input row, kind of hack, saves code */ - do_row(datatype, comps, srcWidth - 2 * border, src, src, - dstWidth - 2 * border, dst); - - if (border) { - /* copy left-most pixel from source */ - assert(dstPtr); - assert(srcPtr); - memcpy(dstPtr, srcPtr, bpt); - /* copy right-most pixel from source */ - memcpy(dstPtr + (dstWidth - 1) * bpt, - srcPtr + (srcWidth - 1) * bpt, - bpt); - } -} - - -static void -make_2d_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, GLint srcHeight, - const GLubyte *srcPtr, GLint srcRowStride, - GLint dstWidth, GLint dstHeight, - GLubyte *dstPtr, GLint dstRowStride) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ - const GLint dstWidthNB = dstWidth - 2 * border; - const GLint dstHeightNB = dstHeight - 2 * border; - const GLint srcRowBytes = bpt * srcRowStride; - const GLint dstRowBytes = bpt * dstRowStride; - const GLubyte *srcA, *srcB; - GLubyte *dst; - GLint row, srcRowStep; - - /* Compute src and dst pointers, skipping any border */ - srcA = srcPtr + border * ((srcWidth + 1) * bpt); - if (srcHeight > 1 && srcHeight > dstHeight) { - /* sample from two source rows */ - srcB = srcA + srcRowBytes; - srcRowStep = 2; - } - else { - /* sample from one source row */ - srcB = srcA; - srcRowStep = 1; - } - - dst = dstPtr + border * ((dstWidth + 1) * bpt); - - for (row = 0; row < dstHeightNB; row++) { - do_row(datatype, comps, srcWidthNB, srcA, srcB, - dstWidthNB, dst); - srcA += srcRowStep * srcRowBytes; - srcB += srcRowStep * srcRowBytes; - dst += dstRowBytes; - } - - /* This is ugly but probably won't be used much */ - if (border > 0) { - /* fill in dest border */ - /* lower-left border pixel */ - assert(dstPtr); - assert(srcPtr); - memcpy(dstPtr, srcPtr, bpt); - /* lower-right border pixel */ - memcpy(dstPtr + (dstWidth - 1) * bpt, - srcPtr + (srcWidth - 1) * bpt, bpt); - /* upper-left border pixel */ - memcpy(dstPtr + dstWidth * (dstHeight - 1) * bpt, - srcPtr + srcWidth * (srcHeight - 1) * bpt, bpt); - /* upper-right border pixel */ - memcpy(dstPtr + (dstWidth * dstHeight - 1) * bpt, - srcPtr + (srcWidth * srcHeight - 1) * bpt, bpt); - /* lower border */ - do_row(datatype, comps, srcWidthNB, - srcPtr + bpt, - srcPtr + bpt, - dstWidthNB, dstPtr + bpt); - /* upper border */ - do_row(datatype, comps, srcWidthNB, - srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, - srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, - dstWidthNB, - dstPtr + (dstWidth * (dstHeight - 1) + 1) * bpt); - /* left and right borders */ - if (srcHeight == dstHeight) { - /* copy border pixel from src to dst */ - for (row = 1; row < srcHeight; row++) { - memcpy(dstPtr + dstWidth * row * bpt, - srcPtr + srcWidth * row * bpt, bpt); - memcpy(dstPtr + (dstWidth * row + dstWidth - 1) * bpt, - srcPtr + (srcWidth * row + srcWidth - 1) * bpt, bpt); - } - } - else { - /* average two src pixels each dest pixel */ - for (row = 0; row < dstHeightNB; row += 2) { - do_row(datatype, comps, 1, - srcPtr + (srcWidth * (row * 2 + 1)) * bpt, - srcPtr + (srcWidth * (row * 2 + 2)) * bpt, - 1, dstPtr + (dstWidth * row + 1) * bpt); - do_row(datatype, comps, 1, - srcPtr + (srcWidth * (row * 2 + 1) + srcWidth - 1) * bpt, - srcPtr + (srcWidth * (row * 2 + 2) + srcWidth - 1) * bpt, - 1, dstPtr + (dstWidth * row + 1 + dstWidth - 1) * bpt); - } - } - } -} - - -static void -make_3d_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLubyte *srcPtr, GLint srcRowStride, - GLint dstWidth, GLint dstHeight, GLint dstDepth, - GLubyte *dstPtr, GLint dstRowStride) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ - const GLint srcDepthNB = srcDepth - 2 * border; - const GLint dstWidthNB = dstWidth - 2 * border; - const GLint dstHeightNB = dstHeight - 2 * border; - const GLint dstDepthNB = dstDepth - 2 * border; - GLint img, row; - GLint bytesPerSrcImage, bytesPerDstImage; - GLint bytesPerSrcRow, bytesPerDstRow; - GLint srcImageOffset, srcRowOffset; - - (void) srcDepthNB; /* silence warnings */ - - - bytesPerSrcImage = srcWidth * srcHeight * bpt; - bytesPerDstImage = dstWidth * dstHeight * bpt; - - bytesPerSrcRow = srcWidth * bpt; - bytesPerDstRow = dstWidth * bpt; - - /* Offset between adjacent src images to be averaged together */ - srcImageOffset = (srcDepth == dstDepth) ? 0 : bytesPerSrcImage; - - /* Offset between adjacent src rows to be averaged together */ - srcRowOffset = (srcHeight == dstHeight) ? 0 : srcWidth * bpt; - - /* - * Need to average together up to 8 src pixels for each dest pixel. - * Break that down into 3 operations: - * 1. take two rows from source image and average them together. - * 2. take two rows from next source image and average them together. - * 3. take the two averaged rows and average them for the final dst row. - */ - - /* - printf("mip3d %d x %d x %d -> %d x %d x %d\n", - srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth); - */ - - for (img = 0; img < dstDepthNB; img++) { - /* first source image pointer, skipping border */ - const GLubyte *imgSrcA = srcPtr - + (bytesPerSrcImage + bytesPerSrcRow + border) * bpt * border - + img * (bytesPerSrcImage + srcImageOffset); - /* second source image pointer, skipping border */ - const GLubyte *imgSrcB = imgSrcA + srcImageOffset; - /* address of the dest image, skipping border */ - GLubyte *imgDst = dstPtr - + (bytesPerDstImage + bytesPerDstRow + border) * bpt * border - + img * bytesPerDstImage; - - /* setup the four source row pointers and the dest row pointer */ - const GLubyte *srcImgARowA = imgSrcA; - const GLubyte *srcImgARowB = imgSrcA + srcRowOffset; - const GLubyte *srcImgBRowA = imgSrcB; - const GLubyte *srcImgBRowB = imgSrcB + srcRowOffset; - GLubyte *dstImgRow = imgDst; - - for (row = 0; row < dstHeightNB; row++) { - do_row_3D(datatype, comps, srcWidthNB, - srcImgARowA, srcImgARowB, - srcImgBRowA, srcImgBRowB, - dstWidthNB, dstImgRow); - - /* advance to next rows */ - srcImgARowA += bytesPerSrcRow + srcRowOffset; - srcImgARowB += bytesPerSrcRow + srcRowOffset; - srcImgBRowA += bytesPerSrcRow + srcRowOffset; - srcImgBRowB += bytesPerSrcRow + srcRowOffset; - dstImgRow += bytesPerDstRow; - } - } - - - /* Luckily we can leverage the make_2d_mipmap() function here! */ - if (border > 0) { - /* do front border image */ - make_2d_mipmap(datatype, comps, 1, srcWidth, srcHeight, srcPtr, srcRowStride, - dstWidth, dstHeight, dstPtr, dstRowStride); - /* do back border image */ - make_2d_mipmap(datatype, comps, 1, srcWidth, srcHeight, - srcPtr + bytesPerSrcImage * (srcDepth - 1), srcRowStride, - dstWidth, dstHeight, - dstPtr + bytesPerDstImage * (dstDepth - 1), dstRowStride); - /* do four remaining border edges that span the image slices */ - if (srcDepth == dstDepth) { - /* just copy border pixels from src to dst */ - for (img = 0; img < dstDepthNB; img++) { - const GLubyte *src; - GLubyte *dst; - - /* do border along [img][row=0][col=0] */ - src = srcPtr + (img + 1) * bytesPerSrcImage; - dst = dstPtr + (img + 1) * bytesPerDstImage; - memcpy(dst, src, bpt); - - /* do border along [img][row=dstHeight-1][col=0] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (srcHeight - 1) * bytesPerSrcRow; - dst = dstPtr + (img + 1) * bytesPerDstImage - + (dstHeight - 1) * bytesPerDstRow; - memcpy(dst, src, bpt); - - /* do border along [img][row=0][col=dstWidth-1] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (srcWidth - 1) * bpt; - dst = dstPtr + (img + 1) * bytesPerDstImage - + (dstWidth - 1) * bpt; - memcpy(dst, src, bpt); - - /* do border along [img][row=dstHeight-1][col=dstWidth-1] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (bytesPerSrcImage - bpt); - dst = dstPtr + (img + 1) * bytesPerDstImage - + (bytesPerDstImage - bpt); - memcpy(dst, src, bpt); - } - } - else { - /* average border pixels from adjacent src image pairs */ - ASSERT(srcDepthNB == 2 * dstDepthNB); - for (img = 0; img < dstDepthNB; img++) { - const GLubyte *src; - GLubyte *dst; - - /* do border along [img][row=0][col=0] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage; - dst = dstPtr + (img + 1) * bytesPerDstImage; - do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); - - /* do border along [img][row=dstHeight-1][col=0] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (srcHeight - 1) * bytesPerSrcRow; - dst = dstPtr + (img + 1) * bytesPerDstImage - + (dstHeight - 1) * bytesPerDstRow; - do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); - - /* do border along [img][row=0][col=dstWidth-1] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (srcWidth - 1) * bpt; - dst = dstPtr + (img + 1) * bytesPerDstImage - + (dstWidth - 1) * bpt; - do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); - - /* do border along [img][row=dstHeight-1][col=dstWidth-1] */ - src = srcPtr + (img * 2 + 1) * bytesPerSrcImage - + (bytesPerSrcImage - bpt); - dst = dstPtr + (img + 1) * bytesPerDstImage - + (bytesPerDstImage - bpt); - do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); - } - } - } -} - - -static void -make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, const GLubyte *srcPtr, GLuint srcRowStride, - GLint dstWidth, GLint dstHeight, - GLubyte *dstPtr, GLuint dstRowStride ) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ - const GLint dstWidthNB = dstWidth - 2 * border; - const GLint dstHeightNB = dstHeight - 2 * border; - const GLint srcRowBytes = bpt * srcRowStride; - const GLint dstRowBytes = bpt * dstRowStride; - const GLubyte *src; - GLubyte *dst; - GLint row; - - /* Compute src and dst pointers, skipping any border */ - src = srcPtr + border * ((srcWidth + 1) * bpt); - dst = dstPtr + border * ((dstWidth + 1) * bpt); - - for (row = 0; row < dstHeightNB; row++) { - do_row(datatype, comps, srcWidthNB, src, src, - dstWidthNB, dst); - src += srcRowBytes; - dst += dstRowBytes; - } - - if (border) { - /* copy left-most pixel from source */ - assert(dstPtr); - assert(srcPtr); - memcpy(dstPtr, srcPtr, bpt); - /* copy right-most pixel from source */ - memcpy(dstPtr + (dstWidth - 1) * bpt, - srcPtr + (srcWidth - 1) * bpt, - bpt); - } -} - - -/** - * \bug - * There is quite a bit of refactoring that could be done with this function - * and \c make_2d_mipmap. - */ -static void -make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, GLint srcHeight, - const GLubyte *srcPtr, GLint srcRowStride, - GLint dstWidth, GLint dstHeight, GLint dstDepth, - GLubyte *dstPtr, GLint dstRowStride) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ - const GLint dstWidthNB = dstWidth - 2 * border; - const GLint dstHeightNB = dstHeight - 2 * border; - const GLint dstDepthNB = dstDepth - 2 * border; - const GLint srcRowBytes = bpt * srcRowStride; - const GLint dstRowBytes = bpt * dstRowStride; - const GLubyte *srcA, *srcB; - GLubyte *dst; - GLint layer; - GLint row; - - /* Compute src and dst pointers, skipping any border */ - srcA = srcPtr + border * ((srcWidth + 1) * bpt); - if (srcHeight > 1) - srcB = srcA + srcRowBytes; - else - srcB = srcA; - dst = dstPtr + border * ((dstWidth + 1) * bpt); - - for (layer = 0; layer < dstDepthNB; layer++) { - for (row = 0; row < dstHeightNB; row++) { - do_row(datatype, comps, srcWidthNB, srcA, srcB, - dstWidthNB, dst); - srcA += 2 * srcRowBytes; - srcB += 2 * srcRowBytes; - dst += dstRowBytes; - } - - /* This is ugly but probably won't be used much */ - if (border > 0) { - /* fill in dest border */ - /* lower-left border pixel */ - assert(dstPtr); - assert(srcPtr); - memcpy(dstPtr, srcPtr, bpt); - /* lower-right border pixel */ - memcpy(dstPtr + (dstWidth - 1) * bpt, - srcPtr + (srcWidth - 1) * bpt, bpt); - /* upper-left border pixel */ - memcpy(dstPtr + dstWidth * (dstHeight - 1) * bpt, - srcPtr + srcWidth * (srcHeight - 1) * bpt, bpt); - /* upper-right border pixel */ - memcpy(dstPtr + (dstWidth * dstHeight - 1) * bpt, - srcPtr + (srcWidth * srcHeight - 1) * bpt, bpt); - /* lower border */ - do_row(datatype, comps, srcWidthNB, - srcPtr + bpt, - srcPtr + bpt, - dstWidthNB, dstPtr + bpt); - /* upper border */ - do_row(datatype, comps, srcWidthNB, - srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, - srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, - dstWidthNB, - dstPtr + (dstWidth * (dstHeight - 1) + 1) * bpt); - /* left and right borders */ - if (srcHeight == dstHeight) { - /* copy border pixel from src to dst */ - for (row = 1; row < srcHeight; row++) { - memcpy(dstPtr + dstWidth * row * bpt, - srcPtr + srcWidth * row * bpt, bpt); - memcpy(dstPtr + (dstWidth * row + dstWidth - 1) * bpt, - srcPtr + (srcWidth * row + srcWidth - 1) * bpt, bpt); - } - } - else { - /* average two src pixels each dest pixel */ - for (row = 0; row < dstHeightNB; row += 2) { - do_row(datatype, comps, 1, - srcPtr + (srcWidth * (row * 2 + 1)) * bpt, - srcPtr + (srcWidth * (row * 2 + 2)) * bpt, - 1, dstPtr + (dstWidth * row + 1) * bpt); - do_row(datatype, comps, 1, - srcPtr + (srcWidth * (row * 2 + 1) + srcWidth - 1) * bpt, - srcPtr + (srcWidth * (row * 2 + 2) + srcWidth - 1) * bpt, - 1, dstPtr + (dstWidth * row + 1 + dstWidth - 1) * bpt); - } - } - } - } -} - - -/** - * Down-sample a texture image to produce the next lower mipmap level. - * \param comps components per texel (1, 2, 3 or 4) - * \param srcRowStride stride between source rows, in texels - * \param dstRowStride stride between destination rows, in texels - */ -void -_mesa_generate_mipmap_level(GLenum target, - GLenum datatype, GLuint comps, - GLint border, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLubyte *srcData, - GLint srcRowStride, - GLint dstWidth, GLint dstHeight, GLint dstDepth, - GLubyte *dstData, - GLint dstRowStride) -{ - /* - * We use simple 2x2 averaging to compute the next mipmap level. - */ - switch (target) { - case GL_TEXTURE_1D: - make_1d_mipmap(datatype, comps, border, - srcWidth, srcData, - dstWidth, dstData); - break; - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - make_2d_mipmap(datatype, comps, border, - srcWidth, srcHeight, srcData, srcRowStride, - dstWidth, dstHeight, dstData, dstRowStride); - break; - case GL_TEXTURE_3D: - make_3d_mipmap(datatype, comps, border, - srcWidth, srcHeight, srcDepth, - srcData, srcRowStride, - dstWidth, dstHeight, dstDepth, - dstData, dstRowStride); - break; - case GL_TEXTURE_1D_ARRAY_EXT: - make_1d_stack_mipmap(datatype, comps, border, - srcWidth, srcData, srcRowStride, - dstWidth, dstHeight, - dstData, dstRowStride); - break; - case GL_TEXTURE_2D_ARRAY_EXT: - make_2d_stack_mipmap(datatype, comps, border, - srcWidth, srcHeight, - srcData, srcRowStride, - dstWidth, dstHeight, - dstDepth, dstData, dstRowStride); - break; - case GL_TEXTURE_RECTANGLE_NV: - /* no mipmaps, do nothing */ - break; - default: - _mesa_problem(NULL, "bad dimensions in _mesa_generate_mipmaps"); - return; - } -} - - -/** - * compute next (level+1) image size - * \return GL_FALSE if no smaller size can be generated (eg. src is 1x1x1 size) - */ -static GLboolean -next_mipmap_level_size(GLenum target, GLint border, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLint *dstWidth, GLint *dstHeight, GLint *dstDepth) -{ - if (srcWidth - 2 * border > 1) { - *dstWidth = (srcWidth - 2 * border) / 2 + 2 * border; - } - else { - *dstWidth = srcWidth; /* can't go smaller */ - } - - if ((srcHeight - 2 * border > 1) && - (target != GL_TEXTURE_1D_ARRAY_EXT)) { - *dstHeight = (srcHeight - 2 * border) / 2 + 2 * border; - } - else { - *dstHeight = srcHeight; /* can't go smaller */ - } - - if ((srcDepth - 2 * border > 1) && - (target != GL_TEXTURE_2D_ARRAY_EXT)) { - *dstDepth = (srcDepth - 2 * border) / 2 + 2 * border; - } - else { - *dstDepth = srcDepth; /* can't go smaller */ - } - - if (*dstWidth == srcWidth && - *dstHeight == srcHeight && - *dstDepth == srcDepth) { - return GL_FALSE; - } - else { - return GL_TRUE; - } -} - - - - -/** - * Automatic mipmap generation. - * This is the fallback/default function for ctx->Driver.GenerateMipmap(). - * Generate a complete set of mipmaps from texObj's BaseLevel image. - * Stop at texObj's MaxLevel or when we get to the 1x1 texture. - * For cube maps, target will be one of - * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z; never GL_TEXTURE_CUBE_MAP. - */ -void -_mesa_generate_mipmap(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj) -{ - const struct gl_texture_image *srcImage; - gl_format convertFormat; - const GLubyte *srcData = NULL; - GLubyte *dstData = NULL; - GLint level, maxLevels; - GLenum datatype; - GLuint comps; - - ASSERT(texObj); - srcImage = _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel); - ASSERT(srcImage); - - maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); - ASSERT(maxLevels > 0); /* bad target */ - - /* Find convertFormat - the format that do_row() will process */ - - if (_mesa_is_format_compressed(srcImage->TexFormat)) { - /* setup for compressed textures - need to allocate temporary - * image buffers to hold uncompressed images. - */ - GLuint row; - GLint components, size; - GLchan *dst; - - assert(texObj->Target == GL_TEXTURE_2D || - texObj->Target == GL_TEXTURE_CUBE_MAP_ARB); - - if (srcImage->_BaseFormat == GL_RGB) { - convertFormat = MESA_FORMAT_RGB888; - components = 3; - } - else if (srcImage->_BaseFormat == GL_RGBA) { - convertFormat = MESA_FORMAT_RGBA8888; - components = 4; - } - else { - _mesa_problem(ctx, "bad srcImage->_BaseFormat in _mesa_generate_mipmaps"); - return; - } - - /* allocate storage for uncompressed GL_RGB or GL_RGBA images */ - size = _mesa_bytes_per_pixel(srcImage->_BaseFormat, CHAN_TYPE) - * srcImage->Width * srcImage->Height * srcImage->Depth + 20; - /* 20 extra bytes, just be safe when calling last FetchTexel */ - srcData = (GLubyte *) malloc(size); - if (!srcData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); - return; - } - dstData = (GLubyte *) malloc(size / 2); /* 1/4 would probably be OK */ - if (!dstData) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); - free((void *) srcData); - return; - } - - /* decompress base image here */ - dst = (GLchan *) srcData; - for (row = 0; row < srcImage->Height; row++) { - GLuint col; - for (col = 0; col < srcImage->Width; col++) { - srcImage->FetchTexelc(srcImage, col, row, 0, dst); - dst += components; - } - } - } - else { - /* uncompressed */ - convertFormat = srcImage->TexFormat; - } - - _mesa_format_to_type_and_comps(convertFormat, &datatype, &comps); - - for (level = texObj->BaseLevel; level < texObj->MaxLevel - && level < maxLevels - 1; level++) { - /* generate image[level+1] from image[level] */ - const struct gl_texture_image *srcImage; - struct gl_texture_image *dstImage; - GLint srcWidth, srcHeight, srcDepth; - GLint dstWidth, dstHeight, dstDepth; - GLint border; - GLboolean nextLevel; - - /* get src image parameters */ - srcImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(srcImage); - srcWidth = srcImage->Width; - srcHeight = srcImage->Height; - srcDepth = srcImage->Depth; - border = srcImage->Border; - - nextLevel = next_mipmap_level_size(target, border, - srcWidth, srcHeight, srcDepth, - &dstWidth, &dstHeight, &dstDepth); - if (!nextLevel) { - /* all done */ - if (_mesa_is_format_compressed(srcImage->TexFormat)) { - free((void *) srcData); - free(dstData); - } - return; - } - - /* get dest gl_texture_image */ - dstImage = _mesa_get_tex_image(ctx, texObj, target, level + 1); - if (!dstImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); - return; - } - - /* Free old image data */ - if (dstImage->Data) - ctx->Driver.FreeTexImageData(ctx, dstImage); - - /* initialize new image */ - _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight, - dstDepth, border, srcImage->InternalFormat); - dstImage->DriverData = NULL; - dstImage->TexFormat = srcImage->TexFormat; - dstImage->FetchTexelc = srcImage->FetchTexelc; - dstImage->FetchTexelf = srcImage->FetchTexelf; - - /* Alloc new teximage data buffer */ - { - GLuint size = _mesa_format_image_size(dstImage->TexFormat, - dstWidth, dstHeight, dstDepth); - dstImage->Data = _mesa_alloc_texmemory(size); - if (!dstImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); - return; - } - } - - /* Setup src and dest data pointers */ - if (_mesa_is_format_compressed(dstImage->TexFormat)) { - /* srcData and dstData are already set */ - ASSERT(srcData); - ASSERT(dstData); - } - else { - srcData = (const GLubyte *) srcImage->Data; - dstData = (GLubyte *) dstImage->Data; - } - - ASSERT(dstImage->TexFormat); - ASSERT(dstImage->FetchTexelc); - ASSERT(dstImage->FetchTexelf); - - _mesa_generate_mipmap_level(target, datatype, comps, border, - srcWidth, srcHeight, srcDepth, - srcData, srcImage->RowStride, - dstWidth, dstHeight, dstDepth, - dstData, dstImage->RowStride); - - - if (_mesa_is_format_compressed(dstImage->TexFormat)) { - GLubyte *temp; - /* compress image from dstData into dstImage->Data */ - const GLenum srcFormat = _mesa_get_format_base_format(convertFormat); - GLint dstRowStride - = _mesa_format_row_stride(dstImage->TexFormat, dstWidth); - ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA); - - _mesa_texstore(ctx, 2, dstImage->_BaseFormat, - dstImage->TexFormat, - dstImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, 0, /* strides */ - dstWidth, dstHeight, 1, /* size */ - srcFormat, CHAN_TYPE, - dstData, /* src data, actually */ - &ctx->DefaultPacking); - - /* swap src and dest pointers */ - temp = (GLubyte *) srcData; - srcData = dstData; - dstData = temp; - } - - } /* loop over mipmap levels */ -} - - -/** - * Helper function for drivers which need to rescale texture images to - * certain aspect ratios. - * Nearest filtering only (for broken hardware that can't support - * all aspect ratios). This can be made a lot faster, but I don't - * really care enough... - */ -void -_mesa_rescale_teximage2d(GLuint bytesPerPixel, - GLuint srcStrideInPixels, - GLuint dstRowStride, - GLint srcWidth, GLint srcHeight, - GLint dstWidth, GLint dstHeight, - const GLvoid *srcImage, GLvoid *dstImage) -{ - GLint row, col; - -#define INNER_LOOP( TYPE, HOP, WOP ) \ - for ( row = 0 ; row < dstHeight ; row++ ) { \ - GLint srcRow = row HOP hScale; \ - for ( col = 0 ; col < dstWidth ; col++ ) { \ - GLint srcCol = col WOP wScale; \ - dst[col] = src[srcRow * srcStrideInPixels + srcCol]; \ - } \ - dst = (TYPE *) ((GLubyte *) dst + dstRowStride); \ - } \ - -#define RESCALE_IMAGE( TYPE ) \ -do { \ - const TYPE *src = (const TYPE *)srcImage; \ - TYPE *dst = (TYPE *)dstImage; \ - \ - if ( srcHeight < dstHeight ) { \ - const GLint hScale = dstHeight / srcHeight; \ - if ( srcWidth < dstWidth ) { \ - const GLint wScale = dstWidth / srcWidth; \ - INNER_LOOP( TYPE, /, / ); \ - } \ - else { \ - const GLint wScale = srcWidth / dstWidth; \ - INNER_LOOP( TYPE, /, * ); \ - } \ - } \ - else { \ - const GLint hScale = srcHeight / dstHeight; \ - if ( srcWidth < dstWidth ) { \ - const GLint wScale = dstWidth / srcWidth; \ - INNER_LOOP( TYPE, *, / ); \ - } \ - else { \ - const GLint wScale = srcWidth / dstWidth; \ - INNER_LOOP( TYPE, *, * ); \ - } \ - } \ -} while (0) - - switch ( bytesPerPixel ) { - case 4: - RESCALE_IMAGE( GLuint ); - break; - - case 2: - RESCALE_IMAGE( GLushort ); - break; - - case 1: - RESCALE_IMAGE( GLubyte ); - break; - default: - _mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d"); - } -} - - -/** - * Upscale an image by replication, not (typical) stretching. - * We use this when the image width or height is less than a - * certain size (4, 8) and we need to upscale an image. - */ -void -_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight, - GLsizei outWidth, GLsizei outHeight, - GLint comps, const GLchan *src, GLint srcRowStride, - GLchan *dest ) -{ - GLint i, j, k; - - ASSERT(outWidth >= inWidth); - ASSERT(outHeight >= inHeight); -#if 0 - ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2); - ASSERT((outWidth & 3) == 0); - ASSERT((outHeight & 3) == 0); -#endif - - for (i = 0; i < outHeight; i++) { - const GLint ii = i % inHeight; - for (j = 0; j < outWidth; j++) { - const GLint jj = j % inWidth; - for (k = 0; k < comps; k++) { - dest[(i * outWidth + j) * comps + k] - = src[ii * srcRowStride + jj * comps + k]; - } - } - } -} - +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file mipmap.c mipmap generation and teximage resizing functions. + */ + +#include "imports.h" +#include "formats.h" +#include "mipmap.h" +#include "teximage.h" +#include "texstore.h" +#include "image.h" + + + +static GLint +bytes_per_pixel(GLenum datatype, GLuint comps) +{ + GLint b = _mesa_sizeof_packed_type(datatype); + assert(b >= 0); + + if (_mesa_type_is_packed(datatype)) + return b; + else + return b * comps; +} + + +/** + * \name Support macros for do_row and do_row_3d + * + * The macro madness is here for two reasons. First, it compacts the code + * slightly. Second, it makes it much easier to adjust the specifics of the + * filter to tune the rounding characteristics. + */ +/*@{*/ +#define DECLARE_ROW_POINTERS(t, e) \ + const t(*rowA)[e] = (const t(*)[e]) srcRowA; \ + const t(*rowB)[e] = (const t(*)[e]) srcRowB; \ + const t(*rowC)[e] = (const t(*)[e]) srcRowC; \ + const t(*rowD)[e] = (const t(*)[e]) srcRowD; \ + t(*dst)[e] = (t(*)[e]) dstRow + +#define DECLARE_ROW_POINTERS0(t) \ + const t *rowA = (const t *) srcRowA; \ + const t *rowB = (const t *) srcRowB; \ + const t *rowC = (const t *) srcRowC; \ + const t *rowD = (const t *) srcRowD; \ + t *dst = (t *) dstRow + +#define FILTER_SUM_3D(Aj, Ak, Bj, Bk, Cj, Ck, Dj, Dk) \ + ((unsigned) Aj + (unsigned) Ak \ + + (unsigned) Bj + (unsigned) Bk \ + + (unsigned) Cj + (unsigned) Ck \ + + (unsigned) Dj + (unsigned) Dk \ + + 4) >> 3 + +#define FILTER_3D(e) \ + do { \ + dst[i][e] = FILTER_SUM_3D(rowA[j][e], rowA[k][e], \ + rowB[j][e], rowB[k][e], \ + rowC[j][e], rowC[k][e], \ + rowD[j][e], rowD[k][e]); \ + } while(0) + +#define FILTER_SUM_3D_SIGNED(Aj, Ak, Bj, Bk, Cj, Ck, Dj, Dk) \ + (Aj + Ak \ + + Bj + Bk \ + + Cj + Ck \ + + Dj + Dk \ + + 4) / 8 + +#define FILTER_3D_SIGNED(e) \ + do { \ + dst[i][e] = FILTER_SUM_3D_SIGNED(rowA[j][e], rowA[k][e], \ + rowB[j][e], rowB[k][e], \ + rowC[j][e], rowC[k][e], \ + rowD[j][e], rowD[k][e]); \ + } while(0) + +#define FILTER_F_3D(e) \ + do { \ + dst[i][e] = (rowA[j][e] + rowA[k][e] \ + + rowB[j][e] + rowB[k][e] \ + + rowC[j][e] + rowC[k][e] \ + + rowD[j][e] + rowD[k][e]) * 0.125F; \ + } while(0) + +#define FILTER_HF_3D(e) \ + do { \ + const GLfloat aj = _mesa_half_to_float(rowA[j][e]); \ + const GLfloat ak = _mesa_half_to_float(rowA[k][e]); \ + const GLfloat bj = _mesa_half_to_float(rowB[j][e]); \ + const GLfloat bk = _mesa_half_to_float(rowB[k][e]); \ + const GLfloat cj = _mesa_half_to_float(rowC[j][e]); \ + const GLfloat ck = _mesa_half_to_float(rowC[k][e]); \ + const GLfloat dj = _mesa_half_to_float(rowD[j][e]); \ + const GLfloat dk = _mesa_half_to_float(rowD[k][e]); \ + dst[i][e] = _mesa_float_to_half((aj + ak + bj + bk + cj + ck + dj + dk) \ + * 0.125F); \ + } while(0) +/*@}*/ + + +/** + * Average together two rows of a source image to produce a single new + * row in the dest image. It's legal for the two source rows to point + * to the same data. The source width must be equal to either the + * dest width or two times the dest width. + * \param datatype GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_FLOAT, etc. + * \param comps number of components per pixel (1..4) + */ +static void +do_row(GLenum datatype, GLuint comps, GLint srcWidth, + const GLvoid *srcRowA, const GLvoid *srcRowB, + GLint dstWidth, GLvoid *dstRow) +{ + const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1; + const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; + + ASSERT(comps >= 1); + ASSERT(comps <= 4); + + /* This assertion is no longer valid with non-power-of-2 textures + assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth); + */ + + if (datatype == GL_UNSIGNED_BYTE && comps == 4) { + GLuint i, j, k; + const GLubyte(*rowA)[4] = (const GLubyte(*)[4]) srcRowA; + const GLubyte(*rowB)[4] = (const GLubyte(*)[4]) srcRowB; + GLubyte(*dst)[4] = (GLubyte(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; + } + } + else if (datatype == GL_UNSIGNED_BYTE && comps == 3) { + GLuint i, j, k; + const GLubyte(*rowA)[3] = (const GLubyte(*)[3]) srcRowA; + const GLubyte(*rowB)[3] = (const GLubyte(*)[3]) srcRowB; + GLubyte(*dst)[3] = (GLubyte(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + } + } + else if (datatype == GL_UNSIGNED_BYTE && comps == 2) { + GLuint i, j, k; + const GLubyte(*rowA)[2] = (const GLubyte(*)[2]) srcRowA; + const GLubyte(*rowB)[2] = (const GLubyte(*)[2]) srcRowB; + GLubyte(*dst)[2] = (GLubyte(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) >> 2; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) >> 2; + } + } + else if (datatype == GL_UNSIGNED_BYTE && comps == 1) { + GLuint i, j, k; + const GLubyte *rowA = (const GLubyte *) srcRowA; + const GLubyte *rowB = (const GLubyte *) srcRowB; + GLubyte *dst = (GLubyte *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) >> 2; + } + } + + else if (datatype == GL_BYTE && comps == 4) { + GLuint i, j, k; + const GLbyte(*rowA)[4] = (const GLbyte(*)[4]) srcRowA; + const GLbyte(*rowB)[4] = (const GLbyte(*)[4]) srcRowB; + GLbyte(*dst)[4] = (GLbyte(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; + } + } + else if (datatype == GL_BYTE && comps == 3) { + GLuint i, j, k; + const GLbyte(*rowA)[3] = (const GLbyte(*)[3]) srcRowA; + const GLbyte(*rowB)[3] = (const GLbyte(*)[3]) srcRowB; + GLbyte(*dst)[3] = (GLbyte(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + } + } + else if (datatype == GL_BYTE && comps == 2) { + GLuint i, j, k; + const GLbyte(*rowA)[2] = (const GLbyte(*)[2]) srcRowA; + const GLbyte(*rowB)[2] = (const GLbyte(*)[2]) srcRowB; + GLbyte(*dst)[2] = (GLbyte(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + } + } + else if (datatype == GL_BYTE && comps == 1) { + GLuint i, j, k; + const GLbyte *rowA = (const GLbyte *) srcRowA; + const GLbyte *rowB = (const GLbyte *) srcRowB; + GLbyte *dst = (GLbyte *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; + } + } + + else if (datatype == GL_UNSIGNED_SHORT && comps == 4) { + GLuint i, j, k; + const GLushort(*rowA)[4] = (const GLushort(*)[4]) srcRowA; + const GLushort(*rowB)[4] = (const GLushort(*)[4]) srcRowB; + GLushort(*dst)[4] = (GLushort(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; + } + } + else if (datatype == GL_UNSIGNED_SHORT && comps == 3) { + GLuint i, j, k; + const GLushort(*rowA)[3] = (const GLushort(*)[3]) srcRowA; + const GLushort(*rowB)[3] = (const GLushort(*)[3]) srcRowB; + GLushort(*dst)[3] = (GLushort(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + } + } + else if (datatype == GL_UNSIGNED_SHORT && comps == 2) { + GLuint i, j, k; + const GLushort(*rowA)[2] = (const GLushort(*)[2]) srcRowA; + const GLushort(*rowB)[2] = (const GLushort(*)[2]) srcRowB; + GLushort(*dst)[2] = (GLushort(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + } + } + else if (datatype == GL_UNSIGNED_SHORT && comps == 1) { + GLuint i, j, k; + const GLushort *rowA = (const GLushort *) srcRowA; + const GLushort *rowB = (const GLushort *) srcRowB; + GLushort *dst = (GLushort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; + } + } + + else if (datatype == GL_SHORT && comps == 4) { + GLuint i, j, k; + const GLshort(*rowA)[4] = (const GLshort(*)[4]) srcRowA; + const GLshort(*rowB)[4] = (const GLshort(*)[4]) srcRowB; + GLshort(*dst)[4] = (GLshort(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4; + } + } + else if (datatype == GL_SHORT && comps == 3) { + GLuint i, j, k; + const GLshort(*rowA)[3] = (const GLshort(*)[3]) srcRowA; + const GLshort(*rowB)[3] = (const GLshort(*)[3]) srcRowB; + GLshort(*dst)[3] = (GLshort(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4; + } + } + else if (datatype == GL_SHORT && comps == 2) { + GLuint i, j, k; + const GLshort(*rowA)[2] = (const GLshort(*)[2]) srcRowA; + const GLshort(*rowB)[2] = (const GLshort(*)[2]) srcRowB; + GLshort(*dst)[2] = (GLshort(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4; + dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4; + } + } + else if (datatype == GL_SHORT && comps == 1) { + GLuint i, j, k; + const GLshort *rowA = (const GLshort *) srcRowA; + const GLshort *rowB = (const GLshort *) srcRowB; + GLshort *dst = (GLshort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4; + } + } + + else if (datatype == GL_FLOAT && comps == 4) { + GLuint i, j, k; + const GLfloat(*rowA)[4] = (const GLfloat(*)[4]) srcRowA; + const GLfloat(*rowB)[4] = (const GLfloat(*)[4]) srcRowB; + GLfloat(*dst)[4] = (GLfloat(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + + rowB[j][0] + rowB[k][0]) * 0.25F; + dst[i][1] = (rowA[j][1] + rowA[k][1] + + rowB[j][1] + rowB[k][1]) * 0.25F; + dst[i][2] = (rowA[j][2] + rowA[k][2] + + rowB[j][2] + rowB[k][2]) * 0.25F; + dst[i][3] = (rowA[j][3] + rowA[k][3] + + rowB[j][3] + rowB[k][3]) * 0.25F; + } + } + else if (datatype == GL_FLOAT && comps == 3) { + GLuint i, j, k; + const GLfloat(*rowA)[3] = (const GLfloat(*)[3]) srcRowA; + const GLfloat(*rowB)[3] = (const GLfloat(*)[3]) srcRowB; + GLfloat(*dst)[3] = (GLfloat(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + + rowB[j][0] + rowB[k][0]) * 0.25F; + dst[i][1] = (rowA[j][1] + rowA[k][1] + + rowB[j][1] + rowB[k][1]) * 0.25F; + dst[i][2] = (rowA[j][2] + rowA[k][2] + + rowB[j][2] + rowB[k][2]) * 0.25F; + } + } + else if (datatype == GL_FLOAT && comps == 2) { + GLuint i, j, k; + const GLfloat(*rowA)[2] = (const GLfloat(*)[2]) srcRowA; + const GLfloat(*rowB)[2] = (const GLfloat(*)[2]) srcRowB; + GLfloat(*dst)[2] = (GLfloat(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i][0] = (rowA[j][0] + rowA[k][0] + + rowB[j][0] + rowB[k][0]) * 0.25F; + dst[i][1] = (rowA[j][1] + rowA[k][1] + + rowB[j][1] + rowB[k][1]) * 0.25F; + } + } + else if (datatype == GL_FLOAT && comps == 1) { + GLuint i, j, k; + const GLfloat *rowA = (const GLfloat *) srcRowA; + const GLfloat *rowB = (const GLfloat *) srcRowB; + GLfloat *dst = (GLfloat *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F; + } + } + + else if (datatype == GL_HALF_FLOAT_ARB && comps == 4) { + GLuint i, j, k, comp; + const GLhalfARB(*rowA)[4] = (const GLhalfARB(*)[4]) srcRowA; + const GLhalfARB(*rowB)[4] = (const GLhalfARB(*)[4]) srcRowB; + GLhalfARB(*dst)[4] = (GLhalfARB(*)[4]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + for (comp = 0; comp < 4; comp++) { + GLfloat aj, ak, bj, bk; + aj = _mesa_half_to_float(rowA[j][comp]); + ak = _mesa_half_to_float(rowA[k][comp]); + bj = _mesa_half_to_float(rowB[j][comp]); + bk = _mesa_half_to_float(rowB[k][comp]); + dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); + } + } + } + else if (datatype == GL_HALF_FLOAT_ARB && comps == 3) { + GLuint i, j, k, comp; + const GLhalfARB(*rowA)[3] = (const GLhalfARB(*)[3]) srcRowA; + const GLhalfARB(*rowB)[3] = (const GLhalfARB(*)[3]) srcRowB; + GLhalfARB(*dst)[3] = (GLhalfARB(*)[3]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + for (comp = 0; comp < 3; comp++) { + GLfloat aj, ak, bj, bk; + aj = _mesa_half_to_float(rowA[j][comp]); + ak = _mesa_half_to_float(rowA[k][comp]); + bj = _mesa_half_to_float(rowB[j][comp]); + bk = _mesa_half_to_float(rowB[k][comp]); + dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); + } + } + } + else if (datatype == GL_HALF_FLOAT_ARB && comps == 2) { + GLuint i, j, k, comp; + const GLhalfARB(*rowA)[2] = (const GLhalfARB(*)[2]) srcRowA; + const GLhalfARB(*rowB)[2] = (const GLhalfARB(*)[2]) srcRowB; + GLhalfARB(*dst)[2] = (GLhalfARB(*)[2]) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + for (comp = 0; comp < 2; comp++) { + GLfloat aj, ak, bj, bk; + aj = _mesa_half_to_float(rowA[j][comp]); + ak = _mesa_half_to_float(rowA[k][comp]); + bj = _mesa_half_to_float(rowB[j][comp]); + bk = _mesa_half_to_float(rowB[k][comp]); + dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); + } + } + } + else if (datatype == GL_HALF_FLOAT_ARB && comps == 1) { + GLuint i, j, k; + const GLhalfARB *rowA = (const GLhalfARB *) srcRowA; + const GLhalfARB *rowB = (const GLhalfARB *) srcRowB; + GLhalfARB *dst = (GLhalfARB *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + GLfloat aj, ak, bj, bk; + aj = _mesa_half_to_float(rowA[j]); + ak = _mesa_half_to_float(rowA[k]); + bj = _mesa_half_to_float(rowB[j]); + bk = _mesa_half_to_float(rowB[k]); + dst[i] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F); + } + } + + else if (datatype == GL_UNSIGNED_INT && comps == 1) { + GLuint i, j, k; + const GLuint *rowA = (const GLuint *) srcRowA; + const GLuint *rowB = (const GLuint *) srcRowB; + GLuint *dst = (GLuint *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + dst[i] = (GLfloat)(rowA[j] / 4 + rowA[k] / 4 + rowB[j] / 4 + rowB[k] / 4); + } + } + + else if (datatype == GL_UNSIGNED_SHORT_5_6_5 && comps == 3) { + GLuint i, j, k; + const GLushort *rowA = (const GLushort *) srcRowA; + const GLushort *rowB = (const GLushort *) srcRowB; + GLushort *dst = (GLushort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x1f; + const GLint rowAr1 = rowA[k] & 0x1f; + const GLint rowBr0 = rowB[j] & 0x1f; + const GLint rowBr1 = rowB[k] & 0x1f; + const GLint rowAg0 = (rowA[j] >> 5) & 0x3f; + const GLint rowAg1 = (rowA[k] >> 5) & 0x3f; + const GLint rowBg0 = (rowB[j] >> 5) & 0x3f; + const GLint rowBg1 = (rowB[k] >> 5) & 0x3f; + const GLint rowAb0 = (rowA[j] >> 11) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 11) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 11) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 11) & 0x1f; + const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; + const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; + const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; + dst[i] = (blue << 11) | (green << 5) | red; + } + } + else if (datatype == GL_UNSIGNED_SHORT_4_4_4_4 && comps == 4) { + GLuint i, j, k; + const GLushort *rowA = (const GLushort *) srcRowA; + const GLushort *rowB = (const GLushort *) srcRowB; + GLushort *dst = (GLushort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0xf; + const GLint rowAr1 = rowA[k] & 0xf; + const GLint rowBr0 = rowB[j] & 0xf; + const GLint rowBr1 = rowB[k] & 0xf; + const GLint rowAg0 = (rowA[j] >> 4) & 0xf; + const GLint rowAg1 = (rowA[k] >> 4) & 0xf; + const GLint rowBg0 = (rowB[j] >> 4) & 0xf; + const GLint rowBg1 = (rowB[k] >> 4) & 0xf; + const GLint rowAb0 = (rowA[j] >> 8) & 0xf; + const GLint rowAb1 = (rowA[k] >> 8) & 0xf; + const GLint rowBb0 = (rowB[j] >> 8) & 0xf; + const GLint rowBb1 = (rowB[k] >> 8) & 0xf; + const GLint rowAa0 = (rowA[j] >> 12) & 0xf; + const GLint rowAa1 = (rowA[k] >> 12) & 0xf; + const GLint rowBa0 = (rowB[j] >> 12) & 0xf; + const GLint rowBa1 = (rowB[k] >> 12) & 0xf; + const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; + const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; + const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; + const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2; + dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red; + } + } + else if (datatype == GL_UNSIGNED_SHORT_1_5_5_5_REV && comps == 4) { + GLuint i, j, k; + const GLushort *rowA = (const GLushort *) srcRowA; + const GLushort *rowB = (const GLushort *) srcRowB; + GLushort *dst = (GLushort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x1f; + const GLint rowAr1 = rowA[k] & 0x1f; + const GLint rowBr0 = rowB[j] & 0x1f; + const GLint rowBr1 = rowB[k] & 0x1f; + const GLint rowAg0 = (rowA[j] >> 5) & 0x1f; + const GLint rowAg1 = (rowA[k] >> 5) & 0x1f; + const GLint rowBg0 = (rowB[j] >> 5) & 0x1f; + const GLint rowBg1 = (rowB[k] >> 5) & 0x1f; + const GLint rowAb0 = (rowA[j] >> 10) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 10) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 10) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 10) & 0x1f; + const GLint rowAa0 = (rowA[j] >> 15) & 0x1; + const GLint rowAa1 = (rowA[k] >> 15) & 0x1; + const GLint rowBa0 = (rowB[j] >> 15) & 0x1; + const GLint rowBa1 = (rowB[k] >> 15) & 0x1; + const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; + const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; + const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; + const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2; + dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red; + } + } + else if (datatype == GL_UNSIGNED_SHORT_5_5_5_1 && comps == 4) { + GLuint i, j, k; + const GLushort *rowA = (const GLushort *) srcRowA; + const GLushort *rowB = (const GLushort *) srcRowB; + GLushort *dst = (GLushort *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = (rowA[j] >> 11) & 0x1f; + const GLint rowAr1 = (rowA[k] >> 11) & 0x1f; + const GLint rowBr0 = (rowB[j] >> 11) & 0x1f; + const GLint rowBr1 = (rowB[k] >> 11) & 0x1f; + const GLint rowAg0 = (rowA[j] >> 6) & 0x1f; + const GLint rowAg1 = (rowA[k] >> 6) & 0x1f; + const GLint rowBg0 = (rowB[j] >> 6) & 0x1f; + const GLint rowBg1 = (rowB[k] >> 6) & 0x1f; + const GLint rowAb0 = (rowA[j] >> 1) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 1) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 1) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 1) & 0x1f; + const GLint rowAa0 = (rowA[j] & 0x1); + const GLint rowAa1 = (rowA[k] & 0x1); + const GLint rowBa0 = (rowB[j] & 0x1); + const GLint rowBa1 = (rowB[k] & 0x1); + const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; + const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; + const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; + const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2; + dst[i] = (red << 11) | (green << 6) | (blue << 1) | alpha; + } + } + + else if (datatype == GL_UNSIGNED_BYTE_3_3_2 && comps == 3) { + GLuint i, j, k; + const GLubyte *rowA = (const GLubyte *) srcRowA; + const GLubyte *rowB = (const GLubyte *) srcRowB; + GLubyte *dst = (GLubyte *) dstRow; + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x3; + const GLint rowAr1 = rowA[k] & 0x3; + const GLint rowBr0 = rowB[j] & 0x3; + const GLint rowBr1 = rowB[k] & 0x3; + const GLint rowAg0 = (rowA[j] >> 2) & 0x7; + const GLint rowAg1 = (rowA[k] >> 2) & 0x7; + const GLint rowBg0 = (rowB[j] >> 2) & 0x7; + const GLint rowBg1 = (rowB[k] >> 2) & 0x7; + const GLint rowAb0 = (rowA[j] >> 5) & 0x7; + const GLint rowAb1 = (rowA[k] >> 5) & 0x7; + const GLint rowBb0 = (rowB[j] >> 5) & 0x7; + const GLint rowBb1 = (rowB[k] >> 5) & 0x7; + const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2; + const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2; + const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2; + dst[i] = (blue << 5) | (green << 2) | red; + } + } + else { + _mesa_problem(NULL, "bad format in do_row()"); + } +} + + +/** + * Average together four rows of a source image to produce a single new + * row in the dest image. It's legal for the two source rows to point + * to the same data. The source width must be equal to either the + * dest width or two times the dest width. + * + * \param datatype GL pixel type \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, + * \c GL_FLOAT, etc. + * \param comps number of components per pixel (1..4) + * \param srcWidth Width of a row in the source data + * \param srcRowA Pointer to one of the rows of source data + * \param srcRowB Pointer to one of the rows of source data + * \param srcRowC Pointer to one of the rows of source data + * \param srcRowD Pointer to one of the rows of source data + * \param dstWidth Width of a row in the destination data + * \param srcRowA Pointer to the row of destination data + */ +static void +do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth, + const GLvoid *srcRowA, const GLvoid *srcRowB, + const GLvoid *srcRowC, const GLvoid *srcRowD, + GLint dstWidth, GLvoid *dstRow) +{ + const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1; + const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; + GLuint i, j, k; + + ASSERT(comps >= 1); + ASSERT(comps <= 4); + + if ((datatype == GL_UNSIGNED_BYTE) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLubyte, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + FILTER_3D(3); + } + } + else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLubyte, 3); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + } + } + else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLubyte, 2); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + } + } + else if ((datatype == GL_UNSIGNED_BYTE) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLubyte, 1); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + } + } + else if ((datatype == GL_BYTE) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLbyte, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D_SIGNED(0); + FILTER_3D_SIGNED(1); + FILTER_3D_SIGNED(2); + FILTER_3D_SIGNED(3); + } + } + else if ((datatype == GL_BYTE) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLbyte, 3); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D_SIGNED(0); + FILTER_3D_SIGNED(1); + FILTER_3D_SIGNED(2); + } + } + else if ((datatype == GL_BYTE) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLbyte, 2); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D_SIGNED(0); + FILTER_3D_SIGNED(1); + } + } + else if ((datatype == GL_BYTE) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLbyte, 1); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D_SIGNED(0); + } + } + else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLushort, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + FILTER_3D(3); + } + } + else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLushort, 3); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + } + } + else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLushort, 2); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + } + } + else if ((datatype == GL_UNSIGNED_SHORT) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLushort, 1); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + } + } + else if ((datatype == GL_SHORT) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLshort, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + FILTER_3D(3); + } + } + else if ((datatype == GL_SHORT) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLshort, 3); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + FILTER_3D(2); + } + } + else if ((datatype == GL_SHORT) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLshort, 2); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + FILTER_3D(1); + } + } + else if ((datatype == GL_SHORT) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLshort, 1); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_3D(0); + } + } + else if ((datatype == GL_FLOAT) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLfloat, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_F_3D(0); + FILTER_F_3D(1); + FILTER_F_3D(2); + FILTER_F_3D(3); + } + } + else if ((datatype == GL_FLOAT) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLfloat, 3); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_F_3D(0); + FILTER_F_3D(1); + FILTER_F_3D(2); + } + } + else if ((datatype == GL_FLOAT) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLfloat, 2); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_F_3D(0); + FILTER_F_3D(1); + } + } + else if ((datatype == GL_FLOAT) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLfloat, 1); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_F_3D(0); + } + } + else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 4)) { + DECLARE_ROW_POINTERS(GLhalfARB, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_HF_3D(0); + FILTER_HF_3D(1); + FILTER_HF_3D(2); + FILTER_HF_3D(3); + } + } + else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 3)) { + DECLARE_ROW_POINTERS(GLhalfARB, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_HF_3D(0); + FILTER_HF_3D(1); + FILTER_HF_3D(2); + } + } + else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 2)) { + DECLARE_ROW_POINTERS(GLhalfARB, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_HF_3D(0); + FILTER_HF_3D(1); + } + } + else if ((datatype == GL_HALF_FLOAT_ARB) && (comps == 1)) { + DECLARE_ROW_POINTERS(GLhalfARB, 4); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + FILTER_HF_3D(0); + } + } + else if ((datatype == GL_UNSIGNED_INT) && (comps == 1)) { + const GLuint *rowA = (const GLuint *) srcRowA; + const GLuint *rowB = (const GLuint *) srcRowB; + const GLuint *rowC = (const GLuint *) srcRowC; + const GLuint *rowD = (const GLuint *) srcRowD; + GLfloat *dst = (GLfloat *) dstRow; + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const uint64_t tmp = (((uint64_t) rowA[j] + (uint64_t) rowA[k]) + + ((uint64_t) rowB[j] + (uint64_t) rowB[k]) + + ((uint64_t) rowC[j] + (uint64_t) rowC[k]) + + ((uint64_t) rowD[j] + (uint64_t) rowD[k])); + dst[i] = (GLfloat)((double) tmp * 0.125); + } + } + else if ((datatype == GL_UNSIGNED_SHORT_5_6_5) && (comps == 3)) { + DECLARE_ROW_POINTERS0(GLushort); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x1f; + const GLint rowAr1 = rowA[k] & 0x1f; + const GLint rowBr0 = rowB[j] & 0x1f; + const GLint rowBr1 = rowB[k] & 0x1f; + const GLint rowCr0 = rowC[j] & 0x1f; + const GLint rowCr1 = rowC[k] & 0x1f; + const GLint rowDr0 = rowD[j] & 0x1f; + const GLint rowDr1 = rowD[k] & 0x1f; + const GLint rowAg0 = (rowA[j] >> 5) & 0x3f; + const GLint rowAg1 = (rowA[k] >> 5) & 0x3f; + const GLint rowBg0 = (rowB[j] >> 5) & 0x3f; + const GLint rowBg1 = (rowB[k] >> 5) & 0x3f; + const GLint rowCg0 = (rowC[j] >> 5) & 0x3f; + const GLint rowCg1 = (rowC[k] >> 5) & 0x3f; + const GLint rowDg0 = (rowD[j] >> 5) & 0x3f; + const GLint rowDg1 = (rowD[k] >> 5) & 0x3f; + const GLint rowAb0 = (rowA[j] >> 11) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 11) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 11) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 11) & 0x1f; + const GLint rowCb0 = (rowC[j] >> 11) & 0x1f; + const GLint rowCb1 = (rowC[k] >> 11) & 0x1f; + const GLint rowDb0 = (rowD[j] >> 11) & 0x1f; + const GLint rowDb1 = (rowD[k] >> 11) & 0x1f; + const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, + rowCr0, rowCr1, rowDr0, rowDr1); + const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, + rowCg0, rowCg1, rowDg0, rowDg1); + const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, + rowCb0, rowCb1, rowDb0, rowDb1); + dst[i] = (b << 11) | (g << 5) | r; + } + } + else if ((datatype == GL_UNSIGNED_SHORT_4_4_4_4) && (comps == 4)) { + DECLARE_ROW_POINTERS0(GLushort); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0xf; + const GLint rowAr1 = rowA[k] & 0xf; + const GLint rowBr0 = rowB[j] & 0xf; + const GLint rowBr1 = rowB[k] & 0xf; + const GLint rowCr0 = rowC[j] & 0xf; + const GLint rowCr1 = rowC[k] & 0xf; + const GLint rowDr0 = rowD[j] & 0xf; + const GLint rowDr1 = rowD[k] & 0xf; + const GLint rowAg0 = (rowA[j] >> 4) & 0xf; + const GLint rowAg1 = (rowA[k] >> 4) & 0xf; + const GLint rowBg0 = (rowB[j] >> 4) & 0xf; + const GLint rowBg1 = (rowB[k] >> 4) & 0xf; + const GLint rowCg0 = (rowC[j] >> 4) & 0xf; + const GLint rowCg1 = (rowC[k] >> 4) & 0xf; + const GLint rowDg0 = (rowD[j] >> 4) & 0xf; + const GLint rowDg1 = (rowD[k] >> 4) & 0xf; + const GLint rowAb0 = (rowA[j] >> 8) & 0xf; + const GLint rowAb1 = (rowA[k] >> 8) & 0xf; + const GLint rowBb0 = (rowB[j] >> 8) & 0xf; + const GLint rowBb1 = (rowB[k] >> 8) & 0xf; + const GLint rowCb0 = (rowC[j] >> 8) & 0xf; + const GLint rowCb1 = (rowC[k] >> 8) & 0xf; + const GLint rowDb0 = (rowD[j] >> 8) & 0xf; + const GLint rowDb1 = (rowD[k] >> 8) & 0xf; + const GLint rowAa0 = (rowA[j] >> 12) & 0xf; + const GLint rowAa1 = (rowA[k] >> 12) & 0xf; + const GLint rowBa0 = (rowB[j] >> 12) & 0xf; + const GLint rowBa1 = (rowB[k] >> 12) & 0xf; + const GLint rowCa0 = (rowC[j] >> 12) & 0xf; + const GLint rowCa1 = (rowC[k] >> 12) & 0xf; + const GLint rowDa0 = (rowD[j] >> 12) & 0xf; + const GLint rowDa1 = (rowD[k] >> 12) & 0xf; + const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, + rowCr0, rowCr1, rowDr0, rowDr1); + const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, + rowCg0, rowCg1, rowDg0, rowDg1); + const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, + rowCb0, rowCb1, rowDb0, rowDb1); + const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1, + rowCa0, rowCa1, rowDa0, rowDa1); + + dst[i] = (a << 12) | (b << 8) | (g << 4) | r; + } + } + else if ((datatype == GL_UNSIGNED_SHORT_1_5_5_5_REV) && (comps == 4)) { + DECLARE_ROW_POINTERS0(GLushort); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x1f; + const GLint rowAr1 = rowA[k] & 0x1f; + const GLint rowBr0 = rowB[j] & 0x1f; + const GLint rowBr1 = rowB[k] & 0x1f; + const GLint rowCr0 = rowC[j] & 0x1f; + const GLint rowCr1 = rowC[k] & 0x1f; + const GLint rowDr0 = rowD[j] & 0x1f; + const GLint rowDr1 = rowD[k] & 0x1f; + const GLint rowAg0 = (rowA[j] >> 5) & 0x1f; + const GLint rowAg1 = (rowA[k] >> 5) & 0x1f; + const GLint rowBg0 = (rowB[j] >> 5) & 0x1f; + const GLint rowBg1 = (rowB[k] >> 5) & 0x1f; + const GLint rowCg0 = (rowC[j] >> 5) & 0x1f; + const GLint rowCg1 = (rowC[k] >> 5) & 0x1f; + const GLint rowDg0 = (rowD[j] >> 5) & 0x1f; + const GLint rowDg1 = (rowD[k] >> 5) & 0x1f; + const GLint rowAb0 = (rowA[j] >> 10) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 10) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 10) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 10) & 0x1f; + const GLint rowCb0 = (rowC[j] >> 10) & 0x1f; + const GLint rowCb1 = (rowC[k] >> 10) & 0x1f; + const GLint rowDb0 = (rowD[j] >> 10) & 0x1f; + const GLint rowDb1 = (rowD[k] >> 10) & 0x1f; + const GLint rowAa0 = (rowA[j] >> 15) & 0x1; + const GLint rowAa1 = (rowA[k] >> 15) & 0x1; + const GLint rowBa0 = (rowB[j] >> 15) & 0x1; + const GLint rowBa1 = (rowB[k] >> 15) & 0x1; + const GLint rowCa0 = (rowC[j] >> 15) & 0x1; + const GLint rowCa1 = (rowC[k] >> 15) & 0x1; + const GLint rowDa0 = (rowD[j] >> 15) & 0x1; + const GLint rowDa1 = (rowD[k] >> 15) & 0x1; + const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, + rowCr0, rowCr1, rowDr0, rowDr1); + const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, + rowCg0, rowCg1, rowDg0, rowDg1); + const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, + rowCb0, rowCb1, rowDb0, rowDb1); + const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1, + rowCa0, rowCa1, rowDa0, rowDa1); + + dst[i] = (a << 15) | (b << 10) | (g << 5) | r; + } + } + else if ((datatype == GL_UNSIGNED_SHORT_5_5_5_1) && (comps == 4)) { + DECLARE_ROW_POINTERS0(GLushort); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = (rowA[j] >> 11) & 0x1f; + const GLint rowAr1 = (rowA[k] >> 11) & 0x1f; + const GLint rowBr0 = (rowB[j] >> 11) & 0x1f; + const GLint rowBr1 = (rowB[k] >> 11) & 0x1f; + const GLint rowCr0 = (rowC[j] >> 11) & 0x1f; + const GLint rowCr1 = (rowC[k] >> 11) & 0x1f; + const GLint rowDr0 = (rowD[j] >> 11) & 0x1f; + const GLint rowDr1 = (rowD[k] >> 11) & 0x1f; + const GLint rowAg0 = (rowA[j] >> 6) & 0x1f; + const GLint rowAg1 = (rowA[k] >> 6) & 0x1f; + const GLint rowBg0 = (rowB[j] >> 6) & 0x1f; + const GLint rowBg1 = (rowB[k] >> 6) & 0x1f; + const GLint rowCg0 = (rowC[j] >> 6) & 0x1f; + const GLint rowCg1 = (rowC[k] >> 6) & 0x1f; + const GLint rowDg0 = (rowD[j] >> 6) & 0x1f; + const GLint rowDg1 = (rowD[k] >> 6) & 0x1f; + const GLint rowAb0 = (rowA[j] >> 1) & 0x1f; + const GLint rowAb1 = (rowA[k] >> 1) & 0x1f; + const GLint rowBb0 = (rowB[j] >> 1) & 0x1f; + const GLint rowBb1 = (rowB[k] >> 1) & 0x1f; + const GLint rowCb0 = (rowC[j] >> 1) & 0x1f; + const GLint rowCb1 = (rowC[k] >> 1) & 0x1f; + const GLint rowDb0 = (rowD[j] >> 1) & 0x1f; + const GLint rowDb1 = (rowD[k] >> 1) & 0x1f; + const GLint rowAa0 = (rowA[j] & 0x1); + const GLint rowAa1 = (rowA[k] & 0x1); + const GLint rowBa0 = (rowB[j] & 0x1); + const GLint rowBa1 = (rowB[k] & 0x1); + const GLint rowCa0 = (rowC[j] & 0x1); + const GLint rowCa1 = (rowC[k] & 0x1); + const GLint rowDa0 = (rowD[j] & 0x1); + const GLint rowDa1 = (rowD[k] & 0x1); + const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, + rowCr0, rowCr1, rowDr0, rowDr1); + const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, + rowCg0, rowCg1, rowDg0, rowDg1); + const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, + rowCb0, rowCb1, rowDb0, rowDb1); + const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1, + rowCa0, rowCa1, rowDa0, rowDa1); + + dst[i] = (r << 11) | (g << 6) | (b << 1) | a; + } + } + else if ((datatype == GL_UNSIGNED_BYTE_3_3_2) && (comps == 3)) { + DECLARE_ROW_POINTERS0(GLushort); + + for (i = j = 0, k = k0; i < (GLuint) dstWidth; + i++, j += colStride, k += colStride) { + const GLint rowAr0 = rowA[j] & 0x3; + const GLint rowAr1 = rowA[k] & 0x3; + const GLint rowBr0 = rowB[j] & 0x3; + const GLint rowBr1 = rowB[k] & 0x3; + const GLint rowCr0 = rowC[j] & 0x3; + const GLint rowCr1 = rowC[k] & 0x3; + const GLint rowDr0 = rowD[j] & 0x3; + const GLint rowDr1 = rowD[k] & 0x3; + const GLint rowAg0 = (rowA[j] >> 2) & 0x7; + const GLint rowAg1 = (rowA[k] >> 2) & 0x7; + const GLint rowBg0 = (rowB[j] >> 2) & 0x7; + const GLint rowBg1 = (rowB[k] >> 2) & 0x7; + const GLint rowCg0 = (rowC[j] >> 2) & 0x7; + const GLint rowCg1 = (rowC[k] >> 2) & 0x7; + const GLint rowDg0 = (rowD[j] >> 2) & 0x7; + const GLint rowDg1 = (rowD[k] >> 2) & 0x7; + const GLint rowAb0 = (rowA[j] >> 5) & 0x7; + const GLint rowAb1 = (rowA[k] >> 5) & 0x7; + const GLint rowBb0 = (rowB[j] >> 5) & 0x7; + const GLint rowBb1 = (rowB[k] >> 5) & 0x7; + const GLint rowCb0 = (rowC[j] >> 5) & 0x7; + const GLint rowCb1 = (rowC[k] >> 5) & 0x7; + const GLint rowDb0 = (rowD[j] >> 5) & 0x7; + const GLint rowDb1 = (rowD[k] >> 5) & 0x7; + const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1, + rowCr0, rowCr1, rowDr0, rowDr1); + const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1, + rowCg0, rowCg1, rowDg0, rowDg1); + const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1, + rowCb0, rowCb1, rowDb0, rowDb1); + dst[i] = (b << 5) | (g << 2) | r; + } + } + else { + _mesa_problem(NULL, "bad format in do_row()"); + } +} + + +/* + * These functions generate a 1/2-size mipmap image from a source image. + * Texture borders are handled by copying or averaging the source image's + * border texels, depending on the scale-down factor. + */ + +static void +make_1d_mipmap(GLenum datatype, GLuint comps, GLint border, + GLint srcWidth, const GLubyte *srcPtr, + GLint dstWidth, GLubyte *dstPtr) +{ + const GLint bpt = bytes_per_pixel(datatype, comps); + const GLubyte *src; + GLubyte *dst; + + /* skip the border pixel, if any */ + src = srcPtr + border * bpt; + dst = dstPtr + border * bpt; + + /* we just duplicate the input row, kind of hack, saves code */ + do_row(datatype, comps, srcWidth - 2 * border, src, src, + dstWidth - 2 * border, dst); + + if (border) { + /* copy left-most pixel from source */ + assert(dstPtr); + assert(srcPtr); + memcpy(dstPtr, srcPtr, bpt); + /* copy right-most pixel from source */ + memcpy(dstPtr + (dstWidth - 1) * bpt, + srcPtr + (srcWidth - 1) * bpt, + bpt); + } +} + + +static void +make_2d_mipmap(GLenum datatype, GLuint comps, GLint border, + GLint srcWidth, GLint srcHeight, + const GLubyte *srcPtr, GLint srcRowStride, + GLint dstWidth, GLint dstHeight, + GLubyte *dstPtr, GLint dstRowStride) +{ + const GLint bpt = bytes_per_pixel(datatype, comps); + const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ + const GLint dstWidthNB = dstWidth - 2 * border; + const GLint dstHeightNB = dstHeight - 2 * border; + const GLint srcRowBytes = bpt * srcRowStride; + const GLint dstRowBytes = bpt * dstRowStride; + const GLubyte *srcA, *srcB; + GLubyte *dst; + GLint row, srcRowStep; + + /* Compute src and dst pointers, skipping any border */ + srcA = srcPtr + border * ((srcWidth + 1) * bpt); + if (srcHeight > 1 && srcHeight > dstHeight) { + /* sample from two source rows */ + srcB = srcA + srcRowBytes; + srcRowStep = 2; + } + else { + /* sample from one source row */ + srcB = srcA; + srcRowStep = 1; + } + + dst = dstPtr + border * ((dstWidth + 1) * bpt); + + for (row = 0; row < dstHeightNB; row++) { + do_row(datatype, comps, srcWidthNB, srcA, srcB, + dstWidthNB, dst); + srcA += srcRowStep * srcRowBytes; + srcB += srcRowStep * srcRowBytes; + dst += dstRowBytes; + } + + /* This is ugly but probably won't be used much */ + if (border > 0) { + /* fill in dest border */ + /* lower-left border pixel */ + assert(dstPtr); + assert(srcPtr); + memcpy(dstPtr, srcPtr, bpt); + /* lower-right border pixel */ + memcpy(dstPtr + (dstWidth - 1) * bpt, + srcPtr + (srcWidth - 1) * bpt, bpt); + /* upper-left border pixel */ + memcpy(dstPtr + dstWidth * (dstHeight - 1) * bpt, + srcPtr + srcWidth * (srcHeight - 1) * bpt, bpt); + /* upper-right border pixel */ + memcpy(dstPtr + (dstWidth * dstHeight - 1) * bpt, + srcPtr + (srcWidth * srcHeight - 1) * bpt, bpt); + /* lower border */ + do_row(datatype, comps, srcWidthNB, + srcPtr + bpt, + srcPtr + bpt, + dstWidthNB, dstPtr + bpt); + /* upper border */ + do_row(datatype, comps, srcWidthNB, + srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, + srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, + dstWidthNB, + dstPtr + (dstWidth * (dstHeight - 1) + 1) * bpt); + /* left and right borders */ + if (srcHeight == dstHeight) { + /* copy border pixel from src to dst */ + for (row = 1; row < srcHeight; row++) { + memcpy(dstPtr + dstWidth * row * bpt, + srcPtr + srcWidth * row * bpt, bpt); + memcpy(dstPtr + (dstWidth * row + dstWidth - 1) * bpt, + srcPtr + (srcWidth * row + srcWidth - 1) * bpt, bpt); + } + } + else { + /* average two src pixels each dest pixel */ + for (row = 0; row < dstHeightNB; row += 2) { + do_row(datatype, comps, 1, + srcPtr + (srcWidth * (row * 2 + 1)) * bpt, + srcPtr + (srcWidth * (row * 2 + 2)) * bpt, + 1, dstPtr + (dstWidth * row + 1) * bpt); + do_row(datatype, comps, 1, + srcPtr + (srcWidth * (row * 2 + 1) + srcWidth - 1) * bpt, + srcPtr + (srcWidth * (row * 2 + 2) + srcWidth - 1) * bpt, + 1, dstPtr + (dstWidth * row + 1 + dstWidth - 1) * bpt); + } + } + } +} + + +static void +make_3d_mipmap(GLenum datatype, GLuint comps, GLint border, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLubyte *srcPtr, GLint srcRowStride, + GLint dstWidth, GLint dstHeight, GLint dstDepth, + GLubyte *dstPtr, GLint dstRowStride) +{ + const GLint bpt = bytes_per_pixel(datatype, comps); + const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ + const GLint srcDepthNB = srcDepth - 2 * border; + const GLint dstWidthNB = dstWidth - 2 * border; + const GLint dstHeightNB = dstHeight - 2 * border; + const GLint dstDepthNB = dstDepth - 2 * border; + GLint img, row; + GLint bytesPerSrcImage, bytesPerDstImage; + GLint bytesPerSrcRow, bytesPerDstRow; + GLint srcImageOffset, srcRowOffset; + + (void) srcDepthNB; /* silence warnings */ + + + bytesPerSrcImage = srcWidth * srcHeight * bpt; + bytesPerDstImage = dstWidth * dstHeight * bpt; + + bytesPerSrcRow = srcWidth * bpt; + bytesPerDstRow = dstWidth * bpt; + + /* Offset between adjacent src images to be averaged together */ + srcImageOffset = (srcDepth == dstDepth) ? 0 : bytesPerSrcImage; + + /* Offset between adjacent src rows to be averaged together */ + srcRowOffset = (srcHeight == dstHeight) ? 0 : srcWidth * bpt; + + /* + * Need to average together up to 8 src pixels for each dest pixel. + * Break that down into 3 operations: + * 1. take two rows from source image and average them together. + * 2. take two rows from next source image and average them together. + * 3. take the two averaged rows and average them for the final dst row. + */ + + /* + printf("mip3d %d x %d x %d -> %d x %d x %d\n", + srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth); + */ + + for (img = 0; img < dstDepthNB; img++) { + /* first source image pointer, skipping border */ + const GLubyte *imgSrcA = srcPtr + + (bytesPerSrcImage + bytesPerSrcRow + border) * bpt * border + + img * (bytesPerSrcImage + srcImageOffset); + /* second source image pointer, skipping border */ + const GLubyte *imgSrcB = imgSrcA + srcImageOffset; + /* address of the dest image, skipping border */ + GLubyte *imgDst = dstPtr + + (bytesPerDstImage + bytesPerDstRow + border) * bpt * border + + img * bytesPerDstImage; + + /* setup the four source row pointers and the dest row pointer */ + const GLubyte *srcImgARowA = imgSrcA; + const GLubyte *srcImgARowB = imgSrcA + srcRowOffset; + const GLubyte *srcImgBRowA = imgSrcB; + const GLubyte *srcImgBRowB = imgSrcB + srcRowOffset; + GLubyte *dstImgRow = imgDst; + + for (row = 0; row < dstHeightNB; row++) { + do_row_3D(datatype, comps, srcWidthNB, + srcImgARowA, srcImgARowB, + srcImgBRowA, srcImgBRowB, + dstWidthNB, dstImgRow); + + /* advance to next rows */ + srcImgARowA += bytesPerSrcRow + srcRowOffset; + srcImgARowB += bytesPerSrcRow + srcRowOffset; + srcImgBRowA += bytesPerSrcRow + srcRowOffset; + srcImgBRowB += bytesPerSrcRow + srcRowOffset; + dstImgRow += bytesPerDstRow; + } + } + + + /* Luckily we can leverage the make_2d_mipmap() function here! */ + if (border > 0) { + /* do front border image */ + make_2d_mipmap(datatype, comps, 1, srcWidth, srcHeight, srcPtr, srcRowStride, + dstWidth, dstHeight, dstPtr, dstRowStride); + /* do back border image */ + make_2d_mipmap(datatype, comps, 1, srcWidth, srcHeight, + srcPtr + bytesPerSrcImage * (srcDepth - 1), srcRowStride, + dstWidth, dstHeight, + dstPtr + bytesPerDstImage * (dstDepth - 1), dstRowStride); + /* do four remaining border edges that span the image slices */ + if (srcDepth == dstDepth) { + /* just copy border pixels from src to dst */ + for (img = 0; img < dstDepthNB; img++) { + const GLubyte *src; + GLubyte *dst; + + /* do border along [img][row=0][col=0] */ + src = srcPtr + (img + 1) * bytesPerSrcImage; + dst = dstPtr + (img + 1) * bytesPerDstImage; + memcpy(dst, src, bpt); + + /* do border along [img][row=dstHeight-1][col=0] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (srcHeight - 1) * bytesPerSrcRow; + dst = dstPtr + (img + 1) * bytesPerDstImage + + (dstHeight - 1) * bytesPerDstRow; + memcpy(dst, src, bpt); + + /* do border along [img][row=0][col=dstWidth-1] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (srcWidth - 1) * bpt; + dst = dstPtr + (img + 1) * bytesPerDstImage + + (dstWidth - 1) * bpt; + memcpy(dst, src, bpt); + + /* do border along [img][row=dstHeight-1][col=dstWidth-1] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (bytesPerSrcImage - bpt); + dst = dstPtr + (img + 1) * bytesPerDstImage + + (bytesPerDstImage - bpt); + memcpy(dst, src, bpt); + } + } + else { + /* average border pixels from adjacent src image pairs */ + ASSERT(srcDepthNB == 2 * dstDepthNB); + for (img = 0; img < dstDepthNB; img++) { + const GLubyte *src; + GLubyte *dst; + + /* do border along [img][row=0][col=0] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage; + dst = dstPtr + (img + 1) * bytesPerDstImage; + do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); + + /* do border along [img][row=dstHeight-1][col=0] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (srcHeight - 1) * bytesPerSrcRow; + dst = dstPtr + (img + 1) * bytesPerDstImage + + (dstHeight - 1) * bytesPerDstRow; + do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); + + /* do border along [img][row=0][col=dstWidth-1] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (srcWidth - 1) * bpt; + dst = dstPtr + (img + 1) * bytesPerDstImage + + (dstWidth - 1) * bpt; + do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); + + /* do border along [img][row=dstHeight-1][col=dstWidth-1] */ + src = srcPtr + (img * 2 + 1) * bytesPerSrcImage + + (bytesPerSrcImage - bpt); + dst = dstPtr + (img + 1) * bytesPerDstImage + + (bytesPerDstImage - bpt); + do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst); + } + } + } +} + + +static void +make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border, + GLint srcWidth, const GLubyte *srcPtr, GLuint srcRowStride, + GLint dstWidth, GLint dstHeight, + GLubyte *dstPtr, GLuint dstRowStride ) +{ + const GLint bpt = bytes_per_pixel(datatype, comps); + const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ + const GLint dstWidthNB = dstWidth - 2 * border; + const GLint dstHeightNB = dstHeight - 2 * border; + const GLint srcRowBytes = bpt * srcRowStride; + const GLint dstRowBytes = bpt * dstRowStride; + const GLubyte *src; + GLubyte *dst; + GLint row; + + /* Compute src and dst pointers, skipping any border */ + src = srcPtr + border * ((srcWidth + 1) * bpt); + dst = dstPtr + border * ((dstWidth + 1) * bpt); + + for (row = 0; row < dstHeightNB; row++) { + do_row(datatype, comps, srcWidthNB, src, src, + dstWidthNB, dst); + src += srcRowBytes; + dst += dstRowBytes; + } + + if (border) { + /* copy left-most pixel from source */ + assert(dstPtr); + assert(srcPtr); + memcpy(dstPtr, srcPtr, bpt); + /* copy right-most pixel from source */ + memcpy(dstPtr + (dstWidth - 1) * bpt, + srcPtr + (srcWidth - 1) * bpt, + bpt); + } +} + + +/** + * \bug + * There is quite a bit of refactoring that could be done with this function + * and \c make_2d_mipmap. + */ +static void +make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border, + GLint srcWidth, GLint srcHeight, + const GLubyte *srcPtr, GLint srcRowStride, + GLint dstWidth, GLint dstHeight, GLint dstDepth, + GLubyte *dstPtr, GLint dstRowStride) +{ + const GLint bpt = bytes_per_pixel(datatype, comps); + const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ + const GLint dstWidthNB = dstWidth - 2 * border; + const GLint dstHeightNB = dstHeight - 2 * border; + const GLint dstDepthNB = dstDepth - 2 * border; + const GLint srcRowBytes = bpt * srcRowStride; + const GLint dstRowBytes = bpt * dstRowStride; + const GLubyte *srcA, *srcB; + GLubyte *dst; + GLint layer; + GLint row; + + /* Compute src and dst pointers, skipping any border */ + srcA = srcPtr + border * ((srcWidth + 1) * bpt); + if (srcHeight > 1) + srcB = srcA + srcRowBytes; + else + srcB = srcA; + dst = dstPtr + border * ((dstWidth + 1) * bpt); + + for (layer = 0; layer < dstDepthNB; layer++) { + for (row = 0; row < dstHeightNB; row++) { + do_row(datatype, comps, srcWidthNB, srcA, srcB, + dstWidthNB, dst); + srcA += 2 * srcRowBytes; + srcB += 2 * srcRowBytes; + dst += dstRowBytes; + } + + /* This is ugly but probably won't be used much */ + if (border > 0) { + /* fill in dest border */ + /* lower-left border pixel */ + assert(dstPtr); + assert(srcPtr); + memcpy(dstPtr, srcPtr, bpt); + /* lower-right border pixel */ + memcpy(dstPtr + (dstWidth - 1) * bpt, + srcPtr + (srcWidth - 1) * bpt, bpt); + /* upper-left border pixel */ + memcpy(dstPtr + dstWidth * (dstHeight - 1) * bpt, + srcPtr + srcWidth * (srcHeight - 1) * bpt, bpt); + /* upper-right border pixel */ + memcpy(dstPtr + (dstWidth * dstHeight - 1) * bpt, + srcPtr + (srcWidth * srcHeight - 1) * bpt, bpt); + /* lower border */ + do_row(datatype, comps, srcWidthNB, + srcPtr + bpt, + srcPtr + bpt, + dstWidthNB, dstPtr + bpt); + /* upper border */ + do_row(datatype, comps, srcWidthNB, + srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, + srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt, + dstWidthNB, + dstPtr + (dstWidth * (dstHeight - 1) + 1) * bpt); + /* left and right borders */ + if (srcHeight == dstHeight) { + /* copy border pixel from src to dst */ + for (row = 1; row < srcHeight; row++) { + memcpy(dstPtr + dstWidth * row * bpt, + srcPtr + srcWidth * row * bpt, bpt); + memcpy(dstPtr + (dstWidth * row + dstWidth - 1) * bpt, + srcPtr + (srcWidth * row + srcWidth - 1) * bpt, bpt); + } + } + else { + /* average two src pixels each dest pixel */ + for (row = 0; row < dstHeightNB; row += 2) { + do_row(datatype, comps, 1, + srcPtr + (srcWidth * (row * 2 + 1)) * bpt, + srcPtr + (srcWidth * (row * 2 + 2)) * bpt, + 1, dstPtr + (dstWidth * row + 1) * bpt); + do_row(datatype, comps, 1, + srcPtr + (srcWidth * (row * 2 + 1) + srcWidth - 1) * bpt, + srcPtr + (srcWidth * (row * 2 + 2) + srcWidth - 1) * bpt, + 1, dstPtr + (dstWidth * row + 1 + dstWidth - 1) * bpt); + } + } + } + } +} + + +/** + * Down-sample a texture image to produce the next lower mipmap level. + * \param comps components per texel (1, 2, 3 or 4) + * \param srcRowStride stride between source rows, in texels + * \param dstRowStride stride between destination rows, in texels + */ +void +_mesa_generate_mipmap_level(GLenum target, + GLenum datatype, GLuint comps, + GLint border, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLubyte *srcData, + GLint srcRowStride, + GLint dstWidth, GLint dstHeight, GLint dstDepth, + GLubyte *dstData, + GLint dstRowStride) +{ + /* + * We use simple 2x2 averaging to compute the next mipmap level. + */ + switch (target) { + case GL_TEXTURE_1D: + make_1d_mipmap(datatype, comps, border, + srcWidth, srcData, + dstWidth, dstData); + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + make_2d_mipmap(datatype, comps, border, + srcWidth, srcHeight, srcData, srcRowStride, + dstWidth, dstHeight, dstData, dstRowStride); + break; + case GL_TEXTURE_3D: + make_3d_mipmap(datatype, comps, border, + srcWidth, srcHeight, srcDepth, + srcData, srcRowStride, + dstWidth, dstHeight, dstDepth, + dstData, dstRowStride); + break; + case GL_TEXTURE_1D_ARRAY_EXT: + make_1d_stack_mipmap(datatype, comps, border, + srcWidth, srcData, srcRowStride, + dstWidth, dstHeight, + dstData, dstRowStride); + break; + case GL_TEXTURE_2D_ARRAY_EXT: + make_2d_stack_mipmap(datatype, comps, border, + srcWidth, srcHeight, + srcData, srcRowStride, + dstWidth, dstHeight, + dstDepth, dstData, dstRowStride); + break; + case GL_TEXTURE_RECTANGLE_NV: + /* no mipmaps, do nothing */ + break; + default: + _mesa_problem(NULL, "bad dimensions in _mesa_generate_mipmaps"); + return; + } +} + + +/** + * compute next (level+1) image size + * \return GL_FALSE if no smaller size can be generated (eg. src is 1x1x1 size) + */ +static GLboolean +next_mipmap_level_size(GLenum target, GLint border, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLint *dstWidth, GLint *dstHeight, GLint *dstDepth) +{ + if (srcWidth - 2 * border > 1) { + *dstWidth = (srcWidth - 2 * border) / 2 + 2 * border; + } + else { + *dstWidth = srcWidth; /* can't go smaller */ + } + + if ((srcHeight - 2 * border > 1) && + (target != GL_TEXTURE_1D_ARRAY_EXT)) { + *dstHeight = (srcHeight - 2 * border) / 2 + 2 * border; + } + else { + *dstHeight = srcHeight; /* can't go smaller */ + } + + if ((srcDepth - 2 * border > 1) && + (target != GL_TEXTURE_2D_ARRAY_EXT)) { + *dstDepth = (srcDepth - 2 * border) / 2 + 2 * border; + } + else { + *dstDepth = srcDepth; /* can't go smaller */ + } + + if (*dstWidth == srcWidth && + *dstHeight == srcHeight && + *dstDepth == srcDepth) { + return GL_FALSE; + } + else { + return GL_TRUE; + } +} + + + + +/** + * Automatic mipmap generation. + * This is the fallback/default function for ctx->Driver.GenerateMipmap(). + * Generate a complete set of mipmaps from texObj's BaseLevel image. + * Stop at texObj's MaxLevel or when we get to the 1x1 texture. + * For cube maps, target will be one of + * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z; never GL_TEXTURE_CUBE_MAP. + */ +void +_mesa_generate_mipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj) +{ + const struct gl_texture_image *srcImage; + gl_format convertFormat; + const GLubyte *srcData = NULL; + GLubyte *dstData = NULL; + GLint level, maxLevels; + GLenum datatype; + GLuint comps; + + ASSERT(texObj); + srcImage = _mesa_select_tex_image(ctx, texObj, target, texObj->BaseLevel); + ASSERT(srcImage); + + maxLevels = _mesa_max_texture_levels(ctx, texObj->Target); + ASSERT(maxLevels > 0); /* bad target */ + + /* Find convertFormat - the format that do_row() will process */ + + if (_mesa_is_format_compressed(srcImage->TexFormat)) { + /* setup for compressed textures - need to allocate temporary + * image buffers to hold uncompressed images. + */ + GLuint row; + GLint components, size; + GLchan *dst; + + assert(texObj->Target == GL_TEXTURE_2D || + texObj->Target == GL_TEXTURE_CUBE_MAP_ARB); + + if (srcImage->_BaseFormat == GL_RGB) { + convertFormat = MESA_FORMAT_RGB888; + components = 3; + } + else if (srcImage->_BaseFormat == GL_RGBA) { + convertFormat = MESA_FORMAT_RGBA8888; + components = 4; + } + else { + _mesa_problem(ctx, "bad srcImage->_BaseFormat in _mesa_generate_mipmaps"); + return; + } + + /* allocate storage for uncompressed GL_RGB or GL_RGBA images */ + size = _mesa_bytes_per_pixel(srcImage->_BaseFormat, CHAN_TYPE) + * srcImage->Width * srcImage->Height * srcImage->Depth + 20; + /* 20 extra bytes, just be safe when calling last FetchTexel */ + srcData = (GLubyte *) malloc(size); + if (!srcData) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); + return; + } + dstData = (GLubyte *) malloc(size / 2); /* 1/4 would probably be OK */ + if (!dstData) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); + free((void *) srcData); + return; + } + + /* decompress base image here */ + dst = (GLchan *) srcData; + for (row = 0; row < srcImage->Height; row++) { + GLuint col; + for (col = 0; col < srcImage->Width; col++) { + srcImage->FetchTexelc(srcImage, col, row, 0, dst); + dst += components; + } + } + } + else { + /* uncompressed */ + convertFormat = srcImage->TexFormat; + } + + _mesa_format_to_type_and_comps(convertFormat, &datatype, &comps); + + for (level = texObj->BaseLevel; level < texObj->MaxLevel + && level < maxLevels - 1; level++) { + /* generate image[level+1] from image[level] */ + const struct gl_texture_image *srcImage; + struct gl_texture_image *dstImage; + GLint srcWidth, srcHeight, srcDepth; + GLint dstWidth, dstHeight, dstDepth; + GLint border; + GLboolean nextLevel; + + /* get src image parameters */ + srcImage = _mesa_select_tex_image(ctx, texObj, target, level); + ASSERT(srcImage); + srcWidth = srcImage->Width; + srcHeight = srcImage->Height; + srcDepth = srcImage->Depth; + border = srcImage->Border; + + nextLevel = next_mipmap_level_size(target, border, + srcWidth, srcHeight, srcDepth, + &dstWidth, &dstHeight, &dstDepth); + if (!nextLevel) { + /* all done */ + if (_mesa_is_format_compressed(srcImage->TexFormat)) { + free((void *) srcData); + free(dstData); + } + return; + } + + /* get dest gl_texture_image */ + dstImage = _mesa_get_tex_image(ctx, texObj, target, level + 1); + if (!dstImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); + return; + } + + /* Free old image data */ + if (dstImage->Data) + ctx->Driver.FreeTexImageData(ctx, dstImage); + + /* initialize new image */ + _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight, + dstDepth, border, srcImage->InternalFormat, + srcImage->TexFormat); + dstImage->DriverData = NULL; + dstImage->FetchTexelc = srcImage->FetchTexelc; + dstImage->FetchTexelf = srcImage->FetchTexelf; + + /* Alloc new teximage data buffer */ + { + GLuint size = _mesa_format_image_size(dstImage->TexFormat, + dstWidth, dstHeight, dstDepth); + dstImage->Data = _mesa_alloc_texmemory(size); + if (!dstImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); + return; + } + } + + /* Setup src and dest data pointers */ + if (_mesa_is_format_compressed(dstImage->TexFormat)) { + /* srcData and dstData are already set */ + ASSERT(srcData); + ASSERT(dstData); + } + else { + srcData = (const GLubyte *) srcImage->Data; + dstData = (GLubyte *) dstImage->Data; + } + + ASSERT(dstImage->TexFormat); + ASSERT(dstImage->FetchTexelc); + ASSERT(dstImage->FetchTexelf); + + _mesa_generate_mipmap_level(target, datatype, comps, border, + srcWidth, srcHeight, srcDepth, + srcData, srcImage->RowStride, + dstWidth, dstHeight, dstDepth, + dstData, dstImage->RowStride); + + + if (_mesa_is_format_compressed(dstImage->TexFormat)) { + GLubyte *temp; + /* compress image from dstData into dstImage->Data */ + const GLenum srcFormat = _mesa_get_format_base_format(convertFormat); + GLint dstRowStride + = _mesa_format_row_stride(dstImage->TexFormat, dstWidth); + ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA); + + _mesa_texstore(ctx, 2, dstImage->_BaseFormat, + dstImage->TexFormat, + dstImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, 0, /* strides */ + dstWidth, dstHeight, 1, /* size */ + srcFormat, CHAN_TYPE, + dstData, /* src data, actually */ + &ctx->DefaultPacking); + + /* swap src and dest pointers */ + temp = (GLubyte *) srcData; + srcData = dstData; + dstData = temp; + } + + } /* loop over mipmap levels */ +} + + +/** + * Helper function for drivers which need to rescale texture images to + * certain aspect ratios. + * Nearest filtering only (for broken hardware that can't support + * all aspect ratios). This can be made a lot faster, but I don't + * really care enough... + */ +void +_mesa_rescale_teximage2d(GLuint bytesPerPixel, + GLuint srcStrideInPixels, + GLuint dstRowStride, + GLint srcWidth, GLint srcHeight, + GLint dstWidth, GLint dstHeight, + const GLvoid *srcImage, GLvoid *dstImage) +{ + GLint row, col; + +#define INNER_LOOP( TYPE, HOP, WOP ) \ + for ( row = 0 ; row < dstHeight ; row++ ) { \ + GLint srcRow = row HOP hScale; \ + for ( col = 0 ; col < dstWidth ; col++ ) { \ + GLint srcCol = col WOP wScale; \ + dst[col] = src[srcRow * srcStrideInPixels + srcCol]; \ + } \ + dst = (TYPE *) ((GLubyte *) dst + dstRowStride); \ + } \ + +#define RESCALE_IMAGE( TYPE ) \ +do { \ + const TYPE *src = (const TYPE *)srcImage; \ + TYPE *dst = (TYPE *)dstImage; \ + \ + if ( srcHeight < dstHeight ) { \ + const GLint hScale = dstHeight / srcHeight; \ + if ( srcWidth < dstWidth ) { \ + const GLint wScale = dstWidth / srcWidth; \ + INNER_LOOP( TYPE, /, / ); \ + } \ + else { \ + const GLint wScale = srcWidth / dstWidth; \ + INNER_LOOP( TYPE, /, * ); \ + } \ + } \ + else { \ + const GLint hScale = srcHeight / dstHeight; \ + if ( srcWidth < dstWidth ) { \ + const GLint wScale = dstWidth / srcWidth; \ + INNER_LOOP( TYPE, *, / ); \ + } \ + else { \ + const GLint wScale = srcWidth / dstWidth; \ + INNER_LOOP( TYPE, *, * ); \ + } \ + } \ +} while (0) + + switch ( bytesPerPixel ) { + case 4: + RESCALE_IMAGE( GLuint ); + break; + + case 2: + RESCALE_IMAGE( GLushort ); + break; + + case 1: + RESCALE_IMAGE( GLubyte ); + break; + default: + _mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d"); + } +} + + +/** + * Upscale an image by replication, not (typical) stretching. + * We use this when the image width or height is less than a + * certain size (4, 8) and we need to upscale an image. + */ +void +_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight, + GLsizei outWidth, GLsizei outHeight, + GLint comps, const GLchan *src, GLint srcRowStride, + GLchan *dest ) +{ + GLint i, j, k; + + ASSERT(outWidth >= inWidth); + ASSERT(outHeight >= inHeight); +#if 0 + ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2); + ASSERT((outWidth & 3) == 0); + ASSERT((outHeight & 3) == 0); +#endif + + for (i = 0; i < outHeight; i++) { + const GLint ii = i % inHeight; + for (j = 0; j < outWidth; j++) { + const GLint jj = j % inWidth; + for (k = 0; k < comps; k++) { + dest[(i * outWidth + j) * comps + k] + = src[ii * srcRowStride + jj * comps + k]; + } + } + } +} + diff --git a/mesalib/src/mesa/main/mipmap.h b/mesalib/src/mesa/main/mipmap.h index 22094c343..c0c6c2592 100644 --- a/mesalib/src/mesa/main/mipmap.h +++ b/mesalib/src/mesa/main/mipmap.h @@ -1,64 +1,64 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MIPMAP_H -#define MIPMAP_H - -#include "mtypes.h" - - -extern void -_mesa_generate_mipmap_level(GLenum target, - GLenum datatype, GLuint comps, - GLint border, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLubyte *srcData, - GLint srcRowStride, - GLint dstWidth, GLint dstHeight, GLint dstDepth, - GLubyte *dstData, - GLint dstRowStride); - - -extern void -_mesa_generate_mipmap(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj); - - -extern void -_mesa_rescale_teximage2d(GLuint bytesPerPixel, - GLuint srcStrideInPixels, - GLuint dstRowStride, - GLint srcWidth, GLint srcHeight, - GLint dstWidth, GLint dstHeight, - const GLvoid *srcImage, GLvoid *dstImage); - -extern void -_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight, - GLsizei outWidth, GLsizei outHeight, - GLint comps, const GLchan *src, GLint srcRowStride, - GLchan *dest); - - -#endif /* MIPMAP_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef MIPMAP_H +#define MIPMAP_H + +#include "mtypes.h" + + +extern void +_mesa_generate_mipmap_level(GLenum target, + GLenum datatype, GLuint comps, + GLint border, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLubyte *srcData, + GLint srcRowStride, + GLint dstWidth, GLint dstHeight, GLint dstDepth, + GLubyte *dstData, + GLint dstRowStride); + + +extern void +_mesa_generate_mipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj); + + +extern void +_mesa_rescale_teximage2d(GLuint bytesPerPixel, + GLuint srcStrideInPixels, + GLuint dstRowStride, + GLint srcWidth, GLint srcHeight, + GLint dstWidth, GLint dstHeight, + const GLvoid *srcImage, GLvoid *dstImage); + +extern void +_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight, + GLsizei outWidth, GLsizei outHeight, + GLint comps, const GLchan *src, GLint srcRowStride, + GLchan *dest); + + +#endif /* MIPMAP_H */ diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 5494be8f4..7cac96c1d 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1,3362 +1,3311 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - - -#include "main/glheader.h" -#include "main/config.h" -#include "main/mfeatures.h" -#include "glapi/glapi.h" -#include "math/m_matrix.h" /* GLmatrix */ -#include "main/simple_list.h" /* struct simple_node */ - -/* Shader stages. Note that these will become 5 with tessellation. - * These MUST have the same values as PIPE_SHADER_* - */ -#define MESA_SHADER_VERTEX 0 -#define MESA_SHADER_FRAGMENT 1 -#define MESA_SHADER_GEOMETRY 2 -#define MESA_SHADER_TYPES 3 - - -/** - * Color channel data type. - */ -#if CHAN_BITS == 8 - typedef GLubyte GLchan; -#define CHAN_MAX 255 -#define CHAN_MAXF 255.0F -#define CHAN_TYPE GL_UNSIGNED_BYTE -#elif CHAN_BITS == 16 - typedef GLushort GLchan; -#define CHAN_MAX 65535 -#define CHAN_MAXF 65535.0F -#define CHAN_TYPE GL_UNSIGNED_SHORT -#elif CHAN_BITS == 32 - typedef GLfloat GLchan; -#define CHAN_MAX 1.0 -#define CHAN_MAXF 1.0F -#define CHAN_TYPE GL_FLOAT -#else -#error "illegal number of color channel bits" -#endif - - -/** - * Stencil buffer data type. - */ -#if STENCIL_BITS==8 - typedef GLubyte GLstencil; -#elif STENCIL_BITS==16 - typedef GLushort GLstencil; -#else -# error "illegal number of stencil bits" -#endif - - -/** - * \name 64-bit extension of GLbitfield. - */ -/*@{*/ -typedef GLuint64 GLbitfield64; - -#define BITFIELD64_ONE 1ULL -#define BITFIELD64_ALLONES ~0ULL - -/** Set a single bit */ -#define BITFIELD64_BIT(b) (BITFIELD64_ONE << (b)) - -/** Set a mask of the least significant \c b bits */ -#define BITFIELD64_MASK(b) (((b) >= 64) ? BITFIELD64_ALLONES : \ - (BITFIELD64_BIT(b) - 1)) - -/** - * Set all bits from l (low bit) to h (high bit), inclusive. - * - * \note \C BITFIELD_64_RANGE(0, 63) return 64 set bits. - */ -#define BITFIELD64_RANGE(l, h) (BITFIELD64_MASK((h) + 1) & ~BITFIELD64_MASK(l)) -/*@}*/ - - -/** - * \name Some forward type declarations - */ -/*@{*/ -struct _mesa_HashTable; -struct gl_attrib_node; -struct gl_list_extensions; -struct gl_meta_state; -struct gl_pixelstore_attrib; -struct gl_program_cache; -struct gl_texture_format; -struct gl_texture_image; -struct gl_texture_object; -struct st_context; -typedef struct __GLcontextRec GLcontext; -typedef struct __GLcontextModesRec GLvisual; -typedef struct gl_framebuffer GLframebuffer; -/*@}*/ - - - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes. In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR0 = 3, - VERT_ATTRIB_COLOR1 = 4, - VERT_ATTRIB_FOG = 5, - VERT_ATTRIB_COLOR_INDEX = 6, - VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ - VERT_ATTRIB_EDGEFLAG = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_GENERIC0 = 16, - VERT_ATTRIB_GENERIC1 = 17, - VERT_ATTRIB_GENERIC2 = 18, - VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_GENERIC4 = 20, - VERT_ATTRIB_GENERIC5 = 21, - VERT_ATTRIB_GENERIC6 = 22, - VERT_ATTRIB_GENERIC7 = 23, - VERT_ATTRIB_GENERIC8 = 24, - VERT_ATTRIB_GENERIC9 = 25, - VERT_ATTRIB_GENERIC10 = 26, - VERT_ATTRIB_GENERIC11 = 27, - VERT_ATTRIB_GENERIC12 = 28, - VERT_ATTRIB_GENERIC13 = 29, - VERT_ATTRIB_GENERIC14 = 30, - VERT_ATTRIB_GENERIC15 = 31, - VERT_ATTRIB_MAX = 32 -} gl_vert_attrib; - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) -/*@}*/ - - -/** - * Indexes for vertex program result attributes - */ -typedef enum -{ - VERT_RESULT_HPOS = 0, - VERT_RESULT_COL0 = 1, - VERT_RESULT_COL1 = 2, - VERT_RESULT_FOGC = 3, - VERT_RESULT_TEX0 = 4, - VERT_RESULT_TEX1 = 5, - VERT_RESULT_TEX2 = 6, - VERT_RESULT_TEX3 = 7, - VERT_RESULT_TEX4 = 8, - VERT_RESULT_TEX5 = 9, - VERT_RESULT_TEX6 = 10, - VERT_RESULT_TEX7 = 11, - VERT_RESULT_PSIZ = 12, - VERT_RESULT_BFC0 = 13, - VERT_RESULT_BFC1 = 14, - VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16, /**< shader varying */ - VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/*********************************************/ - -/** - * Indexes for geometry program attributes. - */ -typedef enum -{ - GEOM_ATTRIB_POSITION = 0, - GEOM_ATTRIB_COLOR0 = 1, - GEOM_ATTRIB_COLOR1 = 2, - GEOM_ATTRIB_SECONDARY_COLOR0 = 3, - GEOM_ATTRIB_SECONDARY_COLOR1 = 4, - GEOM_ATTRIB_FOG_FRAG_COORD = 5, - GEOM_ATTRIB_POINT_SIZE = 6, - GEOM_ATTRIB_CLIP_VERTEX = 7, - GEOM_ATTRIB_PRIMITIVE_ID = 8, - GEOM_ATTRIB_TEX_COORD = 9, - - GEOM_ATTRIB_VAR0 = 16, - GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) -} gl_geom_attrib; - -/** - * Bitflags for geometry attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) -#define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) -#define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) -#define GEOM_BIT_SCOLOR1 (1 << GEOM_ATTRIB_SECONDARY_COLOR1) -#define GEOM_BIT_TEX_COORD (1 << GEOM_ATTRIB_TEX_COORD) -#define GEOM_BIT_FOG_COORD (1 << GEOM_ATTRIB_FOG_FRAG_COORD) -#define GEOM_BIT_POSITION (1 << GEOM_ATTRIB_POSITION) -#define GEOM_BIT_POINT_SIDE (1 << GEOM_ATTRIB_POINT_SIZE) -#define GEOM_BIT_CLIP_VERTEX (1 << GEOM_ATTRIB_CLIP_VERTEX) -#define GEOM_BIT_PRIM_ID (1 << GEOM_ATTRIB_PRIMITIVE_ID) -#define GEOM_BIT_VAR0 (1 << GEOM_ATTRIB_VAR0) - -#define GEOM_BIT_VAR(g) (1 << (GEOM_BIT_VAR0 + (g))) -/*@}*/ - - -/** - * Indexes for geometry program result attributes - */ -/*@{*/ -typedef enum { - GEOM_RESULT_POS = 0, - GEOM_RESULT_COL0 = 1, - GEOM_RESULT_COL1 = 2, - GEOM_RESULT_SCOL0 = 3, - GEOM_RESULT_SCOL1 = 4, - GEOM_RESULT_FOGC = 5, - GEOM_RESULT_TEX0 = 6, - GEOM_RESULT_TEX1 = 7, - GEOM_RESULT_TEX2 = 8, - GEOM_RESULT_TEX3 = 9, - GEOM_RESULT_TEX4 = 10, - GEOM_RESULT_TEX5 = 11, - GEOM_RESULT_TEX6 = 12, - GEOM_RESULT_TEX7 = 13, - GEOM_RESULT_PSIZ = 14, - GEOM_RESULT_CLPV = 15, - GEOM_RESULT_PRID = 16, - GEOM_RESULT_LAYR = 17, - GEOM_RESULT_VAR0 = 18, /**< shader varying, should really be 16 */ - /* ### we need to -2 because var0 is 18 instead 16 like in the others */ - GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) -} gl_geom_result; -/*@}*/ - -/** - * Indexes for fragment program input attributes. - */ -typedef enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL0 = 1, - FRAG_ATTRIB_COL1 = 2, - FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_FACE = 12, /**< front/back face */ - FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -} gl_frag_attrib; - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ - FRAG_BIT_TEX1| \ - FRAG_BIT_TEX2| \ - FRAG_BIT_TEX3| \ - FRAG_BIT_TEX4| \ - FRAG_BIT_TEX5| \ - FRAG_BIT_TEX6| \ - FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ - FRAG_RESULT_DEPTH = 0, - FRAG_RESULT_COLOR = 1, - FRAG_RESULT_DATA0 = 2, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -} gl_frag_result; - - -/** - * Indexes for all renderbuffers - */ -typedef enum -{ - /* the four standard color buffers */ - BUFFER_FRONT_LEFT, - BUFFER_BACK_LEFT, - BUFFER_FRONT_RIGHT, - BUFFER_BACK_RIGHT, - BUFFER_DEPTH, - BUFFER_STENCIL, - BUFFER_ACCUM, - /* optional aux buffer */ - BUFFER_AUX0, - /* generic renderbuffers */ - BUFFER_COLOR0, - BUFFER_COLOR1, - BUFFER_COLOR2, - BUFFER_COLOR3, - BUFFER_COLOR4, - BUFFER_COLOR5, - BUFFER_COLOR6, - BUFFER_COLOR7, - BUFFER_COUNT -} gl_buffer_index; - -/** - * Bit flags for all renderbuffers - */ -#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) -#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) -#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) -#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) -#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) -#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) -#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) -#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) -#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) -#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) -#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) -#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) -#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) -#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) -#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) -#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) -#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) -#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) -#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) - -/** - * Mask of all the color buffer bits (but not accum). - */ -#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ - BUFFER_BIT_BACK_LEFT | \ - BUFFER_BIT_FRONT_RIGHT | \ - BUFFER_BIT_BACK_RIGHT | \ - BUFFER_BIT_AUX0 | \ - BUFFER_BIT_COLOR0 | \ - BUFFER_BIT_COLOR1 | \ - BUFFER_BIT_COLOR2 | \ - BUFFER_BIT_COLOR3 | \ - BUFFER_BIT_COLOR4 | \ - BUFFER_BIT_COLOR5 | \ - BUFFER_BIT_COLOR6 | \ - BUFFER_BIT_COLOR7) - - -/** The pixel transfer path has three color tables: */ -typedef enum -{ - COLORTABLE_PRECONVOLUTION, - COLORTABLE_POSTCONVOLUTION, - COLORTABLE_POSTCOLORMATRIX, - COLORTABLE_MAX -} gl_colortable_index; - - -/** - * Data structure for color tables - */ -struct gl_color_table -{ - GLenum InternalFormat; /**< The user-specified format */ - GLenum _BaseFormat; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */ - GLuint Size; /**< number of entries in table */ - GLfloat *TableF; /**< Color table, floating point values */ - GLubyte *TableUB; /**< Color table, ubyte values */ - GLubyte RedSize; - GLubyte GreenSize; - GLubyte BlueSize; - GLubyte AlphaSize; - GLubyte LuminanceSize; - GLubyte IntensitySize; -}; - - -/** - * \name Bit flags used for updating material values. - */ -/*@{*/ -#define MAT_ATTRIB_FRONT_AMBIENT 0 -#define MAT_ATTRIB_BACK_AMBIENT 1 -#define MAT_ATTRIB_FRONT_DIFFUSE 2 -#define MAT_ATTRIB_BACK_DIFFUSE 3 -#define MAT_ATTRIB_FRONT_SPECULAR 4 -#define MAT_ATTRIB_BACK_SPECULAR 5 -#define MAT_ATTRIB_FRONT_EMISSION 6 -#define MAT_ATTRIB_BACK_EMISSION 7 -#define MAT_ATTRIB_FRONT_SHININESS 8 -#define MAT_ATTRIB_BACK_SHININESS 9 -#define MAT_ATTRIB_FRONT_INDEXES 10 -#define MAT_ATTRIB_BACK_INDEXES 11 -#define MAT_ATTRIB_MAX 12 - -#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) -#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) -#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) -#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) -#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) -#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) - -#define MAT_INDEX_AMBIENT 0 -#define MAT_INDEX_DIFFUSE 1 -#define MAT_INDEX_SPECULAR 2 - -#define MAT_BIT_FRONT_AMBIENT (1< ) */ - GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ - GLfloat _VP_inf_spot_attenuation; - - GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ - GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ - GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ - GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ - GLfloat _dli; /**< CI diffuse light intensity */ - GLfloat _sli; /**< CI specular light intensity */ - /*@}*/ -}; - - -/** - * Light model state. - */ -struct gl_lightmodel -{ - GLfloat Ambient[4]; /**< ambient color */ - GLboolean LocalViewer; /**< Local (or infinite) view point? */ - GLboolean TwoSide; /**< Two (or one) sided lighting? */ - GLenum ColorControl; /**< either GL_SINGLE_COLOR - * or GL_SEPARATE_SPECULAR_COLOR */ -}; - - -/** - * Material state. - */ -struct gl_material -{ - GLfloat Attrib[MAT_ATTRIB_MAX][4]; -}; - - -/** - * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) - */ -struct gl_accum_attrib -{ - GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ -}; - - -/** - * Color buffer attribute group (GL_COLOR_BUFFER_BIT). - */ -struct gl_colorbuffer_attrib -{ - GLuint ClearIndex; /**< Index to use for glClear */ - GLclampf ClearColor[4]; /**< Color to use for glClear */ - - GLuint IndexMask; /**< Color index write mask */ - GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ - - GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ - - /** - * \name alpha testing - */ - /*@{*/ - GLboolean AlphaEnabled; /**< Alpha test enabled flag */ - GLenum AlphaFunc; /**< Alpha test function */ - GLclampf AlphaRef; /**< Alpha reference value */ - /*@}*/ - - /** - * \name Blending - */ - /*@{*/ - GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ - GLenum BlendSrcRGB; /**< Blending source operator */ - GLenum BlendDstRGB; /**< Blending destination operator */ - GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */ - GLenum BlendDstA; /**< GL_INGR_blend_func_separate */ - GLenum BlendEquationRGB; /**< Blending equation */ - GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */ - GLfloat BlendColor[4]; /**< Blending color */ - /*@}*/ - - /** - * \name Logic op - */ - /*@{*/ - GLenum LogicOp; /**< Logic operator */ - GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ - GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ - GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */ - /*@}*/ - - GLboolean DitherFlag; /**< Dither enable flag */ - - GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ - GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ -}; - - -/** - * Current attribute group (GL_CURRENT_BIT). - */ -struct gl_current_attrib -{ - /** - * \name Current vertex attributes. - * \note Values are valid only after FLUSH_VERTICES has been called. - * \note Index and Edgeflag current values are stored as floats in the - * SIX and SEVEN attribute slots. - */ - GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ - - /** - * \name Current raster position attributes (always valid). - * \note This set of attributes is very similar to the SWvertex struct. - */ - /*@{*/ - GLfloat RasterPos[4]; - GLfloat RasterDistance; - GLfloat RasterColor[4]; - GLfloat RasterSecondaryColor[4]; - GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; - GLboolean RasterPosValid; - /*@}*/ -}; - - -/** - * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). - */ -struct gl_depthbuffer_attrib -{ - GLenum Func; /**< Function for depth buffer compare */ - GLclampd Clear; /**< Value to clear depth buffer to */ - GLboolean Test; /**< Depth buffering enabled flag */ - GLboolean Mask; /**< Depth buffer writable? */ - GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ - GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ -}; - - -/** - * Evaluator attribute group (GL_EVAL_BIT). - */ -struct gl_eval_attrib -{ - /** - * \name Enable bits - */ - /*@{*/ - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ - GLboolean AutoNormal; - /*@}*/ - - /** - * \name Map Grid endpoints and divisions and calculated du values - */ - /*@{*/ - GLint MapGrid1un; - GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; - GLint MapGrid2un, MapGrid2vn; - GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; - GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; - /*@}*/ -}; - - -/** - * Fog attribute group (GL_FOG_BIT). - */ -struct gl_fog_attrib -{ - GLboolean Enabled; /**< Fog enabled flag */ - GLfloat Color[4]; /**< Fog color */ - GLfloat Density; /**< Density >= 0.0 */ - GLfloat Start; /**< Start distance in eye coords */ - GLfloat End; /**< End distance in eye coords */ - GLfloat Index; /**< Fog index */ - GLenum Mode; /**< Fog mode */ - GLboolean ColorSumEnabled; - GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ - GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ -}; - - -/** - * Hint attribute group (GL_HINT_BIT). - * - * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. - */ -struct gl_hint_attrib -{ - GLenum PerspectiveCorrection; - GLenum PointSmooth; - GLenum LineSmooth; - GLenum PolygonSmooth; - GLenum Fog; - GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ - GLenum TextureCompression; /**< GL_ARB_texture_compression */ - GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ - GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ -}; - - -/** - * Histogram attributes. - */ -struct gl_histogram_attrib -{ - GLuint Width; /**< number of table entries */ - GLint Format; /**< GL_ALPHA, GL_RGB, etc */ - GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */ - GLboolean Sink; /**< terminate image transfer? */ - GLubyte RedSize; /**< Bits per counter */ - GLubyte GreenSize; - GLubyte BlueSize; - GLubyte AlphaSize; - GLubyte LuminanceSize; -}; - - -/** - * Color Min/max state. - */ -struct gl_minmax_attrib -{ - GLenum Format; - GLboolean Sink; - GLfloat Min[4], Max[4]; /**< RGBA */ -}; - - -/** - * Image convolution state. - */ -struct gl_convolution_attrib -{ - GLenum Format; - GLenum InternalFormat; - GLuint Width; - GLuint Height; - GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4]; -}; - - -/** - * Light state flags. - */ -/*@{*/ -#define LIGHT_SPOT 0x1 -#define LIGHT_LOCAL_VIEWER 0x2 -#define LIGHT_POSITIONAL 0x4 -#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) -/*@}*/ - - -/** - * Lighting attribute group (GL_LIGHT_BIT). - */ -struct gl_light_attrib -{ - struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ - struct gl_lightmodel Model; /**< Lighting model */ - - /** - * Must flush FLUSH_VERTICES before referencing: - */ - /*@{*/ - struct gl_material Material; /**< Includes front & back values */ - /*@}*/ - - GLboolean Enabled; /**< Lighting enabled flag */ - GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ - GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ - GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ - GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ - GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ - GLboolean ColorMaterialEnabled; - GLenum ClampVertexColor; - - struct gl_light EnabledList; /**< List sentinel */ - - /** - * Derived state for optimizations: - */ - /*@{*/ - GLboolean _NeedEyeCoords; - GLboolean _NeedVertices; /**< Use fast shader? */ - GLbitfield _Flags; /**< LIGHT_* flags, see above */ - GLfloat _BaseColor[2][3]; - /*@}*/ -}; - - -/** - * Line attribute group (GL_LINE_BIT). - */ -struct gl_line_attrib -{ - GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ - GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ - GLushort StipplePattern; /**< Stipple pattern */ - GLint StippleFactor; /**< Stipple repeat factor */ - GLfloat Width; /**< Line width */ -}; - - -/** - * Display list attribute group (GL_LIST_BIT). - */ -struct gl_list_attrib -{ - GLuint ListBase; -}; - - -/** - * Multisample attribute group (GL_MULTISAMPLE_BIT). - */ -struct gl_multisample_attrib -{ - GLboolean Enabled; - GLboolean _Enabled; /**< true if Enabled and multisample buffer */ - GLboolean SampleAlphaToCoverage; - GLboolean SampleAlphaToOne; - GLboolean SampleCoverage; - GLfloat SampleCoverageValue; - GLboolean SampleCoverageInvert; -}; - - -/** - * A pixelmap (see glPixelMap) - */ -struct gl_pixelmap -{ - GLint Size; - GLfloat Map[MAX_PIXEL_MAP_TABLE]; - GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ -}; - - -/** - * Collection of all pixelmaps - */ -struct gl_pixelmaps -{ - struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ - struct gl_pixelmap GtoG; - struct gl_pixelmap BtoB; - struct gl_pixelmap AtoA; - struct gl_pixelmap ItoR; - struct gl_pixelmap ItoG; - struct gl_pixelmap ItoB; - struct gl_pixelmap ItoA; - struct gl_pixelmap ItoI; - struct gl_pixelmap StoS; -}; - - -/** - * Pixel attribute group (GL_PIXEL_MODE_BIT). - */ -struct gl_pixel_attrib -{ - GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ - - /*--- Begin Pixel Transfer State ---*/ - /* Fields are in the order in which they're applied... */ - - /** Scale & Bias (index shift, offset) */ - /*@{*/ - GLfloat RedBias, RedScale; - GLfloat GreenBias, GreenScale; - GLfloat BlueBias, BlueScale; - GLfloat AlphaBias, AlphaScale; - GLfloat DepthBias, DepthScale; - GLint IndexShift, IndexOffset; - /*@}*/ - - /* Pixel Maps */ - /* Note: actual pixel maps are not part of this attrib group */ - GLboolean MapColorFlag; - GLboolean MapStencilFlag; - - /* There are multiple color table stages: */ - GLboolean ColorTableEnabled[COLORTABLE_MAX]; - GLfloat ColorTableScale[COLORTABLE_MAX][4]; /**< RGBA */ - GLfloat ColorTableBias[COLORTABLE_MAX][4]; /**< RGBA */ - - /* Convolution (GL_EXT_convolution) */ - GLboolean Convolution1DEnabled; - GLboolean Convolution2DEnabled; - GLboolean Separable2DEnabled; - GLfloat ConvolutionBorderColor[3][4]; /**< RGBA */ - GLenum ConvolutionBorderMode[3]; - GLfloat ConvolutionFilterScale[3][4]; /**< RGBA */ - GLfloat ConvolutionFilterBias[3][4]; /**< RGBA */ - GLfloat PostConvolutionScale[4]; /**< RGBA */ - GLfloat PostConvolutionBias[4]; /**< RGBA */ - - /* Color matrix (GL_SGI_color_matrix) */ - /* Note: the color matrix is not part of this attrib group */ - GLfloat PostColorMatrixScale[4]; /**< RGBA */ - GLfloat PostColorMatrixBias[4]; /**< RGBA */ - - /* Histogram & minmax (GL_EXT_histogram) */ - /* Note: histogram and minmax data are not part of this attrib group */ - GLboolean HistogramEnabled; - GLboolean MinMaxEnabled; - - /*--- End Pixel Transfer State ---*/ - - /** glPixelZoom */ - GLfloat ZoomX, ZoomY; - - /** GL_SGI_texture_color_table */ - GLfloat TextureColorTableScale[4]; /**< RGBA */ - GLfloat TextureColorTableBias[4]; /**< RGBA */ -}; - - -/** - * Point attribute group (GL_POINT_BIT). - */ -struct gl_point_attrib -{ - GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ - GLfloat Size; /**< User-specified point size */ - GLfloat Params[3]; /**< GL_EXT_point_parameters */ - GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ - GLfloat Threshold; /**< GL_EXT_point_parameters */ - GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ - GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ - GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ - GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ - GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ -}; - - -/** - * Polygon attribute group (GL_POLYGON_BIT). - */ -struct gl_polygon_attrib -{ - GLenum FrontFace; /**< Either GL_CW or GL_CCW */ - GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ - GLboolean CullFlag; /**< Culling on/off flag */ - GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ - GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ - GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ - GLfloat OffsetFactor; /**< Polygon offset factor, from user */ - GLfloat OffsetUnits; /**< Polygon offset units, from user */ - GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ - GLboolean OffsetLine; /**< Offset in GL_LINE mode */ - GLboolean OffsetFill; /**< Offset in GL_FILL mode */ -}; - - -/** - * Scissor attributes (GL_SCISSOR_BIT). - */ -struct gl_scissor_attrib -{ - GLboolean Enabled; /**< Scissor test enabled? */ - GLint X, Y; /**< Lower left corner of box */ - GLsizei Width, Height; /**< Size of box */ -}; - - -/** - * Stencil attribute group (GL_STENCIL_BUFFER_BIT). - * - * Three sets of stencil data are tracked so that OpenGL 2.0, - * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported - * simultaneously. In each of the stencil state arrays, element 0 corresponds - * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / - * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the - * GL_EXT_stencil_two_side GL_BACK state. - * - * The derived value \c _BackFace is either 1 or 2 depending on whether or - * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. - * - * The derived value \c _TestTwoSide is set when the front-face and back-face - * stencil state are different. - */ -struct gl_stencil_attrib -{ - GLboolean Enabled; /**< Enabled flag */ - GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ - GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ - GLboolean _Enabled; /**< Enabled and stencil buffer present */ - GLboolean _TestTwoSide; - GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ - GLenum Function[3]; /**< Stencil function */ - GLenum FailFunc[3]; /**< Fail function */ - GLenum ZPassFunc[3]; /**< Depth buffer pass function */ - GLenum ZFailFunc[3]; /**< Depth buffer fail function */ - GLint Ref[3]; /**< Reference value */ - GLuint ValueMask[3]; /**< Value mask */ - GLuint WriteMask[3]; /**< Write mask */ - GLuint Clear; /**< Clear value */ -}; - - -/** - * An index for each type of texture object. These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ - TEXTURE_2D_ARRAY_INDEX, - TEXTURE_1D_ARRAY_INDEX, - TEXTURE_CUBE_INDEX, - TEXTURE_3D_INDEX, - TEXTURE_RECT_INDEX, - TEXTURE_2D_INDEX, - TEXTURE_1D_INDEX, - NUM_TEXTURE_TARGETS -} gl_texture_index; - - -/** - * Bit flags for each type of texture object - * Used for Texture.Unit[]._ReallyEnabled flags. - */ -/*@{*/ -#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) -#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) -#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) -#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) -#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) -#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) -#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) -/*@}*/ - - -/** - * TexGenEnabled flags. - */ -/*@{*/ -#define S_BIT 1 -#define T_BIT 2 -#define R_BIT 4 -#define Q_BIT 8 -#define STR_BITS (S_BIT | T_BIT | R_BIT) -/*@}*/ - - -/** - * Bit flag versions of the corresponding GL_ constants. - */ -/*@{*/ -#define TEXGEN_SPHERE_MAP 0x1 -#define TEXGEN_OBJ_LINEAR 0x2 -#define TEXGEN_EYE_LINEAR 0x4 -#define TEXGEN_REFLECTION_MAP_NV 0x8 -#define TEXGEN_NORMAL_MAP_NV 0x10 - -#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV) -#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV | \ - TEXGEN_EYE_LINEAR) -/*@}*/ - - - -/** Tex-gen enabled for texture unit? */ -#define ENABLE_TEXGEN(unit) (1 << (unit)) - -/** Non-identity texture matrix for texture unit? */ -#define ENABLE_TEXMAT(unit) (1 << (unit)) - - -/** - * Texel fetch function prototype. We use texel fetch functions to - * extract RGBA, color indexes and depth components out of 1D, 2D and 3D - * texture images. These functions help to isolate us from the gritty - * details of all the various texture image encodings. - * - * \param texImage texture image. - * \param col texel column. - * \param row texel row. - * \param img texel image level/layer. - * \param texelOut output texel (up to 4 GLchans) - */ -typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - GLchan *texelOut ); - -/** - * As above, but returns floats. - * Used for depth component images and for upcoming signed/float - * texture images. - */ -typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - GLfloat *texelOut ); - - -typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel); - - -/** - * Texture image state. Describes the dimensions of a texture image, - * the texel format and pointers to Texel Fetch functions. - */ -struct gl_texture_image -{ - GLint InternalFormat; /**< Internal format as given by the user */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_COLOR_INDEX, - * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT - * only. Used for choosing TexEnv arithmetic. - */ - GLuint TexFormat; /**< The actual format: MESA_FORMAT_x */ - - GLuint Border; /**< 0 or 1 */ - GLuint Width; /**< = 2^WidthLog2 + 2*Border */ - GLuint Height; /**< = 2^HeightLog2 + 2*Border */ - GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ - GLuint Width2; /**< = Width - 2*Border */ - GLuint Height2; /**< = Height - 2*Border */ - GLuint Depth2; /**< = Depth - 2*Border */ - GLuint WidthLog2; /**< = log2(Width2) */ - GLuint HeightLog2; /**< = log2(Height2) */ - GLuint DepthLog2; /**< = log2(Depth2) */ - GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ - GLfloat WidthScale; /**< used for mipmap LOD computation */ - GLfloat HeightScale; /**< used for mipmap LOD computation */ - GLfloat DepthScale; /**< used for mipmap LOD computation */ - GLboolean IsClientData; /**< Data owned by client? */ - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ - - struct gl_texture_object *TexObject; /**< Pointer back to parent object */ - - FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ - FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ - - GLuint RowStride; /**< Padded width in units of texels */ - GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to - each 2D slice in 'Data', in texels */ - GLvoid *Data; /**< Image data, accessed via FetchTexel() */ - - /** - * \name For device driver: - */ - /*@{*/ - void *DriverData; /**< Arbitrary device driver data */ - /*@}*/ -}; - - -/** - * Indexes for cube map faces. - */ -typedef enum -{ - FACE_POS_X = 0, - FACE_NEG_X = 1, - FACE_POS_Y = 2, - FACE_NEG_Y = 3, - FACE_POS_Z = 4, - FACE_NEG_Z = 5, - MAX_FACES = 6 -} gl_face_index; - - -/** - * Texture object state. Contains the array of mipmap images, border color, - * wrap modes, filter modes, shadow/texcompare state, and the per-texture - * color palette. - */ -struct gl_texture_object -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< reference count */ - GLuint Name; /**< the user-visible texture object ID */ - GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ - GLfloat Priority; /**< in [0,1] */ - union { - GLfloat f[4]; - GLuint ui[4]; - GLint i[4]; - } BorderColor; /**< Interpreted according to texture format */ - GLenum WrapS; /**< S-axis texture image wrap mode */ - GLenum WrapT; /**< T-axis texture image wrap mode */ - GLenum WrapR; /**< R-axis texture image wrap mode */ - GLenum MinFilter; /**< minification filter */ - GLenum MagFilter; /**< magnification filter */ - GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ - GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ - GLfloat LodBias; /**< OpenGL 1.4 */ - GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ - GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ - GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - GLenum CompareMode; /**< GL_ARB_shadow */ - GLenum CompareFunc; /**< GL_ARB_shadow */ - GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ - GLenum DepthMode; /**< GL_ARB_depth_texture */ - GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ - GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ - GLint CropRect[4]; /**< GL_OES_draw_texture */ - GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ - GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ - GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ - GLboolean _Complete; /**< Is texture object complete? */ - GLboolean _RenderToTexture; /**< Any rendering to this texture? */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - - /** Actual texture images, indexed by [cube face] and [mipmap level] */ - struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; - - /** GL_EXT_paletted_texture */ - struct gl_color_table Palette; - - /** - * \name For device driver. - * Note: instead of attaching driver data to this pointer, it's preferable - * to instead use this struct as a base class for your own texture object - * class. Driver->NewTextureObject() can be used to implement the - * allocation. - */ - void *DriverData; /**< Arbitrary device driver data */ -}; - - -/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ -#define MAX_COMBINER_TERMS 4 - - -/** - * Texture combine environment state. - */ -struct gl_tex_env_combine_state -{ - GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ - GLenum SourceRGB[MAX_COMBINER_TERMS]; - GLenum SourceA[MAX_COMBINER_TERMS]; - /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ - GLenum OperandRGB[MAX_COMBINER_TERMS]; - GLenum OperandA[MAX_COMBINER_TERMS]; - GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ - GLuint ScaleShiftA; /**< 0, 1 or 2 */ - GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ - GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ -}; - - -/** - * Texture coord generation state. - */ -struct gl_texgen -{ - GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ - GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ - GLfloat ObjectPlane[4]; - GLfloat EyePlane[4]; -}; - - -/** - * Texture unit state. Contains enable flags, texture environment/function/ - * combiners, texgen state, pointers to current texture objects and - * post-filter color tables. - */ -struct gl_texture_unit -{ - GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ - GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ - - GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ - GLfloat EnvColor[4]; - - struct gl_texgen GenS; - struct gl_texgen GenT; - struct gl_texgen GenR; - struct gl_texgen GenQ; - GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ - GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ - - GLfloat LodBias; /**< for biasing mipmap levels */ - GLenum BumpTarget; - GLfloat RotMatrix[4]; /* 2x2 matrix */ - - /** - * \name GL_EXT_texture_env_combine - */ - struct gl_tex_env_combine_state Combine; - - /** - * Derived state based on \c EnvMode and the \c BaseFormat of the - * currently enabled texture. - */ - struct gl_tex_env_combine_state _EnvMode; - - /** - * Currently enabled combiner state. This will point to either - * \c Combine or \c _EnvMode. - */ - struct gl_tex_env_combine_state *_CurrentCombine; - - /** Current texture object pointers */ - struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; - - /** Points to highest priority, complete and enabled texture object */ - struct gl_texture_object *_Current; - - /** GL_SGI_texture_color_table */ - /*@{*/ - struct gl_color_table ColorTable; - struct gl_color_table ProxyColorTable; - GLboolean ColorTableEnabled; - /*@}*/ -}; - - -/** - * Texture attribute group (GL_TEXTURE_BIT). - */ -struct gl_texture_attrib -{ - GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ - struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; - - struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; - - /** GL_ARB_seamless_cubemap */ - GLboolean CubeMapSeamless; - - /** GL_EXT_shared_texture_palette */ - GLboolean SharedPalette; - struct gl_color_table Palette; - - /** Texture units/samplers used by vertex or fragment texturing */ - GLbitfield _EnabledUnits; - - /** Texture coord units/sets used for fragment texturing */ - GLbitfield _EnabledCoordUnits; - - /** Texture coord units that have texgen enabled */ - GLbitfield _TexGenEnabled; - - /** Texture coord units that have non-identity matrices */ - GLbitfield _TexMatEnabled; - - /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ - GLbitfield _GenFlags; -}; - - -/** - * Transformation attribute group (GL_TRANSFORM_BIT). - */ -struct gl_transform_attrib -{ - GLenum MatrixMode; /**< Matrix mode */ - GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */ - GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */ - GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ - GLboolean Normalize; /**< Normalize all normals? */ - GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ - GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ - GLboolean DepthClamp; /**< GL_ARB_depth_clamp */ - - GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */ - GLfloat CullEyePos[4]; - GLfloat CullObjPos[4]; -}; - - -/** - * Viewport attribute group (GL_VIEWPORT_BIT). - */ -struct gl_viewport_attrib -{ - GLint X, Y; /**< position */ - GLsizei Width, Height; /**< size */ - GLfloat Near, Far; /**< Depth buffer range */ - GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ -}; - - -/** - * GL_ARB_vertex/pixel_buffer_object buffer object - */ -struct gl_buffer_object -{ - _glthread_Mutex Mutex; - GLint RefCount; - GLuint Name; - GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ - GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ - GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ - /** Fields describing a mapped buffer */ - /*@{*/ - GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ - GLvoid *Pointer; /**< User-space address of mapping */ - GLintptr Offset; /**< Mapped offset */ - GLsizeiptr Length; /**< Mapped length */ - /*@}*/ - GLboolean Written; /**< Ever written to? (for debugging) */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ -}; - - -/** - * Client pixel packing/unpacking attributes - */ -struct gl_pixelstore_attrib -{ - GLint Alignment; - GLint RowLength; - GLint SkipPixels; - GLint SkipRows; - GLint ImageHeight; - GLint SkipImages; - GLboolean SwapBytes; - GLboolean LsbFirst; - GLboolean ClientStorage; /**< GL_APPLE_client_storage */ - GLboolean Invert; /**< GL_MESA_pack_invert */ - struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ -}; - - -/** - * Client vertex array attributes - */ -struct gl_client_array -{ - GLint Size; /**< components per element (1,2,3,4) */ - GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ - GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ - GLsizei Stride; /**< user-specified stride */ - GLsizei StrideB; /**< actual stride in bytes */ - const GLubyte *Ptr; /**< Points to array data */ - GLboolean Enabled; /**< Enabled flag is a boolean */ - GLboolean Normalized; /**< GL_ARB_vertex_program */ - GLuint _ElementSize; /**< size of each element in bytes */ - - struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ - GLuint _MaxElement; /**< max element index into array buffer + 1 */ -}; - - -/** - * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object - * extension, but a nice encapsulation in any case. - */ -struct gl_array_object -{ - /** Name of the array object as received from glGenVertexArrayAPPLE. */ - GLuint Name; - - GLint RefCount; - _glthread_Mutex Mutex; - GLboolean VBOonly; /**< require all arrays to live in VBOs? */ - - /** Conventional vertex arrays */ - /*@{*/ - struct gl_client_array Vertex; - struct gl_client_array Weight; - struct gl_client_array Normal; - struct gl_client_array Color; - struct gl_client_array SecondaryColor; - struct gl_client_array FogCoord; - struct gl_client_array Index; - struct gl_client_array EdgeFlag; - struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; - struct gl_client_array PointSize; - /*@}*/ - - /** - * Generic arrays for vertex programs/shaders. - * For NV vertex programs, these attributes alias and take priority - * over the conventional attribs above. For ARB vertex programs and - * GLSL vertex shaders, these attributes are separate. - */ - struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; - - /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ - GLbitfield _Enabled; - - /** - * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs - * we can determine the max legal (in bounds) glDrawElements array index. - */ - GLuint _MaxElement; -}; - - -/** - * Vertex array state - */ -struct gl_array_attrib -{ - /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */ - struct gl_array_object *ArrayObj; - - /** The default vertex array object */ - struct gl_array_object *DefaultArrayObj; - - /** Array objects (GL_ARB/APPLE_vertex_array_object) */ - struct _mesa_HashTable *Objects; - - GLint ActiveTexture; /**< Client Active Texture */ - GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ - GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ - - /** GL 3.1 (slightly different from GL_NV_primitive_restart) */ - GLboolean PrimitiveRestart; - GLuint RestartIndex; - - GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ - - /* GL_ARB_vertex_buffer_object */ - struct gl_buffer_object *ArrayBufferObj; - struct gl_buffer_object *ElementArrayBufferObj; -}; - - -/** - * Feedback buffer state - */ -struct gl_feedback -{ - GLenum Type; - GLbitfield _Mask; /**< FB_* bits */ - GLfloat *Buffer; - GLuint BufferSize; - GLuint Count; -}; - - -/** - * Selection buffer state - */ -struct gl_selection -{ - GLuint *Buffer; /**< selection buffer */ - GLuint BufferSize; /**< size of the selection buffer */ - GLuint BufferCount; /**< number of values in the selection buffer */ - GLuint Hits; /**< number of records in the selection buffer */ - GLuint NameStackDepth; /**< name stack depth */ - GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ - GLboolean HitFlag; /**< hit flag */ - GLfloat HitMinZ; /**< minimum hit depth */ - GLfloat HitMaxZ; /**< maximum hit depth */ -}; - - -/** - * 1-D Evaluator control points - */ -struct gl_1d_map -{ - GLuint Order; /**< Number of control points */ - GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * 2-D Evaluator control points - */ -struct gl_2d_map -{ - GLuint Uorder; /**< Number of control points in U dimension */ - GLuint Vorder; /**< Number of control points in V dimension */ - GLfloat u1, u2, du; - GLfloat v1, v2, dv; - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * All evaluator control point state - */ -struct gl_evaluators -{ - /** - * \name 1-D maps - */ - /*@{*/ - struct gl_1d_map Map1Vertex3; - struct gl_1d_map Map1Vertex4; - struct gl_1d_map Map1Index; - struct gl_1d_map Map1Color4; - struct gl_1d_map Map1Normal; - struct gl_1d_map Map1Texture1; - struct gl_1d_map Map1Texture2; - struct gl_1d_map Map1Texture3; - struct gl_1d_map Map1Texture4; - struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ - /*@}*/ - - /** - * \name 2-D maps - */ - /*@{*/ - struct gl_2d_map Map2Vertex3; - struct gl_2d_map Map2Vertex4; - struct gl_2d_map Map2Index; - struct gl_2d_map Map2Color4; - struct gl_2d_map Map2Normal; - struct gl_2d_map Map2Texture1; - struct gl_2d_map Map2Texture2; - struct gl_2d_map Map2Texture3; - struct gl_2d_map Map2Texture4; - struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ - /*@}*/ -}; - - -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ - PROGRAM_TEMPORARY, /**< machine->Temporary[] */ - PROGRAM_INPUT, /**< machine->Inputs[] */ - PROGRAM_OUTPUT, /**< machine->Outputs[] */ - PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ - PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ - PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ - PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ - PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ - PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ - PROGRAM_ADDRESS, /**< machine->AddressReg */ - PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ - PROGRAM_UNDEFINED, /**< Invalid/TBD value */ - PROGRAM_FILE_MAX -} gl_register_file; - - -/** Vertex and fragment instructions */ -struct prog_instruction; -struct gl_program_parameter_list; -struct gl_uniform_list; - - -/** - * Base class for any kind of program object - */ -struct gl_program -{ - GLuint Id; - GLubyte *String; /**< Null-terminated program text */ - GLint RefCount; - GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ - GLenum Format; /**< String encoding format */ - GLboolean Resident; - - struct prog_instruction *Instructions; - - GLbitfield InputsRead; /**< Bitmask of which input regs are read */ - GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ - GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */ - GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ - GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ - - - /** Named parameters, constants, etc. from program text */ - struct gl_program_parameter_list *Parameters; - /** Numbered local parameters */ - GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; - - /** Vertex/fragment shader varying vars */ - struct gl_program_parameter_list *Varying; - /** Vertex program user-defined attributes */ - struct gl_program_parameter_list *Attributes; - - /** Map from sampler unit to texture unit (set by glUniform1i()) */ - GLubyte SamplerUnits[MAX_SAMPLERS]; - /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; - - /** Bitmask of which register files are read/written with indirect - * addressing. Mask of (1 << PROGRAM_x) bits. - */ - GLbitfield IndirectRegisterFiles; - - /** Logical counts */ - /*@{*/ - GLuint NumInstructions; - GLuint NumTemporaries; - GLuint NumParameters; - GLuint NumAttributes; - GLuint NumAddressRegs; - GLuint NumAluInstructions; - GLuint NumTexInstructions; - GLuint NumTexIndirections; - /*@}*/ - /** Native, actual h/w counts */ - /*@{*/ - GLuint NumNativeInstructions; - GLuint NumNativeTemporaries; - GLuint NumNativeParameters; - GLuint NumNativeAttributes; - GLuint NumNativeAddressRegs; - GLuint NumNativeAluInstructions; - GLuint NumNativeTexInstructions; - GLuint NumNativeTexIndirections; - /*@}*/ -}; - - -/** Vertex program object */ -struct gl_vertex_program -{ - struct gl_program Base; /**< base class */ - GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ - GLboolean IsPositionInvariant; -}; - - -/** Geometry program object */ -struct gl_geometry_program -{ - struct gl_program Base; /**< base class */ - - GLint VerticesOut; - GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, - GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ - GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ -}; - - -/** Fragment program object */ -struct gl_fragment_program -{ - struct gl_program Base; /**< base class */ - GLenum FogOption; - GLboolean UsesKill; /**< shader uses KIL instruction */ - GLboolean OriginUpperLeft; - GLboolean PixelCenterInteger; -}; - - -/** - * State common to vertex and fragment programs. - */ -struct gl_program_state -{ - GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ - const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ -}; - - -/** - * Context state for vertex programs. - */ -struct gl_vertex_program_state -{ - GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ - GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ - struct gl_vertex_program *Current; /**< User-bound vertex program */ - - /** Currently enabled and valid vertex program (including internal - * programs, user-defined vertex programs and GLSL vertex shaders). - * This is the program we must use when rendering. - */ - struct gl_vertex_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /* For GL_NV_vertex_program only: */ - GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; - GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; - - /** Should fixed-function T&L be implemented with a vertex prog? */ - GLboolean _MaintainTnlProgram; - - /** Program to emulate fixed-function T&L (see above) */ - struct gl_vertex_program *_TnlProgram; - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; - - GLboolean _Overriden; -}; - - -/** - * Context state for geometry programs. - */ -struct gl_geometry_program_state -{ - GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */ - GLboolean _Enabled; /**< Enabled and valid program? */ - struct gl_geometry_program *Current; /**< user-bound geometry program */ - - /** Currently enabled and valid program (including internal programs - * and compiled shader programs). - */ - struct gl_geometry_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; -}; - -/** - * Context state for fragment programs. - */ -struct gl_fragment_program_state -{ - GLboolean Enabled; /**< User-set fragment program enable flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - struct gl_fragment_program *Current; /**< User-bound fragment program */ - - /** Currently enabled and valid fragment program (including internal - * programs, user-defined fragment programs and GLSL fragment shaders). - * This is the program we must use when rendering. - */ - struct gl_fragment_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Should fixed-function texturing be implemented with a fragment prog? */ - GLboolean _MaintainTexEnvProgram; - - /** Program to emulate fixed-function texture env/combine (see above) */ - struct gl_fragment_program *_TexEnvProgram; - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; -}; - - -/** - * ATI_fragment_shader runtime state - */ -#define ATI_FS_INPUT_PRIMARY 0 -#define ATI_FS_INPUT_SECONDARY 1 - -struct atifs_instruction; -struct atifs_setupinst; - -/** - * ATI fragment shader - */ -struct ati_fragment_shader -{ - GLuint Id; - GLint RefCount; - struct atifs_instruction *Instructions[2]; - struct atifs_setupinst *SetupInst[2]; - GLfloat Constants[8][4]; - GLbitfield LocalConstDef; /**< Indicates which constants have been set */ - GLubyte numArithInstr[2]; - GLubyte regsAssigned[2]; - GLubyte NumPasses; /**< 1 or 2 */ - GLubyte cur_pass; - GLubyte last_optype; - GLboolean interpinp1; - GLboolean isValid; - GLuint swizzlerq; -}; - -/** - * Context state for GL_ATI_fragment_shader - */ -struct gl_ati_fragment_shader_state -{ - GLboolean Enabled; - GLboolean _Enabled; /**< enabled and valid shader? */ - GLboolean Compiling; - GLfloat GlobalConstants[8][4]; - struct ati_fragment_shader *Current; -}; - - -/** - * Occlusion/timer query object. - */ -struct gl_query_object -{ - GLenum Target; /**< The query target, when active */ - GLuint Id; /**< hash table ID/name */ - GLuint64EXT Result; /**< the counter */ - GLboolean Active; /**< inside Begin/EndQuery */ - GLboolean Ready; /**< result is ready? */ -}; - - -/** - * Context state for query objects. - */ -struct gl_query_state -{ - struct _mesa_HashTable *QueryObjects; - struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ - struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ - - /** GL_NV_conditional_render */ - struct gl_query_object *CondRenderQuery; - - /** GL_EXT_transform_feedback */ - struct gl_query_object *PrimitivesGenerated; - struct gl_query_object *PrimitivesWritten; - - /** GL_ARB_timer_query */ - struct gl_query_object *TimeElapsed; - - GLenum CondRenderMode; -}; - - -/** Sync object state */ -struct gl_sync_object { - struct simple_node link; - GLenum Type; /**< GL_SYNC_FENCE */ - GLuint Name; /**< Fence name */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; /**< Object was deleted while there were still - * live references (e.g., sync not yet finished) - */ - GLenum SyncCondition; - GLbitfield Flags; /**< Flags passed to glFenceSync */ - GLuint StatusFlag:1; /**< Has the sync object been signaled? */ -}; - - -/** Set by #pragma directives */ -struct gl_sl_pragmas -{ - GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ - GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ - GLboolean Optimize; /**< defaults on */ - GLboolean Debug; /**< defaults off */ -}; - - -/** - * A GLSL vertex or fragment shader object. - */ -struct gl_shader -{ - GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ - GLuint Name; /**< AKA the handle */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - GLboolean CompileStatus; - GLboolean Main; /**< shader defines main() */ - GLboolean UnresolvedRefs; - const GLchar *Source; /**< Source code string */ - GLuint SourceChecksum; /**< for debug/logging purposes */ - struct gl_program *Program; /**< Post-compile assembly code */ - GLchar *InfoLog; - struct gl_sl_pragmas Pragmas; - - unsigned Version; /**< GLSL version used for linking */ - - struct exec_list *ir; - struct glsl_symbol_table *symbols; - - /** Shaders containing built-in functions that are used for linking. */ - struct gl_shader *builtins_to_link[16]; - unsigned num_builtins_to_link; -}; - - -/** - * A GLSL program object. - * Basically a linked collection of vertex and fragment shaders. - */ -struct gl_shader_program -{ - GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ - GLuint Name; /**< aka handle or ID */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - - GLuint NumShaders; /**< number of attached shaders */ - struct gl_shader **Shaders; /**< List of attached the shaders */ - - /** User-defined attribute bindings (glBindAttribLocation) */ - struct gl_program_parameter_list *Attributes; - - /** Transform feedback varyings */ - struct { - GLenum BufferMode; - GLuint NumVarying; - GLchar **VaryingNames; /**< Array [NumVarying] of char * */ - } TransformFeedback; - - /** Geometry shader state - copied into gl_geometry_program at link time */ - struct { - GLint VerticesOut; - GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, - GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ - GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ - } Geom; - - /* post-link info: */ - struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ - struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ - struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ - struct gl_uniform_list *Uniforms; - struct gl_program_parameter_list *Varying; - GLboolean LinkStatus; /**< GL_LINK_STATUS */ - GLboolean Validated; - GLboolean _Used; /**< Ever used for drawing? */ - GLchar *InfoLog; - - unsigned Version; /**< GLSL version used for linking */ - - /** - * Per-stage shaders resulting from the first stage of linking. - */ - /*@{*/ - GLuint _NumLinkedShaders; - struct gl_shader *_LinkedShaders[2]; - /*@}*/ -}; - - -#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ -#define GLSL_LOG 0x2 /**< Write shaders to files */ -#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ -#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ -#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ -#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ -#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ -#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ - - -/** - * Context state for GLSL vertex/fragment shaders. - */ -struct gl_shader_state -{ - struct gl_shader_program *CurrentProgram; /**< The user-bound program */ - void *MemPool; - - GLbitfield Flags; /**< Mask of GLSL_x flags */ -}; - -/** - * Compiler options for a single GLSL shaders type - */ -struct gl_shader_compiler_options -{ - /** Driver-selectable options: */ - GLboolean EmitCondCodes; /**< Use condition codes? */ - GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ - /** - * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't - * support control flow. - */ - GLboolean EmitNoIfs; - GLboolean EmitNoLoops; - GLboolean EmitNoFunctions; - GLboolean EmitNoCont; /**< Emit CONT opcode? */ - GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ - GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ - - /** - * \name Forms of indirect addressing the driver cannot do. - */ - /*@{*/ - GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ - GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ - GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ - GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ - /*@}*/ - - GLuint MaxUnrollIterations; - - struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ -}; - -/** - * Transform feedback object state - */ -struct gl_transform_feedback_object -{ - GLuint Name; /**< AKA the object ID */ - GLint RefCount; - GLboolean Active; /**< Is transform feedback enabled? */ - GLboolean Paused; /**< Is transform feedback paused? */ - - /** The feedback buffers */ - GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; - struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; - - /** Start of feedback data in dest buffer */ - GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; - /** Max data to put into dest buffer (in bytes) */ - GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; -}; - - -/** - * Context state for transform feedback. - */ -struct gl_transform_feedback -{ - GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ - - GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ - - /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ - struct gl_buffer_object *CurrentBuffer; - - /** The table of all transform feedback objects */ - struct _mesa_HashTable *Objects; - - /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ - struct gl_transform_feedback_object *CurrentObject; - - /** The default xform-fb object (Name==0) */ - struct gl_transform_feedback_object *DefaultObject; -}; - - - -/** - * State which can be shared by multiple contexts: - */ -struct gl_shared_state -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< Reference count */ - struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ - struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ - - /** Default texture objects (shared by all texture units) */ - struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; - - /** Fallback texture used when a bound texture is incomplete */ - struct gl_texture_object *FallbackTex; - - /** - * \name Thread safety and statechange notification for texture - * objects. - * - * \todo Improve the granularity of locking. - */ - /*@{*/ - _glthread_Mutex TexMutex; /**< texobj thread safety */ - GLuint TextureStateStamp; /**< state notification for shared tex */ - /*@}*/ - - /** Default buffer object for vertex arrays that aren't in VBOs */ - struct gl_buffer_object *NullBufferObj; - - /** - * \name Vertex/geometry/fragment programs - */ - /*@{*/ - struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ - struct gl_vertex_program *DefaultVertexProgram; - struct gl_fragment_program *DefaultFragmentProgram; - struct gl_geometry_program *DefaultGeometryProgram; - /*@}*/ - - /* GL_ATI_fragment_shader */ - struct _mesa_HashTable *ATIShaders; - struct ati_fragment_shader *DefaultFragmentShader; - - struct _mesa_HashTable *BufferObjects; - - /** Table of both gl_shader and gl_shader_program objects */ - struct _mesa_HashTable *ShaderObjects; - - /* GL_EXT_framebuffer_object */ - struct _mesa_HashTable *RenderBuffers; - struct _mesa_HashTable *FrameBuffers; - - /* GL_ARB_sync */ - struct simple_node SyncObjects; - - void *DriverData; /**< Device driver shared state */ -}; - - - - -/** - * A renderbuffer stores colors or depth values or stencil values. - * A framebuffer object will have a collection of these. - * Data are read/written to the buffer with a handful of Get/Put functions. - * - * Instances of this object are allocated with the Driver's NewRenderbuffer - * hook. Drivers will likely wrap this class inside a driver-specific - * class to simulate inheritance. - */ -struct gl_renderbuffer -{ -#define RB_MAGIC 0xaabbccdd - int Magic; /** XXX TEMPORARY DEBUG INFO */ - _glthread_Mutex Mutex; /**< for thread safety */ - GLuint ClassID; /**< Useful for drivers */ - GLuint Name; - GLint RefCount; - GLuint Width, Height; - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - - GLenum InternalFormat; /**< The user-specified format */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or - GL_STENCIL_INDEX. */ - GLuint Format; /**< The actual format: MESA_FORMAT_x */ - - GLubyte NumSamples; - - GLenum DataType; /**< Type of values passed to the Get/Put functions */ - GLvoid *Data; /**< This may not be used by some kinds of RBs */ - - /* Used to wrap one renderbuffer around another: */ - struct gl_renderbuffer *Wrapped; - - /* Delete this renderbuffer */ - void (*Delete)(struct gl_renderbuffer *rb); - - /* Allocate new storage for this renderbuffer */ - GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height); - - /* Lock/Unlock are called before/after calling the Get/Put functions. - * Not sure this is the right place for these yet. - void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb); - void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb); - */ - - /* Return a pointer to the element/pixel at (x,y). - * Should return NULL if the buffer memory can't be directly addressed. - */ - void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y); - - /* Get/Read a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values); - - /* Get/Read values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values); - - /* Put/Write a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - /* Put/Write a row of RGB values. This is a special-case routine that's - * only used for RGBA renderbuffers when the source data is GL_RGB. That's - * a common case for glDrawPixels and some triangle routines. - * The values will be of format GL_RGB and type DataType. - */ - void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - - /* Put/Write a row of identical values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask); - - /* Put/Write values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask); - /* Put/Write identical values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask); -}; - - -/** - * A renderbuffer attachment points to either a texture object (and specifies - * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. - */ -struct gl_renderbuffer_attachment -{ - GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ - GLboolean Complete; - - /** - * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the - * application supplied renderbuffer object. - */ - struct gl_renderbuffer *Renderbuffer; - - /** - * If \c Type is \c GL_TEXTURE, this stores a pointer to the application - * supplied texture object. - */ - struct gl_texture_object *Texture; - GLuint TextureLevel; /**< Attached mipmap level. */ - GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ - GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D - * and 2D array textures */ -}; - - -/** - * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). - * In C++ terms, think of this as a base class from which device drivers - * will make derived classes. - */ -struct gl_framebuffer -{ - _glthread_Mutex Mutex; /**< for thread safety */ - /** - * If zero, this is a window system framebuffer. If non-zero, this - * is a FBO framebuffer; note that for some devices (i.e. those with - * a natural pixel coordinate system for FBOs that differs from the - * OpenGL/Mesa coordinate system), this means that the viewport, - * polygon face orientation, and polygon stipple will have to be inverted. - */ - GLuint Name; - - GLint RefCount; - GLboolean DeletePending; - - /** - * The framebuffer's visual. Immutable if this is a window system buffer. - * Computed from attachments if user-made FBO. - */ - GLvisual Visual; - - GLboolean Initialized; - - GLuint Width, Height; /**< size of frame buffer in pixels */ - - /** \name Drawing bounds (Intersection of buffer size and scissor box) */ - /*@{*/ - GLint _Xmin, _Xmax; /**< inclusive */ - GLint _Ymin, _Ymax; /**< exclusive */ - /*@}*/ - - /** \name Derived Z buffer stuff */ - /*@{*/ - GLuint _DepthMax; /**< Max depth buffer value */ - GLfloat _DepthMaxF; /**< Float max depth buffer value */ - GLfloat _MRD; /**< minimum resolvable difference in Z values */ - /*@}*/ - - /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ - GLenum _Status; - - /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ - struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; - - /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER - * attribute group and GL_PIXEL attribute group, respectively. - */ - GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; - GLenum ColorReadBuffer; - - /** Computed from ColorDraw/ReadBuffer above */ - GLuint _NumColorDrawBuffers; - GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ - GLint _ColorReadBufferIndex; /* -1 = None */ - struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; - struct gl_renderbuffer *_ColorReadBuffer; - - /** The Actual depth/stencil buffers to use. May be wrappers around the - * depth/stencil buffers attached above. */ - struct gl_renderbuffer *_DepthBuffer; - struct gl_renderbuffer *_StencilBuffer; - - /** Delete this framebuffer */ - void (*Delete)(struct gl_framebuffer *fb); -}; - - -/** - * Limits for vertex and fragment programs/shaders. - */ -struct gl_program_constants -{ - /* logical limits */ - GLuint MaxInstructions; - GLuint MaxAluInstructions; - GLuint MaxTexInstructions; - GLuint MaxTexIndirections; - GLuint MaxAttribs; - GLuint MaxTemps; - GLuint MaxAddressRegs; - GLuint MaxParameters; - GLuint MaxLocalParams; - GLuint MaxEnvParams; - /* native/hardware limits */ - GLuint MaxNativeInstructions; - GLuint MaxNativeAluInstructions; - GLuint MaxNativeTexInstructions; - GLuint MaxNativeTexIndirections; - GLuint MaxNativeAttribs; - GLuint MaxNativeTemps; - GLuint MaxNativeAddressRegs; - GLuint MaxNativeParameters; - /* For shaders */ - GLuint MaxUniformComponents; - /* GL_ARB_geometry_shader4 */ - GLuint MaxGeometryTextureImageUnits; - GLuint MaxGeometryVaryingComponents; - GLuint MaxVertexVaryingComponents; - GLuint MaxGeometryUniformComponents; - GLuint MaxGeometryOutputVertices; - GLuint MaxGeometryTotalOutputComponents; -}; - - -/** - * Constants which may be overridden by device driver during context creation - * but are never changed after that. - */ -struct gl_constants -{ - GLint MaxTextureLevels; /**< Max mipmap levels. */ - GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ - GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ - GLint MaxArrayTextureLayers; /**< Max layers in array textures */ - GLint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ - GLuint MaxTextureCoordUnits; - GLuint MaxTextureImageUnits; - GLuint MaxVertexTextureImageUnits; - GLuint MaxCombinedTextureImageUnits; - GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ - GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ - - GLuint MaxArrayLockSize; - - GLint SubPixelBits; - - GLfloat MinPointSize, MaxPointSize; /**< aliased */ - GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ - GLfloat PointSizeGranularity; - GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ - GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ - GLfloat LineWidthGranularity; - - GLuint MaxColorTableSize; - GLuint MaxConvolutionWidth; - GLuint MaxConvolutionHeight; - - GLuint MaxClipPlanes; - GLuint MaxLights; - GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ - GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ - - GLuint MaxViewportWidth, MaxViewportHeight; - - struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ - struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ - struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */ - GLuint MaxProgramMatrices; - GLuint MaxProgramMatrixStackDepth; - - /** vertex array / buffer object bounds checking */ - GLboolean CheckArrayBounds; - - GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ - - GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ - GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ - GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ - - GLuint MaxVarying; /**< Number of float[4] varying parameters */ - - GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ - - /** Which texture units support GL_ATI_envmap_bumpmap as targets */ - GLbitfield SupportedBumpUnits; - - /** - * Maximum amount of time, measured in nanseconds, that the server can wait. - */ - GLuint64 MaxServerWaitTimeout; - - /** GL_EXT_provoking_vertex */ - GLboolean QuadsFollowProvokingVertexConvention; - - /** OpenGL version 3.0 */ - GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ - - /** OpenGL version 3.2 */ - GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ - - /** GL_EXT_transform_feedback */ - GLuint MaxTransformFeedbackSeparateAttribs; - GLuint MaxTransformFeedbackSeparateComponents; - GLuint MaxTransformFeedbackInterleavedComponents; -}; - - -/** - * Enable flag for each OpenGL extension. Different device drivers will - * enable different extensions at runtime. - */ -struct gl_extensions -{ - GLboolean dummy; /* don't remove this! */ - GLboolean ARB_blend_func_extended; - GLboolean ARB_copy_buffer; - GLboolean ARB_depth_buffer_float; - GLboolean ARB_depth_clamp; - GLboolean ARB_depth_texture; - GLboolean ARB_draw_buffers; - GLboolean ARB_draw_elements_base_vertex; - GLboolean ARB_draw_instanced; - GLboolean ARB_fragment_coord_conventions; - GLboolean ARB_fragment_program; - GLboolean ARB_fragment_program_shadow; - GLboolean ARB_fragment_shader; - GLboolean ARB_framebuffer_object; - GLboolean ARB_explicit_attrib_location; - GLboolean ARB_geometry_shader4; - GLboolean ARB_half_float_pixel; - GLboolean ARB_half_float_vertex; - GLboolean ARB_imaging; - GLboolean ARB_instanced_arrays; - GLboolean ARB_map_buffer_range; - GLboolean ARB_multisample; - GLboolean ARB_multitexture; - GLboolean ARB_occlusion_query; - GLboolean ARB_occlusion_query2; - GLboolean ARB_point_sprite; - GLboolean ARB_sampler_objects; - GLboolean ARB_seamless_cube_map; - GLboolean ARB_shader_objects; - GLboolean ARB_shading_language_100; - GLboolean ARB_shadow; - GLboolean ARB_shadow_ambient; - GLboolean ARB_sync; - GLboolean ARB_texture_border_clamp; - GLboolean ARB_texture_buffer_object; - GLboolean ARB_texture_compression; - GLboolean ARB_texture_cube_map; - GLboolean ARB_texture_env_combine; - GLboolean ARB_texture_env_crossbar; - GLboolean ARB_texture_env_dot3; - GLboolean ARB_texture_float; - GLboolean ARB_texture_mirrored_repeat; - GLboolean ARB_texture_multisample; - GLboolean ARB_texture_non_power_of_two; - GLboolean ARB_texture_rg; - GLboolean ARB_texture_rgb10_a2ui; - GLboolean ARB_timer_query; - GLboolean ARB_transform_feedback2; - GLboolean ARB_transpose_matrix; - GLboolean ARB_uniform_buffer_object; - GLboolean ARB_vertex_array_object; - GLboolean ARB_vertex_buffer_object; - GLboolean ARB_vertex_program; - GLboolean ARB_vertex_shader; - GLboolean ARB_vertex_type_2_10_10_10_rev; - GLboolean ARB_window_pos; - GLboolean EXT_abgr; - GLboolean EXT_bgra; - GLboolean EXT_blend_color; - GLboolean EXT_blend_equation_separate; - GLboolean EXT_blend_func_separate; - GLboolean EXT_blend_logic_op; - GLboolean EXT_blend_minmax; - GLboolean EXT_blend_subtract; - GLboolean EXT_clip_volume_hint; - GLboolean EXT_cull_vertex; - GLboolean EXT_convolution; - GLboolean EXT_compiled_vertex_array; - GLboolean EXT_copy_texture; - GLboolean EXT_depth_bounds_test; - GLboolean EXT_draw_buffers2; - GLboolean EXT_draw_range_elements; - GLboolean EXT_fog_coord; - GLboolean EXT_framebuffer_blit; - GLboolean EXT_framebuffer_multisample; - GLboolean EXT_framebuffer_object; - GLboolean EXT_framebuffer_sRGB; - GLboolean EXT_gpu_program_parameters; - GLboolean EXT_histogram; - GLboolean EXT_multi_draw_arrays; - GLboolean EXT_paletted_texture; - GLboolean EXT_packed_depth_stencil; - GLboolean EXT_packed_float; - GLboolean EXT_packed_pixels; - GLboolean EXT_pixel_buffer_object; - GLboolean EXT_point_parameters; - GLboolean EXT_polygon_offset; - GLboolean EXT_provoking_vertex; - GLboolean EXT_rescale_normal; - GLboolean EXT_shadow_funcs; - GLboolean EXT_secondary_color; - GLboolean EXT_separate_specular_color; - GLboolean EXT_shared_texture_palette; - GLboolean EXT_stencil_wrap; - GLboolean EXT_stencil_two_side; - GLboolean EXT_subtexture; - GLboolean EXT_texture; - GLboolean EXT_texture_object; - GLboolean EXT_texture3D; - GLboolean EXT_texture_array; - GLboolean EXT_texture_compression_s3tc; - GLboolean EXT_texture_compression_rgtc; - GLboolean EXT_texture_env_add; - GLboolean EXT_texture_env_combine; - GLboolean EXT_texture_env_dot3; - GLboolean EXT_texture_filter_anisotropic; - GLboolean EXT_texture_integer; - GLboolean EXT_texture_lod_bias; - GLboolean EXT_texture_mirror_clamp; - GLboolean EXT_texture_shared_exponent; - GLboolean EXT_texture_sRGB; - GLboolean EXT_texture_swizzle; - GLboolean EXT_transform_feedback; - GLboolean EXT_timer_query; - GLboolean EXT_vertex_array; - GLboolean EXT_vertex_array_bgra; - GLboolean EXT_vertex_array_set; - /* vendor extensions */ - GLboolean APPLE_client_storage; - GLboolean APPLE_packed_pixels; - GLboolean APPLE_vertex_array_object; - GLboolean APPLE_object_purgeable; - GLboolean ATI_envmap_bumpmap; - GLboolean ATI_texture_mirror_once; - GLboolean ATI_texture_env_combine3; - GLboolean ATI_fragment_shader; - GLboolean ATI_separate_stencil; - GLboolean IBM_rasterpos_clip; - GLboolean IBM_multimode_draw_arrays; - GLboolean MESA_pack_invert; - GLboolean MESA_packed_depth_stencil; - GLboolean MESA_resize_buffers; - GLboolean MESA_ycbcr_texture; - GLboolean MESA_texture_array; - GLboolean MESA_texture_signed_rgba; - GLboolean NV_blend_square; - GLboolean NV_conditional_render; - GLboolean NV_fragment_program; - GLboolean NV_fragment_program_option; - GLboolean NV_light_max_exponent; - GLboolean NV_point_sprite; - GLboolean NV_primitive_restart; - GLboolean NV_texgen_reflection; - GLboolean NV_texture_env_combine4; - GLboolean NV_texture_rectangle; - GLboolean NV_vertex_program; - GLboolean NV_vertex_program1_1; - GLboolean OES_read_format; - GLboolean SGI_color_matrix; - GLboolean SGI_color_table; - GLboolean SGI_texture_color_table; - GLboolean SGIS_generate_mipmap; - GLboolean SGIS_texture_edge_clamp; - GLboolean SGIS_texture_lod; - GLboolean TDFX_texture_compression_FXT1; - GLboolean S3_s3tc; - GLboolean OES_EGL_image; - GLboolean OES_draw_texture; - /** The extension string */ - const GLubyte *String; - /** Number of supported extensions */ - GLuint Count; -}; - - -/** - * A stack of matrices (projection, modelview, color, texture, etc). - */ -struct gl_matrix_stack -{ - GLmatrix *Top; /**< points into Stack */ - GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ - GLuint Depth; /**< 0 <= Depth < MaxDepth */ - GLuint MaxDepth; /**< size of Stack[] array */ - GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ -}; - - -/** - * \name Bits for image transfer operations - * \sa __GLcontextRec::ImageTransferState. - */ -/*@{*/ -#define IMAGE_SCALE_BIAS_BIT 0x1 -#define IMAGE_SHIFT_OFFSET_BIT 0x2 -#define IMAGE_MAP_COLOR_BIT 0x4 -#define IMAGE_COLOR_TABLE_BIT 0x8 -#define IMAGE_CONVOLUTION_BIT 0x10 -#define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20 -#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40 -#define IMAGE_COLOR_MATRIX_BIT 0x80 -#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100 -#define IMAGE_HISTOGRAM_BIT 0x200 -#define IMAGE_MIN_MAX_BIT 0x400 -#define IMAGE_CLAMP_BIT 0x800 - - -/** Pixel Transfer ops up to convolution */ -#define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \ - IMAGE_SHIFT_OFFSET_BIT | \ - IMAGE_MAP_COLOR_BIT | \ - IMAGE_COLOR_TABLE_BIT) - -/** Pixel transfer ops after convolution */ -#define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \ - IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \ - IMAGE_COLOR_MATRIX_BIT | \ - IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\ - IMAGE_HISTOGRAM_BIT | \ - IMAGE_MIN_MAX_BIT) -/*@}*/ - - -/** - * \name Bits to indicate what state has changed. - * - * 4 unused flags. - */ -/*@{*/ -#define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */ -#define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */ -#define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */ -#define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */ -#define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */ -#define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */ -#define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */ -#define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */ -#define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */ -#define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */ -#define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */ -#define _NEW_LINE 0x800 /**< __GLcontextRec::Line */ -#define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */ -#define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */ -#define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */ -#define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */ -#define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */ -#define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */ -#define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */ -#define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */ -#define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */ -#define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */ -#define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */ -#define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */ -#define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */ -#define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */ -#define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */ -#define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */ -#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */ -#define _NEW_PROGRAM_CONSTANTS 0x20000000 -#define _NEW_BUFFER_OBJECT 0x40000000 -#define _NEW_ALL ~0 -/*@}*/ - - -/** - * \name Bits to track array state changes - * - * Also used to summarize array enabled. - */ -/*@{*/ -#define _NEW_ARRAY_VERTEX VERT_BIT_POS -#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT -#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL -#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 -#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 -#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG -#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX -#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG -#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ -#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 -#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 -#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 -#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 -#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 -#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 -#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 -#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 -#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ -#define _NEW_ARRAY_ALL 0xffffffff - - -#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) -#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) -/*@}*/ - - - -/** - * \name A bunch of flags that we think might be useful to drivers. - * - * Set in the __GLcontextRec::_TriangleCaps bitfield. - */ -/*@{*/ -#define DD_FLATSHADE 0x1 -#define DD_SEPARATE_SPECULAR 0x2 -#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ -#define DD_TRI_LIGHT_TWOSIDE 0x8 -#define DD_TRI_UNFILLED 0x10 -#define DD_TRI_SMOOTH 0x20 -#define DD_TRI_STIPPLE 0x40 -#define DD_TRI_OFFSET 0x80 -#define DD_LINE_SMOOTH 0x100 -#define DD_LINE_STIPPLE 0x200 -#define DD_LINE_WIDTH 0x400 -#define DD_POINT_SMOOTH 0x800 -#define DD_POINT_SIZE 0x1000 -#define DD_POINT_ATTEN 0x2000 -#define DD_TRI_TWOSTENCIL 0x4000 -/*@}*/ - - -/** - * \name Define the state changes under which each of these bits might change - */ -/*@{*/ -#define _DD_NEW_FLATSHADE _NEW_LIGHT -#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) -#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON -#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT -#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON -#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON -#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON -#define _DD_NEW_TRI_OFFSET _NEW_POLYGON -#define _DD_NEW_LINE_SMOOTH _NEW_LINE -#define _DD_NEW_LINE_STIPPLE _NEW_LINE -#define _DD_NEW_LINE_WIDTH _NEW_LINE -#define _DD_NEW_POINT_SMOOTH _NEW_POINT -#define _DD_NEW_POINT_SIZE _NEW_POINT -#define _DD_NEW_POINT_ATTEN _NEW_POINT -/*@}*/ - - -/** - * Composite state flags - */ -/*@{*/ -#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ - _NEW_TEXTURE | \ - _NEW_POINT | \ - _NEW_PROGRAM | \ - _NEW_MODELVIEW) - -#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \ - _NEW_TEXTURE) - -#define _MESA_NEW_TRANSFER_STATE (_NEW_PIXEL | \ - _NEW_COLOR_MATRIX) -/*@}*/ - - - - -/* This has to be included here. */ -#include "dd.h" - - -#define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *)) - -/** - * Core Mesa's support for tnl modules: - */ -struct gl_tnl_module -{ - /** - * Vertex format to be lazily swapped into current dispatch. - */ - const GLvertexformat *Current; - - /** - * \name Record of functions swapped out. - * On restore, only need to swap these functions back in. - */ - /*@{*/ - struct { - _glapi_proc * location; - _glapi_proc function; - } Swapped[NUM_VERTEX_FORMAT_ENTRIES]; - GLuint SwapCount; - /*@}*/ -}; - - -/** - * Display list flags. - * Strictly this is a tnl-private concept, but it doesn't seem - * worthwhile adding a tnl private structure just to hold this one bit - * of information: - */ -#define DLIST_DANGLING_REFS 0x1 - - -/** Opaque declaration of display list payload data type */ -union gl_dlist_node; - - -/** - * Provide a location where information about a display list can be - * collected. Could be extended with driverPrivate structures, - * etc. in the future. - */ -struct gl_display_list -{ - GLuint Name; - GLbitfield Flags; /**< DLIST_x flags */ - /** The dlist commands are in a linked list of nodes */ - union gl_dlist_node *Head; -}; - - -/** - * State used during display list compilation and execution. - */ -struct gl_dlist_state -{ - GLuint CallDepth; /**< Current recursion calling depth */ - - struct gl_display_list *CurrentList; /**< List currently being compiled */ - union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ - GLuint CurrentPos; /**< Index into current block of nodes */ - - GLvertexformat ListVtxfmt; - - GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; - GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; - - GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; - GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; - - GLubyte ActiveIndex; - GLfloat CurrentIndex; - - GLubyte ActiveEdgeFlag; - GLboolean CurrentEdgeFlag; - - struct { - /* State known to have been set by the currently-compiling display - * list. Used to eliminate some redundant state changes. - */ - GLenum ShadeModel; - } Current; -}; - -/** - * Enum for the OpenGL APIs we know about and may support. - */ -typedef enum { - API_OPENGL, - API_OPENGLES, - API_OPENGLES2 -} gl_api; - -/** - * Mesa rendering context. - * - * This is the central context data structure for Mesa. Almost all - * OpenGL state is contained in this structure. - * Think of this as a base class from which device drivers will derive - * sub classes. - * - * The GLcontext typedef names this structure. - */ -struct __GLcontextRec -{ - /** State possibly shared with other contexts in the address space */ - struct gl_shared_state *Shared; - - /** \name API function pointer tables */ - /*@{*/ - gl_api API; - struct _glapi_table *Save; /**< Display list save functions */ - struct _glapi_table *Exec; /**< Execute functions */ - struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ - /*@}*/ - - GLvisual Visual; - GLframebuffer *DrawBuffer; /**< buffer for writing */ - GLframebuffer *ReadBuffer; /**< buffer for reading */ - GLframebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ - GLframebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ - - /** - * Device driver function pointer table - */ - struct dd_function_table Driver; - - void *DriverCtx; /**< Points to device driver context/state */ - - /** Core/Driver constants */ - struct gl_constants Const; - - /** \name The various 4x4 matrix stacks */ - /*@{*/ - struct gl_matrix_stack ModelviewMatrixStack; - struct gl_matrix_stack ProjectionMatrixStack; - struct gl_matrix_stack ColorMatrixStack; - struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; - struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; - struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ - /*@}*/ - - /** Combined modelview and projection matrix */ - GLmatrix _ModelProjectMatrix; - - /** \name Display lists */ - struct gl_dlist_state ListState; - - GLboolean ExecuteFlag; /**< Execute GL commands? */ - GLboolean CompileFlag; /**< Compile GL commands into display list? */ - - /** Extension information */ - struct gl_extensions Extensions; - - /** Version info */ - GLuint VersionMajor, VersionMinor; - char *VersionString; - - /** \name State attribute stack (for glPush/PopAttrib) */ - /*@{*/ - GLuint AttribStackDepth; - struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Renderer attribute groups - * - * We define a struct for each attribute group to make pushing and popping - * attributes easy. Also it's a good organization. - */ - /*@{*/ - struct gl_accum_attrib Accum; /**< Accum buffer attributes */ - struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ - struct gl_current_attrib Current; /**< Current attributes */ - struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ - struct gl_eval_attrib Eval; /**< Eval attributes */ - struct gl_fog_attrib Fog; /**< Fog attributes */ - struct gl_hint_attrib Hint; /**< Hint attributes */ - struct gl_light_attrib Light; /**< Light attributes */ - struct gl_line_attrib Line; /**< Line attributes */ - struct gl_list_attrib List; /**< List attributes */ - struct gl_multisample_attrib Multisample; - struct gl_pixel_attrib Pixel; /**< Pixel attributes */ - struct gl_point_attrib Point; /**< Point attributes */ - struct gl_polygon_attrib Polygon; /**< Polygon attributes */ - GLuint PolygonStipple[32]; /**< Polygon stipple */ - struct gl_scissor_attrib Scissor; /**< Scissor attributes */ - struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ - struct gl_texture_attrib Texture; /**< Texture attributes */ - struct gl_transform_attrib Transform; /**< Transformation attributes */ - struct gl_viewport_attrib Viewport; /**< Viewport attributes */ - /*@}*/ - - /** \name Client attribute stack */ - /*@{*/ - GLuint ClientAttribStackDepth; - struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Client attribute groups */ - /*@{*/ - struct gl_array_attrib Array; /**< Vertex arrays */ - struct gl_pixelstore_attrib Pack; /**< Pixel packing */ - struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ - struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ - /*@}*/ - - /** \name Other assorted state (not pushed/popped on attribute stack) */ - /*@{*/ - struct gl_pixelmaps PixelMaps; - struct gl_histogram_attrib Histogram; - struct gl_minmax_attrib MinMax; - struct gl_convolution_attrib Convolution1D; - struct gl_convolution_attrib Convolution2D; - struct gl_convolution_attrib Separable2D; - - struct gl_evaluators EvalMap; /**< All evaluators */ - struct gl_feedback Feedback; /**< Feedback */ - struct gl_selection Select; /**< Selection */ - - struct gl_color_table ColorTable[COLORTABLE_MAX]; - struct gl_color_table ProxyColorTable[COLORTABLE_MAX]; - - struct gl_program_state Program; /**< general program state */ - struct gl_vertex_program_state VertexProgram; - struct gl_fragment_program_state FragmentProgram; - struct gl_geometry_program_state GeometryProgram; - struct gl_ati_fragment_shader_state ATIFragmentShader; - - struct gl_shader_state Shader; /**< GLSL shader object state */ - struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; - - struct gl_query_state Query; /**< occlusion, timer queries */ - - struct gl_transform_feedback TransformFeedback; - - struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ - struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ - /*@}*/ - - struct gl_meta_state *Meta; /**< for "meta" operations */ - - /* GL_EXT_framebuffer_object */ - struct gl_renderbuffer *CurrentRenderbuffer; - - GLenum ErrorValue; /**< Last error code */ - - /** - * Recognize and silence repeated error debug messages in buggy apps. - */ - const char *ErrorDebugFmtString; - GLuint ErrorDebugCount; - - GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ - GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - - GLboolean ViewportInitialized; /**< has viewport size been initialized? */ - - GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ - - /** \name Derived state */ - /*@{*/ - /** Bitwise-or of DD_* flags. Note that this bitfield may be used before - * state validation so they need to always be current. - */ - GLbitfield _TriangleCaps; - GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ - GLfloat _EyeZDir[3]; - GLfloat _ModelViewInvScale; - GLboolean _NeedEyeCoords; - GLboolean _ForceEyeCoords; - - GLuint TextureStateTimestamp; /**< detect changes to shared state */ - - struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ - struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ - /**@}*/ - - struct gl_list_extensions *ListExt; /**< driver dlist extensions */ - - /** \name For debugging/development only */ - /*@{*/ - GLboolean FirstTimeCurrent; - /*@}*/ - - /** Dither disable via MESA_NO_DITHER env var */ - GLboolean NoDither; - - /** software compression/decompression supported or not */ - GLboolean Mesa_DXTn; - - /** - * Use dp4 (rather than mul/mad) instructions for position - * transformation? - */ - GLboolean mvp_with_dp4; - - /** Core tnl module support */ - struct gl_tnl_module TnlModule; - - /** - * \name Hooks for module contexts. - * - * These will eventually live in the driver or elsewhere. - */ - /*@{*/ - void *swrast_context; - void *swsetup_context; - void *swtnl_context; - void *swtnl_im; - struct st_context *st; - void *aelt_context; - /*@}*/ -}; - - -/** The string names for GL_POINT, GL_LINE_LOOP, etc */ -extern const char *_mesa_prim_name[GL_POLYGON+4]; - - -#ifdef DEBUG -extern int MESA_VERBOSE; -extern int MESA_DEBUG_FLAGS; -# define MESA_FUNCTION __FUNCTION__ -#else -# define MESA_VERBOSE 0 -# define MESA_DEBUG_FLAGS 0 -# define MESA_FUNCTION "a function" -# ifndef NDEBUG -# define NDEBUG -# endif -#endif - - -/** The MESA_VERBOSE var is a bitmask of these flags */ -enum _verbose -{ - VERBOSE_VARRAY = 0x0001, - VERBOSE_TEXTURE = 0x0002, - VERBOSE_MATERIAL = 0x0004, - VERBOSE_PIPELINE = 0x0008, - VERBOSE_DRIVER = 0x0010, - VERBOSE_STATE = 0x0020, - VERBOSE_API = 0x0040, - VERBOSE_DISPLAY_LIST = 0x0100, - VERBOSE_LIGHTING = 0x0200, - VERBOSE_PRIMS = 0x0400, - VERBOSE_VERTS = 0x0800, - VERBOSE_DISASSEM = 0x1000, - VERBOSE_DRAW = 0x2000, - VERBOSE_SWAPBUFFERS = 0x4000 -}; - - -/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ -enum _debug -{ - DEBUG_ALWAYS_FLUSH = 0x1 -}; - - - -#endif /* MTYPES_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ + +#ifndef MTYPES_H +#define MTYPES_H + + +#include "main/glheader.h" +#include "main/config.h" +#include "main/mfeatures.h" +#include "glapi/glapi.h" +#include "math/m_matrix.h" /* GLmatrix */ +#include "main/simple_list.h" /* struct simple_node */ + + +/** + * Color channel data type. + */ +#if CHAN_BITS == 8 + typedef GLubyte GLchan; +#define CHAN_MAX 255 +#define CHAN_MAXF 255.0F +#define CHAN_TYPE GL_UNSIGNED_BYTE +#elif CHAN_BITS == 16 + typedef GLushort GLchan; +#define CHAN_MAX 65535 +#define CHAN_MAXF 65535.0F +#define CHAN_TYPE GL_UNSIGNED_SHORT +#elif CHAN_BITS == 32 + typedef GLfloat GLchan; +#define CHAN_MAX 1.0 +#define CHAN_MAXF 1.0F +#define CHAN_TYPE GL_FLOAT +#else +#error "illegal number of color channel bits" +#endif + + +/** + * Stencil buffer data type. + */ +#if STENCIL_BITS==8 + typedef GLubyte GLstencil; +#elif STENCIL_BITS==16 + typedef GLushort GLstencil; +#else +# error "illegal number of stencil bits" +#endif + + +/** + * \name 64-bit extension of GLbitfield. + */ +/*@{*/ +typedef GLuint64 GLbitfield64; + +#define BITFIELD64_ONE 1ULL +#define BITFIELD64_ALLONES ~0ULL + +/** Set a single bit */ +#define BITFIELD64_BIT(b) (BITFIELD64_ONE << (b)) + +/** Set a mask of the least significant \c b bits */ +#define BITFIELD64_MASK(b) (((b) >= 64) ? BITFIELD64_ALLONES : \ + (BITFIELD64_BIT(b) - 1)) + +/** + * Set all bits from l (low bit) to h (high bit), inclusive. + * + * \note \C BITFIELD_64_RANGE(0, 63) return 64 set bits. + */ +#define BITFIELD64_RANGE(l, h) (BITFIELD64_MASK((h) + 1) & ~BITFIELD64_MASK(l)) +/*@}*/ + + +/** + * \name Some forward type declarations + */ +/*@{*/ +struct _mesa_HashTable; +struct gl_attrib_node; +struct gl_list_extensions; +struct gl_meta_state; +struct gl_pixelstore_attrib; +struct gl_program_cache; +struct gl_texture_format; +struct gl_texture_image; +struct gl_texture_object; +struct gl_context; +struct st_context; +/*@}*/ + + + +/** + * Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as gallium's PIPE_SHADER_* + */ +typedef enum +{ + MESA_SHADER_VERTEX = 0, + MESA_SHADER_FRAGMENT = 1, + MESA_SHADER_GEOMETRY = 2, + MESA_SHADER_TYPES = 3 +} gl_shader_type; + + + +/** + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). + */ +typedef enum +{ + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_COLOR_INDEX = 6, + VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ + VERT_ATTRIB_EDGEFLAG = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 +} gl_vert_attrib; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) + +#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ + + +/** + * Indexes for vertex program result attributes + */ +typedef enum +{ + VERT_RESULT_HPOS = 0, + VERT_RESULT_COL0 = 1, + VERT_RESULT_COL1 = 2, + VERT_RESULT_FOGC = 3, + VERT_RESULT_TEX0 = 4, + VERT_RESULT_TEX1 = 5, + VERT_RESULT_TEX2 = 6, + VERT_RESULT_TEX3 = 7, + VERT_RESULT_TEX4 = 8, + VERT_RESULT_TEX5 = 9, + VERT_RESULT_TEX6 = 10, + VERT_RESULT_TEX7 = 11, + VERT_RESULT_PSIZ = 12, + VERT_RESULT_BFC0 = 13, + VERT_RESULT_BFC1 = 14, + VERT_RESULT_EDGE = 15, + VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) +} gl_vert_result; + + +/*********************************************/ + +/** + * Indexes for geometry program attributes. + */ +typedef enum +{ + GEOM_ATTRIB_POSITION = 0, + GEOM_ATTRIB_COLOR0 = 1, + GEOM_ATTRIB_COLOR1 = 2, + GEOM_ATTRIB_SECONDARY_COLOR0 = 3, + GEOM_ATTRIB_SECONDARY_COLOR1 = 4, + GEOM_ATTRIB_FOG_FRAG_COORD = 5, + GEOM_ATTRIB_POINT_SIZE = 6, + GEOM_ATTRIB_CLIP_VERTEX = 7, + GEOM_ATTRIB_PRIMITIVE_ID = 8, + GEOM_ATTRIB_TEX_COORD = 9, + + GEOM_ATTRIB_VAR0 = 16, + GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) +} gl_geom_attrib; + +/** + * Bitflags for geometry attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) +#define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) +#define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) +#define GEOM_BIT_SCOLOR1 (1 << GEOM_ATTRIB_SECONDARY_COLOR1) +#define GEOM_BIT_TEX_COORD (1 << GEOM_ATTRIB_TEX_COORD) +#define GEOM_BIT_FOG_COORD (1 << GEOM_ATTRIB_FOG_FRAG_COORD) +#define GEOM_BIT_POSITION (1 << GEOM_ATTRIB_POSITION) +#define GEOM_BIT_POINT_SIDE (1 << GEOM_ATTRIB_POINT_SIZE) +#define GEOM_BIT_CLIP_VERTEX (1 << GEOM_ATTRIB_CLIP_VERTEX) +#define GEOM_BIT_PRIM_ID (1 << GEOM_ATTRIB_PRIMITIVE_ID) +#define GEOM_BIT_VAR0 (1 << GEOM_ATTRIB_VAR0) + +#define GEOM_BIT_VAR(g) (1 << (GEOM_BIT_VAR0 + (g))) +/*@}*/ + + +/** + * Indexes for geometry program result attributes + */ +/*@{*/ +typedef enum { + GEOM_RESULT_POS = 0, + GEOM_RESULT_COL0 = 1, + GEOM_RESULT_COL1 = 2, + GEOM_RESULT_SCOL0 = 3, + GEOM_RESULT_SCOL1 = 4, + GEOM_RESULT_FOGC = 5, + GEOM_RESULT_TEX0 = 6, + GEOM_RESULT_TEX1 = 7, + GEOM_RESULT_TEX2 = 8, + GEOM_RESULT_TEX3 = 9, + GEOM_RESULT_TEX4 = 10, + GEOM_RESULT_TEX5 = 11, + GEOM_RESULT_TEX6 = 12, + GEOM_RESULT_TEX7 = 13, + GEOM_RESULT_PSIZ = 14, + GEOM_RESULT_CLPV = 15, + GEOM_RESULT_PRID = 16, + GEOM_RESULT_LAYR = 17, + GEOM_RESULT_VAR0 = 18, /**< shader varying, should really be 16 */ + /* ### we need to -2 because var0 is 18 instead 16 like in the others */ + GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) +} gl_geom_result; +/*@}*/ + +/** + * Indexes for fragment program input attributes. + */ +typedef enum +{ + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11, + FRAG_ATTRIB_FACE = 12, /**< front/back face */ + FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ + FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) +} gl_frag_attrib; + +/** + * Bitflags for fragment program input attributes. + */ +/*@{*/ +#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) +#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) +#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) +#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) +#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) +#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) +#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) +#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) +#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) +#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) +#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) +#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) +#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) +#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) +#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) + +#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) +#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) + +#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ + FRAG_BIT_TEX1| \ + FRAG_BIT_TEX2| \ + FRAG_BIT_TEX3| \ + FRAG_BIT_TEX4| \ + FRAG_BIT_TEX5| \ + FRAG_BIT_TEX6| \ + FRAG_BIT_TEX7) +/*@}*/ + + +/** + * Fragment program results + */ +typedef enum +{ + FRAG_RESULT_DEPTH = 0, + FRAG_RESULT_STENCIL = 1, + FRAG_RESULT_COLOR = 2, + FRAG_RESULT_DATA0 = 3, + FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) +} gl_frag_result; + + +/** + * Indexes for all renderbuffers + */ +typedef enum +{ + /* the four standard color buffers */ + BUFFER_FRONT_LEFT, + BUFFER_BACK_LEFT, + BUFFER_FRONT_RIGHT, + BUFFER_BACK_RIGHT, + BUFFER_DEPTH, + BUFFER_STENCIL, + BUFFER_ACCUM, + /* optional aux buffer */ + BUFFER_AUX0, + /* generic renderbuffers */ + BUFFER_COLOR0, + BUFFER_COLOR1, + BUFFER_COLOR2, + BUFFER_COLOR3, + BUFFER_COLOR4, + BUFFER_COLOR5, + BUFFER_COLOR6, + BUFFER_COLOR7, + BUFFER_COUNT +} gl_buffer_index; + +/** + * Bit flags for all renderbuffers + */ +#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) +#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) +#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) +#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) +#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) +#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) +#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) +#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) +#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) +#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) +#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) +#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) +#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) +#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) +#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) +#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) +#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) +#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) +#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) + +/** + * Mask of all the color buffer bits (but not accum). + */ +#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ + BUFFER_BIT_BACK_LEFT | \ + BUFFER_BIT_FRONT_RIGHT | \ + BUFFER_BIT_BACK_RIGHT | \ + BUFFER_BIT_AUX0 | \ + BUFFER_BIT_COLOR0 | \ + BUFFER_BIT_COLOR1 | \ + BUFFER_BIT_COLOR2 | \ + BUFFER_BIT_COLOR3 | \ + BUFFER_BIT_COLOR4 | \ + BUFFER_BIT_COLOR5 | \ + BUFFER_BIT_COLOR6 | \ + BUFFER_BIT_COLOR7) + + +/** + * Framebuffer configuration (aka visual / pixelformat) + * Note: some of these fields should be boolean, but it appears that + * code in drivers/dri/common/util.c requires int-sized fields. + */ +struct gl_config +{ + GLboolean rgbMode; + GLboolean floatMode; + GLboolean colorIndexMode; /* XXX is this used anywhere? */ + GLuint doubleBufferMode; + GLuint stereoMode; + + GLboolean haveAccumBuffer; + GLboolean haveDepthBuffer; + GLboolean haveStencilBuffer; + + GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ + GLuint redMask, greenMask, blueMask, alphaMask; + GLint rgbBits; /* total bits for rgb */ + GLint indexBits; /* total bits for colorindex */ + + GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; + GLint depthBits; + GLint stencilBits; + + GLint numAuxBuffers; + + GLint level; + + /* EXT_visual_rating / GLX 1.2 */ + GLint visualRating; + + /* EXT_visual_info / GLX 1.2 */ + GLint transparentPixel; + /* colors are floats scaled to ints */ + GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; + GLint transparentIndex; + + /* ARB_multisample / SGIS_multisample */ + GLint sampleBuffers; + GLint samples; + + /* SGIX_pbuffer / GLX 1.3 */ + GLint maxPbufferWidth; + GLint maxPbufferHeight; + GLint maxPbufferPixels; + GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ + GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ + + /* OML_swap_method */ + GLint swapMethod; + + /* EXT_texture_from_pixmap */ + GLint bindToTextureRgb; + GLint bindToTextureRgba; + GLint bindToMipmapTexture; + GLint bindToTextureTargets; + GLint yInverted; +}; + + +/** + * Data structure for color tables + */ +struct gl_color_table +{ + GLenum InternalFormat; /**< The user-specified format */ + GLenum _BaseFormat; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */ + GLuint Size; /**< number of entries in table */ + GLfloat *TableF; /**< Color table, floating point values */ + GLubyte *TableUB; /**< Color table, ubyte values */ + GLubyte RedSize; + GLubyte GreenSize; + GLubyte BlueSize; + GLubyte AlphaSize; + GLubyte LuminanceSize; + GLubyte IntensitySize; +}; + + +/** + * \name Bit flags used for updating material values. + */ +/*@{*/ +#define MAT_ATTRIB_FRONT_AMBIENT 0 +#define MAT_ATTRIB_BACK_AMBIENT 1 +#define MAT_ATTRIB_FRONT_DIFFUSE 2 +#define MAT_ATTRIB_BACK_DIFFUSE 3 +#define MAT_ATTRIB_FRONT_SPECULAR 4 +#define MAT_ATTRIB_BACK_SPECULAR 5 +#define MAT_ATTRIB_FRONT_EMISSION 6 +#define MAT_ATTRIB_BACK_EMISSION 7 +#define MAT_ATTRIB_FRONT_SHININESS 8 +#define MAT_ATTRIB_BACK_SHININESS 9 +#define MAT_ATTRIB_FRONT_INDEXES 10 +#define MAT_ATTRIB_BACK_INDEXES 11 +#define MAT_ATTRIB_MAX 12 + +#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) +#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) +#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) +#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) +#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) +#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) + +#define MAT_INDEX_AMBIENT 0 +#define MAT_INDEX_DIFFUSE 1 +#define MAT_INDEX_SPECULAR 2 + +#define MAT_BIT_FRONT_AMBIENT (1< ) */ + GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ + GLfloat _VP_inf_spot_attenuation; + + GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ + GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ + GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ + GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ + GLfloat _dli; /**< CI diffuse light intensity */ + GLfloat _sli; /**< CI specular light intensity */ + /*@}*/ +}; + + +/** + * Light model state. + */ +struct gl_lightmodel +{ + GLfloat Ambient[4]; /**< ambient color */ + GLboolean LocalViewer; /**< Local (or infinite) view point? */ + GLboolean TwoSide; /**< Two (or one) sided lighting? */ + GLenum ColorControl; /**< either GL_SINGLE_COLOR + * or GL_SEPARATE_SPECULAR_COLOR */ +}; + + +/** + * Material state. + */ +struct gl_material +{ + GLfloat Attrib[MAT_ATTRIB_MAX][4]; +}; + + +/** + * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) + */ +struct gl_accum_attrib +{ + GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ +}; + + +/** + * Color buffer attribute group (GL_COLOR_BUFFER_BIT). + */ +struct gl_colorbuffer_attrib +{ + GLuint ClearIndex; /**< Index to use for glClear */ + GLclampf ClearColor[4]; /**< Color to use for glClear */ + + GLuint IndexMask; /**< Color index write mask */ + GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ + + GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ + + /** + * \name alpha testing + */ + /*@{*/ + GLboolean AlphaEnabled; /**< Alpha test enabled flag */ + GLenum AlphaFunc; /**< Alpha test function */ + GLclampf AlphaRef; /**< Alpha reference value */ + /*@}*/ + + /** + * \name Blending + */ + /*@{*/ + GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ + GLenum BlendSrcRGB; /**< Blending source operator */ + GLenum BlendDstRGB; /**< Blending destination operator */ + GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */ + GLenum BlendDstA; /**< GL_INGR_blend_func_separate */ + GLenum BlendEquationRGB; /**< Blending equation */ + GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */ + GLfloat BlendColor[4]; /**< Blending color */ + /*@}*/ + + /** + * \name Logic op + */ + /*@{*/ + GLenum LogicOp; /**< Logic operator */ + GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ + GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ + GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */ + /*@}*/ + + GLboolean DitherFlag; /**< Dither enable flag */ + + GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ +}; + + +/** + * Current attribute group (GL_CURRENT_BIT). + */ +struct gl_current_attrib +{ + /** + * \name Current vertex attributes. + * \note Values are valid only after FLUSH_VERTICES has been called. + * \note Index and Edgeflag current values are stored as floats in the + * SIX and SEVEN attribute slots. + */ + GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ + + /** + * \name Current raster position attributes (always valid). + * \note This set of attributes is very similar to the SWvertex struct. + */ + /*@{*/ + GLfloat RasterPos[4]; + GLfloat RasterDistance; + GLfloat RasterColor[4]; + GLfloat RasterSecondaryColor[4]; + GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; + GLboolean RasterPosValid; + /*@}*/ +}; + + +/** + * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). + */ +struct gl_depthbuffer_attrib +{ + GLenum Func; /**< Function for depth buffer compare */ + GLclampd Clear; /**< Value to clear depth buffer to */ + GLboolean Test; /**< Depth buffering enabled flag */ + GLboolean Mask; /**< Depth buffer writable? */ + GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ + GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ +}; + + +/** + * Evaluator attribute group (GL_EVAL_BIT). + */ +struct gl_eval_attrib +{ + /** + * \name Enable bits + */ + /*@{*/ + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ + GLboolean AutoNormal; + /*@}*/ + + /** + * \name Map Grid endpoints and divisions and calculated du values + */ + /*@{*/ + GLint MapGrid1un; + GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; + GLint MapGrid2un, MapGrid2vn; + GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; + GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; + /*@}*/ +}; + + +/** + * Fog attribute group (GL_FOG_BIT). + */ +struct gl_fog_attrib +{ + GLboolean Enabled; /**< Fog enabled flag */ + GLfloat Color[4]; /**< Fog color */ + GLfloat Density; /**< Density >= 0.0 */ + GLfloat Start; /**< Start distance in eye coords */ + GLfloat End; /**< End distance in eye coords */ + GLfloat Index; /**< Fog index */ + GLenum Mode; /**< Fog mode */ + GLboolean ColorSumEnabled; + GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ + GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ +}; + + +/** + * Hint attribute group (GL_HINT_BIT). + * + * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. + */ +struct gl_hint_attrib +{ + GLenum PerspectiveCorrection; + GLenum PointSmooth; + GLenum LineSmooth; + GLenum PolygonSmooth; + GLenum Fog; + GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ + GLenum TextureCompression; /**< GL_ARB_texture_compression */ + GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ +}; + +/** + * Light state flags. + */ +/*@{*/ +#define LIGHT_SPOT 0x1 +#define LIGHT_LOCAL_VIEWER 0x2 +#define LIGHT_POSITIONAL 0x4 +#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) +/*@}*/ + + +/** + * Lighting attribute group (GL_LIGHT_BIT). + */ +struct gl_light_attrib +{ + struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ + struct gl_lightmodel Model; /**< Lighting model */ + + /** + * Must flush FLUSH_VERTICES before referencing: + */ + /*@{*/ + struct gl_material Material; /**< Includes front & back values */ + /*@}*/ + + GLboolean Enabled; /**< Lighting enabled flag */ + GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ + GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ + GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ + GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ + GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ + GLboolean ColorMaterialEnabled; + GLenum ClampVertexColor; + + struct gl_light EnabledList; /**< List sentinel */ + + /** + * Derived state for optimizations: + */ + /*@{*/ + GLboolean _NeedEyeCoords; + GLboolean _NeedVertices; /**< Use fast shader? */ + GLbitfield _Flags; /**< LIGHT_* flags, see above */ + GLfloat _BaseColor[2][3]; + /*@}*/ +}; + + +/** + * Line attribute group (GL_LINE_BIT). + */ +struct gl_line_attrib +{ + GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ + GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ + GLushort StipplePattern; /**< Stipple pattern */ + GLint StippleFactor; /**< Stipple repeat factor */ + GLfloat Width; /**< Line width */ +}; + + +/** + * Display list attribute group (GL_LIST_BIT). + */ +struct gl_list_attrib +{ + GLuint ListBase; +}; + + +/** + * Multisample attribute group (GL_MULTISAMPLE_BIT). + */ +struct gl_multisample_attrib +{ + GLboolean Enabled; + GLboolean _Enabled; /**< true if Enabled and multisample buffer */ + GLboolean SampleAlphaToCoverage; + GLboolean SampleAlphaToOne; + GLboolean SampleCoverage; + GLfloat SampleCoverageValue; + GLboolean SampleCoverageInvert; +}; + + +/** + * A pixelmap (see glPixelMap) + */ +struct gl_pixelmap +{ + GLint Size; + GLfloat Map[MAX_PIXEL_MAP_TABLE]; + GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ +}; + + +/** + * Collection of all pixelmaps + */ +struct gl_pixelmaps +{ + struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ + struct gl_pixelmap GtoG; + struct gl_pixelmap BtoB; + struct gl_pixelmap AtoA; + struct gl_pixelmap ItoR; + struct gl_pixelmap ItoG; + struct gl_pixelmap ItoB; + struct gl_pixelmap ItoA; + struct gl_pixelmap ItoI; + struct gl_pixelmap StoS; +}; + + +/** + * Pixel attribute group (GL_PIXEL_MODE_BIT). + */ +struct gl_pixel_attrib +{ + GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ + + /*--- Begin Pixel Transfer State ---*/ + /* Fields are in the order in which they're applied... */ + + /** Scale & Bias (index shift, offset) */ + /*@{*/ + GLfloat RedBias, RedScale; + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLfloat DepthBias, DepthScale; + GLint IndexShift, IndexOffset; + /*@}*/ + + /* Pixel Maps */ + /* Note: actual pixel maps are not part of this attrib group */ + GLboolean MapColorFlag; + GLboolean MapStencilFlag; + + /*--- End Pixel Transfer State ---*/ + + /** glPixelZoom */ + GLfloat ZoomX, ZoomY; + + /** GL_SGI_texture_color_table */ + GLfloat TextureColorTableScale[4]; /**< RGBA */ + GLfloat TextureColorTableBias[4]; /**< RGBA */ +}; + + +/** + * Point attribute group (GL_POINT_BIT). + */ +struct gl_point_attrib +{ + GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ + GLfloat Size; /**< User-specified point size */ + GLfloat Params[3]; /**< GL_EXT_point_parameters */ + GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ + GLfloat Threshold; /**< GL_EXT_point_parameters */ + GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ + GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ + GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ + GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ + GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ +}; + + +/** + * Polygon attribute group (GL_POLYGON_BIT). + */ +struct gl_polygon_attrib +{ + GLenum FrontFace; /**< Either GL_CW or GL_CCW */ + GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ + GLboolean CullFlag; /**< Culling on/off flag */ + GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ + GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ + GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ + GLfloat OffsetFactor; /**< Polygon offset factor, from user */ + GLfloat OffsetUnits; /**< Polygon offset units, from user */ + GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ + GLboolean OffsetLine; /**< Offset in GL_LINE mode */ + GLboolean OffsetFill; /**< Offset in GL_FILL mode */ +}; + + +/** + * Scissor attributes (GL_SCISSOR_BIT). + */ +struct gl_scissor_attrib +{ + GLboolean Enabled; /**< Scissor test enabled? */ + GLint X, Y; /**< Lower left corner of box */ + GLsizei Width, Height; /**< Size of box */ +}; + + +/** + * Stencil attribute group (GL_STENCIL_BUFFER_BIT). + * + * Three sets of stencil data are tracked so that OpenGL 2.0, + * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported + * simultaneously. In each of the stencil state arrays, element 0 corresponds + * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / + * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the + * GL_EXT_stencil_two_side GL_BACK state. + * + * The derived value \c _BackFace is either 1 or 2 depending on whether or + * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. + * + * The derived value \c _TestTwoSide is set when the front-face and back-face + * stencil state are different. + */ +struct gl_stencil_attrib +{ + GLboolean Enabled; /**< Enabled flag */ + GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ + GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ + GLboolean _Enabled; /**< Enabled and stencil buffer present */ + GLboolean _TestTwoSide; + GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ + GLenum Function[3]; /**< Stencil function */ + GLenum FailFunc[3]; /**< Fail function */ + GLenum ZPassFunc[3]; /**< Depth buffer pass function */ + GLenum ZFailFunc[3]; /**< Depth buffer fail function */ + GLint Ref[3]; /**< Reference value */ + GLuint ValueMask[3]; /**< Value mask */ + GLuint WriteMask[3]; /**< Write mask */ + GLuint Clear; /**< Clear value */ +}; + + +/** + * An index for each type of texture object. These correspond to the GL + * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. + * Note: the order is from highest priority to lowest priority. + */ +typedef enum +{ + TEXTURE_2D_ARRAY_INDEX, + TEXTURE_1D_ARRAY_INDEX, + TEXTURE_CUBE_INDEX, + TEXTURE_3D_INDEX, + TEXTURE_RECT_INDEX, + TEXTURE_2D_INDEX, + TEXTURE_1D_INDEX, + NUM_TEXTURE_TARGETS +} gl_texture_index; + + +/** + * Bit flags for each type of texture object + * Used for Texture.Unit[]._ReallyEnabled flags. + */ +/*@{*/ +#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) +#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) +#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) +#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) +#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) +#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) +/*@}*/ + + +/** + * TexGenEnabled flags. + */ +/*@{*/ +#define S_BIT 1 +#define T_BIT 2 +#define R_BIT 4 +#define Q_BIT 8 +#define STR_BITS (S_BIT | T_BIT | R_BIT) +/*@}*/ + + +/** + * Bit flag versions of the corresponding GL_ constants. + */ +/*@{*/ +#define TEXGEN_SPHERE_MAP 0x1 +#define TEXGEN_OBJ_LINEAR 0x2 +#define TEXGEN_EYE_LINEAR 0x4 +#define TEXGEN_REFLECTION_MAP_NV 0x8 +#define TEXGEN_NORMAL_MAP_NV 0x10 + +#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV) +#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV | \ + TEXGEN_EYE_LINEAR) +/*@}*/ + + + +/** Tex-gen enabled for texture unit? */ +#define ENABLE_TEXGEN(unit) (1 << (unit)) + +/** Non-identity texture matrix for texture unit? */ +#define ENABLE_TEXMAT(unit) (1 << (unit)) + + +/** + * Texel fetch function prototype. We use texel fetch functions to + * extract RGBA, color indexes and depth components out of 1D, 2D and 3D + * texture images. These functions help to isolate us from the gritty + * details of all the various texture image encodings. + * + * \param texImage texture image. + * \param col texel column. + * \param row texel row. + * \param img texel image level/layer. + * \param texelOut output texel (up to 4 GLchans) + */ +typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLchan *texelOut ); + +/** + * As above, but returns floats. + * Used for depth component images and for upcoming signed/float + * texture images. + */ +typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLfloat *texelOut ); + + +typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + const void *texel); + + +/** + * Texture image state. Describes the dimensions of a texture image, + * the texel format and pointers to Texel Fetch functions. + */ +struct gl_texture_image +{ + GLint InternalFormat; /**< Internal format as given by the user */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_COLOR_INDEX, + * GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT + * only. Used for choosing TexEnv arithmetic. + */ + GLuint TexFormat; /**< The actual format: MESA_FORMAT_x */ + + GLuint Border; /**< 0 or 1 */ + GLuint Width; /**< = 2^WidthLog2 + 2*Border */ + GLuint Height; /**< = 2^HeightLog2 + 2*Border */ + GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ + GLuint Width2; /**< = Width - 2*Border */ + GLuint Height2; /**< = Height - 2*Border */ + GLuint Depth2; /**< = Depth - 2*Border */ + GLuint WidthLog2; /**< = log2(Width2) */ + GLuint HeightLog2; /**< = log2(Height2) */ + GLuint DepthLog2; /**< = log2(Depth2) */ + GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ + GLfloat WidthScale; /**< used for mipmap LOD computation */ + GLfloat HeightScale; /**< used for mipmap LOD computation */ + GLfloat DepthScale; /**< used for mipmap LOD computation */ + GLboolean IsClientData; /**< Data owned by client? */ + GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ + + struct gl_texture_object *TexObject; /**< Pointer back to parent object */ + + FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ + FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ + + GLuint RowStride; /**< Padded width in units of texels */ + GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to + each 2D slice in 'Data', in texels */ + GLvoid *Data; /**< Image data, accessed via FetchTexel() */ + + /** + * \name For device driver: + */ + /*@{*/ + void *DriverData; /**< Arbitrary device driver data */ + /*@}*/ +}; + + +/** + * Indexes for cube map faces. + */ +typedef enum +{ + FACE_POS_X = 0, + FACE_NEG_X = 1, + FACE_POS_Y = 2, + FACE_NEG_Y = 3, + FACE_POS_Z = 4, + FACE_NEG_Z = 5, + MAX_FACES = 6 +} gl_face_index; + + +/** + * Texture object state. Contains the array of mipmap images, border color, + * wrap modes, filter modes, shadow/texcompare state, and the per-texture + * color palette. + */ +struct gl_texture_object +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< reference count */ + GLuint Name; /**< the user-visible texture object ID */ + GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ + GLfloat Priority; /**< in [0,1] */ + union { + GLfloat f[4]; + GLuint ui[4]; + GLint i[4]; + } BorderColor; /**< Interpreted according to texture format */ + GLenum WrapS; /**< S-axis texture image wrap mode */ + GLenum WrapT; /**< T-axis texture image wrap mode */ + GLenum WrapR; /**< R-axis texture image wrap mode */ + GLenum MinFilter; /**< minification filter */ + GLenum MagFilter; /**< magnification filter */ + GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ + GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ + GLfloat LodBias; /**< OpenGL 1.4 */ + GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ + GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ + GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLenum CompareMode; /**< GL_ARB_shadow */ + GLenum CompareFunc; /**< GL_ARB_shadow */ + GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ + GLenum DepthMode; /**< GL_ARB_depth_texture */ + GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ + GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ + GLint CropRect[4]; /**< GL_OES_draw_texture */ + GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ + GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ + GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLboolean _Complete; /**< Is texture object complete? */ + GLboolean _RenderToTexture; /**< Any rendering to this texture? */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + /** Actual texture images, indexed by [cube face] and [mipmap level] */ + struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; + + /** GL_EXT_paletted_texture */ + struct gl_color_table Palette; + + /** + * \name For device driver. + * Note: instead of attaching driver data to this pointer, it's preferable + * to instead use this struct as a base class for your own texture object + * class. Driver->NewTextureObject() can be used to implement the + * allocation. + */ + void *DriverData; /**< Arbitrary device driver data */ +}; + + +/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ +#define MAX_COMBINER_TERMS 4 + + +/** + * Texture combine environment state. + */ +struct gl_tex_env_combine_state +{ + GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ + GLenum SourceRGB[MAX_COMBINER_TERMS]; + GLenum SourceA[MAX_COMBINER_TERMS]; + /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ + GLenum OperandRGB[MAX_COMBINER_TERMS]; + GLenum OperandA[MAX_COMBINER_TERMS]; + GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ + GLuint ScaleShiftA; /**< 0, 1 or 2 */ + GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ + GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ +}; + + +/** + * Texture coord generation state. + */ +struct gl_texgen +{ + GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ + GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ + GLfloat ObjectPlane[4]; + GLfloat EyePlane[4]; +}; + + +/** + * Texture unit state. Contains enable flags, texture environment/function/ + * combiners, texgen state, pointers to current texture objects and + * post-filter color tables. + */ +struct gl_texture_unit +{ + GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ + GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ + + GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ + GLfloat EnvColor[4]; + + struct gl_texgen GenS; + struct gl_texgen GenT; + struct gl_texgen GenR; + struct gl_texgen GenQ; + GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ + GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ + + GLfloat LodBias; /**< for biasing mipmap levels */ + GLenum BumpTarget; + GLfloat RotMatrix[4]; /* 2x2 matrix */ + + /** + * \name GL_EXT_texture_env_combine + */ + struct gl_tex_env_combine_state Combine; + + /** + * Derived state based on \c EnvMode and the \c BaseFormat of the + * currently enabled texture. + */ + struct gl_tex_env_combine_state _EnvMode; + + /** + * Currently enabled combiner state. This will point to either + * \c Combine or \c _EnvMode. + */ + struct gl_tex_env_combine_state *_CurrentCombine; + + /** Current texture object pointers */ + struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; + + /** Points to highest priority, complete and enabled texture object */ + struct gl_texture_object *_Current; + + /** GL_SGI_texture_color_table */ + /*@{*/ + struct gl_color_table ColorTable; + struct gl_color_table ProxyColorTable; + GLboolean ColorTableEnabled; + /*@}*/ +}; + + +/** + * Texture attribute group (GL_TEXTURE_BIT). + */ +struct gl_texture_attrib +{ + GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ + struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + + struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; + + /** GL_ARB_seamless_cubemap */ + GLboolean CubeMapSeamless; + + /** GL_EXT_shared_texture_palette */ + GLboolean SharedPalette; + struct gl_color_table Palette; + + /** Texture units/samplers used by vertex or fragment texturing */ + GLbitfield _EnabledUnits; + + /** Texture coord units/sets used for fragment texturing */ + GLbitfield _EnabledCoordUnits; + + /** Texture coord units that have texgen enabled */ + GLbitfield _TexGenEnabled; + + /** Texture coord units that have non-identity matrices */ + GLbitfield _TexMatEnabled; + + /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ + GLbitfield _GenFlags; +}; + + +/** + * Transformation attribute group (GL_TRANSFORM_BIT). + */ +struct gl_transform_attrib +{ + GLenum MatrixMode; /**< Matrix mode */ + GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */ + GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */ + GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ + GLboolean Normalize; /**< Normalize all normals? */ + GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ + GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ + GLboolean DepthClamp; /**< GL_ARB_depth_clamp */ + + GLfloat CullEyePos[4]; + GLfloat CullObjPos[4]; +}; + + +/** + * Viewport attribute group (GL_VIEWPORT_BIT). + */ +struct gl_viewport_attrib +{ + GLint X, Y; /**< position */ + GLsizei Width, Height; /**< size */ + GLfloat Near, Far; /**< Depth buffer range */ + GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ +}; + + +/** + * GL_ARB_vertex/pixel_buffer_object buffer object + */ +struct gl_buffer_object +{ + _glthread_Mutex Mutex; + GLint RefCount; + GLuint Name; + GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ + GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ + GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ + /** Fields describing a mapped buffer */ + /*@{*/ + GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ + GLvoid *Pointer; /**< User-space address of mapping */ + GLintptr Offset; /**< Mapped offset */ + GLsizeiptr Length; /**< Mapped length */ + /*@}*/ + GLboolean Written; /**< Ever written to? (for debugging) */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ +}; + + +/** + * Client pixel packing/unpacking attributes + */ +struct gl_pixelstore_attrib +{ + GLint Alignment; + GLint RowLength; + GLint SkipPixels; + GLint SkipRows; + GLint ImageHeight; + GLint SkipImages; + GLboolean SwapBytes; + GLboolean LsbFirst; + GLboolean ClientStorage; /**< GL_APPLE_client_storage */ + GLboolean Invert; /**< GL_MESA_pack_invert */ + struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ +}; + + +/** + * Client vertex array attributes + */ +struct gl_client_array +{ + GLint Size; /**< components per element (1,2,3,4) */ + GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ + GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ + GLsizei Stride; /**< user-specified stride */ + GLsizei StrideB; /**< actual stride in bytes */ + const GLubyte *Ptr; /**< Points to array data */ + GLboolean Enabled; /**< Enabled flag is a boolean */ + GLboolean Normalized; /**< GL_ARB_vertex_program */ + GLboolean Integer; /**< Integer-valued? */ + GLuint _ElementSize; /**< size of each element in bytes */ + + struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ + GLuint _MaxElement; /**< max element index into array buffer + 1 */ +}; + + +/** + * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object + * extension, but a nice encapsulation in any case. + */ +struct gl_array_object +{ + /** Name of the array object as received from glGenVertexArrayAPPLE. */ + GLuint Name; + + GLint RefCount; + _glthread_Mutex Mutex; + GLboolean VBOonly; /**< require all arrays to live in VBOs? */ + + /** Conventional vertex arrays */ + /*@{*/ + struct gl_client_array Vertex; + struct gl_client_array Weight; + struct gl_client_array Normal; + struct gl_client_array Color; + struct gl_client_array SecondaryColor; + struct gl_client_array FogCoord; + struct gl_client_array Index; + struct gl_client_array EdgeFlag; + struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; + struct gl_client_array PointSize; + /*@}*/ + + /** + * Generic arrays for vertex programs/shaders. + * For NV vertex programs, these attributes alias and take priority + * over the conventional attribs above. For ARB vertex programs and + * GLSL vertex shaders, these attributes are separate. + */ + struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; + + /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ + GLbitfield _Enabled; + + /** + * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs + * we can determine the max legal (in bounds) glDrawElements array index. + */ + GLuint _MaxElement; +}; + + +/** + * Vertex array state + */ +struct gl_array_attrib +{ + /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */ + struct gl_array_object *ArrayObj; + + /** The default vertex array object */ + struct gl_array_object *DefaultArrayObj; + + /** Array objects (GL_ARB/APPLE_vertex_array_object) */ + struct _mesa_HashTable *Objects; + + GLint ActiveTexture; /**< Client Active Texture */ + GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ + GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ + + /** GL 3.1 (slightly different from GL_NV_primitive_restart) */ + GLboolean PrimitiveRestart; + GLuint RestartIndex; + + GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ + + /* GL_ARB_vertex_buffer_object */ + struct gl_buffer_object *ArrayBufferObj; + struct gl_buffer_object *ElementArrayBufferObj; +}; + + +/** + * Feedback buffer state + */ +struct gl_feedback +{ + GLenum Type; + GLbitfield _Mask; /**< FB_* bits */ + GLfloat *Buffer; + GLuint BufferSize; + GLuint Count; +}; + + +/** + * Selection buffer state + */ +struct gl_selection +{ + GLuint *Buffer; /**< selection buffer */ + GLuint BufferSize; /**< size of the selection buffer */ + GLuint BufferCount; /**< number of values in the selection buffer */ + GLuint Hits; /**< number of records in the selection buffer */ + GLuint NameStackDepth; /**< name stack depth */ + GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ + GLboolean HitFlag; /**< hit flag */ + GLfloat HitMinZ; /**< minimum hit depth */ + GLfloat HitMaxZ; /**< maximum hit depth */ +}; + + +/** + * 1-D Evaluator control points + */ +struct gl_1d_map +{ + GLuint Order; /**< Number of control points */ + GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * 2-D Evaluator control points + */ +struct gl_2d_map +{ + GLuint Uorder; /**< Number of control points in U dimension */ + GLuint Vorder; /**< Number of control points in V dimension */ + GLfloat u1, u2, du; + GLfloat v1, v2, dv; + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * All evaluator control point state + */ +struct gl_evaluators +{ + /** + * \name 1-D maps + */ + /*@{*/ + struct gl_1d_map Map1Vertex3; + struct gl_1d_map Map1Vertex4; + struct gl_1d_map Map1Index; + struct gl_1d_map Map1Color4; + struct gl_1d_map Map1Normal; + struct gl_1d_map Map1Texture1; + struct gl_1d_map Map1Texture2; + struct gl_1d_map Map1Texture3; + struct gl_1d_map Map1Texture4; + struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ + + /** + * \name 2-D maps + */ + /*@{*/ + struct gl_2d_map Map2Vertex3; + struct gl_2d_map Map2Vertex4; + struct gl_2d_map Map2Index; + struct gl_2d_map Map2Color4; + struct gl_2d_map Map2Normal; + struct gl_2d_map Map2Texture1; + struct gl_2d_map Map2Texture2; + struct gl_2d_map Map2Texture3; + struct gl_2d_map Map2Texture4; + struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ +}; + + +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, + * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to + * be "uniform" variables since they can only be set outside glBegin/End. + * They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ + PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ + PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_FILE_MAX +} gl_register_file; + + +/** Vertex and fragment instructions */ +struct prog_instruction; +struct gl_program_parameter_list; +struct gl_uniform_list; + + +/** + * Base class for any kind of program object + */ +struct gl_program +{ + GLuint Id; + GLubyte *String; /**< Null-terminated program text */ + GLint RefCount; + GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ + GLenum Format; /**< String encoding format */ + GLboolean Resident; + + struct prog_instruction *Instructions; + + GLbitfield InputsRead; /**< Bitmask of which input regs are read */ + GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ + GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */ + GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ + GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ + + + /** Named parameters, constants, etc. from program text */ + struct gl_program_parameter_list *Parameters; + /** Numbered local parameters */ + GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; + + /** Vertex/fragment shader varying vars */ + struct gl_program_parameter_list *Varying; + /** Vertex program user-defined attributes */ + struct gl_program_parameter_list *Attributes; + + /** Map from sampler unit to texture unit (set by glUniform1i()) */ + GLubyte SamplerUnits[MAX_SAMPLERS]; + /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ + gl_texture_index SamplerTargets[MAX_SAMPLERS]; + + /** Bitmask of which register files are read/written with indirect + * addressing. Mask of (1 << PROGRAM_x) bits. + */ + GLbitfield IndirectRegisterFiles; + + /** Logical counts */ + /*@{*/ + GLuint NumInstructions; + GLuint NumTemporaries; + GLuint NumParameters; + GLuint NumAttributes; + GLuint NumAddressRegs; + GLuint NumAluInstructions; + GLuint NumTexInstructions; + GLuint NumTexIndirections; + /*@}*/ + /** Native, actual h/w counts */ + /*@{*/ + GLuint NumNativeInstructions; + GLuint NumNativeTemporaries; + GLuint NumNativeParameters; + GLuint NumNativeAttributes; + GLuint NumNativeAddressRegs; + GLuint NumNativeAluInstructions; + GLuint NumNativeTexInstructions; + GLuint NumNativeTexIndirections; + /*@}*/ +}; + + +/** Vertex program object */ +struct gl_vertex_program +{ + struct gl_program Base; /**< base class */ + GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ + GLboolean IsPositionInvariant; +}; + + +/** Geometry program object */ +struct gl_geometry_program +{ + struct gl_program Base; /**< base class */ + + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ +}; + + +/** Fragment program object */ +struct gl_fragment_program +{ + struct gl_program Base; /**< base class */ + GLenum FogOption; + GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; +}; + + +/** + * State common to vertex and fragment programs. + */ +struct gl_program_state +{ + GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ + const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ +}; + + +/** + * Context state for vertex programs. + */ +struct gl_vertex_program_state +{ + GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ + GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ + struct gl_vertex_program *Current; /**< User-bound vertex program */ + + /** Currently enabled and valid vertex program (including internal + * programs, user-defined vertex programs and GLSL vertex shaders). + * This is the program we must use when rendering. + */ + struct gl_vertex_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /* For GL_NV_vertex_program only: */ + GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; + GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; + + /** Should fixed-function T&L be implemented with a vertex prog? */ + GLboolean _MaintainTnlProgram; + + /** Program to emulate fixed-function T&L (see above) */ + struct gl_vertex_program *_TnlProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; + + GLboolean _Overriden; +}; + + +/** + * Context state for geometry programs. + */ +struct gl_geometry_program_state +{ + GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */ + GLboolean _Enabled; /**< Enabled and valid program? */ + struct gl_geometry_program *Current; /**< user-bound geometry program */ + + /** Currently enabled and valid program (including internal programs + * and compiled shader programs). + */ + struct gl_geometry_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + +/** + * Context state for fragment programs. + */ +struct gl_fragment_program_state +{ + GLboolean Enabled; /**< User-set fragment program enable flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + struct gl_fragment_program *Current; /**< User-bound fragment program */ + + /** Currently enabled and valid fragment program (including internal + * programs, user-defined fragment programs and GLSL fragment shaders). + * This is the program we must use when rendering. + */ + struct gl_fragment_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Should fixed-function texturing be implemented with a fragment prog? */ + GLboolean _MaintainTexEnvProgram; + + /** Program to emulate fixed-function texture env/combine (see above) */ + struct gl_fragment_program *_TexEnvProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + + +/** + * ATI_fragment_shader runtime state + */ +#define ATI_FS_INPUT_PRIMARY 0 +#define ATI_FS_INPUT_SECONDARY 1 + +struct atifs_instruction; +struct atifs_setupinst; + +/** + * ATI fragment shader + */ +struct ati_fragment_shader +{ + GLuint Id; + GLint RefCount; + struct atifs_instruction *Instructions[2]; + struct atifs_setupinst *SetupInst[2]; + GLfloat Constants[8][4]; + GLbitfield LocalConstDef; /**< Indicates which constants have been set */ + GLubyte numArithInstr[2]; + GLubyte regsAssigned[2]; + GLubyte NumPasses; /**< 1 or 2 */ + GLubyte cur_pass; + GLubyte last_optype; + GLboolean interpinp1; + GLboolean isValid; + GLuint swizzlerq; +}; + +/** + * Context state for GL_ATI_fragment_shader + */ +struct gl_ati_fragment_shader_state +{ + GLboolean Enabled; + GLboolean _Enabled; /**< enabled and valid shader? */ + GLboolean Compiling; + GLfloat GlobalConstants[8][4]; + struct ati_fragment_shader *Current; +}; + + +/** + * Occlusion/timer query object. + */ +struct gl_query_object +{ + GLenum Target; /**< The query target, when active */ + GLuint Id; /**< hash table ID/name */ + GLuint64EXT Result; /**< the counter */ + GLboolean Active; /**< inside Begin/EndQuery */ + GLboolean Ready; /**< result is ready? */ +}; + + +/** + * Context state for query objects. + */ +struct gl_query_state +{ + struct _mesa_HashTable *QueryObjects; + struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ + struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ + + /** GL_NV_conditional_render */ + struct gl_query_object *CondRenderQuery; + + /** GL_EXT_transform_feedback */ + struct gl_query_object *PrimitivesGenerated; + struct gl_query_object *PrimitivesWritten; + + /** GL_ARB_timer_query */ + struct gl_query_object *TimeElapsed; + + GLenum CondRenderMode; +}; + + +/** Sync object state */ +struct gl_sync_object { + struct simple_node link; + GLenum Type; /**< GL_SYNC_FENCE */ + GLuint Name; /**< Fence name */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; /**< Object was deleted while there were still + * live references (e.g., sync not yet finished) + */ + GLenum SyncCondition; + GLbitfield Flags; /**< Flags passed to glFenceSync */ + GLuint StatusFlag:1; /**< Has the sync object been signaled? */ +}; + + +/** Set by #pragma directives */ +struct gl_sl_pragmas +{ + GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ + GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ + GLboolean Optimize; /**< defaults on */ + GLboolean Debug; /**< defaults off */ +}; + + +/** + * A GLSL vertex or fragment shader object. + */ +struct gl_shader +{ + GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ + GLuint Name; /**< AKA the handle */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + GLboolean CompileStatus; + GLboolean Main; /**< shader defines main() */ + GLboolean UnresolvedRefs; + const GLchar *Source; /**< Source code string */ + GLuint SourceChecksum; /**< for debug/logging purposes */ + struct gl_program *Program; /**< Post-compile assembly code */ + GLchar *InfoLog; + struct gl_sl_pragmas Pragmas; + + unsigned Version; /**< GLSL version used for linking */ + + struct exec_list *ir; + struct glsl_symbol_table *symbols; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; +}; + + +/** + * A GLSL program object. + * Basically a linked collection of vertex and fragment shaders. + */ +struct gl_shader_program +{ + GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ + GLuint Name; /**< aka handle or ID */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct gl_shader **Shaders; /**< List of attached the shaders */ + + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + + /** Transform feedback varyings */ + struct { + GLenum BufferMode; + GLuint NumVarying; + GLchar **VaryingNames; /**< Array [NumVarying] of char * */ + } TransformFeedback; + + /** Geometry shader state - copied into gl_geometry_program at link time */ + struct { + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ + } Geom; + + /* post-link info: */ + struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ + struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ + struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ + struct gl_uniform_list *Uniforms; + struct gl_program_parameter_list *Varying; + GLboolean LinkStatus; /**< GL_LINK_STATUS */ + GLboolean Validated; + GLboolean _Used; /**< Ever used for drawing? */ + GLchar *InfoLog; + + unsigned Version; /**< GLSL version used for linking */ + + /** + * Per-stage shaders resulting from the first stage of linking. + * + * Set of linked shaders for this program. The array is accessed using the + * \c MESA_SHADER_* defines. Entries for non-existent stages will be + * \c NULL. + */ + struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; +}; + + +#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ +#define GLSL_LOG 0x2 /**< Write shaders to files */ +#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ +#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ +#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ +#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ +#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ +#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ + + +/** + * Context state for GLSL vertex/fragment shaders. + */ +struct gl_shader_state +{ + /** + * Programs used for rendering + * + * There is a separate program set for each shader stage. If + * GL_EXT_separate_shader_objects is not supported, each of these must point + * to \c NULL or to the same program. + */ + struct gl_shader_program *CurrentVertexProgram; + struct gl_shader_program *CurrentGeometryProgram; + struct gl_shader_program *CurrentFragmentProgram; + + /** + * Program used by glUniform calls. + * + * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. + */ + struct gl_shader_program *ActiveProgram; + + void *MemPool; + + GLbitfield Flags; /**< Mask of GLSL_x flags */ +}; + +/** + * Compiler options for a single GLSL shaders type + */ +struct gl_shader_compiler_options +{ + /** Driver-selectable options: */ + GLboolean EmitCondCodes; /**< Use condition codes? */ + GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ + /** + * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't + * support control flow. + */ + GLboolean EmitNoIfs; + GLboolean EmitNoLoops; + GLboolean EmitNoFunctions; + GLboolean EmitNoCont; /**< Emit CONT opcode? */ + GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ + GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ + GLboolean EmitNoPow; /**< Emit POW opcodes? */ + + /** + * \name Forms of indirect addressing the driver cannot do. + */ + /*@{*/ + GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ + GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ + GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ + GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ + /*@}*/ + + GLuint MaxUnrollIterations; + + struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ +}; + +/** + * Transform feedback object state + */ +struct gl_transform_feedback_object +{ + GLuint Name; /**< AKA the object ID */ + GLint RefCount; + GLboolean Active; /**< Is transform feedback enabled? */ + GLboolean Paused; /**< Is transform feedback paused? */ + + /** The feedback buffers */ + GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; + struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + + /** Start of feedback data in dest buffer */ + GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; + /** Max data to put into dest buffer (in bytes) */ + GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; +}; + + +/** + * Context state for transform feedback. + */ +struct gl_transform_feedback +{ + GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ + + GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ + + /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ + struct gl_buffer_object *CurrentBuffer; + + /** The table of all transform feedback objects */ + struct _mesa_HashTable *Objects; + + /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ + struct gl_transform_feedback_object *CurrentObject; + + /** The default xform-fb object (Name==0) */ + struct gl_transform_feedback_object *DefaultObject; +}; + + + +/** + * State which can be shared by multiple contexts: + */ +struct gl_shared_state +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< Reference count */ + struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ + struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ + + /** Default texture objects (shared by all texture units) */ + struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; + + /** Fallback texture used when a bound texture is incomplete */ + struct gl_texture_object *FallbackTex; + + /** + * \name Thread safety and statechange notification for texture + * objects. + * + * \todo Improve the granularity of locking. + */ + /*@{*/ + _glthread_Mutex TexMutex; /**< texobj thread safety */ + GLuint TextureStateStamp; /**< state notification for shared tex */ + /*@}*/ + + /** Default buffer object for vertex arrays that aren't in VBOs */ + struct gl_buffer_object *NullBufferObj; + + /** + * \name Vertex/geometry/fragment programs + */ + /*@{*/ + struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ + struct gl_vertex_program *DefaultVertexProgram; + struct gl_fragment_program *DefaultFragmentProgram; + struct gl_geometry_program *DefaultGeometryProgram; + /*@}*/ + + /* GL_ATI_fragment_shader */ + struct _mesa_HashTable *ATIShaders; + struct ati_fragment_shader *DefaultFragmentShader; + + struct _mesa_HashTable *BufferObjects; + + /** Table of both gl_shader and gl_shader_program objects */ + struct _mesa_HashTable *ShaderObjects; + + /* GL_EXT_framebuffer_object */ + struct _mesa_HashTable *RenderBuffers; + struct _mesa_HashTable *FrameBuffers; + + /* GL_ARB_sync */ + struct simple_node SyncObjects; + + void *DriverData; /**< Device driver shared state */ +}; + + + + +/** + * A renderbuffer stores colors or depth values or stencil values. + * A framebuffer object will have a collection of these. + * Data are read/written to the buffer with a handful of Get/Put functions. + * + * Instances of this object are allocated with the Driver's NewRenderbuffer + * hook. Drivers will likely wrap this class inside a driver-specific + * class to simulate inheritance. + */ +struct gl_renderbuffer +{ +#define RB_MAGIC 0xaabbccdd + int Magic; /** XXX TEMPORARY DEBUG INFO */ + _glthread_Mutex Mutex; /**< for thread safety */ + GLuint ClassID; /**< Useful for drivers */ + GLuint Name; + GLint RefCount; + GLuint Width, Height; + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + GLenum InternalFormat; /**< The user-specified format */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or + GL_STENCIL_INDEX. */ + GLuint Format; /**< The actual format: MESA_FORMAT_x */ + + GLubyte NumSamples; + + GLenum DataType; /**< Type of values passed to the Get/Put functions */ + GLvoid *Data; /**< This may not be used by some kinds of RBs */ + + /* Used to wrap one renderbuffer around another: */ + struct gl_renderbuffer *Wrapped; + + /* Delete this renderbuffer */ + void (*Delete)(struct gl_renderbuffer *rb); + + /* Allocate new storage for this renderbuffer */ + GLboolean (*AllocStorage)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height); + + /* Lock/Unlock are called before/after calling the Get/Put functions. + * Not sure this is the right place for these yet. + void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + */ + + /* Return a pointer to the element/pixel at (x,y). + * Should return NULL if the buffer memory can't be directly addressed. + */ + void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y); + + /* Get/Read a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values); + + /* Get/Read values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values); + + /* Put/Write a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + /* Put/Write a row of RGB values. This is a special-case routine that's + * only used for RGBA renderbuffers when the source data is GL_RGB. That's + * a common case for glDrawPixels and some triangle routines. + * The values will be of format GL_RGB and type DataType. + */ + void (*PutRowRGB)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + + /* Put/Write a row of identical values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask); + + /* Put/Write values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask); + /* Put/Write identical values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask); +}; + + +/** + * A renderbuffer attachment points to either a texture object (and specifies + * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. + */ +struct gl_renderbuffer_attachment +{ + GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ + GLboolean Complete; + + /** + * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the + * application supplied renderbuffer object. + */ + struct gl_renderbuffer *Renderbuffer; + + /** + * If \c Type is \c GL_TEXTURE, this stores a pointer to the application + * supplied texture object. + */ + struct gl_texture_object *Texture; + GLuint TextureLevel; /**< Attached mipmap level. */ + GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ + GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D + * and 2D array textures */ +}; + + +/** + * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). + * In C++ terms, think of this as a base class from which device drivers + * will make derived classes. + */ +struct gl_framebuffer +{ + _glthread_Mutex Mutex; /**< for thread safety */ + /** + * If zero, this is a window system framebuffer. If non-zero, this + * is a FBO framebuffer; note that for some devices (i.e. those with + * a natural pixel coordinate system for FBOs that differs from the + * OpenGL/Mesa coordinate system), this means that the viewport, + * polygon face orientation, and polygon stipple will have to be inverted. + */ + GLuint Name; + + GLint RefCount; + GLboolean DeletePending; + + /** + * The framebuffer's visual. Immutable if this is a window system buffer. + * Computed from attachments if user-made FBO. + */ + struct gl_config Visual; + + GLboolean Initialized; + + GLuint Width, Height; /**< size of frame buffer in pixels */ + + /** \name Drawing bounds (Intersection of buffer size and scissor box) */ + /*@{*/ + GLint _Xmin, _Xmax; /**< inclusive */ + GLint _Ymin, _Ymax; /**< exclusive */ + /*@}*/ + + /** \name Derived Z buffer stuff */ + /*@{*/ + GLuint _DepthMax; /**< Max depth buffer value */ + GLfloat _DepthMaxF; /**< Float max depth buffer value */ + GLfloat _MRD; /**< minimum resolvable difference in Z values */ + /*@}*/ + + /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ + GLenum _Status; + + /** Integer color values */ + GLboolean _IntegerColor; + + /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ + struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; + + /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER + * attribute group and GL_PIXEL attribute group, respectively. + */ + GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; + GLenum ColorReadBuffer; + + /** Computed from ColorDraw/ReadBuffer above */ + GLuint _NumColorDrawBuffers; + GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ + GLint _ColorReadBufferIndex; /* -1 = None */ + struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; + struct gl_renderbuffer *_ColorReadBuffer; + + /** The Actual depth/stencil buffers to use. May be wrappers around the + * depth/stencil buffers attached above. */ + struct gl_renderbuffer *_DepthBuffer; + struct gl_renderbuffer *_StencilBuffer; + + /** Delete this framebuffer */ + void (*Delete)(struct gl_framebuffer *fb); +}; + + +/** + * Limits for vertex and fragment programs/shaders. + */ +struct gl_program_constants +{ + /* logical limits */ + GLuint MaxInstructions; + GLuint MaxAluInstructions; + GLuint MaxTexInstructions; + GLuint MaxTexIndirections; + GLuint MaxAttribs; + GLuint MaxTemps; + GLuint MaxAddressRegs; + GLuint MaxParameters; + GLuint MaxLocalParams; + GLuint MaxEnvParams; + /* native/hardware limits */ + GLuint MaxNativeInstructions; + GLuint MaxNativeAluInstructions; + GLuint MaxNativeTexInstructions; + GLuint MaxNativeTexIndirections; + GLuint MaxNativeAttribs; + GLuint MaxNativeTemps; + GLuint MaxNativeAddressRegs; + GLuint MaxNativeParameters; + /* For shaders */ + GLuint MaxUniformComponents; + /* GL_ARB_geometry_shader4 */ + GLuint MaxGeometryTextureImageUnits; + GLuint MaxGeometryVaryingComponents; + GLuint MaxVertexVaryingComponents; + GLuint MaxGeometryUniformComponents; + GLuint MaxGeometryOutputVertices; + GLuint MaxGeometryTotalOutputComponents; +}; + + +/** + * Constants which may be overridden by device driver during context creation + * but are never changed after that. + */ +struct gl_constants +{ + GLint MaxTextureMbytes; /**< Max memory per image, in MB */ + GLint MaxTextureLevels; /**< Max mipmap levels. */ + GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ + GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ + GLint MaxArrayTextureLayers; /**< Max layers in array textures */ + GLint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ + GLuint MaxTextureCoordUnits; + GLuint MaxTextureImageUnits; + GLuint MaxVertexTextureImageUnits; + GLuint MaxCombinedTextureImageUnits; + GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ + GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ + + GLuint MaxArrayLockSize; + + GLint SubPixelBits; + + GLfloat MinPointSize, MaxPointSize; /**< aliased */ + GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ + GLfloat PointSizeGranularity; + GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ + GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ + GLfloat LineWidthGranularity; + + GLuint MaxColorTableSize; + + GLuint MaxClipPlanes; + GLuint MaxLights; + GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ + GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ + + GLuint MaxViewportWidth, MaxViewportHeight; + + struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ + struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ + struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */ + GLuint MaxProgramMatrices; + GLuint MaxProgramMatrixStackDepth; + + /** vertex array / buffer object bounds checking */ + GLboolean CheckArrayBounds; + + GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ + + GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ + GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ + GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ + + GLuint MaxVarying; /**< Number of float[4] varying parameters */ + + GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ + + /** Which texture units support GL_ATI_envmap_bumpmap as targets */ + GLbitfield SupportedBumpUnits; + + /** + * Maximum amount of time, measured in nanseconds, that the server can wait. + */ + GLuint64 MaxServerWaitTimeout; + + /** GL_EXT_provoking_vertex */ + GLboolean QuadsFollowProvokingVertexConvention; + + /** OpenGL version 3.0 */ + GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ + + /** OpenGL version 3.2 */ + GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ + + /** GL_EXT_transform_feedback */ + GLuint MaxTransformFeedbackSeparateAttribs; + GLuint MaxTransformFeedbackSeparateComponents; + GLuint MaxTransformFeedbackInterleavedComponents; + + /** GL_EXT_gpu_shader4 */ + GLint MinProgramTexelOffset, MaxProgramTexelOffset; +}; + + +/** + * Enable flag for each OpenGL extension. Different device drivers will + * enable different extensions at runtime. + */ +struct gl_extensions +{ + GLboolean dummy; /* don't remove this! */ + GLboolean ARB_blend_func_extended; + GLboolean ARB_copy_buffer; + GLboolean ARB_depth_buffer_float; + GLboolean ARB_depth_clamp; + GLboolean ARB_depth_texture; + GLboolean ARB_draw_buffers; + GLboolean ARB_draw_elements_base_vertex; + GLboolean ARB_draw_instanced; + GLboolean ARB_fragment_coord_conventions; + GLboolean ARB_fragment_program; + GLboolean ARB_fragment_program_shadow; + GLboolean ARB_fragment_shader; + GLboolean ARB_framebuffer_object; + GLboolean ARB_explicit_attrib_location; + GLboolean ARB_geometry_shader4; + GLboolean ARB_half_float_pixel; + GLboolean ARB_half_float_vertex; + GLboolean ARB_instanced_arrays; + GLboolean ARB_map_buffer_range; + GLboolean ARB_multisample; + GLboolean ARB_multitexture; + GLboolean ARB_occlusion_query; + GLboolean ARB_occlusion_query2; + GLboolean ARB_point_sprite; + GLboolean ARB_sampler_objects; + GLboolean ARB_seamless_cube_map; + GLboolean ARB_shader_objects; + GLboolean ARB_shader_stencil_export; + GLboolean ARB_shading_language_100; + GLboolean ARB_shadow; + GLboolean ARB_shadow_ambient; + GLboolean ARB_sync; + GLboolean ARB_texture_border_clamp; + GLboolean ARB_texture_buffer_object; + GLboolean ARB_texture_compression; + GLboolean ARB_texture_compression_rgtc; + GLboolean ARB_texture_cube_map; + GLboolean ARB_texture_env_combine; + GLboolean ARB_texture_env_crossbar; + GLboolean ARB_texture_env_dot3; + GLboolean ARB_texture_float; + GLboolean ARB_texture_mirrored_repeat; + GLboolean ARB_texture_multisample; + GLboolean ARB_texture_non_power_of_two; + GLboolean ARB_texture_rg; + GLboolean ARB_texture_rgb10_a2ui; + GLboolean ARB_timer_query; + GLboolean ARB_transform_feedback2; + GLboolean ARB_transpose_matrix; + GLboolean ARB_uniform_buffer_object; + GLboolean ARB_vertex_array_object; + GLboolean ARB_vertex_buffer_object; + GLboolean ARB_vertex_program; + GLboolean ARB_vertex_shader; + GLboolean ARB_vertex_type_2_10_10_10_rev; + GLboolean ARB_window_pos; + GLboolean EXT_abgr; + GLboolean EXT_bgra; + GLboolean EXT_blend_color; + GLboolean EXT_blend_equation_separate; + GLboolean EXT_blend_func_separate; + GLboolean EXT_blend_logic_op; + GLboolean EXT_blend_minmax; + GLboolean EXT_blend_subtract; + GLboolean EXT_clip_volume_hint; + GLboolean EXT_compiled_vertex_array; + GLboolean EXT_copy_texture; + GLboolean EXT_depth_bounds_test; + GLboolean EXT_draw_buffers2; + GLboolean EXT_draw_range_elements; + GLboolean EXT_fog_coord; + GLboolean EXT_framebuffer_blit; + GLboolean EXT_framebuffer_multisample; + GLboolean EXT_framebuffer_object; + GLboolean EXT_framebuffer_sRGB; + GLboolean EXT_gpu_program_parameters; + GLboolean EXT_gpu_shader4; + GLboolean EXT_multi_draw_arrays; + GLboolean EXT_paletted_texture; + GLboolean EXT_packed_depth_stencil; + GLboolean EXT_packed_float; + GLboolean EXT_packed_pixels; + GLboolean EXT_pixel_buffer_object; + GLboolean EXT_point_parameters; + GLboolean EXT_polygon_offset; + GLboolean EXT_provoking_vertex; + GLboolean EXT_rescale_normal; + GLboolean EXT_shadow_funcs; + GLboolean EXT_secondary_color; + GLboolean EXT_separate_shader_objects; + GLboolean EXT_separate_specular_color; + GLboolean EXT_shared_texture_palette; + GLboolean EXT_stencil_wrap; + GLboolean EXT_stencil_two_side; + GLboolean EXT_subtexture; + GLboolean EXT_texture; + GLboolean EXT_texture_object; + GLboolean EXT_texture3D; + GLboolean EXT_texture_array; + GLboolean EXT_texture_compression_s3tc; + GLboolean EXT_texture_env_add; + GLboolean EXT_texture_env_combine; + GLboolean EXT_texture_env_dot3; + GLboolean EXT_texture_filter_anisotropic; + GLboolean EXT_texture_integer; + GLboolean EXT_texture_lod_bias; + GLboolean EXT_texture_mirror_clamp; + GLboolean EXT_texture_shared_exponent; + GLboolean EXT_texture_sRGB; + GLboolean EXT_texture_swizzle; + GLboolean EXT_transform_feedback; + GLboolean EXT_timer_query; + GLboolean EXT_vertex_array; + GLboolean EXT_vertex_array_bgra; + GLboolean EXT_vertex_array_set; + /* vendor extensions */ + GLboolean APPLE_client_storage; + GLboolean APPLE_packed_pixels; + GLboolean APPLE_vertex_array_object; + GLboolean APPLE_object_purgeable; + GLboolean ATI_envmap_bumpmap; + GLboolean ATI_texture_mirror_once; + GLboolean ATI_texture_env_combine3; + GLboolean ATI_fragment_shader; + GLboolean ATI_separate_stencil; + GLboolean IBM_rasterpos_clip; + GLboolean IBM_multimode_draw_arrays; + GLboolean MESA_pack_invert; + GLboolean MESA_resize_buffers; + GLboolean MESA_ycbcr_texture; + GLboolean MESA_texture_array; + GLboolean MESA_texture_signed_rgba; + GLboolean NV_blend_square; + GLboolean NV_conditional_render; + GLboolean NV_fragment_program; + GLboolean NV_fragment_program_option; + GLboolean NV_light_max_exponent; + GLboolean NV_point_sprite; + GLboolean NV_primitive_restart; + GLboolean NV_texgen_reflection; + GLboolean NV_texture_env_combine4; + GLboolean NV_texture_rectangle; + GLboolean NV_vertex_program; + GLboolean NV_vertex_program1_1; + GLboolean OES_read_format; + GLboolean SGI_texture_color_table; + GLboolean SGIS_generate_mipmap; + GLboolean SGIS_texture_edge_clamp; + GLboolean SGIS_texture_lod; + GLboolean TDFX_texture_compression_FXT1; + GLboolean S3_s3tc; + GLboolean OES_EGL_image; + GLboolean OES_draw_texture; + GLboolean EXT_texture_format_BGRA8888; + /** The extension string */ + const GLubyte *String; + /** Number of supported extensions */ + GLuint Count; +}; + + +/** + * A stack of matrices (projection, modelview, color, texture, etc). + */ +struct gl_matrix_stack +{ + GLmatrix *Top; /**< points into Stack */ + GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ + GLuint Depth; /**< 0 <= Depth < MaxDepth */ + GLuint MaxDepth; /**< size of Stack[] array */ + GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ +}; + + +/** + * \name Bits for image transfer operations + * \sa __struct gl_contextRec::ImageTransferState. + */ +/*@{*/ +#define IMAGE_SCALE_BIAS_BIT 0x1 +#define IMAGE_SHIFT_OFFSET_BIT 0x2 +#define IMAGE_MAP_COLOR_BIT 0x4 +#define IMAGE_CLAMP_BIT 0x800 + + +/** Pixel Transfer ops */ +#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ + IMAGE_SHIFT_OFFSET_BIT | \ + IMAGE_MAP_COLOR_BIT) + +/** + * \name Bits to indicate what state has changed. + * + * 4 unused flags. + */ +/*@{*/ +#define _NEW_MODELVIEW 0x1 /**< __struct gl_contextRec::ModelView */ +#define _NEW_PROJECTION 0x2 /**< __struct gl_contextRec::Projection */ +#define _NEW_TEXTURE_MATRIX 0x4 /**< __struct gl_contextRec::TextureMatrix */ +#define _NEW_ACCUM 0x10 /**< __struct gl_contextRec::Accum */ +#define _NEW_COLOR 0x20 /**< __struct gl_contextRec::Color */ +#define _NEW_DEPTH 0x40 /**< __struct gl_contextRec::Depth */ +#define _NEW_EVAL 0x80 /**< __struct gl_contextRec::Eval, __struct gl_contextRec::EvalMap */ +#define _NEW_FOG 0x100 /**< __struct gl_contextRec::Fog */ +#define _NEW_HINT 0x200 /**< __struct gl_contextRec::Hint */ +#define _NEW_LIGHT 0x400 /**< __struct gl_contextRec::Light */ +#define _NEW_LINE 0x800 /**< __struct gl_contextRec::Line */ +#define _NEW_PIXEL 0x1000 /**< __struct gl_contextRec::Pixel */ +#define _NEW_POINT 0x2000 /**< __struct gl_contextRec::Point */ +#define _NEW_POLYGON 0x4000 /**< __struct gl_contextRec::Polygon */ +#define _NEW_POLYGONSTIPPLE 0x8000 /**< __struct gl_contextRec::PolygonStipple */ +#define _NEW_SCISSOR 0x10000 /**< __struct gl_contextRec::Scissor */ +#define _NEW_STENCIL 0x20000 /**< __struct gl_contextRec::Stencil */ +#define _NEW_TEXTURE 0x40000 /**< __struct gl_contextRec::Texture */ +#define _NEW_TRANSFORM 0x80000 /**< __struct gl_contextRec::Transform */ +#define _NEW_VIEWPORT 0x100000 /**< __struct gl_contextRec::Viewport */ +#define _NEW_PACKUNPACK 0x200000 /**< __struct gl_contextRec::Pack, __struct gl_contextRec::Unpack */ +#define _NEW_ARRAY 0x400000 /**< __struct gl_contextRec::Array */ +#define _NEW_RENDERMODE 0x800000 /**< __struct gl_contextRec::RenderMode, __struct gl_contextRec::Feedback, __struct gl_contextRec::Select */ +#define _NEW_BUFFERS 0x1000000 /**< __struct gl_contextRec::Visual, __struct gl_contextRec::DrawBuffer, */ +#define _NEW_MULTISAMPLE 0x2000000 /**< __struct gl_contextRec::Multisample */ +#define _NEW_TRACK_MATRIX 0x4000000 /**< __struct gl_contextRec::VertexProgram */ +#define _NEW_PROGRAM 0x8000000 /**< __struct gl_contextRec::VertexProgram */ +#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __struct gl_contextRec::Current */ +#define _NEW_PROGRAM_CONSTANTS 0x20000000 +#define _NEW_BUFFER_OBJECT 0x40000000 +#define _NEW_ALL ~0 +/*@}*/ + + +/** + * \name Bits to track array state changes + * + * Also used to summarize array enabled. + */ +/*@{*/ +#define _NEW_ARRAY_VERTEX VERT_BIT_POS +#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT +#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL +#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 +#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 +#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG +#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX +#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG +#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ +#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 +#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 +#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 +#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 +#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 +#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 +#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 +#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 +#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ +#define _NEW_ARRAY_ALL 0xffffffff + + +#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) +#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) +/*@}*/ + + + +/** + * \name A bunch of flags that we think might be useful to drivers. + * + * Set in the __struct gl_contextRec::_TriangleCaps bitfield. + */ +/*@{*/ +#define DD_FLATSHADE 0x1 +#define DD_SEPARATE_SPECULAR 0x2 +#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ +#define DD_TRI_LIGHT_TWOSIDE 0x8 +#define DD_TRI_UNFILLED 0x10 +#define DD_TRI_SMOOTH 0x20 +#define DD_TRI_STIPPLE 0x40 +#define DD_TRI_OFFSET 0x80 +#define DD_LINE_SMOOTH 0x100 +#define DD_LINE_STIPPLE 0x200 +#define DD_POINT_SMOOTH 0x400 +#define DD_POINT_ATTEN 0x800 +#define DD_TRI_TWOSTENCIL 0x1000 +/*@}*/ + + +/** + * \name Define the state changes under which each of these bits might change + */ +/*@{*/ +#define _DD_NEW_FLATSHADE _NEW_LIGHT +#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) +#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON +#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT +#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON +#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON +#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON +#define _DD_NEW_TRI_OFFSET _NEW_POLYGON +#define _DD_NEW_LINE_SMOOTH _NEW_LINE +#define _DD_NEW_LINE_STIPPLE _NEW_LINE +#define _DD_NEW_LINE_WIDTH _NEW_LINE +#define _DD_NEW_POINT_SMOOTH _NEW_POINT +#define _DD_NEW_POINT_SIZE _NEW_POINT +#define _DD_NEW_POINT_ATTEN _NEW_POINT +/*@}*/ + + +/** + * Composite state flags + */ +/*@{*/ +#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ + _NEW_TEXTURE | \ + _NEW_POINT | \ + _NEW_PROGRAM | \ + _NEW_MODELVIEW) + +#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \ + _NEW_TEXTURE) + +#define _MESA_NEW_TRANSFER_STATE (_NEW_PIXEL) +/*@}*/ + + + + +/* This has to be included here. */ +#include "dd.h" + + +/** + * Display list flags. + * Strictly this is a tnl-private concept, but it doesn't seem + * worthwhile adding a tnl private structure just to hold this one bit + * of information: + */ +#define DLIST_DANGLING_REFS 0x1 + + +/** Opaque declaration of display list payload data type */ +union gl_dlist_node; + + +/** + * Provide a location where information about a display list can be + * collected. Could be extended with driverPrivate structures, + * etc. in the future. + */ +struct gl_display_list +{ + GLuint Name; + GLbitfield Flags; /**< DLIST_x flags */ + /** The dlist commands are in a linked list of nodes */ + union gl_dlist_node *Head; +}; + + +/** + * State used during display list compilation and execution. + */ +struct gl_dlist_state +{ + GLuint CallDepth; /**< Current recursion calling depth */ + + struct gl_display_list *CurrentList; /**< List currently being compiled */ + union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ + GLuint CurrentPos; /**< Index into current block of nodes */ + + GLvertexformat ListVtxfmt; + + GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; + GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; + + GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; + GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; + + GLubyte ActiveIndex; + GLfloat CurrentIndex; + + GLubyte ActiveEdgeFlag; + GLboolean CurrentEdgeFlag; + + struct { + /* State known to have been set by the currently-compiling display + * list. Used to eliminate some redundant state changes. + */ + GLenum ShadeModel; + } Current; +}; + +/** + * Enum for the OpenGL APIs we know about and may support. + */ +typedef enum { + API_OPENGL, + API_OPENGLES, + API_OPENGLES2 +} gl_api; + +/** + * Mesa rendering context. + * + * This is the central context data structure for Mesa. Almost all + * OpenGL state is contained in this structure. + * Think of this as a base class from which device drivers will derive + * sub classes. + * + * The struct gl_context typedef names this structure. + */ +struct gl_context +{ + /** State possibly shared with other contexts in the address space */ + struct gl_shared_state *Shared; + + /** \name API function pointer tables */ + /*@{*/ + gl_api API; + struct _glapi_table *Save; /**< Display list save functions */ + struct _glapi_table *Exec; /**< Execute functions */ + struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ + /*@}*/ + + struct gl_config Visual; + struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ + struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ + struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ + struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ + + /** + * Device driver function pointer table + */ + struct dd_function_table Driver; + + void *DriverCtx; /**< Points to device driver context/state */ + + /** Core/Driver constants */ + struct gl_constants Const; + + /** \name The various 4x4 matrix stacks */ + /*@{*/ + struct gl_matrix_stack ModelviewMatrixStack; + struct gl_matrix_stack ProjectionMatrixStack; + struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; + struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; + struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ + /*@}*/ + + /** Combined modelview and projection matrix */ + GLmatrix _ModelProjectMatrix; + + /** \name Display lists */ + struct gl_dlist_state ListState; + + GLboolean ExecuteFlag; /**< Execute GL commands? */ + GLboolean CompileFlag; /**< Compile GL commands into display list? */ + + /** Extension information */ + struct gl_extensions Extensions; + + /** Version info */ + GLuint VersionMajor, VersionMinor; + char *VersionString; + + /** \name State attribute stack (for glPush/PopAttrib) */ + /*@{*/ + GLuint AttribStackDepth; + struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Renderer attribute groups + * + * We define a struct for each attribute group to make pushing and popping + * attributes easy. Also it's a good organization. + */ + /*@{*/ + struct gl_accum_attrib Accum; /**< Accum buffer attributes */ + struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ + struct gl_current_attrib Current; /**< Current attributes */ + struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ + struct gl_eval_attrib Eval; /**< Eval attributes */ + struct gl_fog_attrib Fog; /**< Fog attributes */ + struct gl_hint_attrib Hint; /**< Hint attributes */ + struct gl_light_attrib Light; /**< Light attributes */ + struct gl_line_attrib Line; /**< Line attributes */ + struct gl_list_attrib List; /**< List attributes */ + struct gl_multisample_attrib Multisample; + struct gl_pixel_attrib Pixel; /**< Pixel attributes */ + struct gl_point_attrib Point; /**< Point attributes */ + struct gl_polygon_attrib Polygon; /**< Polygon attributes */ + GLuint PolygonStipple[32]; /**< Polygon stipple */ + struct gl_scissor_attrib Scissor; /**< Scissor attributes */ + struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ + struct gl_texture_attrib Texture; /**< Texture attributes */ + struct gl_transform_attrib Transform; /**< Transformation attributes */ + struct gl_viewport_attrib Viewport; /**< Viewport attributes */ + /*@}*/ + + /** \name Client attribute stack */ + /*@{*/ + GLuint ClientAttribStackDepth; + struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Client attribute groups */ + /*@{*/ + struct gl_array_attrib Array; /**< Vertex arrays */ + struct gl_pixelstore_attrib Pack; /**< Pixel packing */ + struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ + struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ + /*@}*/ + + /** \name Other assorted state (not pushed/popped on attribute stack) */ + /*@{*/ + struct gl_pixelmaps PixelMaps; + + struct gl_evaluators EvalMap; /**< All evaluators */ + struct gl_feedback Feedback; /**< Feedback */ + struct gl_selection Select; /**< Selection */ + + struct gl_program_state Program; /**< general program state */ + struct gl_vertex_program_state VertexProgram; + struct gl_fragment_program_state FragmentProgram; + struct gl_geometry_program_state GeometryProgram; + struct gl_ati_fragment_shader_state ATIFragmentShader; + + struct gl_shader_state Shader; /**< GLSL shader object state */ + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; + + struct gl_query_state Query; /**< occlusion, timer queries */ + + struct gl_transform_feedback TransformFeedback; + + struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ + struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ + /*@}*/ + + struct gl_meta_state *Meta; /**< for "meta" operations */ + + /* GL_EXT_framebuffer_object */ + struct gl_renderbuffer *CurrentRenderbuffer; + + GLenum ErrorValue; /**< Last error code */ + + /** + * Recognize and silence repeated error debug messages in buggy apps. + */ + const char *ErrorDebugFmtString; + GLuint ErrorDebugCount; + + GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ + GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + + GLboolean ViewportInitialized; /**< has viewport size been initialized? */ + + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ + + /** \name Derived state */ + /*@{*/ + /** Bitwise-or of DD_* flags. Note that this bitfield may be used before + * state validation so they need to always be current. + */ + GLbitfield _TriangleCaps; + GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ + GLfloat _EyeZDir[3]; + GLfloat _ModelViewInvScale; + GLboolean _NeedEyeCoords; + GLboolean _ForceEyeCoords; + + GLuint TextureStateTimestamp; /**< detect changes to shared state */ + + struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ + struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ + /**@}*/ + + struct gl_list_extensions *ListExt; /**< driver dlist extensions */ + + /** \name For debugging/development only */ + /*@{*/ + GLboolean FirstTimeCurrent; + /*@}*/ + + /** Dither disable via MESA_NO_DITHER env var */ + GLboolean NoDither; + + /** software compression/decompression supported or not */ + GLboolean Mesa_DXTn; + + /** + * Use dp4 (rather than mul/mad) instructions for position + * transformation? + */ + GLboolean mvp_with_dp4; + + /** + * \name Hooks for module contexts. + * + * These will eventually live in the driver or elsewhere. + */ + /*@{*/ + void *swrast_context; + void *swsetup_context; + void *swtnl_context; + void *swtnl_im; + struct st_context *st; + void *aelt_context; + /*@}*/ +}; + + +/** The string names for GL_POINT, GL_LINE_LOOP, etc */ +extern const char *_mesa_prim_name[GL_POLYGON+4]; + + +#ifdef DEBUG +extern int MESA_VERBOSE; +extern int MESA_DEBUG_FLAGS; +# define MESA_FUNCTION __FUNCTION__ +#else +# define MESA_VERBOSE 0 +# define MESA_DEBUG_FLAGS 0 +# define MESA_FUNCTION "a function" +# ifndef NDEBUG +# define NDEBUG +# endif +#endif + + +/** The MESA_VERBOSE var is a bitmask of these flags */ +enum _verbose +{ + VERBOSE_VARRAY = 0x0001, + VERBOSE_TEXTURE = 0x0002, + VERBOSE_MATERIAL = 0x0004, + VERBOSE_PIPELINE = 0x0008, + VERBOSE_DRIVER = 0x0010, + VERBOSE_STATE = 0x0020, + VERBOSE_API = 0x0040, + VERBOSE_DISPLAY_LIST = 0x0100, + VERBOSE_LIGHTING = 0x0200, + VERBOSE_PRIMS = 0x0400, + VERBOSE_VERTS = 0x0800, + VERBOSE_DISASSEM = 0x1000, + VERBOSE_DRAW = 0x2000, + VERBOSE_SWAPBUFFERS = 0x4000 +}; + + +/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ +enum _debug +{ + DEBUG_ALWAYS_FLUSH = 0x1 +}; + + + +#endif /* MTYPES_H */ diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c index 01b68df7a..824778195 100644 --- a/mesalib/src/mesa/main/multisample.c +++ b/mesalib/src/mesa/main/multisample.c @@ -1,61 +1,61 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/multisample.h" - - -/** - * Called via glSampleCoverageARB - */ -void GLAPIENTRY -_mesa_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); - - ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0); - ctx->Multisample.SampleCoverageInvert = invert; - ctx->NewState |= _NEW_MULTISAMPLE; -} - - -/** - * Initialize the context's multisample state. - * \param ctx the GL context. - */ -void -_mesa_init_multisample(GLcontext *ctx) -{ - ctx->Multisample.Enabled = GL_TRUE; - ctx->Multisample.SampleAlphaToCoverage = GL_FALSE; - ctx->Multisample.SampleAlphaToOne = GL_FALSE; - ctx->Multisample.SampleCoverage = GL_FALSE; - ctx->Multisample.SampleCoverageValue = 1.0; - ctx->Multisample.SampleCoverageInvert = GL_FALSE; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/multisample.h" + + +/** + * Called via glSampleCoverageARB + */ +void GLAPIENTRY +_mesa_SampleCoverageARB(GLclampf value, GLboolean invert) +{ + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); + + ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0); + ctx->Multisample.SampleCoverageInvert = invert; + ctx->NewState |= _NEW_MULTISAMPLE; +} + + +/** + * Initialize the context's multisample state. + * \param ctx the GL context. + */ +void +_mesa_init_multisample(struct gl_context *ctx) +{ + ctx->Multisample.Enabled = GL_TRUE; + ctx->Multisample.SampleAlphaToCoverage = GL_FALSE; + ctx->Multisample.SampleAlphaToOne = GL_FALSE; + ctx->Multisample.SampleCoverage = GL_FALSE; + ctx->Multisample.SampleCoverageValue = 1.0; + ctx->Multisample.SampleCoverageInvert = GL_FALSE; +} diff --git a/mesalib/src/mesa/main/multisample.h b/mesalib/src/mesa/main/multisample.h index 998488ef4..c1c967bbe 100644 --- a/mesalib/src/mesa/main/multisample.h +++ b/mesalib/src/mesa/main/multisample.h @@ -1,39 +1,41 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef MULTISAMPLE_H -#define MULTISAMPLE_H - -#include "mtypes.h" - -extern void GLAPIENTRY -_mesa_SampleCoverageARB(GLclampf value, GLboolean invert); - - -extern void -_mesa_init_multisample(GLcontext *ctx); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef MULTISAMPLE_H +#define MULTISAMPLE_H + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_SampleCoverageARB(GLclampf value, GLboolean invert); + + +extern void +_mesa_init_multisample(struct gl_context *ctx); + + +#endif diff --git a/mesalib/src/mesa/main/nvprogram.c b/mesalib/src/mesa/main/nvprogram.c index 3a570b7dd..89b9bc426 100644 --- a/mesalib/src/mesa/main/nvprogram.c +++ b/mesalib/src/mesa/main/nvprogram.c @@ -1,919 +1,919 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file nvprogram.c - * NVIDIA vertex/fragment program state management functions. - * \author Brian Paul - */ - -/* - * Regarding GL_NV_fragment/vertex_program, GL_NV_vertex_program1_1, etc: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/nvprogram.h" -#include "program/arbprogparse.h" -#include "program/nvfragparse.h" -#include "program/nvvertparse.h" -#include "program/program.h" -#include "program/prog_instruction.h" -#include "program/prog_parameter.h" - - - -/** - * Execute a vertex state program. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - struct gl_vertex_program *vprog; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_VERTEX_STATE_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glExecuteProgramNV"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id); - - if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV"); - return; - } - - _mesa_problem(ctx, "glExecuteProgramNV() not supported"); -} - - -/** - * Determine if a set of programs is resident in hardware. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -GLboolean GLAPIENTRY -_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, - GLboolean *residences) -{ - GLint i, j; - GLboolean allResident = GL_TRUE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV(n)"); - return GL_FALSE; - } - - for (i = 0; i < n; i++) { - const struct gl_program *prog; - if (ids[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); - return GL_FALSE; - } - prog = _mesa_lookup_program(ctx, ids[i]); - if (!prog) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); - return GL_FALSE; - } - if (prog->Resident) { - if (!allResident) - residences[i] = GL_TRUE; - } - else { - if (allResident) { - allResident = GL_FALSE; - for (j = 0; j < i; j++) - residences[j] = GL_TRUE; - } - residences[i] = GL_FALSE; - } - } - - return allResident; -} - - -/** - * Request that a set of programs be resident in hardware. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(n)"); - return; - } - - /* just error checking for now */ - for (i = 0; i < n; i++) { - struct gl_program *prog; - - if (ids[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); - return; - } - - prog = _mesa_lookup_program(ctx, ids[i]); - if (!prog) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); - return; - } - - /* XXX this is really a hardware thing we should hook out */ - prog->Resident = GL_TRUE; - } -} - - -/** - * Get a program parameter register. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV) { - if (pname == GL_PROGRAM_PARAMETER_NV) { - if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { - COPY_4V(params, ctx->VertexProgram.Parameters[index]); - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetProgramParameterfvNV(index)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(pname)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(target)"); - return; - } -} - - -/** - * Get a program parameter register. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, - GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV) { - if (pname == GL_PROGRAM_PARAMETER_NV) { - if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { - COPY_4V(params, ctx->VertexProgram.Parameters[index]); - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetProgramParameterdvNV(index)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(pname)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(target)"); - return; - } -} - - -/** - * Get a program attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - prog = _mesa_lookup_program(ctx, id); - if (!prog) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV"); - return; - } - - switch (pname) { - case GL_PROGRAM_TARGET_NV: - *params = prog->Target; - return; - case GL_PROGRAM_LENGTH_NV: - *params = prog->String ?(GLint) strlen((char *) prog->String) : 0; - return; - case GL_PROGRAM_RESIDENT_NV: - *params = prog->Resident; - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivNV(pname)"); - return; - } -} - - -/** - * Get the program source code. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname != GL_PROGRAM_STRING_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringNV(pname)"); - return; - } - - prog = _mesa_lookup_program(ctx, id); - if (!prog) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV"); - return; - } - - if (prog->String) { - memcpy(program, prog->String, strlen((char *) prog->String)); - } - else { - program[0] = 0; - } -} - - -/** - * Get matrix tracking information. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV - && ctx->Extensions.NV_vertex_program) { - GLuint i; - - if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetTrackMatrixivNV(address)"); - return; - } - - i = address / 4; - - switch (pname) { - case GL_TRACK_MATRIX_NV: - params[0] = (GLint) ctx->VertexProgram.TrackMatrix[i]; - return; - case GL_TRACK_MATRIX_TRANSFORM_NV: - params[0] = (GLint) ctx->VertexProgram.TrackMatrixTransform[i]; - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); - return; - } -} - - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[index]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribdvNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - COPY_4V(params, ctx->Current.Attrib[index]); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[index]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = (GLfloat) array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = (GLfloat) array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = (GLfloat) array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribfvNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - COPY_4V(params, ctx->Current.Attrib[index]); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[index]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribivNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = (GLint) ctx->Current.Attrib[index][0]; - params[1] = (GLint) ctx->Current.Attrib[index][1]; - params[2] = (GLint) ctx->Current.Attrib[index][2]; - params[3] = (GLint) ctx->Current.Attrib[index][3]; - break; - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: - params[0] = array->BufferObj->Name; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - - -/** - * Get a vertex array attribute pointer. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerNV(index)"); - return; - } - - if (pname != GL_ATTRIB_ARRAY_POINTER_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerNV(pname)"); - return; - } - - *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr; -} - -void -_mesa_emit_nv_temp_initialization(GLcontext *ctx, - struct gl_program *program) -{ - struct prog_instruction *inst; - GLuint i; - struct gl_shader_compiler_options* options = - &ctx->ShaderCompilerOptions[_mesa_program_target_to_index(program->Target)]; - - if (!options->EmitNVTempInitialization) - return; - - /* We'll swizzle up a zero temporary so we can use it for the - * ARL. - */ - if (program->NumTemporaries == 0) - program->NumTemporaries = 1; - - _mesa_insert_instructions(program, 0, program->NumTemporaries + 1); - - for (i = 0; i < program->NumTemporaries; i++) { - struct prog_instruction *inst = &program->Instructions[i]; - - inst->Opcode = OPCODE_SWZ; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = i; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = 0; - inst->SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO, - SWIZZLE_ZERO, - SWIZZLE_ZERO, - SWIZZLE_ZERO); - } - - inst = &program->Instructions[i]; - inst->Opcode = OPCODE_ARL; - inst->DstReg.File = PROGRAM_ADDRESS; - inst->DstReg.Index = 0; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = 0; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - - if (program->NumAddressRegs == 0) - program->NumAddressRegs = 1; -} - -void -_mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program) -{ - GLuint i; - - program->NumTemporaries = 0; - for (i = 0; i < program->NumInstructions; i++) { - struct prog_instruction *inst = &program->Instructions[i]; - - if (inst->DstReg.File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2(program->NumTemporaries, - inst->DstReg.Index + 1); - } - if (inst->SrcReg[0].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[0].Index + 1); - } - if (inst->SrcReg[1].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[1].Index + 1); - } - if (inst->SrcReg[2].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[2].Index + 1); - } - } -} - -/** - * Load/parse/compile a program. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte *program) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.NV_vertex_program - && !ctx->Extensions.NV_fragment_program) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()"); - return; - } - - if (id == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)"); - return; - } - - if (len < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(len)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - prog = _mesa_lookup_program(ctx, id); - - if (prog && prog->Target != 0 && prog->Target != target) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(target)"); - return; - } - - if ((target == GL_VERTEX_PROGRAM_NV || - target == GL_VERTEX_STATE_PROGRAM_NV) - && ctx->Extensions.NV_vertex_program) { - struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog; - if (!vprog || prog == &_mesa_DummyProgram) { - vprog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!vprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, vprog); - } - - if (ctx->Extensions.ARB_vertex_program - && (strncmp((char *) program, "!!ARB", 5) == 0)) { - _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog); - } else { - _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog); - } - } - else if (target == GL_FRAGMENT_PROGRAM_NV - && ctx->Extensions.NV_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!fprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, fprog); - } - _mesa_parse_nv_fragment_program(ctx, target, program, len, fprog); - } - else if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!fprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, fprog); - } - _mesa_parse_arb_fragment_program(ctx, target, program, len, fprog); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)"); - } -} - - - -/** - * Set a sequence of program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, - GLuint num, const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - GLuint i; - if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4dvNV"); - return; - } - for (i = 0; i < num; i++) { - ctx->VertexProgram.Parameters[index + i][0] = (GLfloat) params[0]; - ctx->VertexProgram.Parameters[index + i][1] = (GLfloat) params[1]; - ctx->VertexProgram.Parameters[index + i][2] = (GLfloat) params[2]; - ctx->VertexProgram.Parameters[index + i][3] = (GLfloat) params[3]; - params += 4; - }; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4dvNV"); - return; - } -} - - -/** - * Set a sequence of program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, - GLuint num, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - GLuint i; - if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4fvNV"); - return; - } - for (i = 0; i < num; i++) { - COPY_4V(ctx->VertexProgram.Parameters[index + i], params); - params += 4; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4fvNV"); - return; - } -} - - - -/** - * Setup tracking of matrices into program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - if (address & 0x3) { - /* addr must be multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)"); - return; - } - - switch (matrix) { - case GL_NONE: - case GL_MODELVIEW: - case GL_PROJECTION: - case GL_TEXTURE: - case GL_COLOR: - case GL_MODELVIEW_PROJECTION_NV: - case GL_MATRIX0_NV: - case GL_MATRIX1_NV: - case GL_MATRIX2_NV: - case GL_MATRIX3_NV: - case GL_MATRIX4_NV: - case GL_MATRIX5_NV: - case GL_MATRIX6_NV: - case GL_MATRIX7_NV: - /* OK, fallthrough */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(matrix)"); - return; - } - - switch (transform) { - case GL_IDENTITY_NV: - case GL_INVERSE_NV: - case GL_TRANSPOSE_NV: - case GL_INVERSE_TRANSPOSE_NV: - /* OK, fallthrough */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(transform)"); - return; - } - - ctx->VertexProgram.TrackMatrix[address / 4] = matrix; - ctx->VertexProgram.TrackMatrixTransform[address / 4] = transform; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(target)"); - return; - } -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - struct gl_program *prog; - struct gl_fragment_program *fragProg; - GLfloat *v; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - prog = _mesa_lookup_program(ctx, id); - if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramNamedParameterNV"); - return; - } - - if (len <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(len)"); - return; - } - - fragProg = (struct gl_fragment_program *) prog; - v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len, - (char *) name); - if (v) { - v[0] = x; - v[1] = y; - v[2] = z; - v[3] = w; - return; - } - - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(name)"); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, - const float v[]) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y, - (GLfloat)z, (GLfloat)w); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, - const double v[]) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, - (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3]); -} - - -void GLAPIENTRY -_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat *params) -{ - struct gl_program *prog; - struct gl_fragment_program *fragProg; - const GLfloat *v; - - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - prog = _mesa_lookup_program(ctx, id); - if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramNamedParameterNV"); - return; - } - - if (len <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); - return; - } - - fragProg = (struct gl_fragment_program *) prog; - v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, - len, (char *) name); - if (v) { - params[0] = v[0]; - params[1] = v[1]; - params[2] = v[2]; - params[3] = v[3]; - return; - } - - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); -} - - -void GLAPIENTRY -_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble *params) -{ - GLfloat floatParams[4]; - _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams); - COPY_4V(params, floatParams); -} +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file nvprogram.c + * NVIDIA vertex/fragment program state management functions. + * \author Brian Paul + */ + +/* + * Regarding GL_NV_fragment/vertex_program, GL_NV_vertex_program1_1, etc: + * + * Portions of this software may use or implement intellectual + * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims + * any and all warranties with respect to such intellectual property, + * including any use thereof or modifications thereto. + */ + +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/nvprogram.h" +#include "program/arbprogparse.h" +#include "program/nvfragparse.h" +#include "program/nvvertparse.h" +#include "program/program.h" +#include "program/prog_instruction.h" +#include "program/prog_parameter.h" + + + +/** + * Execute a vertex state program. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + struct gl_vertex_program *vprog; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_VERTEX_STATE_PROGRAM_NV) { + _mesa_error(ctx, GL_INVALID_ENUM, "glExecuteProgramNV"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id); + + if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV"); + return; + } + + _mesa_problem(ctx, "glExecuteProgramNV() not supported"); +} + + +/** + * Determine if a set of programs is resident in hardware. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +GLboolean GLAPIENTRY +_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, + GLboolean *residences) +{ + GLint i, j; + GLboolean allResident = GL_TRUE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV(n)"); + return GL_FALSE; + } + + for (i = 0; i < n; i++) { + const struct gl_program *prog; + if (ids[i] == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); + return GL_FALSE; + } + prog = _mesa_lookup_program(ctx, ids[i]); + if (!prog) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); + return GL_FALSE; + } + if (prog->Resident) { + if (!allResident) + residences[i] = GL_TRUE; + } + else { + if (allResident) { + allResident = GL_FALSE; + for (j = 0; j < i; j++) + residences[j] = GL_TRUE; + } + residences[i] = GL_FALSE; + } + } + + return allResident; +} + + +/** + * Request that a set of programs be resident in hardware. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(n)"); + return; + } + + /* just error checking for now */ + for (i = 0; i < n; i++) { + struct gl_program *prog; + + if (ids[i] == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); + return; + } + + prog = _mesa_lookup_program(ctx, ids[i]); + if (!prog) { + _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); + return; + } + + /* XXX this is really a hardware thing we should hook out */ + prog->Resident = GL_TRUE; + } +} + + +/** + * Get a program parameter register. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, + GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_NV) { + if (pname == GL_PROGRAM_PARAMETER_NV) { + if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { + COPY_4V(params, ctx->VertexProgram.Parameters[index]); + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetProgramParameterfvNV(index)"); + return; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(pname)"); + return; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(target)"); + return; + } +} + + +/** + * Get a program parameter register. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, + GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_NV) { + if (pname == GL_PROGRAM_PARAMETER_NV) { + if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { + COPY_4V(params, ctx->VertexProgram.Parameters[index]); + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetProgramParameterdvNV(index)"); + return; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(pname)"); + return; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(target)"); + return; + } +} + + +/** + * Get a program attribute. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params) +{ + struct gl_program *prog; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + prog = _mesa_lookup_program(ctx, id); + if (!prog) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV"); + return; + } + + switch (pname) { + case GL_PROGRAM_TARGET_NV: + *params = prog->Target; + return; + case GL_PROGRAM_LENGTH_NV: + *params = prog->String ?(GLint) strlen((char *) prog->String) : 0; + return; + case GL_PROGRAM_RESIDENT_NV: + *params = prog->Resident; + return; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivNV(pname)"); + return; + } +} + + +/** + * Get the program source code. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) +{ + struct gl_program *prog; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname != GL_PROGRAM_STRING_NV) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringNV(pname)"); + return; + } + + prog = _mesa_lookup_program(ctx, id); + if (!prog) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV"); + return; + } + + if (prog->String) { + memcpy(program, prog->String, strlen((char *) prog->String)); + } + else { + program[0] = 0; + } +} + + +/** + * Get matrix tracking information. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, + GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_NV + && ctx->Extensions.NV_vertex_program) { + GLuint i; + + if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetTrackMatrixivNV(address)"); + return; + } + + i = address / 4; + + switch (pname) { + case GL_TRACK_MATRIX_NV: + params[0] = (GLint) ctx->VertexProgram.TrackMatrix[i]; + return; + case GL_TRACK_MATRIX_TRANSFORM_NV: + params[0] = (GLint) ctx->VertexProgram.TrackMatrixTransform[i]; + return; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); + return; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); + return; + } +} + + +/** + * Get a vertex (or vertex array) attribute. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params) +{ + const struct gl_client_array *array; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); + return; + } + + array = &ctx->Array.ArrayObj->VertexAttrib[index]; + + switch (pname) { + case GL_ATTRIB_ARRAY_SIZE_NV: + params[0] = array->Size; + break; + case GL_ATTRIB_ARRAY_STRIDE_NV: + params[0] = array->Stride; + break; + case GL_ATTRIB_ARRAY_TYPE_NV: + params[0] = array->Type; + break; + case GL_CURRENT_ATTRIB_NV: + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribdvNV(index == 0)"); + return; + } + FLUSH_CURRENT(ctx, 0); + COPY_4V(params, ctx->Current.Attrib[index]); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); + return; + } +} + +/** + * Get a vertex (or vertex array) attribute. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params) +{ + const struct gl_client_array *array; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); + return; + } + + array = &ctx->Array.ArrayObj->VertexAttrib[index]; + + switch (pname) { + case GL_ATTRIB_ARRAY_SIZE_NV: + params[0] = (GLfloat) array->Size; + break; + case GL_ATTRIB_ARRAY_STRIDE_NV: + params[0] = (GLfloat) array->Stride; + break; + case GL_ATTRIB_ARRAY_TYPE_NV: + params[0] = (GLfloat) array->Type; + break; + case GL_CURRENT_ATTRIB_NV: + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribfvNV(index == 0)"); + return; + } + FLUSH_CURRENT(ctx, 0); + COPY_4V(params, ctx->Current.Attrib[index]); + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); + return; + } +} + +/** + * Get a vertex (or vertex array) attribute. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params) +{ + const struct gl_client_array *array; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); + return; + } + + array = &ctx->Array.ArrayObj->VertexAttrib[index]; + + switch (pname) { + case GL_ATTRIB_ARRAY_SIZE_NV: + params[0] = array->Size; + break; + case GL_ATTRIB_ARRAY_STRIDE_NV: + params[0] = array->Stride; + break; + case GL_ATTRIB_ARRAY_TYPE_NV: + params[0] = array->Type; + break; + case GL_CURRENT_ATTRIB_NV: + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribivNV(index == 0)"); + return; + } + FLUSH_CURRENT(ctx, 0); + params[0] = (GLint) ctx->Current.Attrib[index][0]; + params[1] = (GLint) ctx->Current.Attrib[index][1]; + params[2] = (GLint) ctx->Current.Attrib[index][2]; + params[3] = (GLint) ctx->Current.Attrib[index][3]; + break; + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: + params[0] = array->BufferObj->Name; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); + return; + } +} + + +/** + * Get a vertex array attribute pointer. + * \note Not compiled into display lists. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerNV(index)"); + return; + } + + if (pname != GL_ATTRIB_ARRAY_POINTER_NV) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerNV(pname)"); + return; + } + + *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr; +} + +void +_mesa_emit_nv_temp_initialization(struct gl_context *ctx, + struct gl_program *program) +{ + struct prog_instruction *inst; + GLuint i; + struct gl_shader_compiler_options* options = + &ctx->ShaderCompilerOptions[_mesa_program_target_to_index(program->Target)]; + + if (!options->EmitNVTempInitialization) + return; + + /* We'll swizzle up a zero temporary so we can use it for the + * ARL. + */ + if (program->NumTemporaries == 0) + program->NumTemporaries = 1; + + _mesa_insert_instructions(program, 0, program->NumTemporaries + 1); + + for (i = 0; i < program->NumTemporaries; i++) { + struct prog_instruction *inst = &program->Instructions[i]; + + inst->Opcode = OPCODE_SWZ; + inst->DstReg.File = PROGRAM_TEMPORARY; + inst->DstReg.Index = i; + inst->DstReg.WriteMask = WRITEMASK_XYZW; + inst->SrcReg[0].File = PROGRAM_TEMPORARY; + inst->SrcReg[0].Index = 0; + inst->SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO, + SWIZZLE_ZERO, + SWIZZLE_ZERO, + SWIZZLE_ZERO); + } + + inst = &program->Instructions[i]; + inst->Opcode = OPCODE_ARL; + inst->DstReg.File = PROGRAM_ADDRESS; + inst->DstReg.Index = 0; + inst->DstReg.WriteMask = WRITEMASK_XYZW; + inst->SrcReg[0].File = PROGRAM_TEMPORARY; + inst->SrcReg[0].Index = 0; + inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; + + if (program->NumAddressRegs == 0) + program->NumAddressRegs = 1; +} + +void +_mesa_setup_nv_temporary_count(struct gl_context *ctx, struct gl_program *program) +{ + GLuint i; + + program->NumTemporaries = 0; + for (i = 0; i < program->NumInstructions; i++) { + struct prog_instruction *inst = &program->Instructions[i]; + + if (inst->DstReg.File == PROGRAM_TEMPORARY) { + program->NumTemporaries = MAX2(program->NumTemporaries, + inst->DstReg.Index + 1); + } + if (inst->SrcReg[0].File == PROGRAM_TEMPORARY) { + program->NumTemporaries = MAX2((GLint)program->NumTemporaries, + inst->SrcReg[0].Index + 1); + } + if (inst->SrcReg[1].File == PROGRAM_TEMPORARY) { + program->NumTemporaries = MAX2((GLint)program->NumTemporaries, + inst->SrcReg[1].Index + 1); + } + if (inst->SrcReg[2].File == PROGRAM_TEMPORARY) { + program->NumTemporaries = MAX2((GLint)program->NumTemporaries, + inst->SrcReg[2].Index + 1); + } + } +} + +/** + * Load/parse/compile a program. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte *program) +{ + struct gl_program *prog; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.NV_vertex_program + && !ctx->Extensions.NV_fragment_program) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()"); + return; + } + + if (id == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)"); + return; + } + + if (len < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(len)"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + prog = _mesa_lookup_program(ctx, id); + + if (prog && prog->Target != 0 && prog->Target != target) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(target)"); + return; + } + + if ((target == GL_VERTEX_PROGRAM_NV || + target == GL_VERTEX_STATE_PROGRAM_NV) + && ctx->Extensions.NV_vertex_program) { + struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog; + if (!vprog || prog == &_mesa_DummyProgram) { + vprog = (struct gl_vertex_program *) + ctx->Driver.NewProgram(ctx, target, id); + if (!vprog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + _mesa_HashInsert(ctx->Shared->Programs, id, vprog); + } + + if (ctx->Extensions.ARB_vertex_program + && (strncmp((char *) program, "!!ARB", 5) == 0)) { + _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog); + } else { + _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog); + } + } + else if (target == GL_FRAGMENT_PROGRAM_NV + && ctx->Extensions.NV_fragment_program) { + struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; + if (!fprog || prog == &_mesa_DummyProgram) { + fprog = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, target, id); + if (!fprog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + _mesa_HashInsert(ctx->Shared->Programs, id, fprog); + } + _mesa_parse_nv_fragment_program(ctx, target, program, len, fprog); + } + else if (target == GL_FRAGMENT_PROGRAM_ARB + && ctx->Extensions.ARB_fragment_program) { + struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; + if (!fprog || prog == &_mesa_DummyProgram) { + fprog = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, target, id); + if (!fprog) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + _mesa_HashInsert(ctx->Shared->Programs, id, fprog); + } + _mesa_parse_arb_fragment_program(ctx, target, program, len, fprog); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)"); + } +} + + + +/** + * Set a sequence of program parameter registers. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, + GLsizei num, const GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { + GLint i; + if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4dvNV"); + return; + } + for (i = 0; i < num; i++) { + ctx->VertexProgram.Parameters[index + i][0] = (GLfloat) params[0]; + ctx->VertexProgram.Parameters[index + i][1] = (GLfloat) params[1]; + ctx->VertexProgram.Parameters[index + i][2] = (GLfloat) params[2]; + ctx->VertexProgram.Parameters[index + i][3] = (GLfloat) params[3]; + params += 4; + }; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4dvNV"); + return; + } +} + + +/** + * Set a sequence of program parameter registers. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, + GLsizei num, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { + GLint i; + if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4fvNV"); + return; + } + for (i = 0; i < num; i++) { + COPY_4V(ctx->VertexProgram.Parameters[index + i], params); + params += 4; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4fvNV"); + return; + } +} + + + +/** + * Setup tracking of matrices into program parameter registers. + * \note Called from the GL API dispatcher. + */ +void GLAPIENTRY +_mesa_TrackMatrixNV(GLenum target, GLuint address, + GLenum matrix, GLenum transform) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { + if (address & 0x3) { + /* addr must be multiple of four */ + _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)"); + return; + } + + switch (matrix) { + case GL_NONE: + case GL_MODELVIEW: + case GL_PROJECTION: + case GL_TEXTURE: + case GL_COLOR: + case GL_MODELVIEW_PROJECTION_NV: + case GL_MATRIX0_NV: + case GL_MATRIX1_NV: + case GL_MATRIX2_NV: + case GL_MATRIX3_NV: + case GL_MATRIX4_NV: + case GL_MATRIX5_NV: + case GL_MATRIX6_NV: + case GL_MATRIX7_NV: + /* OK, fallthrough */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(matrix)"); + return; + } + + switch (transform) { + case GL_IDENTITY_NV: + case GL_INVERSE_NV: + case GL_TRANSPOSE_NV: + case GL_INVERSE_TRANSPOSE_NV: + /* OK, fallthrough */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(transform)"); + return; + } + + ctx->VertexProgram.TrackMatrix[address / 4] = matrix; + ctx->VertexProgram.TrackMatrixTransform[address / 4] = transform; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(target)"); + return; + } +} + + +void GLAPIENTRY +_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + struct gl_program *prog; + struct gl_fragment_program *fragProg; + GLfloat *v; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + prog = _mesa_lookup_program(ctx, id); + if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramNamedParameterNV"); + return; + } + + if (len <= 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(len)"); + return; + } + + fragProg = (struct gl_fragment_program *) prog; + v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len, + (char *) name); + if (v) { + v[0] = x; + v[1] = y; + v[2] = z; + v[3] = w; + return; + } + + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(name)"); +} + + +void GLAPIENTRY +_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, + const float v[]) +{ + _mesa_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +void GLAPIENTRY +_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + _mesa_ProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y, + (GLfloat)z, (GLfloat)w); +} + + +void GLAPIENTRY +_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, + const double v[]) +{ + _mesa_ProgramNamedParameter4fNV(id, len, name, + (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3]); +} + + +void GLAPIENTRY +_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, + GLfloat *params) +{ + struct gl_program *prog; + struct gl_fragment_program *fragProg; + const GLfloat *v; + + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + prog = _mesa_lookup_program(ctx, id); + if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramNamedParameterNV"); + return; + } + + if (len <= 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); + return; + } + + fragProg = (struct gl_fragment_program *) prog; + v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, + len, (char *) name); + if (v) { + params[0] = v[0]; + params[1] = v[1]; + params[2] = v[2]; + params[3] = v[3]; + return; + } + + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); +} + + +void GLAPIENTRY +_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, + GLdouble *params) +{ + GLfloat floatParams[4]; + _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams); + COPY_4V(params, floatParams); +} diff --git a/mesalib/src/mesa/main/nvprogram.h b/mesalib/src/mesa/main/nvprogram.h index 260a25ba9..3d12b4e33 100644 --- a/mesalib/src/mesa/main/nvprogram.h +++ b/mesalib/src/mesa/main/nvprogram.h @@ -1,115 +1,119 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Brian Paul - */ - - -#ifndef NVPROGRAM_H -#define NVPROGRAM_H - -#include "glheader.h" -#include "mtypes.h" - -extern void GLAPIENTRY -_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params); - -extern GLboolean GLAPIENTRY -_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, GLboolean *residences); - -extern void GLAPIENTRY -_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids); - -extern void GLAPIENTRY -_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble *params); - -extern void GLAPIENTRY -_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program); - -extern void GLAPIENTRY -_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer); - -extern void GLAPIENTRY -_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program); - -extern void GLAPIENTRY -_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble *params); - -extern void GLAPIENTRY -_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat *params); - -extern void GLAPIENTRY -_mesa_TrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform); - - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, - const float v[]); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, - const double v[]); - -extern void GLAPIENTRY -_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble *params); - -extern void -_mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program); - -extern void -_mesa_emit_nv_temp_initialization(GLcontext *ctx, - struct gl_program *program); - -#endif +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Brian Paul + */ + + +#ifndef NVPROGRAM_H +#define NVPROGRAM_H + +#include "glheader.h" + +struct gl_context; +struct gl_program; + +extern void GLAPIENTRY +_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params); + +extern GLboolean GLAPIENTRY +_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, GLboolean *residences); + +extern void GLAPIENTRY +_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids); + +extern void GLAPIENTRY +_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat *params); + +extern void GLAPIENTRY +_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble *params); + +extern void GLAPIENTRY +_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program); + +extern void GLAPIENTRY +_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params); + +extern void GLAPIENTRY +_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params); + +extern void GLAPIENTRY +_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer); + +extern void GLAPIENTRY +_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program); + +extern void GLAPIENTRY +_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, GLsizei num, + const GLdouble *params); + +extern void GLAPIENTRY +_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, GLsizei num, + const GLfloat *params); + +extern void GLAPIENTRY +_mesa_TrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform); + + +extern void GLAPIENTRY +_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, + GLfloat x, GLfloat y, GLfloat z, GLfloat w); + +extern void GLAPIENTRY +_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, + const float v[]); + +extern void GLAPIENTRY +_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, + GLdouble x, GLdouble y, GLdouble z, GLdouble w); + +extern void GLAPIENTRY +_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, + const double v[]); + +extern void GLAPIENTRY +_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, + GLfloat *params); + +extern void GLAPIENTRY +_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, + GLdouble *params); + +extern void +_mesa_setup_nv_temporary_count(struct gl_context *ctx, struct gl_program *program); + +extern void +_mesa_emit_nv_temp_initialization(struct gl_context *ctx, + struct gl_program *program); + +#endif diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c new file mode 100644 index 000000000..f323c51f1 --- /dev/null +++ b/mesalib/src/mesa/main/pack.c @@ -0,0 +1,5063 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THEA AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file pack.c + * Image and pixel span packing and unpacking. + */ + + +#include "glheader.h" +#include "colormac.h" +#include "enums.h" +#include "image.h" +#include "imports.h" +#include "pack.h" +#include "pixeltransfer.h" +#include "imports.h" + + +/** + * NOTE: + * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when + * we later convert the float to a packed integer value (such as for + * GL_RGB5_A1) because we'll wind up with a non-zero value. + * + * We redefine the macros here so zero is handled correctly. + */ +#undef BYTE_TO_FLOAT +#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F))) + +#undef SHORT_TO_FLOAT +#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))) + + + +/** Compute ceiling of integer quotient of A divided by B. */ +#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) + + +/** + * Flip the 8 bits in each byte of the given array. + * + * \param p array. + * \param n number of bytes. + * + * \todo try this trick to flip bytes someday: + * \code + * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); + * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); + * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); + * \endcode + */ +static void +flip_bytes( GLubyte *p, GLuint n ) +{ + GLuint i, a, b; + for (i = 0; i < n; i++) { + b = (GLuint) p[i]; /* words are often faster than bytes */ + a = ((b & 0x01) << 7) | + ((b & 0x02) << 5) | + ((b & 0x04) << 3) | + ((b & 0x08) << 1) | + ((b & 0x10) >> 1) | + ((b & 0x20) >> 3) | + ((b & 0x40) >> 5) | + ((b & 0x80) >> 7); + p[i] = (GLubyte) a; + } +} + + + +/* + * Unpack a 32x32 pixel polygon stipple from user memory using the + * current pixel unpack settings. + */ +void +_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], + const struct gl_pixelstore_attrib *unpacking ) +{ + GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking); + if (ptrn) { + /* Convert pattern from GLubytes to GLuints and handle big/little + * endian differences + */ + GLubyte *p = ptrn; + GLint i; + for (i = 0; i < 32; i++) { + dest[i] = (p[0] << 24) + | (p[1] << 16) + | (p[2] << 8) + | (p[3] ); + p += 4; + } + free(ptrn); + } +} + + +/* + * Pack polygon stipple into user memory given current pixel packing + * settings. + */ +void +_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, + const struct gl_pixelstore_attrib *packing ) +{ + /* Convert pattern from GLuints to GLubytes to handle big/little + * endian differences. + */ + GLubyte ptrn[32*4]; + GLint i; + for (i = 0; i < 32; i++) { + ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); + ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); + ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); + ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); + } + + _mesa_pack_bitmap(32, 32, ptrn, dest, packing); +} + + +/* + * Unpack bitmap data. Resulting data will be in most-significant-bit-first + * order with row alignment = 1 byte. + */ +GLvoid * +_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, + const struct gl_pixelstore_attrib *packing ) +{ + GLint bytes, row, width_in_bytes; + GLubyte *buffer, *dst; + + if (!pixels) + return NULL; + + /* Alloc dest storage */ + bytes = ((width + 7) / 8 * height); + buffer = (GLubyte *) malloc( bytes ); + if (!buffer) + return NULL; + + width_in_bytes = CEILING( width, 8 ); + dst = buffer; + for (row = 0; row < height; row++) { + const GLubyte *src = (const GLubyte *) + _mesa_image_address2d(packing, pixels, width, height, + GL_COLOR_INDEX, GL_BITMAP, row, 0); + if (!src) { + free(buffer); + return NULL; + } + + if ((packing->SkipPixels & 7) == 0) { + memcpy( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + dst += width_in_bytes; + } + + return buffer; +} + + +/* + * Pack bitmap data. + */ +void +_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, + GLubyte *dest, const struct gl_pixelstore_attrib *packing ) +{ + GLint row, width_in_bytes; + const GLubyte *src; + + if (!source) + return; + + width_in_bytes = CEILING( width, 8 ); + src = source; + for (row = 0; row < height; row++) { + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, + width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); + if (!dst) + return; + + if ((packing->SkipPixels & 7) == 0) { + memcpy( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 128; + GLubyte dstMask = 1 << (packing->SkipPixels & 0x7); + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 128) { + dstMask = 1; + d++; + *d = 0; + } + else { + dstMask = dstMask << 1; + } + } + } + else { + GLubyte srcMask = 128; + GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7); + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + src += width_in_bytes; + } +} + + +/** + * Get indexes of color components for a basic color format, such as + * GL_RGBA, GL_RED, GL_LUMINANCE_ALPHA, etc. Return -1 for indexes + * that do not apply. + */ +static void +get_component_indexes(GLenum format, + GLint *redIndex, + GLint *greenIndex, + GLint *blueIndex, + GLint *alphaIndex, + GLint *luminanceIndex, + GLint *intensityIndex) +{ + *redIndex = -1; + *greenIndex = -1; + *blueIndex = -1; + *alphaIndex = -1; + *luminanceIndex = -1; + *intensityIndex = -1; + + switch (format) { + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + *luminanceIndex = 0; + break; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + *luminanceIndex = 0; + *alphaIndex = 1; + break; + case GL_INTENSITY: + *intensityIndex = 0; + break; + case GL_RED: + case GL_RED_INTEGER_EXT: + *redIndex = 0; + break; + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + *greenIndex = 0; + break; + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + *blueIndex = 0; + break; + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + *alphaIndex = 0; + break; + case GL_RG: + case GL_RG_INTEGER: + *redIndex = 0; + *greenIndex = 1; + break; + case GL_RGB: + case GL_RGB_INTEGER_EXT: + *redIndex = 0; + *greenIndex = 1; + *blueIndex = 2; + break; + case GL_BGR: + case GL_BGR_INTEGER_EXT: + *blueIndex = 0; + *greenIndex = 1; + *redIndex = 2; + break; + case GL_RGBA: + case GL_RGBA_INTEGER_EXT: + *redIndex = 0; + *greenIndex = 1; + *blueIndex = 2; + *alphaIndex = 3; + break; + case GL_BGRA: + case GL_BGRA_INTEGER: + *redIndex = 2; + *greenIndex = 1; + *blueIndex = 0; + *alphaIndex = 3; + break; + case GL_ABGR_EXT: + *redIndex = 3; + *greenIndex = 2; + *blueIndex = 1; + *alphaIndex = 0; + break; + case GL_DU8DV8_ATI: + case GL_DUDV_ATI: + *redIndex = 0; + *greenIndex = 1; + break; + default: + assert(0 && "bad format in get_component_indexes()"); + } +} + + + +/** + * For small integer types, return the min and max possible values. + * Used for clamping floats to unscaled integer types. + * \return GL_TRUE if type is handled, GL_FALSE otherwise. + */ +static GLboolean +get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) +{ + switch (type) { + case GL_BYTE: + *min = -128.0; + *max = 127.0; + return GL_TRUE; + case GL_UNSIGNED_BYTE: + *min = 0.0; + *max = 255.0; + return GL_TRUE; + case GL_SHORT: + *min = -32768.0; + *max = 32767.0; + return GL_TRUE; + case GL_UNSIGNED_SHORT: + *min = 0.0; + *max = 65535.0; + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + +/** + * Used to pack an array [][4] of RGBA float colors as specified + * by the dstFormat, dstType and dstPacking. Used by glReadPixels. + * Historically, the RGBA values were in [0,1] and rescaled to fit + * into GLubytes, etc. But with new integer formats, the RGBA values + * may have any value and we don't always rescale when converting to + * integers. + * + * Note: the rgba values will be modified by this function when any pixel + * transfer ops are enabled. + */ +void +_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps) +{ + GLfloat *luminance; + const GLint comps = _mesa_components_in_format(dstFormat); + const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat); + GLuint i; + + if (dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_LUMINANCE_INTEGER_EXT || + dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) { + luminance = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!luminance) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + } + else { + luminance = NULL; + } + + /* XXX + * This test should probably go away. Have the caller set/clear the + * IMAGE_CLAMP_BIT as needed. + */ + if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + if (!intDstFormat) { + /* need to clamp to [0, 1] */ + transferOps |= IMAGE_CLAMP_BIT; + } + } + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + /* + * Component clamping (besides clamping to [0,1] in + * _mesa_apply_rgba_transfer_ops()). + */ + if (intDstFormat) { + /* clamping to dest type's min/max values */ + GLfloat min, max; + if (get_type_min_max(dstType, &min, &max)) { + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], min, max); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], min, max); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], min, max); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], min, max); + } + } + } + else if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { + /* compute luminance values */ + if (transferOps & IMAGE_CLAMP_BIT) { + for (i = 0; i < n; i++) { + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); + } + } + else { + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + } + } + } + + /* + * Pack/store the pixels. Ugh! Lots of cases!!! + */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dstAddr; + switch (dstFormat) { + case GL_RED: + for (i=0;iSwapBytes) { + GLint swapSize = _mesa_sizeof_packed_type(dstType); + if (swapSize == 2) { + if (dstPacking->SwapBytes) { + _mesa_swap2((GLushort *) dstAddr, n * comps); + } + } + else if (swapSize == 4) { + if (dstPacking->SwapBytes) { + _mesa_swap4((GLuint *) dstAddr, n * comps); + } + } + } + + free(luminance); +} + + + +#define SWAP2BYTE(VALUE) \ + { \ + GLubyte *bytes = (GLubyte *) &(VALUE); \ + GLubyte tmp = bytes[0]; \ + bytes[0] = bytes[1]; \ + bytes[1] = tmp; \ + } + +#define SWAP4BYTE(VALUE) \ + { \ + GLubyte *bytes = (GLubyte *) &(VALUE); \ + GLubyte tmp = bytes[0]; \ + bytes[0] = bytes[3]; \ + bytes[3] = tmp; \ + tmp = bytes[1]; \ + bytes[1] = bytes[2]; \ + bytes[2] = tmp; \ + } + + +static void +extract_uint_indexes(GLuint n, GLuint indexes[], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + const struct gl_pixelstore_attrib *unpack ) +{ + ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_UNSIGNED_INT_24_8_EXT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + switch (srcType) { + case GL_BITMAP: + { + GLubyte *ubsrc = (GLubyte *) src; + if (unpack->LsbFirst) { + GLubyte mask = 1 << (unpack->SkipPixels & 0x7); + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (*ubsrc & mask) ? 1 : 0; + if (mask == 128) { + mask = 1; + ubsrc++; + } + else { + mask = mask << 1; + } + } + } + else { + GLubyte mask = 128 >> (unpack->SkipPixels & 0x7); + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (*ubsrc & mask) ? 1 : 0; + if (mask == 1) { + mask = 128; + ubsrc++; + } + else { + mask = mask >> 1; + } + } + } + } + break; + case GL_UNSIGNED_BYTE: + { + GLuint i; + const GLubyte *s = (const GLubyte *) src; + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + break; + case GL_BYTE: + { + GLuint i; + const GLbyte *s = (const GLbyte *) src; + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint i; + const GLushort *s = (const GLushort *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLushort value = s[i]; + SWAP2BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_SHORT: + { + GLuint i; + const GLshort *s = (const GLshort *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLshort value = s[i]; + SWAP2BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint i; + const GLuint *s = (const GLuint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLuint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_INT: + { + GLuint i; + const GLint *s = (const GLint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_FLOAT: + { + GLuint i; + const GLfloat *s = (const GLfloat *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLfloat value = s[i]; + SWAP4BYTE(value); + indexes[i] = (GLuint) value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = (GLuint) s[i]; + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLuint i; + const GLhalfARB *s = (const GLhalfARB *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLhalfARB value = s[i]; + SWAP2BYTE(value); + indexes[i] = (GLuint) _mesa_half_to_float(value); + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = (GLuint) _mesa_half_to_float(s[i]); + } + } + break; + case GL_UNSIGNED_INT_24_8_EXT: + { + GLuint i; + const GLuint *s = (const GLuint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLuint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value & 0xff; /* lower 8 bits */ + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i] & 0xff; /* lower 8 bits */ + } + } + break; + + default: + _mesa_problem(NULL, "bad srcType in extract_uint_indexes"); + return; + } +} + + +/** + * Return source/dest RGBA indexes for unpacking pixels. + */ +static void +get_component_mapping(GLenum format, + GLint *rSrc, + GLint *gSrc, + GLint *bSrc, + GLint *aSrc, + GLint *rDst, + GLint *gDst, + GLint *bDst, + GLint *aDst) +{ + switch (format) { + case GL_RED: + case GL_RED_INTEGER_EXT: + *rSrc = 0; + *gSrc = *bSrc = *aSrc = -1; + break; + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + *gSrc = 0; + *rSrc = *bSrc = *aSrc = -1; + break; + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + *bSrc = 0; + *rSrc = *gSrc = *aSrc = -1; + break; + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = -1; + *aSrc = 0; + break; + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = 0; + *aSrc = -1; + break; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = 0; + *aSrc = 1; + break; + case GL_INTENSITY: + *rSrc = *gSrc = *bSrc = *aSrc = 0; + break; + case GL_RG: + case GL_RG_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = -1; + *aSrc = -1; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_RGB: + case GL_RGB_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = 2; + *aSrc = -1; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_BGR: + *rSrc = 2; + *gSrc = 1; + *bSrc = 0; + *aSrc = -1; + *rDst = 2; + *gDst = 1; + *bDst = 0; + *aDst = 3; + break; + case GL_RGBA: + case GL_RGBA_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = 2; + *aSrc = 3; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_BGRA: + *rSrc = 2; + *gSrc = 1; + *bSrc = 0; + *aSrc = 3; + *rDst = 2; + *gDst = 1; + *bDst = 0; + *aDst = 3; + break; + case GL_ABGR_EXT: + *rSrc = 3; + *gSrc = 2; + *bSrc = 1; + *aSrc = 0; + *rDst = 3; + *gDst = 2; + *bDst = 1; + *aDst = 0; + break; + case GL_DU8DV8_ATI: + case GL_DUDV_ATI: + *rSrc = 0; + *gSrc = 1; + *bSrc = -1; + *aSrc = -1; + break; + default: + _mesa_problem(NULL, "bad srcFormat %s in get_component_mapping", + _mesa_lookup_enum_by_nr(format)); + return; + } +} + + + +/* + * This function extracts floating point RGBA values from arbitrary + * image data. srcFormat and srcType are the format and type parameters + * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc. + * + * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function + * implements the "Conversion to floating point", "Conversion to RGB", + * and "Final Expansion to RGBA" operations. + * + * Args: n - number of pixels + * rgba - output colors + * srcFormat - format of incoming data + * srcType - data type of incoming data + * src - source data pointer + * swapBytes - perform byteswapping of incoming data? + */ +static void +extract_float_rgba(GLuint n, GLfloat rgba[][4], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + GLboolean swapBytes) +{ + GLint rSrc, gSrc, bSrc, aSrc; + GLint stride; + GLint rDst, bDst, gDst, aDst; + GLboolean intFormat; + GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */ + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_DU8DV8_ATI || + srcFormat == GL_DUDV_ATI || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + get_component_mapping(srcFormat, + &rSrc, &gSrc, &bSrc, &aSrc, + &rDst, &gDst, &bDst, &aDst); + + stride = _mesa_components_in_format(srcFormat); + + intFormat = _mesa_is_integer_format(srcFormat); + +#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT_FLT, DEFAULT_INT, TYPE, CONVERSION) \ + if ((SRC_INDEX) < 0) { \ + GLuint i; \ + if (intFormat) { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT_INT; \ + } \ + } \ + else { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT_FLT; \ + } \ + } \ + } \ + else if (swapBytes) { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + TYPE value = s[SRC_INDEX]; \ + if (sizeof(TYPE) == 2) { \ + SWAP2BYTE(value); \ + } \ + else if (sizeof(TYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + if (intFormat) \ + rgba[i][DST_INDEX] = (GLfloat) value; \ + else \ + rgba[i][DST_INDEX] = (GLfloat) CONVERSION(value); \ + s += stride; \ + } \ + } \ + else { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + if (intFormat) { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = (GLfloat) s[SRC_INDEX]; \ + s += stride; \ + } \ + } \ + else { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = (GLfloat) CONVERSION(s[SRC_INDEX]); \ + s += stride; \ + } \ + } \ + } + + switch (srcType) { + case GL_UNSIGNED_BYTE: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT); + break; + case GL_BYTE: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT); + break; + case GL_UNSIGNED_SHORT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT); + break; + case GL_SHORT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT); + break; + case GL_UNSIGNED_INT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT); + break; + case GL_INT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT); + break; + case GL_FLOAT: + PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); + break; + case GL_HALF_FLOAT_ARB: + PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLhalfARB, _mesa_half_to_float); + break; + case GL_UNSIGNED_BYTE_3_3_2: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + if (!intFormat) { + rs = 1.0F / 7.0F; + gs = 1.0F / 7.0F; + bs = 1.0F / 3.0F; + } + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p >> 5) ) * rs; + rgba[i][gDst] = ((p >> 2) & 0x7) * gs; + rgba[i][bDst] = ((p ) & 0x3) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + if (!intFormat) { + rs = 1.0F / 7.0F; + gs = 1.0F / 7.0F; + bs = 1.0F / 3.0F; + } + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p ) & 0x7) * rs; + rgba[i][gDst] = ((p >> 3) & 0x7) * gs; + rgba[i][bDst] = ((p >> 6) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (!intFormat) { + rs = 1.0F / 31.0F; + gs = 1.0F / 63.0F; + bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p ) & 0x1f) * bs; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p ) & 0x1f) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (!intFormat) { + rs = 1.0F / 31.0F; + gs = 1.0F / 63.0F; + bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p >> 11) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p >> 11) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if (!intFormat) { + rs = gs = bs = as = 1.0F / 15.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 12) ) * rs; + rgba[i][gDst] = ((p >> 8) & 0xf) * gs; + rgba[i][bDst] = ((p >> 4) & 0xf) * bs; + rgba[i][aDst] = ((p ) & 0xf) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 12) ) * rs; + rgba[i][gDst] = ((p >> 8) & 0xf) * gs; + rgba[i][bDst] = ((p >> 4) & 0xf) * bs; + rgba[i][aDst] = ((p ) & 0xf) * as; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if (!intFormat) { + rs = gs = bs = as = 1.0F / 15.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0xf) * rs; + rgba[i][gDst] = ((p >> 4) & 0xf) * gs; + rgba[i][bDst] = ((p >> 8) & 0xf) * bs; + rgba[i][aDst] = ((p >> 12) ) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0xf) * rs; + rgba[i][gDst] = ((p >> 4) & 0xf) * gs; + rgba[i][bDst] = ((p >> 8) & 0xf) * bs; + rgba[i][aDst] = ((p >> 12) ) * as; + } + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if (!intFormat) { + rs = gs = bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; + rgba[i][aDst] = ((p ) & 0x1) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; + rgba[i][aDst] = ((p ) & 0x1) * as; + } + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (!intFormat) { + rs = gs = bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; + rgba[i][aDst] = ((p >> 15) ) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; + rgba[i][aDst] = ((p >> 15) ) * as; + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p ) & 0xff); + rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][aDst] = (GLfloat) ((p >> 24) ); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); + } + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p >> 24) ); + rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][aDst] = (GLfloat) ((p ) & 0xff); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); + } + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p >> 24) ); + rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][aDst] = (GLfloat) ((p ) & 0xff); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); + } + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p ) & 0xff); + rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][aDst] = (GLfloat) ((p >> 24) ); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); + } + } + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if (!intFormat) { + rs = 1.0F / 1023.0F; + gs = 1.0F / 1023.0F; + bs = 1.0F / 1023.0F; + as = 1.0F / 3.0F; + } + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p >> 22) ) * rs; + rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; + rgba[i][aDst] = ((p ) & 0x3 ) * as; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 22) ) * rs; + rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; + rgba[i][aDst] = ((p ) & 0x3 ) * as; + } + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (!intFormat) { + rs = 1.0F / 1023.0F; + gs = 1.0F / 1023.0F; + bs = 1.0F / 1023.0F; + as = 1.0F / 3.0F; + } + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p ) & 0x3ff) * rs; + rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; + rgba[i][aDst] = ((p >> 30) ) * as; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0x3ff) * rs; + rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; + rgba[i][aDst] = ((p >> 30) ) * as; + } + } + break; + default: + _mesa_problem(NULL, "bad srcType in extract float data"); + break; + } +#undef PROCESS +} + + +static INLINE GLuint +clamp_byte_to_uint(GLbyte b) +{ + return b < 0 ? 0 : b; +} + + +static INLINE GLuint +clamp_short_to_uint(GLshort s) +{ + return s < 0 ? 0 : s; +} + + +static INLINE GLuint +clamp_int_to_uint(GLint i) +{ + return i < 0 ? 0 : i; +} + + +static INLINE GLuint +clamp_float_to_uint(GLfloat f) +{ + return f < 0.0F ? 0 : IROUND(f); +} + + +static INLINE GLuint +clamp_half_to_uint(GLhalfARB h) +{ + GLfloat f = _mesa_half_to_float(h); + return f < 0.0F ? 0 : IROUND(f); +} + + +/** + * \sa extract_float_rgba() + */ +static void +extract_uint_rgba(GLuint n, GLuint rgba[][4], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + GLboolean swapBytes) +{ + GLint rSrc, gSrc, bSrc, aSrc; + GLint stride; + GLint rDst, bDst, gDst, aDst; + GLboolean intFormat; + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_DU8DV8_ATI || + srcFormat == GL_DUDV_ATI || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + get_component_mapping(srcFormat, + &rSrc, &gSrc, &bSrc, &aSrc, + &rDst, &gDst, &bDst, &aDst); + + stride = _mesa_components_in_format(srcFormat); + + intFormat = _mesa_is_integer_format(srcFormat); + +#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT, TYPE, CONVERSION) \ + if ((SRC_INDEX) < 0) { \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT; \ + } \ + } \ + else if (swapBytes) { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + TYPE value = s[SRC_INDEX]; \ + if (sizeof(TYPE) == 2) { \ + SWAP2BYTE(value); \ + } \ + else if (sizeof(TYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + rgba[i][DST_INDEX] = CONVERSION(value); \ + s += stride; \ + } \ + } \ + else { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = CONVERSION(s[SRC_INDEX]); \ + s += stride; \ + } \ + } + + switch (srcType) { + case GL_UNSIGNED_BYTE: + PROCESS(rSrc, RCOMP, 0, GLubyte, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLubyte, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLubyte, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint)); + break; + case GL_BYTE: + PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint); + break; + case GL_UNSIGNED_SHORT: + PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLushort, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLushort, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint)); + break; + case GL_SHORT: + PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint); + break; + case GL_UNSIGNED_INT: + PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLuint, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLuint, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint)); + break; + case GL_INT: + PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint); + break; + case GL_FLOAT: + PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(gSrc, GCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(bSrc, BCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint); + break; + case GL_HALF_FLOAT_ARB: + PROCESS(rSrc, RCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(gSrc, GCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(bSrc, BCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(aSrc, ACOMP, 1, GLhalfARB, clamp_half_to_uint); + break; + case GL_UNSIGNED_BYTE_3_3_2: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p >> 5) ); + rgba[i][gDst] = ((p >> 2) & 0x7); + rgba[i][bDst] = ((p ) & 0x3); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p ) & 0x7); + rgba[i][gDst] = ((p >> 3) & 0x7); + rgba[i][bDst] = ((p >> 6) ); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p ) & 0x1f); + rgba[i][aDst] = 1; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p ) & 0x1f); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p >> 11) ); + rgba[i][aDst] = 1; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p >> 11) ); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 12) ); + rgba[i][gDst] = ((p >> 8) & 0xf); + rgba[i][bDst] = ((p >> 4) & 0xf); + rgba[i][aDst] = ((p ) & 0xf); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 12) ); + rgba[i][gDst] = ((p >> 8) & 0xf); + rgba[i][bDst] = ((p >> 4) & 0xf); + rgba[i][aDst] = ((p ) & 0xf); + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0xf); + rgba[i][gDst] = ((p >> 4) & 0xf); + rgba[i][bDst] = ((p >> 8) & 0xf); + rgba[i][aDst] = ((p >> 12) ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0xf); + rgba[i][gDst] = ((p >> 4) & 0xf); + rgba[i][bDst] = ((p >> 8) & 0xf); + rgba[i][aDst] = ((p >> 12) ); + } + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 6) & 0x1f); + rgba[i][bDst] = ((p >> 1) & 0x1f); + rgba[i][aDst] = ((p ) & 0x1 ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 6) & 0x1f); + rgba[i][bDst] = ((p >> 1) & 0x1f); + rgba[i][aDst] = ((p ) & 0x1 ); + } + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x1f); + rgba[i][bDst] = ((p >> 10) & 0x1f); + rgba[i][aDst] = ((p >> 15) ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x1f); + rgba[i][bDst] = ((p >> 10) & 0x1f); + rgba[i][aDst] = ((p >> 15) ); + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0xff); + rgba[i][gDst] = ((p >> 8) & 0xff); + rgba[i][bDst] = ((p >> 16) & 0xff); + rgba[i][aDst] = ((p >> 24) ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 24) ); + rgba[i][gDst] = ((p >> 16) & 0xff); + rgba[i][bDst] = ((p >> 8) & 0xff); + rgba[i][aDst] = ((p ) & 0xff); + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 24) ); + rgba[i][gDst] = ((p >> 16) & 0xff); + rgba[i][bDst] = ((p >> 8) & 0xff); + rgba[i][aDst] = ((p ) & 0xff); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0xff); + rgba[i][gDst] = ((p >> 8) & 0xff); + rgba[i][bDst] = ((p >> 16) & 0xff); + rgba[i][aDst] = ((p >> 24) ); + } + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p >> 22) ); + rgba[i][gDst] = ((p >> 12) & 0x3ff); + rgba[i][bDst] = ((p >> 2) & 0x3ff); + rgba[i][aDst] = ((p ) & 0x3 ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 22) ); + rgba[i][gDst] = ((p >> 12) & 0x3ff); + rgba[i][bDst] = ((p >> 2) & 0x3ff); + rgba[i][aDst] = ((p ) & 0x3 ); + } + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p ) & 0x3ff); + rgba[i][gDst] = ((p >> 10) & 0x3ff); + rgba[i][bDst] = ((p >> 20) & 0x3ff); + rgba[i][aDst] = ((p >> 30) ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0x3ff); + rgba[i][gDst] = ((p >> 10) & 0x3ff); + rgba[i][bDst] = ((p >> 20) & 0x3ff); + rgba[i][aDst] = ((p >> 30) ); + } + } + break; + default: + _mesa_problem(NULL, "bad srcType in extract uint data"); + break; + } +#undef PROCESS +} + + + +/* + * Unpack a row of color image data from a client buffer according to + * the pixel unpacking parameters. + * Return GLchan values in the specified dest image format. + * This is used by glDrawPixels and glTexImage?D(). + * \param ctx - the context + * n - number of pixels in the span + * dstFormat - format of destination color array + * dest - the destination color array + * srcFormat - source image format + * srcType - source image data type + * source - source image pointer + * srcPacking - pixel unpacking parameters + * transferOps - bitmask of IMAGE_*_BIT values of operations to apply + * + * XXX perhaps expand this to process whole images someday. + */ +void +_mesa_unpack_color_span_chan( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLchan dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA || + dstFormat == GL_COLOR_INDEX); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + /* Try simple cases first */ + if (transferOps == 0) { + if (srcType == CHAN_TYPE) { + if (dstFormat == GL_RGBA) { + if (srcFormat == GL_RGBA) { + memcpy( dest, source, n * 4 * sizeof(GLchan) ); + return; + } + else if (srcFormat == GL_RGB) { + GLuint i; + const GLchan *src = (const GLchan *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = CHAN_MAX; + src += 3; + dst += 4; + } + return; + } + } + else if (dstFormat == GL_RGB) { + if (srcFormat == GL_RGB) { + memcpy( dest, source, n * 3 * sizeof(GLchan) ); + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLchan *src = (const GLchan *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + src += 4; + dst += 3; + } + return; + } + } + else if (dstFormat == srcFormat) { + GLint comps = _mesa_components_in_format(srcFormat); + assert(comps > 0); + memcpy( dest, source, n * comps * sizeof(GLchan) ); + return; + } + } + /* + * Common situation, loading 8bit RGBA/RGB source images + * into 16/32 bit destination. (OSMesa16/32) + */ + else if (srcType == GL_UNSIGNED_BYTE) { + if (dstFormat == GL_RGBA) { + if (srcFormat == GL_RGB) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + dst[3] = CHAN_MAX; + src += 3; + dst += 4; + } + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + dst[3] = UBYTE_TO_CHAN(src[3]); + src += 4; + dst += 4; + } + return; + } + } + else if (dstFormat == GL_RGB) { + if (srcFormat == GL_RGB) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + src += 3; + dst += 3; + } + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + src += 4; + dst += 3; + } + return; + } + } + } + } + + + /* general solution begins here */ + { + GLint dstComponents; + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + if (srcFormat == GL_COLOR_INDEX) { + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + srcPacking); + + if (dstFormat == GL_COLOR_INDEX) { + GLuint i; + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + /* convert to GLchan and return */ + for (i = 0; i < n; i++) { + dest[i] = (GLchan) (indexes[i] & 0xff); + } + free(indexes); + free(rgba); + return; + } + else { + /* Convert indexes to RGBA */ + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + } + + /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting + * with color indexes. + */ + transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); + + free(indexes); + } + else { + /* non-color index data */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + } + + /* Need to clamp if returning GLubytes or GLushorts */ +#if CHAN_TYPE != GL_FLOAT + transferOps |= IMAGE_CLAMP_BIT; +#endif + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now return the GLchan data in the requested dstFormat */ + if (rDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[rDst], rgba[i][RCOMP]); + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[gDst], rgba[i][GCOMP]); + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[bDst], rgba[i][BCOMP]); + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[aDst], rgba[i][ACOMP]); + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLchan *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]); + } + } + + if (lDst >= 0) { + GLchan *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]); + dst += dstComponents; + } + } + + free(rgba); + } +} + + +/** + * Same as _mesa_unpack_color_span_chan(), but return GLfloat data + * instead of GLchan. + */ +void +_mesa_unpack_color_span_float( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA || + dstFormat == GL_COLOR_INDEX); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + /* general solution, no special cases, yet */ + { + GLint dstComponents; + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + if (srcFormat == GL_COLOR_INDEX) { + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + free(rgba); + return; + } + + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + srcPacking); + + if (dstFormat == GL_COLOR_INDEX) { + GLuint i; + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + /* convert to GLchan and return */ + for (i = 0; i < n; i++) { + dest[i] = (GLchan) (indexes[i] & 0xff); + } + free(indexes); + free(rgba); + return; + } + else { + /* Convert indexes to RGBA */ + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + } + + /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting + * with color indexes. + */ + transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); + + free(indexes); + } + else { + /* non-color index data */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + } + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now pack results in the requested dstFormat */ + if (rDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[rDst] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[gDst] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[bDst] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[aDst] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (lDst >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + free(rgba); + } +} + + +/** + * Same as _mesa_unpack_color_span_chan(), but return GLuint data + * instead of GLchan. + * No pixel transfer ops are applied. + */ +void +_mesa_unpack_color_span_uint(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLuint *dest, + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint (*rgba)[4] = (GLuint (*)[4]) malloc(n * 4 * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + + /* Extract image data as uint[4] pixels */ + extract_uint_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + if (dstFormat == GL_RGBA) { + /* simple case */ + memcpy(dest, rgba, 4 * sizeof(GLuint) * n); + } + else { + /* general case */ + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLint dstComponents = _mesa_components_in_format( dstFormat ); + + assert(dstComponents > 0); + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now pack values in the requested dest format */ + if (rDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[rDst] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[gDst] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[bDst] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[aDst] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLuint *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (lDst >= 0) { + GLuint *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + } + + free(rgba); +} + + + +/** + * Similar to _mesa_unpack_color_span_float(), but for dudv data instead of rgba, + * directly return GLbyte data, no transfer ops apply. + */ +void +_mesa_unpack_dudv_span_byte( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLbyte dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_DUDV_ATI); + ASSERT(srcFormat == GL_DUDV_ATI); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + /* general solution */ + { + GLint dstComponents; + GLbyte *dst = dest; + GLuint i; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + + /* Now pack results in the requested dstFormat */ + for (i = 0; i < n; i++) { + /* not sure - need clamp[-1,1] here? */ + dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst += dstComponents; + } + + free(rgba); + } +} + +/* + * Unpack a row of color index data from a client buffer according to + * the pixel unpacking parameters. + * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc. + * + * Args: ctx - the context + * n - number of pixels + * dstType - destination data type + * dest - destination array + * srcType - source pixel type + * source - source data pointer + * srcPacking - pixel unpacking parameters + * transferOps - the pixel transfer operations to apply + */ +void +_mesa_unpack_index_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + ASSERT(dstType == GL_UNSIGNED_BYTE || + dstType == GL_UNSIGNED_SHORT || + dstType == GL_UNSIGNED_INT); + + + transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); + + /* + * Try simple cases first + */ + if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE + && dstType == GL_UNSIGNED_BYTE) { + memcpy(dest, source, n * sizeof(GLubyte)); + } + else if (transferOps == 0 && srcType == GL_UNSIGNED_INT + && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { + memcpy(dest, source, n * sizeof(GLuint)); + } + else { + /* + * general solution + */ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, + srcPacking); + + if (transferOps) + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + + /* convert to dest type */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLubyte) (indexes[i] & 0xff); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) (indexes[i] & 0xffff); + } + } + break; + case GL_UNSIGNED_INT: + memcpy(dest, indexes, n * sizeof(GLuint)); + break; + default: + _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span"); + } + + free(indexes); + } +} + + +void +_mesa_pack_index_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLuint *source, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps ) +{ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + + transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); + + if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) { + /* make a copy of input */ + memcpy(indexes, source, n * sizeof(GLuint)); + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + source = indexes; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + *dst++ = (GLubyte) source[i]; + } + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLbyte) source[i]; + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLshort) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLuint) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLint) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLfloat) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = _mesa_float_to_half((GLfloat) source[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); + } + + free(indexes); +} + + +/* + * Unpack a row of stencil data from a client buffer according to + * the pixel unpacking parameters. + * This is (or will be) used by glDrawPixels + * + * Args: ctx - the context + * n - number of pixels + * dstType - destination data type + * dest - destination array + * srcType - source pixel type + * source - source data pointer + * srcPacking - pixel unpacking parameters + * transferOps - apply offset/bias/lookup ops? + */ +void +_mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_UNSIGNED_INT_24_8_EXT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + ASSERT(dstType == GL_UNSIGNED_BYTE || + dstType == GL_UNSIGNED_SHORT || + dstType == GL_UNSIGNED_INT); + + /* only shift and offset apply to stencil */ + transferOps &= IMAGE_SHIFT_OFFSET_BIT; + + /* + * Try simple cases first + */ + if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && + srcType == GL_UNSIGNED_BYTE && + dstType == GL_UNSIGNED_BYTE) { + memcpy(dest, source, n * sizeof(GLubyte)); + } + else if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && + srcType == GL_UNSIGNED_INT && + dstType == GL_UNSIGNED_INT && + !srcPacking->SwapBytes) { + memcpy(dest, source, n * sizeof(GLuint)); + } + else { + /* + * general solution + */ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking"); + return; + } + + extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, + srcPacking); + + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + /* shift and offset indexes */ + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + + if (ctx->Pixel.MapStencilFlag) { + /* Apply stencil lookup table */ + const GLuint mask = ctx->PixelMaps.StoS.Size - 1; + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (GLuint)ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; + } + } + + /* convert to dest type */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLubyte) (indexes[i] & 0xff); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) (indexes[i] & 0xffff); + } + } + break; + case GL_UNSIGNED_INT: + memcpy(dest, indexes, n * sizeof(GLuint)); + break; + default: + _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); + } + + free(indexes); + } +} + + +void +_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLstencil *source, + const struct gl_pixelstore_attrib *dstPacking ) +{ + GLstencil *stencil = (GLstencil *) malloc(n * sizeof(GLstencil)); + + if (!stencil) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing"); + return; + } + + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || + ctx->Pixel.MapStencilFlag) { + /* make a copy of input */ + memcpy(stencil, source, n * sizeof(GLstencil)); + _mesa_apply_stencil_transfer_ops(ctx, n, stencil); + source = stencil; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + if (sizeof(GLstencil) == 1) { + memcpy( dest, source, n ); + } + else { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_BITMAP: + if (dstPacking->LsbFirst) { + GLubyte *dst = (GLubyte *) dest; + GLint shift = 0; + GLuint i; + for (i = 0; i < n; i++) { + if (shift == 0) + *dst = 0; + *dst |= ((source[i] != 0) << shift); + shift++; + if (shift == 8) { + shift = 0; + dst++; + } + } + } + else { + GLubyte *dst = (GLubyte *) dest; + GLint shift = 7; + GLuint i; + for (i = 0; i < n; i++) { + if (shift == 7) + *dst = 0; + *dst |= ((source[i] != 0) << shift); + shift--; + if (shift < 0) { + shift = 7; + dst++; + } + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); + } + + free(stencil); +} + +#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ + do { \ + GLuint i; \ + const GLTYPE *src = (const GLTYPE *)source; \ + for (i = 0; i < n; i++) { \ + GLTYPE value = src[i]; \ + if (srcPacking->SwapBytes) { \ + if (sizeof(GLTYPE) == 2) { \ + SWAP2BYTE(value); \ + } else if (sizeof(GLTYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + } \ + depthValues[i] = GLTYPE2FLOAT(value); \ + } \ + } while (0) + + +/** + * Unpack a row of depth/z values from memory, returning GLushort, GLuint + * or GLfloat values. + * The glPixelTransfer (scale/bias) params will be applied. + * + * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT + * \param depthMax max value for returned GLushort or GLuint values + * (ignored for GLfloat). + */ +void +_mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, GLuint depthMax, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking ) +{ + GLfloat *depthTemp, *depthValues; + GLboolean needClamp = GL_FALSE; + + /* Look for special cases first. + * Not only are these faster, they're less prone to numeric conversion + * problems. Otherwise, converting from an int type to a float then + * back to an int type can introduce errors that will show up as + * artifacts in things like depth peeling which uses glCopyTexImage. + */ + if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { + if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { + const GLuint *src = (const GLuint *) source; + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 16; + } + return; + } + if (srcType == GL_UNSIGNED_SHORT + && dstType == GL_UNSIGNED_INT + && depthMax == 0xffffffff) { + const GLushort *src = (const GLushort *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] | (src[i] << 16); + } + return; + } + if (srcType == GL_UNSIGNED_INT_24_8 + && dstType == GL_UNSIGNED_INT + && depthMax == 0xffffff) { + const GLuint *src = (const GLuint *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 8; + } + return; + } + /* XXX may want to add additional cases here someday */ + } + + /* general case path follows */ + + depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!depthTemp) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + if (dstType == GL_FLOAT) { + depthValues = (GLfloat *) dest; + } + else { + depthValues = depthTemp; + } + + /* Convert incoming values to GLfloat. Some conversions will require + * clamping, below. + */ + switch (srcType) { + case GL_BYTE: + DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_BYTE: + DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); + break; + case GL_SHORT: + DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_SHORT: + DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); + break; + case GL_INT: + DEPTH_VALUES(GLint, INT_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_INT: + DEPTH_VALUES(GLuint, UINT_TO_FLOAT); + break; + case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ + if (dstType == GL_UNSIGNED_INT_24_8_EXT && + depthMax == 0xffffff && + ctx->Pixel.DepthScale == 1.0 && + ctx->Pixel.DepthBias == 0.0) { + const GLuint *src = (const GLuint *) source; + GLuint *zValues = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + zValues[i] = value & 0xffffff00; + } + return; + } + else { + const GLuint *src = (const GLuint *) source; + const GLfloat scale = 1.0f / 0xffffff; + GLuint i; + for (i = 0; i < n; i++) { + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + depthValues[i] = (value >> 8) * scale; + } + } + break; + case GL_FLOAT: + DEPTH_VALUES(GLfloat, 1*); + needClamp = GL_TRUE; + break; + case GL_HALF_FLOAT_ARB: + { + GLuint i; + const GLhalfARB *src = (const GLhalfARB *) source; + for (i = 0; i < n; i++) { + GLhalfARB value = src[i]; + if (srcPacking->SwapBytes) { + SWAP2BYTE(value); + } + depthValues[i] = _mesa_half_to_float(value); + } + needClamp = GL_TRUE; + } + break; + default: + _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()"); + free(depthTemp); + return; + } + + /* apply depth scale and bias */ + { + const GLfloat scale = ctx->Pixel.DepthScale; + const GLfloat bias = ctx->Pixel.DepthBias; + if (scale != 1.0 || bias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = depthValues[i] * scale + bias; + } + needClamp = GL_TRUE; + } + } + + /* clamp to [0, 1] */ + if (needClamp) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = (GLfloat)CLAMP(depthValues[i], 0.0, 1.0); + } + } + + /* + * Convert values to dstType + */ + if (dstType == GL_UNSIGNED_INT) { + GLuint *zValues = (GLuint *) dest; + GLuint i; + if (depthMax <= 0xffffff) { + /* no overflow worries */ + for (i = 0; i < n; i++) { + zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); + } + } + else { + /* need to use double precision to prevent overflow problems */ + for (i = 0; i < n; i++) { + GLdouble z = depthValues[i] * (GLfloat) depthMax; + if (z >= (GLdouble) 0xffffffff) + zValues[i] = 0xffffffff; + else + zValues[i] = (GLuint) z; + } + } + } + else if (dstType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) dest; + GLuint i; + ASSERT(depthMax <= 0xffff); + for (i = 0; i < n; i++) { + zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); + } + } + else { + ASSERT(dstType == GL_FLOAT); + /*ASSERT(depthMax == 1.0F);*/ + } + + free(depthTemp); +} + + +/* + * Pack an array of depth values. The values are floats in [0,1]. + */ +void +_mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest, + GLenum dstType, const GLfloat *depthSpan, + const struct gl_pixelstore_attrib *dstPacking ) +{ + GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!depthCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + + if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { + memcpy(depthCopy, depthSpan, n * sizeof(GLfloat)); + _mesa_scale_and_bias_depth(ctx, n, depthCopy); + depthSpan = depthCopy; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_UBYTE( depthSpan[i] ); + } + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_BYTE( depthSpan[i] ); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_SHORT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_UINT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_INT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = depthSpan[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = _mesa_float_to_half(depthSpan[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_depth_span"); + } + + free(depthCopy); +} + + + +/** + * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8. + */ +void +_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest, + const GLfloat *depthVals, + const GLstencil *stencilVals, + const struct gl_pixelstore_attrib *dstPacking) +{ + GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); + GLstencil *stencilCopy = (GLstencil *) malloc(n * sizeof(GLstencil)); + GLuint i; + + if (!depthCopy || !stencilCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + free(depthCopy); + free(stencilCopy); + return; + } + + if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { + memcpy(depthCopy, depthVals, n * sizeof(GLfloat)); + _mesa_scale_and_bias_depth(ctx, n, depthCopy); + depthVals = depthCopy; + } + + if (ctx->Pixel.IndexShift || + ctx->Pixel.IndexOffset || + ctx->Pixel.MapStencilFlag) { + memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil)); + _mesa_apply_stencil_transfer_ops(ctx, n, stencilCopy); + stencilVals = stencilCopy; + } + + for (i = 0; i < n; i++) { + GLuint z = (GLuint) (depthVals[i] * 0xffffff); + dest[i] = (z << 8) | (stencilVals[i] & 0xff); + } + + if (dstPacking->SwapBytes) { + _mesa_swap4(dest, n); + } + + free(depthCopy); + free(stencilCopy); +} + + + + +/** + * Unpack image data. Apply byte swapping, byte flipping (bitmap). + * Return all image data in a contiguous block. This is used when we + * compile glDrawPixels, glTexImage, etc into a display list. We + * need a copy of the data in a standard format. + */ +void * +_mesa_unpack_image( GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack ) +{ + GLint bytesPerRow, compsPerRow; + GLboolean flipBytes, swap2, swap4; + + if (!pixels) + return NULL; /* not necessarily an error */ + + if (width <= 0 || height <= 0 || depth <= 0) + return NULL; /* generate error later */ + + if (type == GL_BITMAP) { + bytesPerRow = (width + 7) >> 3; + flipBytes = unpack->LsbFirst; + swap2 = swap4 = GL_FALSE; + compsPerRow = 0; + } + else { + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + GLint components = _mesa_components_in_format(format); + GLint bytesPerComp; + + if (_mesa_type_is_packed(type)) + components = 1; + + if (bytesPerPixel <= 0 || components <= 0) + return NULL; /* bad format or type. generate error later */ + bytesPerRow = bytesPerPixel * width; + bytesPerComp = bytesPerPixel / components; + flipBytes = GL_FALSE; + swap2 = (bytesPerComp == 2) && unpack->SwapBytes; + swap4 = (bytesPerComp == 4) && unpack->SwapBytes; + compsPerRow = components * width; + assert(compsPerRow >= width); + } + + { + GLubyte *destBuffer + = (GLubyte *) malloc(bytesPerRow * height * depth); + GLubyte *dst; + GLint img, row; + if (!destBuffer) + return NULL; /* generate GL_OUT_OF_MEMORY later */ + + dst = destBuffer; + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, + width, height, format, type, img, row, 0); + + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + else { + memcpy(dst, src, bytesPerRow); + } + + /* byte flipping/swapping */ + if (flipBytes) { + flip_bytes((GLubyte *) dst, bytesPerRow); + } + else if (swap2) { + _mesa_swap2((GLushort*) dst, compsPerRow); + } + else if (swap4) { + _mesa_swap4((GLuint*) dst, compsPerRow); + } + dst += bytesPerRow; + } + } + return destBuffer; + } +} + diff --git a/mesalib/src/mesa/main/pack.h b/mesalib/src/mesa/main/pack.h new file mode 100644 index 000000000..1f19a5a7c --- /dev/null +++ b/mesalib/src/mesa/main/pack.h @@ -0,0 +1,147 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +#ifndef PACK_H +#define PACK_H + + +#include "mtypes.h" + + +extern void +_mesa_unpack_polygon_stipple(const GLubyte *pattern, GLuint dest[32], + const struct gl_pixelstore_attrib *unpacking); + + +extern void +_mesa_pack_polygon_stipple(const GLuint pattern[32], GLubyte *dest, + const struct gl_pixelstore_attrib *packing); + + +extern GLvoid * +_mesa_unpack_bitmap(GLint width, GLint height, const GLubyte *pixels, + const struct gl_pixelstore_attrib *packing); + +extern void +_mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source, + GLubyte *dest, const struct gl_pixelstore_attrib *packing); + + +extern void +_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, + GLfloat rgba[][4], + GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps); + + +extern void +_mesa_unpack_color_span_chan(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLchan dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + + +extern void +_mesa_unpack_color_span_float(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_unpack_color_span_uint(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLuint *dest, + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking); + +extern void +_mesa_unpack_dudv_span_byte(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLbyte dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_unpack_index_span(struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + + +extern void +_mesa_pack_index_span(struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLuint *source, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps); + + +extern void +_mesa_unpack_stencil_span(struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_pack_stencil_span(struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLstencil *source, + const struct gl_pixelstore_attrib *dstPacking); + + +extern void +_mesa_unpack_depth_span(struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, GLuint depthMax, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking); + +extern void +_mesa_pack_depth_span(struct gl_context *ctx, GLuint n, GLvoid *dest, + GLenum dstType, const GLfloat *depthSpan, + const struct gl_pixelstore_attrib *dstPacking); + + +extern void +_mesa_pack_depth_stencil_span(struct gl_context *ctx, + GLuint n, GLuint *dest, + const GLfloat *depthVals, + const GLstencil *stencilVals, + const struct gl_pixelstore_attrib *dstPacking); + + +extern void * +_mesa_unpack_image(GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack); + + +#endif diff --git a/mesalib/src/mesa/main/pixel.c b/mesalib/src/mesa/main/pixel.c index 675e933ca..db1f05a58 100644 --- a/mesalib/src/mesa/main/pixel.c +++ b/mesalib/src/mesa/main/pixel.c @@ -1,870 +1,700 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file pixel.c - * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer) - */ - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "pixel.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_pixel_transfer - - -/**********************************************************************/ -/***** glPixelZoom *****/ -/**********************************************************************/ - -static void GLAPIENTRY -_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Pixel.ZoomX == xfactor && - ctx->Pixel.ZoomY == yfactor) - return; - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ZoomX = xfactor; - ctx->Pixel.ZoomY = yfactor; -} - - - -/**********************************************************************/ -/***** glPixelMap *****/ -/**********************************************************************/ - -/** - * Return pointer to a pixelmap by name. - */ -static struct gl_pixelmap * -get_pixelmap(GLcontext *ctx, GLenum map) -{ - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - return &ctx->PixelMaps.ItoI; - case GL_PIXEL_MAP_S_TO_S: - return &ctx->PixelMaps.StoS; - case GL_PIXEL_MAP_I_TO_R: - return &ctx->PixelMaps.ItoR; - case GL_PIXEL_MAP_I_TO_G: - return &ctx->PixelMaps.ItoG; - case GL_PIXEL_MAP_I_TO_B: - return &ctx->PixelMaps.ItoB; - case GL_PIXEL_MAP_I_TO_A: - return &ctx->PixelMaps.ItoA; - case GL_PIXEL_MAP_R_TO_R: - return &ctx->PixelMaps.RtoR; - case GL_PIXEL_MAP_G_TO_G: - return &ctx->PixelMaps.GtoG; - case GL_PIXEL_MAP_B_TO_B: - return &ctx->PixelMaps.BtoB; - case GL_PIXEL_MAP_A_TO_A: - return &ctx->PixelMaps.AtoA; - default: - return NULL; - } -} - - -/** - * Helper routine used by the other _mesa_PixelMap() functions. - */ -static void -store_pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, - const GLfloat *values) -{ - GLint i; - struct gl_pixelmap *pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); - return; - } - - switch (map) { - case GL_PIXEL_MAP_S_TO_S: - /* special case */ - ctx->PixelMaps.StoS.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]); - } - break; - case GL_PIXEL_MAP_I_TO_I: - /* special case */ - ctx->PixelMaps.ItoI.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.ItoI.Map[i] = values[i]; - } - break; - default: - /* general case */ - pm->Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP(values[i], 0.0F, 1.0F); - pm->Map[i] = val; - pm->Map8[i] = (GLint) (val * 255.0F); - } - } -} - - -/** - * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap(). - */ -static GLboolean -validate_pbo_access(GLcontext *ctx, struct gl_pixelstore_attrib *pack, - GLsizei mapsize, GLenum format, GLenum type, - const GLvoid *ptr) -{ - GLboolean ok; - - /* Note, need to use DefaultPacking and Unpack's buffer object */ - _mesa_reference_buffer_object(ctx, - &ctx->DefaultPacking.BufferObj, - pack->BufferObj); - - ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - format, type, ptr); - - /* restore */ - _mesa_reference_buffer_object(ctx, - &ctx->DefaultPacking.BufferObj, - ctx->Shared->NullBufferObj); - - if (!ok) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMap(invalid PBO access)"); - } - return ok; -} - - -static void GLAPIENTRY -_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */ - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, - GL_INTENSITY, GL_FLOAT, values)) { - return; - } - - values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapfv(PBO is mapped)"); - } - return; - } - - store_pixelmap(ctx, map, mapsize, values); - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); -} - - -static void GLAPIENTRY -_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, - GL_INTENSITY, GL_UNSIGNED_INT, values)) { - return; - } - - values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapuiv(PBO is mapped)"); - } - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT( values[i] ); - } - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, - GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { - return; - } - - values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapusv(PBO is mapped)"); - } - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT( values[i] ); - } - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); - return; - } - - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, - GL_INTENSITY, GL_FLOAT, values)) { - return; - } - - values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapfv(PBO is mapped)"); - } - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - for (i = 0; i < mapsize; i++) { - values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; - } - } - else { - memcpy(values, pm->Map, mapsize * sizeof(GLfloat)); - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); - return; - } - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, - GL_INTENSITY, GL_UNSIGNED_INT, values)) { - return; - } - - values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapuiv(PBO is mapped)"); - } - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); - } - else { - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( pm->Map[i] ); - } - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapusv( GLenum map, GLushort *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); - return; - } - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, - GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { - return; - } - - values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapusv(PBO is mapped)"); - } - return; - } - - switch (map) { - /* special cases */ - case GL_PIXEL_MAP_I_TO_I: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); - } - break; - case GL_PIXEL_MAP_S_TO_S: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); - } - break; - default: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); - } - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - - -/**********************************************************************/ -/***** glPixelTransfer *****/ -/**********************************************************************/ - - -/* - * Implements glPixelTransfer[fi] whether called immediately or from a - * display list. - */ -static void GLAPIENTRY -_mesa_PixelTransferf( GLenum pname, GLfloat param ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_MAP_COLOR: - if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_MAP_STENCIL: - if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_INDEX_SHIFT: - if (ctx->Pixel.IndexShift == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexShift = (GLint) param; - break; - case GL_INDEX_OFFSET: - if (ctx->Pixel.IndexOffset == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexOffset = (GLint) param; - break; - case GL_RED_SCALE: - if (ctx->Pixel.RedScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedScale = param; - break; - case GL_RED_BIAS: - if (ctx->Pixel.RedBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedBias = param; - break; - case GL_GREEN_SCALE: - if (ctx->Pixel.GreenScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenScale = param; - break; - case GL_GREEN_BIAS: - if (ctx->Pixel.GreenBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenBias = param; - break; - case GL_BLUE_SCALE: - if (ctx->Pixel.BlueScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueScale = param; - break; - case GL_BLUE_BIAS: - if (ctx->Pixel.BlueBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueBias = param; - break; - case GL_ALPHA_SCALE: - if (ctx->Pixel.AlphaScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaScale = param; - break; - case GL_ALPHA_BIAS: - if (ctx->Pixel.AlphaBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaBias = param; - break; - case GL_DEPTH_SCALE: - if (ctx->Pixel.DepthScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthScale = param; - break; - case GL_DEPTH_BIAS: - if (ctx->Pixel.DepthBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthBias = param; - break; - case GL_POST_COLOR_MATRIX_RED_SCALE: - if (ctx->Pixel.PostColorMatrixScale[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixScale[0] = param; - break; - case GL_POST_COLOR_MATRIX_RED_BIAS: - if (ctx->Pixel.PostColorMatrixBias[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixBias[0] = param; - break; - case GL_POST_COLOR_MATRIX_GREEN_SCALE: - if (ctx->Pixel.PostColorMatrixScale[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixScale[1] = param; - break; - case GL_POST_COLOR_MATRIX_GREEN_BIAS: - if (ctx->Pixel.PostColorMatrixBias[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixBias[1] = param; - break; - case GL_POST_COLOR_MATRIX_BLUE_SCALE: - if (ctx->Pixel.PostColorMatrixScale[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixScale[2] = param; - break; - case GL_POST_COLOR_MATRIX_BLUE_BIAS: - if (ctx->Pixel.PostColorMatrixBias[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixBias[2] = param; - break; - case GL_POST_COLOR_MATRIX_ALPHA_SCALE: - if (ctx->Pixel.PostColorMatrixScale[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixScale[3] = param; - break; - case GL_POST_COLOR_MATRIX_ALPHA_BIAS: - if (ctx->Pixel.PostColorMatrixBias[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostColorMatrixBias[3] = param; - break; - case GL_POST_CONVOLUTION_RED_SCALE: - if (ctx->Pixel.PostConvolutionScale[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[0] = param; - break; - case GL_POST_CONVOLUTION_RED_BIAS: - if (ctx->Pixel.PostConvolutionBias[0] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[0] = param; - break; - case GL_POST_CONVOLUTION_GREEN_SCALE: - if (ctx->Pixel.PostConvolutionScale[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[1] = param; - break; - case GL_POST_CONVOLUTION_GREEN_BIAS: - if (ctx->Pixel.PostConvolutionBias[1] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[1] = param; - break; - case GL_POST_CONVOLUTION_BLUE_SCALE: - if (ctx->Pixel.PostConvolutionScale[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[2] = param; - break; - case GL_POST_CONVOLUTION_BLUE_BIAS: - if (ctx->Pixel.PostConvolutionBias[2] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[2] = param; - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE: - if (ctx->Pixel.PostConvolutionScale[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionScale[3] = param; - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS: - if (ctx->Pixel.PostConvolutionBias[3] == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.PostConvolutionBias[3] = param; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); - return; - } -} - - -static void GLAPIENTRY -_mesa_PixelTransferi( GLenum pname, GLint param ) -{ - _mesa_PixelTransferf( pname, (GLfloat) param ); -} - - - -/**********************************************************************/ -/***** State Management *****/ -/**********************************************************************/ - -/* - * Return a bitmask of IMAGE_*_BIT flags which to indicate which - * pixel transfer operations are enabled. - */ -static void -update_image_transfer_state(GLcontext *ctx) -{ - GLuint mask = 0; - - if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || - ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || - ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || - ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) - mask |= IMAGE_SCALE_BIAS_BIT; - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) - mask |= IMAGE_SHIFT_OFFSET_BIT; - - if (ctx->Pixel.MapColorFlag) - mask |= IMAGE_MAP_COLOR_BIT; - - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]) - mask |= IMAGE_COLOR_TABLE_BIT; - - if (ctx->Pixel.Convolution1DEnabled || - ctx->Pixel.Convolution2DEnabled || - ctx->Pixel.Separable2DEnabled) { - mask |= IMAGE_CONVOLUTION_BIT; - if (ctx->Pixel.PostConvolutionScale[0] != 1.0F || - ctx->Pixel.PostConvolutionScale[1] != 1.0F || - ctx->Pixel.PostConvolutionScale[2] != 1.0F || - ctx->Pixel.PostConvolutionScale[3] != 1.0F || - ctx->Pixel.PostConvolutionBias[0] != 0.0F || - ctx->Pixel.PostConvolutionBias[1] != 0.0F || - ctx->Pixel.PostConvolutionBias[2] != 0.0F || - ctx->Pixel.PostConvolutionBias[3] != 0.0F) { - mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS; - } - } - - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]) - mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT; - - if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY || - ctx->Pixel.PostColorMatrixScale[0] != 1.0F || - ctx->Pixel.PostColorMatrixBias[0] != 0.0F || - ctx->Pixel.PostColorMatrixScale[1] != 1.0F || - ctx->Pixel.PostColorMatrixBias[1] != 0.0F || - ctx->Pixel.PostColorMatrixScale[2] != 1.0F || - ctx->Pixel.PostColorMatrixBias[2] != 0.0F || - ctx->Pixel.PostColorMatrixScale[3] != 1.0F || - ctx->Pixel.PostColorMatrixBias[3] != 0.0F) - mask |= IMAGE_COLOR_MATRIX_BIT; - - if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]) - mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT; - - if (ctx->Pixel.HistogramEnabled) - mask |= IMAGE_HISTOGRAM_BIT; - - if (ctx->Pixel.MinMaxEnabled) - mask |= IMAGE_MIN_MAX_BIT; - - ctx->_ImageTransferState = mask; -} - - -/** - * Update mesa pixel transfer derived state. - */ -void _mesa_update_pixel( GLcontext *ctx, GLuint new_state ) -{ - if (new_state & _NEW_COLOR_MATRIX) - _math_matrix_analyse( ctx->ColorMatrixStack.Top ); - - /* References ColorMatrix.type (derived above). - */ - if (new_state & _MESA_NEW_TRANSFER_STATE) - update_image_transfer_state(ctx); -} - - -void -_mesa_init_pixel_dispatch(struct _glapi_table *disp) -{ - SET_GetPixelMapfv(disp, _mesa_GetPixelMapfv); - SET_GetPixelMapuiv(disp, _mesa_GetPixelMapuiv); - SET_GetPixelMapusv(disp, _mesa_GetPixelMapusv); - SET_PixelMapfv(disp, _mesa_PixelMapfv); - SET_PixelMapuiv(disp, _mesa_PixelMapuiv); - SET_PixelMapusv(disp, _mesa_PixelMapusv); - SET_PixelTransferf(disp, _mesa_PixelTransferf); - SET_PixelTransferi(disp, _mesa_PixelTransferi); - SET_PixelZoom(disp, _mesa_PixelZoom); -} - - -#endif /* FEATURE_pixel_transfer */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -static void -init_pixelmap(struct gl_pixelmap *map) -{ - map->Size = 1; - map->Map[0] = 0.0; - map->Map8[0] = 0; -} - - -/** - * Initialize the context's PIXEL attribute group. - */ -void -_mesa_init_pixel( GLcontext *ctx ) -{ - int i; - - /* Pixel group */ - ctx->Pixel.RedBias = 0.0; - ctx->Pixel.RedScale = 1.0; - ctx->Pixel.GreenBias = 0.0; - ctx->Pixel.GreenScale = 1.0; - ctx->Pixel.BlueBias = 0.0; - ctx->Pixel.BlueScale = 1.0; - ctx->Pixel.AlphaBias = 0.0; - ctx->Pixel.AlphaScale = 1.0; - ctx->Pixel.DepthBias = 0.0; - ctx->Pixel.DepthScale = 1.0; - ctx->Pixel.IndexOffset = 0; - ctx->Pixel.IndexShift = 0; - ctx->Pixel.ZoomX = 1.0; - ctx->Pixel.ZoomY = 1.0; - ctx->Pixel.MapColorFlag = GL_FALSE; - ctx->Pixel.MapStencilFlag = GL_FALSE; - init_pixelmap(&ctx->PixelMaps.StoS); - init_pixelmap(&ctx->PixelMaps.ItoI); - init_pixelmap(&ctx->PixelMaps.ItoR); - init_pixelmap(&ctx->PixelMaps.ItoG); - init_pixelmap(&ctx->PixelMaps.ItoB); - init_pixelmap(&ctx->PixelMaps.ItoA); - init_pixelmap(&ctx->PixelMaps.RtoR); - init_pixelmap(&ctx->PixelMaps.GtoG); - init_pixelmap(&ctx->PixelMaps.BtoB); - init_pixelmap(&ctx->PixelMaps.AtoA); - ctx->Pixel.HistogramEnabled = GL_FALSE; - ctx->Pixel.MinMaxEnabled = GL_FALSE; - ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0); - for (i = 0; i < COLORTABLE_MAX; i++) { - ASSIGN_4V(ctx->Pixel.ColorTableScale[i], 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.ColorTableBias[i], 0.0, 0.0, 0.0, 0.0); - ctx->Pixel.ColorTableEnabled[i] = GL_FALSE; - } - ctx->Pixel.Convolution1DEnabled = GL_FALSE; - ctx->Pixel.Convolution2DEnabled = GL_FALSE; - ctx->Pixel.Separable2DEnabled = GL_FALSE; - for (i = 0; i < 3; i++) { - ASSIGN_4V(ctx->Pixel.ConvolutionBorderColor[i], 0.0, 0.0, 0.0, 0.0); - ctx->Pixel.ConvolutionBorderMode[i] = GL_REDUCE; - ASSIGN_4V(ctx->Pixel.ConvolutionFilterScale[i], 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.ConvolutionFilterBias[i], 0.0, 0.0, 0.0, 0.0); - } - for (i = 0; i < MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_WIDTH * 4; i++) { - ctx->Convolution1D.Filter[i] = 0.0; - ctx->Convolution2D.Filter[i] = 0.0; - ctx->Separable2D.Filter[i] = 0.0; - } - ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0); - /* GL_SGI_texture_color_table */ - ASSIGN_4V(ctx->Pixel.TextureColorTableScale, 1.0, 1.0, 1.0, 1.0); - ASSIGN_4V(ctx->Pixel.TextureColorTableBias, 0.0, 0.0, 0.0, 0.0); - - if (ctx->Visual.doubleBufferMode) { - ctx->Pixel.ReadBuffer = GL_BACK; - } - else { - ctx->Pixel.ReadBuffer = GL_FRONT; - } - - /* Miscellaneous */ - ctx->_ImageTransferState = 0; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file pixel.c + * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer) + */ + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "context.h" +#include "macros.h" +#include "pixel.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_pixel_transfer + + +/**********************************************************************/ +/***** glPixelZoom *****/ +/**********************************************************************/ + +static void GLAPIENTRY +_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) +{ + GET_CURRENT_CONTEXT(ctx); + + if (ctx->Pixel.ZoomX == xfactor && + ctx->Pixel.ZoomY == yfactor) + return; + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.ZoomX = xfactor; + ctx->Pixel.ZoomY = yfactor; +} + + + +/**********************************************************************/ +/***** glPixelMap *****/ +/**********************************************************************/ + +/** + * Return pointer to a pixelmap by name. + */ +static struct gl_pixelmap * +get_pixelmap(struct gl_context *ctx, GLenum map) +{ + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + return &ctx->PixelMaps.ItoI; + case GL_PIXEL_MAP_S_TO_S: + return &ctx->PixelMaps.StoS; + case GL_PIXEL_MAP_I_TO_R: + return &ctx->PixelMaps.ItoR; + case GL_PIXEL_MAP_I_TO_G: + return &ctx->PixelMaps.ItoG; + case GL_PIXEL_MAP_I_TO_B: + return &ctx->PixelMaps.ItoB; + case GL_PIXEL_MAP_I_TO_A: + return &ctx->PixelMaps.ItoA; + case GL_PIXEL_MAP_R_TO_R: + return &ctx->PixelMaps.RtoR; + case GL_PIXEL_MAP_G_TO_G: + return &ctx->PixelMaps.GtoG; + case GL_PIXEL_MAP_B_TO_B: + return &ctx->PixelMaps.BtoB; + case GL_PIXEL_MAP_A_TO_A: + return &ctx->PixelMaps.AtoA; + default: + return NULL; + } +} + + +/** + * Helper routine used by the other _mesa_PixelMap() functions. + */ +static void +store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize, + const GLfloat *values) +{ + GLint i; + struct gl_pixelmap *pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); + return; + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + /* special case */ + ctx->PixelMaps.StoS.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]); + } + break; + case GL_PIXEL_MAP_I_TO_I: + /* special case */ + ctx->PixelMaps.ItoI.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.ItoI.Map[i] = values[i]; + } + break; + default: + /* general case */ + pm->Size = mapsize; + for (i = 0; i < mapsize; i++) { + GLfloat val = CLAMP(values[i], 0.0F, 1.0F); + pm->Map[i] = val; + pm->Map8[i] = (GLint) (val * 255.0F); + } + } +} + + +/** + * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap(). + */ +static GLboolean +validate_pbo_access(struct gl_context *ctx, struct gl_pixelstore_attrib *pack, + GLsizei mapsize, GLenum format, GLenum type, + const GLvoid *ptr) +{ + GLboolean ok; + + /* Note, need to use DefaultPacking and Unpack's buffer object */ + _mesa_reference_buffer_object(ctx, + &ctx->DefaultPacking.BufferObj, + pack->BufferObj); + + ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, + format, type, ptr); + + /* restore */ + _mesa_reference_buffer_object(ctx, + &ctx->DefaultPacking.BufferObj, + ctx->Shared->NullBufferObj); + + if (!ok) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMap(invalid PBO access)"); + } + return ok; +} + + +static void GLAPIENTRY +_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */ + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_FLOAT, values)) { + return; + } + + values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapfv(PBO is mapped)"); + } + return; + } + + store_pixelmap(ctx, map, mapsize, values); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); +} + + +static void GLAPIENTRY +_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_UNSIGNED_INT, values)) { + return; + } + + values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapuiv(PBO is mapped)"); + } + return; + } + + /* convert to floats */ + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = UINT_TO_FLOAT( values[i] ); + } + } + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); + + store_pixelmap(ctx, map, mapsize, fvalues); +} + + +static void GLAPIENTRY +_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, + GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { + return; + } + + values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapusv(PBO is mapped)"); + } + return; + } + + /* convert to floats */ + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = USHORT_TO_FLOAT( values[i] ); + } + } + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); + + store_pixelmap(ctx, map, mapsize, fvalues); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); + return; + } + + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_FLOAT, values)) { + return; + } + + values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapfv(PBO is mapped)"); + } + return; + } + + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + for (i = 0; i < mapsize; i++) { + values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; + } + } + else { + memcpy(values, pm->Map, mapsize * sizeof(GLfloat)); + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); + return; + } + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_UNSIGNED_INT, values)) { + return; + } + + values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapuiv(PBO is mapped)"); + } + return; + } + + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); + } + else { + for (i = 0; i < mapsize; i++) { + values[i] = FLOAT_TO_UINT( pm->Map[i] ); + } + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapusv( GLenum map, GLushort *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); + return; + } + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, + GL_INTENSITY, GL_UNSIGNED_SHORT, values)) { + return; + } + + values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapusv(PBO is mapped)"); + } + return; + } + + switch (map) { + /* special cases */ + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); + } + break; + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); + } + break; + default: + for (i = 0; i < mapsize; i++) { + CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); + } + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + + +/**********************************************************************/ +/***** glPixelTransfer *****/ +/**********************************************************************/ + + +/* + * Implements glPixelTransfer[fi] whether called immediately or from a + * display list. + */ +static void GLAPIENTRY +_mesa_PixelTransferf( GLenum pname, GLfloat param ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_MAP_COLOR: + if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_MAP_STENCIL: + if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_INDEX_SHIFT: + if (ctx->Pixel.IndexShift == (GLint) param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.IndexShift = (GLint) param; + break; + case GL_INDEX_OFFSET: + if (ctx->Pixel.IndexOffset == (GLint) param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.IndexOffset = (GLint) param; + break; + case GL_RED_SCALE: + if (ctx->Pixel.RedScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.RedScale = param; + break; + case GL_RED_BIAS: + if (ctx->Pixel.RedBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.RedBias = param; + break; + case GL_GREEN_SCALE: + if (ctx->Pixel.GreenScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.GreenScale = param; + break; + case GL_GREEN_BIAS: + if (ctx->Pixel.GreenBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.GreenBias = param; + break; + case GL_BLUE_SCALE: + if (ctx->Pixel.BlueScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.BlueScale = param; + break; + case GL_BLUE_BIAS: + if (ctx->Pixel.BlueBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.BlueBias = param; + break; + case GL_ALPHA_SCALE: + if (ctx->Pixel.AlphaScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.AlphaScale = param; + break; + case GL_ALPHA_BIAS: + if (ctx->Pixel.AlphaBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.AlphaBias = param; + break; + case GL_DEPTH_SCALE: + if (ctx->Pixel.DepthScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.DepthScale = param; + break; + case GL_DEPTH_BIAS: + if (ctx->Pixel.DepthBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.DepthBias = param; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); + return; + } +} + + +static void GLAPIENTRY +_mesa_PixelTransferi( GLenum pname, GLint param ) +{ + _mesa_PixelTransferf( pname, (GLfloat) param ); +} + + + +/**********************************************************************/ +/***** State Management *****/ +/**********************************************************************/ + +/* + * Return a bitmask of IMAGE_*_BIT flags which to indicate which + * pixel transfer operations are enabled. + */ +static void +update_image_transfer_state(struct gl_context *ctx) +{ + GLuint mask = 0; + + if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || + ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || + ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || + ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) + mask |= IMAGE_SCALE_BIAS_BIT; + + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) + mask |= IMAGE_SHIFT_OFFSET_BIT; + + if (ctx->Pixel.MapColorFlag) + mask |= IMAGE_MAP_COLOR_BIT; + + ctx->_ImageTransferState = mask; +} + + +/** + * Update mesa pixel transfer derived state. + */ +void _mesa_update_pixel( struct gl_context *ctx, GLuint new_state ) +{ + if (new_state & _MESA_NEW_TRANSFER_STATE) + update_image_transfer_state(ctx); +} + + +void +_mesa_init_pixel_dispatch(struct _glapi_table *disp) +{ + SET_GetPixelMapfv(disp, _mesa_GetPixelMapfv); + SET_GetPixelMapuiv(disp, _mesa_GetPixelMapuiv); + SET_GetPixelMapusv(disp, _mesa_GetPixelMapusv); + SET_PixelMapfv(disp, _mesa_PixelMapfv); + SET_PixelMapuiv(disp, _mesa_PixelMapuiv); + SET_PixelMapusv(disp, _mesa_PixelMapusv); + SET_PixelTransferf(disp, _mesa_PixelTransferf); + SET_PixelTransferi(disp, _mesa_PixelTransferi); + SET_PixelZoom(disp, _mesa_PixelZoom); +} + + +#endif /* FEATURE_pixel_transfer */ + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +static void +init_pixelmap(struct gl_pixelmap *map) +{ + map->Size = 1; + map->Map[0] = 0.0; + map->Map8[0] = 0; +} + + +/** + * Initialize the context's PIXEL attribute group. + */ +void +_mesa_init_pixel( struct gl_context *ctx ) +{ + /* Pixel group */ + ctx->Pixel.RedBias = 0.0; + ctx->Pixel.RedScale = 1.0; + ctx->Pixel.GreenBias = 0.0; + ctx->Pixel.GreenScale = 1.0; + ctx->Pixel.BlueBias = 0.0; + ctx->Pixel.BlueScale = 1.0; + ctx->Pixel.AlphaBias = 0.0; + ctx->Pixel.AlphaScale = 1.0; + ctx->Pixel.DepthBias = 0.0; + ctx->Pixel.DepthScale = 1.0; + ctx->Pixel.IndexOffset = 0; + ctx->Pixel.IndexShift = 0; + ctx->Pixel.ZoomX = 1.0; + ctx->Pixel.ZoomY = 1.0; + ctx->Pixel.MapColorFlag = GL_FALSE; + ctx->Pixel.MapStencilFlag = GL_FALSE; + init_pixelmap(&ctx->PixelMaps.StoS); + init_pixelmap(&ctx->PixelMaps.ItoI); + init_pixelmap(&ctx->PixelMaps.ItoR); + init_pixelmap(&ctx->PixelMaps.ItoG); + init_pixelmap(&ctx->PixelMaps.ItoB); + init_pixelmap(&ctx->PixelMaps.ItoA); + init_pixelmap(&ctx->PixelMaps.RtoR); + init_pixelmap(&ctx->PixelMaps.GtoG); + init_pixelmap(&ctx->PixelMaps.BtoB); + init_pixelmap(&ctx->PixelMaps.AtoA); + /* GL_SGI_texture_color_table */ + ASSIGN_4V(ctx->Pixel.TextureColorTableScale, 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.TextureColorTableBias, 0.0, 0.0, 0.0, 0.0); + + if (ctx->Visual.doubleBufferMode) { + ctx->Pixel.ReadBuffer = GL_BACK; + } + else { + ctx->Pixel.ReadBuffer = GL_FRONT; + } + + /* Miscellaneous */ + ctx->_ImageTransferState = 0; +} diff --git a/mesalib/src/mesa/main/pixel.h b/mesalib/src/mesa/main/pixel.h index f4d3f1efd..c54b1fc5e 100644 --- a/mesalib/src/mesa/main/pixel.h +++ b/mesalib/src/mesa/main/pixel.h @@ -1,67 +1,72 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file pixel.h - * Pixel operations. - */ - - -#ifndef PIXEL_H -#define PIXEL_H - - -#include "main/mtypes.h" - - -#if FEATURE_pixel_transfer - -extern void -_mesa_update_pixel( GLcontext *ctx, GLuint newstate ); - -extern void -_mesa_init_pixel_dispatch( struct _glapi_table * disp ); - -#else /* FEATURE_pixel_transfer */ - -static INLINE void -_mesa_update_pixel(GLcontext *ctx, GLuint newstate) -{ -} - -static INLINE void -_mesa_init_pixel_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_pixel_transfer */ - - -extern void -_mesa_init_pixel( GLcontext * ctx ); - -/*@}*/ - -#endif /* PIXEL_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file pixel.h + * Pixel operations. + */ + + +#ifndef PIXEL_H +#define PIXEL_H + + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct gl_context; + + +#if FEATURE_pixel_transfer + +extern void +_mesa_update_pixel( struct gl_context *ctx, GLuint newstate ); + +extern void +_mesa_init_pixel_dispatch( struct _glapi_table * disp ); + +#else /* FEATURE_pixel_transfer */ + +static INLINE void +_mesa_update_pixel(struct gl_context *ctx, GLuint newstate) +{ +} + +static INLINE void +_mesa_init_pixel_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_pixel_transfer */ + + +extern void +_mesa_init_pixel( struct gl_context * ctx ); + +/*@}*/ + +#endif /* PIXEL_H */ diff --git a/mesalib/src/mesa/main/pixelstore.c b/mesalib/src/mesa/main/pixelstore.c index ec585ef0c..5d90391ca 100644 --- a/mesalib/src/mesa/main/pixelstore.c +++ b/mesalib/src/mesa/main/pixelstore.c @@ -1,283 +1,283 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pixelstore.c - * glPixelStore functions. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "context.h" -#include "pixelstore.h" -#include "mtypes.h" - - -void GLAPIENTRY -_mesa_PixelStorei( GLenum pname, GLint param ) -{ - /* NOTE: this call can't be compiled into the display list */ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_PACK_SWAP_BYTES: - if (param == (GLint)ctx->Pack.SwapBytes) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; - break; - case GL_PACK_LSB_FIRST: - if (param == (GLint)ctx->Pack.LsbFirst) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; - break; - case GL_PACK_ROW_LENGTH: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.RowLength == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.RowLength = param; - break; - case GL_PACK_IMAGE_HEIGHT: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.ImageHeight == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.ImageHeight = param; - break; - case GL_PACK_SKIP_PIXELS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipPixels == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipPixels = param; - break; - case GL_PACK_SKIP_ROWS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipRows == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipRows = param; - break; - case GL_PACK_SKIP_IMAGES: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.SkipImages == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.SkipImages = param; - break; - case GL_PACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Pack.Alignment == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.Alignment = param; - break; - case GL_PACK_INVERT_MESA: - if (!ctx->Extensions.MESA_pack_invert) { - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" ); - return; - } - if (ctx->Pack.Invert == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Pack.Invert = param; - break; - - case GL_UNPACK_SWAP_BYTES: - if (param == (GLint)ctx->Unpack.SwapBytes) - return; - if ((GLint)ctx->Unpack.SwapBytes == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; - break; - case GL_UNPACK_LSB_FIRST: - if (param == (GLint)ctx->Unpack.LsbFirst) - return; - if ((GLint)ctx->Unpack.LsbFirst == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; - break; - case GL_UNPACK_ROW_LENGTH: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.RowLength == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.RowLength = param; - break; - case GL_UNPACK_IMAGE_HEIGHT: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.ImageHeight == param) - return; - - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.ImageHeight = param; - break; - case GL_UNPACK_SKIP_PIXELS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipPixels == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipPixels = param; - break; - case GL_UNPACK_SKIP_ROWS: - if (param<0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipRows == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipRows = param; - break; - case GL_UNPACK_SKIP_IMAGES: - if (param < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); - return; - } - if (ctx->Unpack.SkipImages == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.SkipImages = param; - break; - case GL_UNPACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" ); - return; - } - if (ctx->Unpack.Alignment == param) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.Alignment = param; - break; - case GL_UNPACK_CLIENT_STORAGE_APPLE: - if (param == (GLint)ctx->Unpack.ClientStorage) - return; - FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); - ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); - return; - } -} - - -void GLAPIENTRY -_mesa_PixelStoref( GLenum pname, GLfloat param ) -{ - _mesa_PixelStorei( pname, (GLint) param ); -} - - - -/** - * Initialize the context's pixel store state. - */ -void -_mesa_init_pixelstore( GLcontext *ctx ) -{ - /* Pixel transfer */ - ctx->Pack.Alignment = 4; - ctx->Pack.RowLength = 0; - ctx->Pack.ImageHeight = 0; - ctx->Pack.SkipPixels = 0; - ctx->Pack.SkipRows = 0; - ctx->Pack.SkipImages = 0; - ctx->Pack.SwapBytes = GL_FALSE; - ctx->Pack.LsbFirst = GL_FALSE; - ctx->Pack.ClientStorage = GL_FALSE; - ctx->Pack.Invert = GL_FALSE; -#if FEATURE_EXT_pixel_buffer_object - _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, - ctx->Shared->NullBufferObj); -#endif - ctx->Unpack.Alignment = 4; - ctx->Unpack.RowLength = 0; - ctx->Unpack.ImageHeight = 0; - ctx->Unpack.SkipPixels = 0; - ctx->Unpack.SkipRows = 0; - ctx->Unpack.SkipImages = 0; - ctx->Unpack.SwapBytes = GL_FALSE; - ctx->Unpack.LsbFirst = GL_FALSE; - ctx->Unpack.ClientStorage = GL_FALSE; - ctx->Unpack.Invert = GL_FALSE; -#if FEATURE_EXT_pixel_buffer_object - _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, - ctx->Shared->NullBufferObj); -#endif - - /* - * _mesa_unpack_image() returns image data in this format. When we - * execute image commands (glDrawPixels(), glTexImage(), etc) from - * within display lists we have to be sure to set the current - * unpacking parameters to these values! - */ - ctx->DefaultPacking.Alignment = 1; - ctx->DefaultPacking.RowLength = 0; - ctx->DefaultPacking.SkipPixels = 0; - ctx->DefaultPacking.SkipRows = 0; - ctx->DefaultPacking.ImageHeight = 0; - ctx->DefaultPacking.SkipImages = 0; - ctx->DefaultPacking.SwapBytes = GL_FALSE; - ctx->DefaultPacking.LsbFirst = GL_FALSE; - ctx->DefaultPacking.ClientStorage = GL_FALSE; - ctx->DefaultPacking.Invert = GL_FALSE; -#if FEATURE_EXT_pixel_buffer_object - _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, - ctx->Shared->NullBufferObj); -#endif -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file pixelstore.c + * glPixelStore functions. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "context.h" +#include "pixelstore.h" +#include "mtypes.h" + + +void GLAPIENTRY +_mesa_PixelStorei( GLenum pname, GLint param ) +{ + /* NOTE: this call can't be compiled into the display list */ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_PACK_SWAP_BYTES: + if (param == (GLint)ctx->Pack.SwapBytes) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_LSB_FIRST: + if (param == (GLint)ctx->Pack.LsbFirst) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_ROW_LENGTH: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.RowLength == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.RowLength = param; + break; + case GL_PACK_IMAGE_HEIGHT: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.ImageHeight == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.ImageHeight = param; + break; + case GL_PACK_SKIP_PIXELS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipPixels == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipPixels = param; + break; + case GL_PACK_SKIP_ROWS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipRows == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipRows = param; + break; + case GL_PACK_SKIP_IMAGES: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipImages == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipImages = param; + break; + case GL_PACK_ALIGNMENT: + if (param!=1 && param!=2 && param!=4 && param!=8) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.Alignment == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.Alignment = param; + break; + case GL_PACK_INVERT_MESA: + if (!ctx->Extensions.MESA_pack_invert) { + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" ); + return; + } + if (ctx->Pack.Invert == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.Invert = param; + break; + + case GL_UNPACK_SWAP_BYTES: + if (param == (GLint)ctx->Unpack.SwapBytes) + return; + if ((GLint)ctx->Unpack.SwapBytes == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_LSB_FIRST: + if (param == (GLint)ctx->Unpack.LsbFirst) + return; + if ((GLint)ctx->Unpack.LsbFirst == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_ROW_LENGTH: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.RowLength == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.RowLength = param; + break; + case GL_UNPACK_IMAGE_HEIGHT: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.ImageHeight == param) + return; + + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.ImageHeight = param; + break; + case GL_UNPACK_SKIP_PIXELS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipPixels == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipPixels = param; + break; + case GL_UNPACK_SKIP_ROWS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipRows == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipRows = param; + break; + case GL_UNPACK_SKIP_IMAGES: + if (param < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipImages == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipImages = param; + break; + case GL_UNPACK_ALIGNMENT: + if (param!=1 && param!=2 && param!=4 && param!=8) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" ); + return; + } + if (ctx->Unpack.Alignment == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.Alignment = param; + break; + case GL_UNPACK_CLIENT_STORAGE_APPLE: + if (param == (GLint)ctx->Unpack.ClientStorage) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); + return; + } +} + + +void GLAPIENTRY +_mesa_PixelStoref( GLenum pname, GLfloat param ) +{ + _mesa_PixelStorei( pname, (GLint) param ); +} + + + +/** + * Initialize the context's pixel store state. + */ +void +_mesa_init_pixelstore( struct gl_context *ctx ) +{ + /* Pixel transfer */ + ctx->Pack.Alignment = 4; + ctx->Pack.RowLength = 0; + ctx->Pack.ImageHeight = 0; + ctx->Pack.SkipPixels = 0; + ctx->Pack.SkipRows = 0; + ctx->Pack.SkipImages = 0; + ctx->Pack.SwapBytes = GL_FALSE; + ctx->Pack.LsbFirst = GL_FALSE; + ctx->Pack.ClientStorage = GL_FALSE; + ctx->Pack.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, + ctx->Shared->NullBufferObj); +#endif + ctx->Unpack.Alignment = 4; + ctx->Unpack.RowLength = 0; + ctx->Unpack.ImageHeight = 0; + ctx->Unpack.SkipPixels = 0; + ctx->Unpack.SkipRows = 0; + ctx->Unpack.SkipImages = 0; + ctx->Unpack.SwapBytes = GL_FALSE; + ctx->Unpack.LsbFirst = GL_FALSE; + ctx->Unpack.ClientStorage = GL_FALSE; + ctx->Unpack.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, + ctx->Shared->NullBufferObj); +#endif + + /* + * _mesa_unpack_image() returns image data in this format. When we + * execute image commands (glDrawPixels(), glTexImage(), etc) from + * within display lists we have to be sure to set the current + * unpacking parameters to these values! + */ + ctx->DefaultPacking.Alignment = 1; + ctx->DefaultPacking.RowLength = 0; + ctx->DefaultPacking.SkipPixels = 0; + ctx->DefaultPacking.SkipRows = 0; + ctx->DefaultPacking.ImageHeight = 0; + ctx->DefaultPacking.SkipImages = 0; + ctx->DefaultPacking.SwapBytes = GL_FALSE; + ctx->DefaultPacking.LsbFirst = GL_FALSE; + ctx->DefaultPacking.ClientStorage = GL_FALSE; + ctx->DefaultPacking.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, + ctx->Shared->NullBufferObj); +#endif +} diff --git a/mesalib/src/mesa/main/pixelstore.h b/mesalib/src/mesa/main/pixelstore.h index 47bff4276..2995beb10 100644 --- a/mesalib/src/mesa/main/pixelstore.h +++ b/mesalib/src/mesa/main/pixelstore.h @@ -1,51 +1,52 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file pixelstore.h - * glPixelStore functions. - */ - - -#ifndef PIXELSTORE_H -#define PIXELSTORE_H - - -#include "glheader.h" -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_PixelStorei( GLenum pname, GLint param ); - - -extern void GLAPIENTRY -_mesa_PixelStoref( GLenum pname, GLfloat param ); - - -extern void -_mesa_init_pixelstore( GLcontext *ctx ); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file pixelstore.h + * glPixelStore functions. + */ + + +#ifndef PIXELSTORE_H +#define PIXELSTORE_H + + +#include "glheader.h" + +struct gl_context; + + +extern void GLAPIENTRY +_mesa_PixelStorei( GLenum pname, GLint param ); + + +extern void GLAPIENTRY +_mesa_PixelStoref( GLenum pname, GLfloat param ); + + +extern void +_mesa_init_pixelstore( struct gl_context *ctx ); + + +#endif diff --git a/mesalib/src/mesa/main/pixeltransfer.c b/mesalib/src/mesa/main/pixeltransfer.c new file mode 100644 index 000000000..67173ce3e --- /dev/null +++ b/mesalib/src/mesa/main/pixeltransfer.c @@ -0,0 +1,566 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file pixeltransfer.c + * Pixel transfer operations (scale, bias, table lookups, etc) + */ + + +#include "glheader.h" +#include "colormac.h" +#include "pixeltransfer.h" +#include "imports.h" + + +/* + * Apply scale and bias factors to an array of RGBA pixels. + */ +void +_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], + GLfloat rScale, GLfloat gScale, + GLfloat bScale, GLfloat aScale, + GLfloat rBias, GLfloat gBias, + GLfloat bBias, GLfloat aBias) +{ + if (rScale != 1.0 || rBias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = rgba[i][RCOMP] * rScale + rBias; + } + } + if (gScale != 1.0 || gBias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][GCOMP] = rgba[i][GCOMP] * gScale + gBias; + } + } + if (bScale != 1.0 || bBias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][BCOMP] = rgba[i][BCOMP] * bScale + bBias; + } + } + if (aScale != 1.0 || aBias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias; + } + } +} + + +/* + * Apply pixel mapping to an array of floating point RGBA pixels. + */ +void +_mesa_map_rgba( const struct gl_context *ctx, GLuint n, GLfloat rgba[][4] ) +{ + const GLfloat rscale = (GLfloat) (ctx->PixelMaps.RtoR.Size - 1); + const GLfloat gscale = (GLfloat) (ctx->PixelMaps.GtoG.Size - 1); + const GLfloat bscale = (GLfloat) (ctx->PixelMaps.BtoB.Size - 1); + const GLfloat ascale = (GLfloat) (ctx->PixelMaps.AtoA.Size - 1); + const GLfloat *rMap = ctx->PixelMaps.RtoR.Map; + const GLfloat *gMap = ctx->PixelMaps.GtoG.Map; + const GLfloat *bMap = ctx->PixelMaps.BtoB.Map; + const GLfloat *aMap = ctx->PixelMaps.AtoA.Map; + GLuint i; + for (i=0;iSize - 1; + const GLfloat scale = (GLfloat) max; + const GLfloat *lut = table->TableF; + GLuint i; + + if (!table->TableF || table->Size == 0) + return; + + switch (table->_BaseFormat) { + case GL_INTENSITY: + /* replace RGBA with I */ + for (i = 0; i < n; i++) { + GLint j = IROUND(rgba[i][RCOMP] * scale); + GLfloat c = lut[CLAMP(j, 0, max)]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = + rgba[i][ACOMP] = c; + } + break; + case GL_LUMINANCE: + /* replace RGB with L */ + for (i = 0; i < n; i++) { + GLint j = IROUND(rgba[i][RCOMP] * scale); + GLfloat c = lut[CLAMP(j, 0, max)]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = c; + } + break; + case GL_ALPHA: + /* replace A with A */ + for (i = 0; i < n; i++) { + GLint j = IROUND(rgba[i][ACOMP] * scale); + rgba[i][ACOMP] = lut[CLAMP(j, 0, max)]; + } + break; + case GL_LUMINANCE_ALPHA: + /* replace RGBA with LLLA */ + for (i = 0; i < n; i++) { + GLint jL = IROUND(rgba[i][RCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); + GLfloat luminance, alpha; + jL = CLAMP(jL, 0, max); + jA = CLAMP(jA, 0, max); + luminance = lut[jL * 2 + 0]; + alpha = lut[jA * 2 + 1]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + break; + case GL_RED: + /* replace RGB with RGB */ + for (i = 0; i < n; i++) { + GLint jR = IROUND(rgba[i][RCOMP] * scale); + jR = CLAMP(jR, 0, max); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + } + break; + case GL_RG: + /* replace RG with RG */ + for (i = 0; i < n; i++) { + GLint jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + jR = CLAMP(jR, 0, max); + jG = CLAMP(jG, 0, max); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + } + break; + case GL_RGB: + /* replace RGB with RGB */ + for (i = 0; i < n; i++) { + GLint jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(rgba[i][BCOMP] * scale); + jR = CLAMP(jR, 0, max); + jG = CLAMP(jG, 0, max); + jB = CLAMP(jB, 0, max); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + rgba[i][BCOMP] = lut[jB * 3 + 2]; + } + break; + case GL_RGBA: + /* replace RGBA with RGBA */ + for (i = 0; i < n; i++) { + GLint jR = IROUND(rgba[i][RCOMP] * scale); + GLint jG = IROUND(rgba[i][GCOMP] * scale); + GLint jB = IROUND(rgba[i][BCOMP] * scale); + GLint jA = IROUND(rgba[i][ACOMP] * scale); + jR = CLAMP(jR, 0, max); + jG = CLAMP(jG, 0, max); + jB = CLAMP(jB, 0, max); + jA = CLAMP(jA, 0, max); + rgba[i][RCOMP] = lut[jR * 4 + 0]; + rgba[i][GCOMP] = lut[jG * 4 + 1]; + rgba[i][BCOMP] = lut[jB * 4 + 2]; + rgba[i][ACOMP] = lut[jA * 4 + 3]; + } + break; + default: + _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_float"); + return; + } +} + + + +/** + * Apply a color table lookup to an array of ubyte/RGBA colors. + */ +void +_mesa_lookup_rgba_ubyte(const struct gl_color_table *table, + GLuint n, GLubyte rgba[][4]) +{ + const GLubyte *lut = table->TableUB; + const GLfloat scale = (GLfloat) (table->Size - 1) / (GLfloat)255.0; + GLuint i; + + if (!table->TableUB || table->Size == 0) + return; + + switch (table->_BaseFormat) { + case GL_INTENSITY: + /* replace RGBA with I */ + if (table->Size == 256) { + for (i = 0; i < n; i++) { + const GLubyte c = lut[rgba[i][RCOMP]]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = + rgba[i][ACOMP] = c; + } + } + else { + for (i = 0; i < n; i++) { + GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale); + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = + rgba[i][ACOMP] = lut[j]; + } + } + break; + case GL_LUMINANCE: + /* replace RGB with L */ + if (table->Size == 256) { + for (i = 0; i < n; i++) { + const GLubyte c = lut[rgba[i][RCOMP]]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = c; + } + } + else { + for (i = 0; i < n; i++) { + GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale); + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = lut[j]; + } + } + break; + case GL_ALPHA: + /* replace A with A */ + if (table->Size == 256) { + for (i = 0; i < n; i++) { + rgba[i][ACOMP] = lut[rgba[i][ACOMP]]; + } + } + else { + for (i = 0; i < n; i++) { + GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale); + rgba[i][ACOMP] = lut[j]; + } + } + break; + case GL_LUMINANCE_ALPHA: + /* replace RGBA with LLLA */ + if (table->Size == 256) { + for (i = 0; i < n; i++) { + GLubyte l = lut[rgba[i][RCOMP] * 2 + 0]; + GLubyte a = lut[rgba[i][ACOMP] * 2 + 1];; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = l; + rgba[i][ACOMP] = a; + } + } + else { + for (i = 0; i < n; i++) { + GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale); + GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale); + GLubyte luminance = lut[jL * 2 + 0]; + GLubyte alpha = lut[jA * 2 + 1]; + rgba[i][RCOMP] = + rgba[i][GCOMP] = + rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha; + } + } + break; + case GL_RGB: + if (table->Size == 256) { + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0]; + rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1]; + rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2]; + } + } + else { + for (i = 0; i < n; i++) { + GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale); + GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale); + GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + rgba[i][BCOMP] = lut[jB * 3 + 2]; + } + } + break; + case GL_RGBA: + if (table->Size == 256) { + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0]; + rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1]; + rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2]; + rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3]; + } + } + else { + for (i = 0; i < n; i++) { + GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale); + GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale); + GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale); + GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale); + CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]); + CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]); + } + } + break; + default: + _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_chan"); + return; + } +} + + + +/* + * Map color indexes to float rgba values. + */ +void +_mesa_map_ci_to_rgba( const struct gl_context *ctx, GLuint n, + const GLuint index[], GLfloat rgba[][4] ) +{ + GLuint rmask = ctx->PixelMaps.ItoR.Size - 1; + GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; + GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; + GLuint amask = ctx->PixelMaps.ItoA.Size - 1; + const GLfloat *rMap = ctx->PixelMaps.ItoR.Map; + const GLfloat *gMap = ctx->PixelMaps.ItoG.Map; + const GLfloat *bMap = ctx->PixelMaps.ItoB.Map; + const GLfloat *aMap = ctx->PixelMaps.ItoA.Map; + GLuint i; + for (i=0;iPixelMaps.ItoR.Size - 1; + GLuint gmask = ctx->PixelMaps.ItoG.Size - 1; + GLuint bmask = ctx->PixelMaps.ItoB.Size - 1; + GLuint amask = ctx->PixelMaps.ItoA.Size - 1; + const GLubyte *rMap = ctx->PixelMaps.ItoR.Map8; + const GLubyte *gMap = ctx->PixelMaps.ItoG.Map8; + const GLubyte *bMap = ctx->PixelMaps.ItoB.Map8; + const GLubyte *aMap = ctx->PixelMaps.ItoA.Map8; + GLuint i; + for (i=0;iPixel.DepthScale; + const GLfloat bias = ctx->Pixel.DepthBias; + GLuint i; + for (i = 0; i < n; i++) { + GLfloat d = depthValues[i] * scale + bias; + depthValues[i] = CLAMP(d, 0.0F, 1.0F); + } +} + + +void +_mesa_scale_and_bias_depth_uint(const struct gl_context *ctx, GLuint n, + GLuint depthValues[]) +{ + const GLdouble max = (double) 0xffffffff; + const GLdouble scale = ctx->Pixel.DepthScale; + const GLdouble bias = ctx->Pixel.DepthBias * max; + GLuint i; + for (i = 0; i < n; i++) { + GLdouble d = (GLdouble) depthValues[i] * scale + bias; + d = CLAMP(d, 0.0, max); + depthValues[i] = (GLuint) d; + } +} + +/** + * Apply various pixel transfer operations to an array of RGBA pixels + * as indicated by the transferOps bitmask + */ +void +_mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, + GLuint n, GLfloat rgba[][4]) +{ + /* scale & bias */ + if (transferOps & IMAGE_SCALE_BIAS_BIT) { + _mesa_scale_and_bias_rgba(n, rgba, + ctx->Pixel.RedScale, ctx->Pixel.GreenScale, + ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale, + ctx->Pixel.RedBias, ctx->Pixel.GreenBias, + ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias); + } + /* color map lookup */ + if (transferOps & IMAGE_MAP_COLOR_BIT) { + _mesa_map_rgba( ctx, n, rgba ); + } + + /* clamping to [0,1] */ + if (transferOps & IMAGE_CLAMP_BIT) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); + } + } +} + + +/* + * Apply color index shift and offset to an array of pixels. + */ +void +_mesa_shift_and_offset_ci(const struct gl_context *ctx, + GLuint n, GLuint indexes[]) +{ + GLint shift = ctx->Pixel.IndexShift; + GLint offset = ctx->Pixel.IndexOffset; + GLuint i; + if (shift > 0) { + for (i=0;i> shift) + offset; + } + } + else { + for (i=0;iPixelMaps.ItoI.Size - 1; + GLuint i; + for (i = 0; i < n; i++) { + const GLuint j = indexes[i] & mask; + indexes[i] = IROUND(ctx->PixelMaps.ItoI.Map[j]); + } + } +} + + +/** + * Apply stencil index shift, offset and table lookup to an array + * of stencil values. + */ +void +_mesa_apply_stencil_transfer_ops(const struct gl_context *ctx, GLuint n, + GLstencil stencil[]) +{ + if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) { + const GLint offset = ctx->Pixel.IndexOffset; + GLint shift = ctx->Pixel.IndexShift; + GLuint i; + if (shift > 0) { + for (i = 0; i < n; i++) { + stencil[i] = (stencil[i] << shift) + offset; + } + } + else if (shift < 0) { + shift = -shift; + for (i = 0; i < n; i++) { + stencil[i] = (stencil[i] >> shift) + offset; + } + } + else { + for (i = 0; i < n; i++) { + stencil[i] = stencil[i] + offset; + } + } + } + if (ctx->Pixel.MapStencilFlag) { + GLuint mask = ctx->PixelMaps.StoS.Size - 1; + GLuint i; + for (i = 0; i < n; i++) { + stencil[i] = (GLstencil)ctx->PixelMaps.StoS.Map[ stencil[i] & mask ]; + } + } +} diff --git a/mesalib/src/mesa/main/pixeltransfer.h b/mesalib/src/mesa/main/pixeltransfer.h new file mode 100644 index 000000000..c00da3f2a --- /dev/null +++ b/mesalib/src/mesa/main/pixeltransfer.h @@ -0,0 +1,90 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +#ifndef PIXELTRANSFER_H +#define PIXELTRANSFER_H + + +#include "mtypes.h" + + +extern void +_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], + GLfloat rScale, GLfloat gScale, + GLfloat bScale, GLfloat aScale, + GLfloat rBias, GLfloat gBias, + GLfloat bBias, GLfloat aBias); + +extern void +_mesa_map_rgba(const struct gl_context *ctx, GLuint n, GLfloat rgba[][4]); + +extern void +_mesa_lookup_rgba_float(const struct gl_color_table *table, + GLuint n, GLfloat rgba[][4]); + +extern void +_mesa_lookup_rgba_ubyte(const struct gl_color_table *table, + GLuint n, GLubyte rgba[][4]); + + +extern void +_mesa_map_ci_to_rgba(const struct gl_context *ctx, + GLuint n, const GLuint index[], GLfloat rgba[][4]); + + +extern void +_mesa_map_ci8_to_rgba8(const struct gl_context *ctx, + GLuint n, const GLubyte index[], + GLubyte rgba[][4]); + + +extern void +_mesa_scale_and_bias_depth(const struct gl_context *ctx, GLuint n, + GLfloat depthValues[]); + +extern void +_mesa_scale_and_bias_depth_uint(const struct gl_context *ctx, GLuint n, + GLuint depthValues[]); + +extern void +_mesa_apply_rgba_transfer_ops(struct gl_context *ctx, GLbitfield transferOps, + GLuint n, GLfloat rgba[][4]); + +extern void +_mesa_shift_and_offset_ci(const struct gl_context *ctx, + GLuint n, GLuint indexes[]); + +extern void +_mesa_apply_ci_transfer_ops(const struct gl_context *ctx, + GLbitfield transferOps, + GLuint n, GLuint indexes[]); + + +extern void +_mesa_apply_stencil_transfer_ops(const struct gl_context *ctx, GLuint n, + GLstencil stencil[]); + + +#endif diff --git a/mesalib/src/mesa/main/points.c b/mesalib/src/mesa/main/points.c index eab9d13d6..78d40f61c 100644 --- a/mesalib/src/mesa/main/points.c +++ b/mesalib/src/mesa/main/points.c @@ -1,272 +1,272 @@ -/** - * \file points.c - * Point operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "points.h" -#include "mtypes.h" - - -/** - * Set current point size. - * \param size point diameter in pixels - * \sa glPointSize(). - */ -void GLAPIENTRY -_mesa_PointSize( GLfloat size ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (size <= 0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPointSize" ); - return; - } - - if (ctx->Point.Size == size) - return; - - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.Size = size; - - if (ctx->Driver.PointSize) - ctx->Driver.PointSize(ctx, size); -} - - -#if _HAVE_FULL_GL - - -void GLAPIENTRY -_mesa_PointParameteri( GLenum pname, GLint param ) -{ - GLfloat p[3]; - p[0] = (GLfloat) param; - p[1] = p[2] = 0.0F; - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameteriv( GLenum pname, const GLint *params ) -{ - GLfloat p[3]; - p[0] = (GLfloat) params[0]; - if (pname == GL_DISTANCE_ATTENUATION_EXT) { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - } - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameterf( GLenum pname, GLfloat param) -{ - GLfloat p[3]; - p[0] = param; - p[1] = p[2] = 0.0F; - _mesa_PointParameterfv(pname, p); -} - - -void GLAPIENTRY -_mesa_PointParameterfv( GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_DISTANCE_ATTENUATION_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (TEST_EQ_3V(ctx->Point.Params, params)) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - COPY_3V(ctx->Point.Params, params); - ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || - ctx->Point.Params[1] != 0.0 || - ctx->Point.Params[2] != 0.0); - - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - else - ctx->_TriangleCaps &= ~DD_POINT_ATTEN; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SIZE_MIN_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.MinSize == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.MinSize = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SIZE_MAX_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.MaxSize == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.MaxSize = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - if (ctx->Extensions.EXT_point_parameters) { - if (params[0] < 0.0F) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)" ); - return; - } - if (ctx->Point.Threshold == params[0]) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.Threshold = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SPRITE_R_MODE_NV: - /* This is one area where ARB_point_sprite and NV_point_sprite - * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is - * always ZERO. NV_point_sprite adds the S and R modes. - */ - if (ctx->Extensions.NV_point_sprite) { - GLenum value = (GLenum) params[0]; - if (value != GL_ZERO && value != GL_S && value != GL_R) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)"); - return; - } - if (ctx->Point.SpriteRMode == value) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SpriteRMode = value; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - /* This is not completely correct. GL_POINT_SPRITE_COORD_ORIGIN was - * added to point sprites when the extension was merged into OpenGL - * 2.0. It is expected that an implementation supporting OpenGL 1.4 - * and GL_ARB_point_sprite will generate an error here. - */ - if (ctx->Extensions.ARB_point_sprite) { - GLenum value = (GLenum) params[0]; - if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glPointParameterf[v]{EXT,ARB}(param)"); - return; - } - if (ctx->Point.SpriteOrigin == value) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SpriteOrigin = value; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)"); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, - "glPointParameterf[v]{EXT,ARB}(pname)" ); - return; - } - - if (ctx->Driver.PointParameterfv) - (*ctx->Driver.PointParameterfv)(ctx, pname, params); -} -#endif - - - -/** - * Initialize the context point state. - * - * \param ctx GL context. - * - * Initializes __GLcontextRec::Point and point related constants in - * __GLcontextRec::Const. - */ -void -_mesa_init_point(GLcontext *ctx) -{ - GLuint i; - - ctx->Point.SmoothFlag = GL_FALSE; - ctx->Point.Size = 1.0; - ctx->Point.Params[0] = 1.0; - ctx->Point.Params[1] = 0.0; - ctx->Point.Params[2] = 0.0; - ctx->Point._Attenuated = GL_FALSE; - ctx->Point.MinSize = 0.0; - ctx->Point.MaxSize - = MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA); - ctx->Point.Threshold = 1.0; - ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */ - ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ - ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) { - ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ - } -} +/** + * \file points.c + * Point operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "context.h" +#include "macros.h" +#include "points.h" +#include "mtypes.h" + + +/** + * Set current point size. + * \param size point diameter in pixels + * \sa glPointSize(). + */ +void GLAPIENTRY +_mesa_PointSize( GLfloat size ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (size <= 0.0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPointSize" ); + return; + } + + if (ctx->Point.Size == size) + return; + + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.Size = size; + + if (ctx->Driver.PointSize) + ctx->Driver.PointSize(ctx, size); +} + + +#if _HAVE_FULL_GL + + +void GLAPIENTRY +_mesa_PointParameteri( GLenum pname, GLint param ) +{ + GLfloat p[3]; + p[0] = (GLfloat) param; + p[1] = p[2] = 0.0F; + _mesa_PointParameterfv(pname, p); +} + + +void GLAPIENTRY +_mesa_PointParameteriv( GLenum pname, const GLint *params ) +{ + GLfloat p[3]; + p[0] = (GLfloat) params[0]; + if (pname == GL_DISTANCE_ATTENUATION_EXT) { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + } + _mesa_PointParameterfv(pname, p); +} + + +void GLAPIENTRY +_mesa_PointParameterf( GLenum pname, GLfloat param) +{ + GLfloat p[3]; + p[0] = param; + p[1] = p[2] = 0.0F; + _mesa_PointParameterfv(pname, p); +} + + +void GLAPIENTRY +_mesa_PointParameterfv( GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_DISTANCE_ATTENUATION_EXT: + if (ctx->Extensions.EXT_point_parameters) { + if (TEST_EQ_3V(ctx->Point.Params, params)) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + COPY_3V(ctx->Point.Params, params); + ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || + ctx->Point.Params[1] != 0.0 || + ctx->Point.Params[2] != 0.0); + + if (ctx->Point._Attenuated) + ctx->_TriangleCaps |= DD_POINT_ATTEN; + else + ctx->_TriangleCaps &= ~DD_POINT_ATTEN; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + case GL_POINT_SIZE_MIN_EXT: + if (ctx->Extensions.EXT_point_parameters) { + if (params[0] < 0.0F) { + _mesa_error( ctx, GL_INVALID_VALUE, + "glPointParameterf[v]{EXT,ARB}(param)" ); + return; + } + if (ctx->Point.MinSize == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.MinSize = params[0]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + case GL_POINT_SIZE_MAX_EXT: + if (ctx->Extensions.EXT_point_parameters) { + if (params[0] < 0.0F) { + _mesa_error( ctx, GL_INVALID_VALUE, + "glPointParameterf[v]{EXT,ARB}(param)" ); + return; + } + if (ctx->Point.MaxSize == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.MaxSize = params[0]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + case GL_POINT_FADE_THRESHOLD_SIZE_EXT: + if (ctx->Extensions.EXT_point_parameters) { + if (params[0] < 0.0F) { + _mesa_error( ctx, GL_INVALID_VALUE, + "glPointParameterf[v]{EXT,ARB}(param)" ); + return; + } + if (ctx->Point.Threshold == params[0]) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.Threshold = params[0]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + case GL_POINT_SPRITE_R_MODE_NV: + /* This is one area where ARB_point_sprite and NV_point_sprite + * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is + * always ZERO. NV_point_sprite adds the S and R modes. + */ + if (ctx->Extensions.NV_point_sprite) { + GLenum value = (GLenum) params[0]; + if (value != GL_ZERO && value != GL_S && value != GL_R) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glPointParameterf[v]{EXT,ARB}(param)"); + return; + } + if (ctx->Point.SpriteRMode == value) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.SpriteRMode = value; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + case GL_POINT_SPRITE_COORD_ORIGIN: + /* This is not completely correct. GL_POINT_SPRITE_COORD_ORIGIN was + * added to point sprites when the extension was merged into OpenGL + * 2.0. It is expected that an implementation supporting OpenGL 1.4 + * and GL_ARB_point_sprite will generate an error here. + */ + if (ctx->Extensions.ARB_point_sprite) { + GLenum value = (GLenum) params[0]; + if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glPointParameterf[v]{EXT,ARB}(param)"); + return; + } + if (ctx->Point.SpriteOrigin == value) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.SpriteOrigin = value; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)"); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, + "glPointParameterf[v]{EXT,ARB}(pname)" ); + return; + } + + if (ctx->Driver.PointParameterfv) + (*ctx->Driver.PointParameterfv)(ctx, pname, params); +} +#endif + + + +/** + * Initialize the context point state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Point and point related constants in + * __struct gl_contextRec::Const. + */ +void +_mesa_init_point(struct gl_context *ctx) +{ + GLuint i; + + ctx->Point.SmoothFlag = GL_FALSE; + ctx->Point.Size = 1.0; + ctx->Point.Params[0] = 1.0; + ctx->Point.Params[1] = 0.0; + ctx->Point.Params[2] = 0.0; + ctx->Point._Attenuated = GL_FALSE; + ctx->Point.MinSize = 0.0; + ctx->Point.MaxSize + = MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA); + ctx->Point.Threshold = 1.0; + ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */ + ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ + ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ + for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) { + ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ + } +} diff --git a/mesalib/src/mesa/main/points.h b/mesalib/src/mesa/main/points.h index 156641eab..442053c8f 100644 --- a/mesalib/src/mesa/main/points.h +++ b/mesalib/src/mesa/main/points.h @@ -1,57 +1,59 @@ -/** - * \file points.h - * Point operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef POINTS_H -#define POINTS_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_PointSize( GLfloat size ); - -extern void GLAPIENTRY -_mesa_PointParameteri( GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_PointParameteriv( GLenum pname, const GLint *params ); - -extern void GLAPIENTRY -_mesa_PointParameterf( GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_PointParameterfv( GLenum pname, const GLfloat *params ); - -extern void -_mesa_init_point( GLcontext * ctx ); - - -#endif +/** + * \file points.h + * Point operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef POINTS_H +#define POINTS_H + + +#include "glheader.h" + +struct gl_context; + + +extern void GLAPIENTRY +_mesa_PointSize( GLfloat size ); + +extern void GLAPIENTRY +_mesa_PointParameteri( GLenum pname, GLint param ); + +extern void GLAPIENTRY +_mesa_PointParameteriv( GLenum pname, const GLint *params ); + +extern void GLAPIENTRY +_mesa_PointParameterf( GLenum pname, GLfloat param ); + +extern void GLAPIENTRY +_mesa_PointParameterfv( GLenum pname, const GLfloat *params ); + +extern void +_mesa_init_point( struct gl_context * ctx ); + + +#endif diff --git a/mesalib/src/mesa/main/polygon.c b/mesalib/src/mesa/main/polygon.c index 30e4a606b..71ef929fc 100644 --- a/mesalib/src/mesa/main/polygon.c +++ b/mesalib/src/mesa/main/polygon.c @@ -1,321 +1,322 @@ -/** - * \file polygon.c - * Polygon operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "image.h" -#include "enums.h" -#include "polygon.h" -#include "mtypes.h" - - -/** - * Specify whether to cull front- or back-facing facets. - * - * \param mode culling mode. - * - * \sa glCullFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On - * change, flushes the vertices and notifies the driver via - * the dd_function_table::CullFace callback. - */ -void GLAPIENTRY -_mesa_CullFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); - return; - } - - if (ctx->Polygon.CullFaceMode == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFaceMode = mode; - - if (ctx->Driver.CullFace) - ctx->Driver.CullFace( ctx, mode ); -} - - -/** - * Define front- and back-facing - * - * \param mode orientation of front-facing polygons. - * - * \sa glFrontFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::FrontFace callback. - */ -void GLAPIENTRY -_mesa_FrontFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_CW && mode!=GL_CCW) { - _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); - return; - } - - if (ctx->Polygon.FrontFace == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontFace = mode; - - ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); - - if (ctx->Driver.FrontFace) - ctx->Driver.FrontFace( ctx, mode ); -} - - -/** - * Set the polygon rasterization mode. - * - * \param face the polygons which \p mode applies to. - * \param mode how polygons should be rasterized. - * - * \sa glPolygonMode(). - * - * Verifies the parameters and updates gl_polygon_attrib::FrontMode and - * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the - * driver via the dd_function_table::PolygonMode callback. - */ -void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonMode %s %s\n", - _mesa_lookup_enum_by_nr(face), - _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); - return; - } - - switch (face) { - case GL_FRONT: - if (ctx->Polygon.FrontMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - break; - case GL_FRONT_AND_BACK: - if (ctx->Polygon.FrontMode == mode && - ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - ctx->Polygon.BackMode = mode; - break; - case GL_BACK: - if (ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.BackMode = mode; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); - return; - } - - if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) - ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; - else - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - - if (ctx->Driver.PolygonMode) - ctx->Driver.PolygonMode(ctx, face, mode); -} - -#if _HAVE_FULL_GL - - -/** - * This routine updates the ctx->Polygon.Stipple state. - * If we're getting the stipple data from a PBO, we map the buffer - * in order to access the data. - * In any case, we obey the current pixel unpacking parameters when fetching - * the stipple data. - * - * In the future, this routine should be used as a fallback, called via - * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers - * too. - */ -void -_mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) -{ - pattern = _mesa_map_validate_pbo_source(ctx, 2, - &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, pattern, - "glPolygonStipple"); - if (!pattern) - return; - - _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonStipple\n"); - - FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); - - _mesa_polygon_stipple(ctx, pattern); - - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple(ctx, pattern); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *dest ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glGetPolygonStipple\n"); - - dest = _mesa_map_validate_pbo_dest(ctx, 2, - &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, dest, - "glGetPolygonStipple"); - if (!dest) - return; - - _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); - - if (ctx->Polygon.OffsetFactor == factor && - ctx->Polygon.OffsetUnits == units) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFactor = factor; - ctx->Polygon.OffsetUnits = units; - - if (ctx->Driver.PolygonOffset) - ctx->Driver.PolygonOffset( ctx, factor, units ); -} - - -void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); -} - -#endif - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialize the context polygon state. - * - * \param ctx GL context. - * - * Initializes __GLcontextRec::Polygon and __GLcontextRec::PolygonStipple - * attribute groups. - */ -void _mesa_init_polygon( GLcontext * ctx ) -{ - /* Polygon group */ - ctx->Polygon.CullFlag = GL_FALSE; - ctx->Polygon.CullFaceMode = GL_BACK; - ctx->Polygon.FrontFace = GL_CCW; - ctx->Polygon._FrontBit = 0; - ctx->Polygon.FrontMode = GL_FILL; - ctx->Polygon.BackMode = GL_FILL; - ctx->Polygon.SmoothFlag = GL_FALSE; - ctx->Polygon.StippleFlag = GL_FALSE; - ctx->Polygon.OffsetFactor = 0.0F; - ctx->Polygon.OffsetUnits = 0.0F; - ctx->Polygon.OffsetPoint = GL_FALSE; - ctx->Polygon.OffsetLine = GL_FALSE; - ctx->Polygon.OffsetFill = GL_FALSE; - - - /* Polygon Stipple group */ - memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); -} - -/*@}*/ +/** + * \file polygon.c + * Polygon operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "image.h" +#include "enums.h" +#include "pack.h" +#include "polygon.h" +#include "mtypes.h" + + +/** + * Specify whether to cull front- or back-facing facets. + * + * \param mode culling mode. + * + * \sa glCullFace(). + * + * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On + * change, flushes the vertices and notifies the driver via + * the dd_function_table::CullFace callback. + */ +void GLAPIENTRY +_mesa_CullFace( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { + _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); + return; + } + + if (ctx->Polygon.CullFaceMode == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.CullFaceMode = mode; + + if (ctx->Driver.CullFace) + ctx->Driver.CullFace( ctx, mode ); +} + + +/** + * Define front- and back-facing + * + * \param mode orientation of front-facing polygons. + * + * \sa glFrontFace(). + * + * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change + * flushes the vertices and notifies the driver via + * the dd_function_table::FrontFace callback. + */ +void GLAPIENTRY +_mesa_FrontFace( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_CW && mode!=GL_CCW) { + _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); + return; + } + + if (ctx->Polygon.FrontFace == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontFace = mode; + + ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); + + if (ctx->Driver.FrontFace) + ctx->Driver.FrontFace( ctx, mode ); +} + + +/** + * Set the polygon rasterization mode. + * + * \param face the polygons which \p mode applies to. + * \param mode how polygons should be rasterized. + * + * \sa glPolygonMode(). + * + * Verifies the parameters and updates gl_polygon_attrib::FrontMode and + * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the + * driver via the dd_function_table::PolygonMode callback. + */ +void GLAPIENTRY +_mesa_PolygonMode( GLenum face, GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonMode %s %s\n", + _mesa_lookup_enum_by_nr(face), + _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { + _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); + return; + } + + switch (face) { + case GL_FRONT: + if (ctx->Polygon.FrontMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontMode = mode; + break; + case GL_FRONT_AND_BACK: + if (ctx->Polygon.FrontMode == mode && + ctx->Polygon.BackMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontMode = mode; + ctx->Polygon.BackMode = mode; + break; + case GL_BACK: + if (ctx->Polygon.BackMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.BackMode = mode; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); + return; + } + + if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) + ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; + else + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + + if (ctx->Driver.PolygonMode) + ctx->Driver.PolygonMode(ctx, face, mode); +} + +#if _HAVE_FULL_GL + + +/** + * This routine updates the ctx->Polygon.Stipple state. + * If we're getting the stipple data from a PBO, we map the buffer + * in order to access the data. + * In any case, we obey the current pixel unpacking parameters when fetching + * the stipple data. + * + * In the future, this routine should be used as a fallback, called via + * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers + * too. + */ +void +_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern) +{ + pattern = _mesa_map_validate_pbo_source(ctx, 2, + &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, pattern, + "glPolygonStipple"); + if (!pattern) + return; + + _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); +} + + +/** + * Called by glPolygonStipple. + */ +void GLAPIENTRY +_mesa_PolygonStipple( const GLubyte *pattern ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonStipple\n"); + + FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); + + _mesa_polygon_stipple(ctx, pattern); + + if (ctx->Driver.PolygonStipple) + ctx->Driver.PolygonStipple(ctx, pattern); +} + + +/** + * Called by glPolygonStipple. + */ +void GLAPIENTRY +_mesa_GetPolygonStipple( GLubyte *dest ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glGetPolygonStipple\n"); + + dest = _mesa_map_validate_pbo_dest(ctx, 2, + &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, dest, + "glGetPolygonStipple"); + if (!dest) + return; + + _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +void GLAPIENTRY +_mesa_PolygonOffset( GLfloat factor, GLfloat units ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); + + if (ctx->Polygon.OffsetFactor == factor && + ctx->Polygon.OffsetUnits == units) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetFactor = factor; + ctx->Polygon.OffsetUnits = units; + + if (ctx->Driver.PolygonOffset) + ctx->Driver.PolygonOffset( ctx, factor, units ); +} + + +void GLAPIENTRY +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) +{ + GET_CURRENT_CONTEXT(ctx); + /* XXX mult by DepthMaxF here??? */ + _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); +} + +#endif + + +/**********************************************************************/ +/** \name Initialization */ +/*@{*/ + +/** + * Initialize the context polygon state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple + * attribute groups. + */ +void _mesa_init_polygon( struct gl_context * ctx ) +{ + /* Polygon group */ + ctx->Polygon.CullFlag = GL_FALSE; + ctx->Polygon.CullFaceMode = GL_BACK; + ctx->Polygon.FrontFace = GL_CCW; + ctx->Polygon._FrontBit = 0; + ctx->Polygon.FrontMode = GL_FILL; + ctx->Polygon.BackMode = GL_FILL; + ctx->Polygon.SmoothFlag = GL_FALSE; + ctx->Polygon.StippleFlag = GL_FALSE; + ctx->Polygon.OffsetFactor = 0.0F; + ctx->Polygon.OffsetUnits = 0.0F; + ctx->Polygon.OffsetPoint = GL_FALSE; + ctx->Polygon.OffsetLine = GL_FALSE; + ctx->Polygon.OffsetFill = GL_FALSE; + + + /* Polygon Stipple group */ + memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/polygon.h b/mesalib/src/mesa/main/polygon.h index 78e8394d0..1357d4b01 100644 --- a/mesalib/src/mesa/main/polygon.h +++ b/mesalib/src/mesa/main/polygon.h @@ -1,66 +1,67 @@ -/** - * \file polygon.h - * Polygon operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef POLYGON_H -#define POLYGON_H - - -#include "mtypes.h" - - -extern void -_mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern); - - -extern void GLAPIENTRY -_mesa_CullFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_FrontFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ); - -extern void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); - -extern void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *mask ); - -extern void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *mask ); - -extern void -_mesa_init_polygon( GLcontext * ctx ); - -#endif +/** + * \file polygon.h + * Polygon operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef POLYGON_H +#define POLYGON_H + + +#include "glheader.h" + +struct gl_context; + +extern void +_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern); + + +extern void GLAPIENTRY +_mesa_CullFace( GLenum mode ); + +extern void GLAPIENTRY +_mesa_FrontFace( GLenum mode ); + +extern void GLAPIENTRY +_mesa_PolygonMode( GLenum face, GLenum mode ); + +extern void GLAPIENTRY +_mesa_PolygonOffset( GLfloat factor, GLfloat units ); + +extern void GLAPIENTRY +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); + +extern void GLAPIENTRY +_mesa_PolygonStipple( const GLubyte *mask ); + +extern void GLAPIENTRY +_mesa_GetPolygonStipple( GLubyte *mask ); + +extern void +_mesa_init_polygon( struct gl_context * ctx ); + +#endif diff --git a/mesalib/src/mesa/main/querymatrix.c b/mesalib/src/mesa/main/querymatrix.c index 36236eb9a..aade8a614 100644 --- a/mesalib/src/mesa/main/querymatrix.c +++ b/mesalib/src/mesa/main/querymatrix.c @@ -1,216 +1,212 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - **************************************************************************/ - - -/** - * Code to implement GL_OES_query_matrix. See the spec at: - * http://www.khronos.org/registry/gles/extensions/OES/OES_query_matrix.txt - */ - - -#include -#include -#include "GLES/gl.h" -#include "GLES/glext.h" - - -/** - * This is from the GL_OES_query_matrix extension specification: - * - * GLbitfield glQueryMatrixxOES( GLfixed mantissa[16], - * GLint exponent[16] ) - * mantissa[16] contains the contents of the current matrix in GLfixed - * format. exponent[16] contains the unbiased exponents applied to the - * matrix components, so that the internal representation of component i - * is close to mantissa[i] * 2^exponent[i]. The function returns a status - * word which is zero if all the components are valid. If - * status & (1< - -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} -fpclassify(double x) -{ - switch(_fpclass(x)) { - case _FPCLASS_SNAN: /* signaling NaN */ - case _FPCLASS_QNAN: /* quiet NaN */ - return FP_NAN; - case _FPCLASS_NINF: /* negative infinity */ - case _FPCLASS_PINF: /* positive infinity */ - return FP_INFINITE; - case _FPCLASS_NN: /* negative normal */ - case _FPCLASS_PN: /* positive normal */ - return FP_NORMAL; - case _FPCLASS_ND: /* negative denormalized */ - case _FPCLASS_PD: /* positive denormalized */ - return FP_SUBNORMAL; - case _FPCLASS_NZ: /* negative zero */ - case _FPCLASS_PZ: /* positive zero */ - return FP_ZERO; - default: - /* Should never get here; but if we do, this will guarantee - * that the pattern is not treated like a number. - */ - return FP_NAN; - } -} - -#elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ - (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \ - (defined(__sun) && defined(__GNUC__)) - -/* fpclassify is available. */ - -#elif !defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600 - -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} -fpclassify(double x) -{ - /* XXX do something better someday */ - return FP_NORMAL; -} - -#endif - -extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]); - -/* The Mesa functions we'll need */ -extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint *params); -extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat *params); - -GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) -{ - GLfloat matrix[16]; - GLint tmp; - GLenum currentMode = GL_FALSE; - GLenum desiredMatrix = GL_FALSE; - /* The bitfield returns 1 for each component that is invalid (i.e. - * NaN or Inf). In case of error, everything is invalid. - */ - GLbitfield rv; - register unsigned int i; - unsigned int bit; - - /* This data structure defines the mapping between the current matrix - * mode and the desired matrix identifier. - */ - static struct { - GLenum currentMode; - GLenum desiredMatrix; - } modes[] = { - {GL_MODELVIEW, GL_MODELVIEW_MATRIX}, - {GL_PROJECTION, GL_PROJECTION_MATRIX}, - {GL_TEXTURE, GL_TEXTURE_MATRIX}, -#if 0 - /* this doesn't exist in GLES */ - {GL_COLOR, GL_COLOR_MATRIX}, -#endif - }; - - /* Call Mesa to get the current matrix in floating-point form. First, - * we have to figure out what the current matrix mode is. - */ - _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp); - currentMode = (GLenum) tmp; - - /* The mode is either GL_FALSE, if for some reason we failed to query - * the mode, or a given mode from the above table. Search for the - * returned mode to get the desired matrix; if we don't find it, - * we can return immediately, as _mesa_GetInteger() will have - * logged the necessary error already. - */ - for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { - if (modes[i].currentMode == currentMode) { - desiredMatrix = modes[i].desiredMatrix; - break; - } - } - if (desiredMatrix == GL_FALSE) { - /* Early error means all values are invalid. */ - return 0xffff; - } - - /* Now pull the matrix itself. */ - _mesa_GetFloatv(desiredMatrix, matrix); - - rv = 0; - for (i = 0, bit = 1; i < 16; i++, bit<<=1) { - float normalizedFraction; - int exp; - - switch (fpclassify(matrix[i])) { - /* A "subnormal" or denormalized number is too small to be - * represented in normal format; but despite that it's a - * valid floating point number. FP_ZERO and FP_NORMAL - * are both valid as well. We should be fine treating - * these three cases as legitimate floating-point numbers. - */ - case FP_SUBNORMAL: - case FP_NORMAL: - case FP_ZERO: - normalizedFraction = (GLfloat)frexp(matrix[i], &exp); - mantissa[i] = FLOAT_TO_FIXED(normalizedFraction); - exponent[i] = (GLint) exp; - break; - - /* If the entry is not-a-number or an infinity, then the - * matrix component is invalid. The invalid flag for - * the component is already set; might as well set the - * other return values to known values. We'll set - * distinct values so that a savvy end user could determine - * whether the matrix component was a NaN or an infinity, - * but this is more useful for debugging than anything else - * since the standard doesn't specify any such magic - * values to return. - */ - case FP_NAN: - mantissa[i] = INT_TO_FIXED(0); - exponent[i] = (GLint) 0; - rv |= bit; - break; - - case FP_INFINITE: - /* Return +/- 1 based on whether it's a positive or - * negative infinity. - */ - if (matrix[i] > 0) { - mantissa[i] = INT_TO_FIXED(1); - } - else { - mantissa[i] = -INT_TO_FIXED(1); - } - exponent[i] = (GLint) 0; - rv |= bit; - break; - - /* We should never get here; but here's a catching case - * in case fpclassify() is returnings something unexpected. - */ - default: - mantissa[i] = INT_TO_FIXED(2); - exponent[i] = (GLint) 0; - rv |= bit; - break; - } - - } /* for each component */ - - /* All done */ - return rv; -} +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Code to implement GL_OES_query_matrix. See the spec at: + * http://www.khronos.org/registry/gles/extensions/OES/OES_query_matrix.txt + */ + + +#include +#include +#include "GLES/gl.h" +#include "GLES/glext.h" + + +/** + * This is from the GL_OES_query_matrix extension specification: + * + * GLbitfield glQueryMatrixxOES( GLfixed mantissa[16], + * GLint exponent[16] ) + * mantissa[16] contains the contents of the current matrix in GLfixed + * format. exponent[16] contains the unbiased exponents applied to the + * matrix components, so that the internal representation of component i + * is close to mantissa[i] * 2^exponent[i]. The function returns a status + * word which is zero if all the components are valid. If + * status & (1< + +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} +fpclassify(double x) +{ + switch(_fpclass(x)) { + case _FPCLASS_SNAN: /* signaling NaN */ + case _FPCLASS_QNAN: /* quiet NaN */ + return FP_NAN; + case _FPCLASS_NINF: /* negative infinity */ + case _FPCLASS_PINF: /* positive infinity */ + return FP_INFINITE; + case _FPCLASS_NN: /* negative normal */ + case _FPCLASS_PN: /* positive normal */ + return FP_NORMAL; + case _FPCLASS_ND: /* negative denormalized */ + case _FPCLASS_PD: /* positive denormalized */ + return FP_SUBNORMAL; + case _FPCLASS_NZ: /* negative zero */ + case _FPCLASS_PZ: /* positive zero */ + return FP_ZERO; + default: + /* Should never get here; but if we do, this will guarantee + * that the pattern is not treated like a number. + */ + return FP_NAN; + } +} + +#elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ + defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ + (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \ + (defined(__sun) && defined(__GNUC__)) + +/* fpclassify is available. */ + +#elif !defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600 + +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} +fpclassify(double x) +{ + /* XXX do something better someday */ + return FP_NORMAL; +} + +#endif + +extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]); + +/* The Mesa functions we'll need */ +extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint *params); +extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat *params); + +GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) +{ + GLfloat matrix[16]; + GLint tmp; + GLenum currentMode = GL_FALSE; + GLenum desiredMatrix = GL_FALSE; + /* The bitfield returns 1 for each component that is invalid (i.e. + * NaN or Inf). In case of error, everything is invalid. + */ + GLbitfield rv; + register unsigned int i; + unsigned int bit; + + /* This data structure defines the mapping between the current matrix + * mode and the desired matrix identifier. + */ + static struct { + GLenum currentMode; + GLenum desiredMatrix; + } modes[] = { + {GL_MODELVIEW, GL_MODELVIEW_MATRIX}, + {GL_PROJECTION, GL_PROJECTION_MATRIX}, + {GL_TEXTURE, GL_TEXTURE_MATRIX}, + }; + + /* Call Mesa to get the current matrix in floating-point form. First, + * we have to figure out what the current matrix mode is. + */ + _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp); + currentMode = (GLenum) tmp; + + /* The mode is either GL_FALSE, if for some reason we failed to query + * the mode, or a given mode from the above table. Search for the + * returned mode to get the desired matrix; if we don't find it, + * we can return immediately, as _mesa_GetInteger() will have + * logged the necessary error already. + */ + for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { + if (modes[i].currentMode == currentMode) { + desiredMatrix = modes[i].desiredMatrix; + break; + } + } + if (desiredMatrix == GL_FALSE) { + /* Early error means all values are invalid. */ + return 0xffff; + } + + /* Now pull the matrix itself. */ + _mesa_GetFloatv(desiredMatrix, matrix); + + rv = 0; + for (i = 0, bit = 1; i < 16; i++, bit<<=1) { + float normalizedFraction; + int exp; + + switch (fpclassify(matrix[i])) { + /* A "subnormal" or denormalized number is too small to be + * represented in normal format; but despite that it's a + * valid floating point number. FP_ZERO and FP_NORMAL + * are both valid as well. We should be fine treating + * these three cases as legitimate floating-point numbers. + */ + case FP_SUBNORMAL: + case FP_NORMAL: + case FP_ZERO: + normalizedFraction = (GLfloat)frexp(matrix[i], &exp); + mantissa[i] = FLOAT_TO_FIXED(normalizedFraction); + exponent[i] = (GLint) exp; + break; + + /* If the entry is not-a-number or an infinity, then the + * matrix component is invalid. The invalid flag for + * the component is already set; might as well set the + * other return values to known values. We'll set + * distinct values so that a savvy end user could determine + * whether the matrix component was a NaN or an infinity, + * but this is more useful for debugging than anything else + * since the standard doesn't specify any such magic + * values to return. + */ + case FP_NAN: + mantissa[i] = INT_TO_FIXED(0); + exponent[i] = (GLint) 0; + rv |= bit; + break; + + case FP_INFINITE: + /* Return +/- 1 based on whether it's a positive or + * negative infinity. + */ + if (matrix[i] > 0) { + mantissa[i] = INT_TO_FIXED(1); + } + else { + mantissa[i] = -INT_TO_FIXED(1); + } + exponent[i] = (GLint) 0; + rv |= bit; + break; + + /* We should never get here; but here's a catching case + * in case fpclassify() is returnings something unexpected. + */ + default: + mantissa[i] = INT_TO_FIXED(2); + exponent[i] = (GLint) 0; + rv |= bit; + break; + } + + } /* for each component */ + + /* All done */ + return rv; +} diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index a907dac83..a8e1e8101 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -1,565 +1,584 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "context.h" -#include "hash.h" -#include "imports.h" -#include "queryobj.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_queryobj - - -/** - * Allocate a new query object. This is a fallback routine called via - * ctx->Driver.NewQueryObject(). - * \param ctx - rendering context - * \param id - the new object's ID - * \return pointer to new query_object object or NULL if out of memory. - */ -static struct gl_query_object * -_mesa_new_query_object(GLcontext *ctx, GLuint id) -{ - struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); - (void) ctx; - if (q) { - q->Id = id; - q->Result = 0; - q->Active = GL_FALSE; - q->Ready = GL_TRUE; /* correct, see spec */ - } - return q; -} - - -/** - * Begin a query. Software driver fallback. - * Called via ctx->Driver.BeginQuery(). - */ -static void -_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q) -{ - /* no-op */ -} - - -/** - * End a query. Software driver fallback. - * Called via ctx->Driver.EndQuery(). - */ -static void -_mesa_end_query(GLcontext *ctx, struct gl_query_object *q) -{ - q->Ready = GL_TRUE; -} - - -/** - * Wait for query to complete. Software driver fallback. - * Called via ctx->Driver.WaitQuery(). - */ -static void -_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) -{ - /* For software drivers, _mesa_end_query() should have completed the query. - * For real hardware, implement a proper WaitQuery() driver function, - * which may require issuing a flush. - */ - assert(q->Ready); -} - - -/** - * Check if a query results are ready. Software driver fallback. - * Called via ctx->Driver.CheckQuery(). - */ -static void -_mesa_check_query(GLcontext *ctx, struct gl_query_object *q) -{ - /* No-op for sw rendering. - * HW drivers may need to flush at this time. - */ -} - - -/** - * Delete a query object. Called via ctx->Driver.DeleteQuery(). - * Not removed from hash table here. - */ -static void -_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) -{ - free(q); -} - - -void -_mesa_init_query_object_functions(struct dd_function_table *driver) -{ - driver->NewQueryObject = _mesa_new_query_object; - driver->DeleteQuery = _mesa_delete_query; - driver->BeginQuery = _mesa_begin_query; - driver->EndQuery = _mesa_end_query; - driver->WaitQuery = _mesa_wait_query; - driver->CheckQuery = _mesa_check_query; -} - - -/** - * Return pointer to the query object binding point for the given target. - * \return NULL if invalid target, else the address of binding point - */ -static struct gl_query_object ** -get_query_binding_point(GLcontext *ctx, GLenum target) -{ - switch (target) { - case GL_SAMPLES_PASSED_ARB: - if (ctx->Extensions.ARB_occlusion_query) - return &ctx->Query.CurrentOcclusionObject; - else - return NULL; - case GL_TIME_ELAPSED_EXT: - if (ctx->Extensions.EXT_timer_query) - return &ctx->Query.CurrentTimerObject; - else - return NULL; -#if FEATURE_EXT_transform_feedback - case GL_PRIMITIVES_GENERATED: - if (ctx->Extensions.EXT_transform_feedback) - return &ctx->Query.PrimitivesGenerated; - else - return NULL; - case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: - if (ctx->Extensions.EXT_transform_feedback) - return &ctx->Query.PrimitivesWritten; - else - return NULL; -#endif - default: - return NULL; - } -} - - -void GLAPIENTRY -_mesa_GenQueriesARB(GLsizei n, GLuint *ids) -{ - GLuint first; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); - return; - } - - /* No query objects can be active at this time! */ - if (ctx->Query.CurrentOcclusionObject || - ctx->Query.CurrentTimerObject) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB"); - return; - } - - first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n); - if (first) { - GLsizei i; - for (i = 0; i < n; i++) { - struct gl_query_object *q - = ctx->Driver.NewQueryObject(ctx, first + i); - if (!q) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB"); - return; - } - ids[i] = first + i; - _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q); - } - } -} - - -void GLAPIENTRY -_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)"); - return; - } - - /* No query objects can be active at this time! */ - if (ctx->Query.CurrentOcclusionObject || - ctx->Query.CurrentTimerObject) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB"); - return; - } - - for (i = 0; i < n; i++) { - if (ids[i] > 0) { - struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]); - if (q) { - ASSERT(!q->Active); /* should be caught earlier */ - _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]); - ctx->Driver.DeleteQuery(ctx, q); - } - } - } -} - - -GLboolean GLAPIENTRY -_mesa_IsQueryARB(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (id && _mesa_lookup_query_object(ctx, id)) - return GL_TRUE; - else - return GL_FALSE; -} - - -static void GLAPIENTRY -_mesa_BeginQueryARB(GLenum target, GLuint id) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)"); - return; - } - - if (id == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)"); - return; - } - - q = _mesa_lookup_query_object(ctx, id); - if (!q) { - /* create new object */ - q = ctx->Driver.NewQueryObject(ctx, id); - if (!q) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB"); - return; - } - _mesa_HashInsert(ctx->Query.QueryObjects, id, q); - } - else { - /* pre-existing object */ - if (q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBeginQueryARB(query already active)"); - return; - } - } - - q->Target = target; - q->Active = GL_TRUE; - q->Result = 0; - q->Ready = GL_FALSE; - - /* XXX should probably refcount query objects */ - *bindpt = q; - - ctx->Driver.BeginQuery(ctx, q); -} - - -static void GLAPIENTRY -_mesa_EndQueryARB(GLenum target) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)"); - return; - } - - /* XXX should probably refcount query objects */ - q = *bindpt; - *bindpt = NULL; - - if (!q || !q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEndQueryARB(no matching glBeginQueryARB)"); - return; - } - - q->Active = GL_FALSE; - ctx->Driver.EndQuery(ctx, q); -} - - -void GLAPIENTRY -_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); - return; - } - - q = *bindpt; - - switch (pname) { - case GL_QUERY_COUNTER_BITS_ARB: - *params = 8 * sizeof(q->Result); - break; - case GL_CURRENT_QUERY_ARB: - *params = q ? q->Id : 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)"); - return; - } -} - - -void GLAPIENTRY -_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectivARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - /* if result is too large for returned type, clamp to max value */ - if (q->Result > 0x7fffffff) { - *params = 0x7fffffff; - } - else { - *params = (GLint)q->Result; - } - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)"); - return; - } -} - - -void GLAPIENTRY -_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectuivARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - /* if result is too large for returned type, clamp to max value */ - if (q->Result > 0xffffffff) { - *params = 0xffffffff; - } - else { - *params = (GLuint)q->Result; - } - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)"); - return; - } -} - - -/** - * New with GL_EXT_timer_query - */ -static void GLAPIENTRY -_mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectui64vARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - *params = q->Result; - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)"); - return; - } -} - - -/** - * New with GL_EXT_timer_query - */ -static void GLAPIENTRY -_mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - *params = q->Result; - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)"); - return; - } -} - - -void -_mesa_init_queryobj_dispatch(struct _glapi_table *disp) -{ - SET_GenQueriesARB(disp, _mesa_GenQueriesARB); - SET_DeleteQueriesARB(disp, _mesa_DeleteQueriesARB); - SET_IsQueryARB(disp, _mesa_IsQueryARB); - SET_BeginQueryARB(disp, _mesa_BeginQueryARB); - SET_EndQueryARB(disp, _mesa_EndQueryARB); - SET_GetQueryivARB(disp, _mesa_GetQueryivARB); - SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB); - SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB); - - SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT); - SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT); -} - - -#endif /* FEATURE_queryobj */ - - -/** - * Allocate/init the context state related to query objects. - */ -void -_mesa_init_queryobj(GLcontext *ctx) -{ - ctx->Query.QueryObjects = _mesa_NewHashTable(); - ctx->Query.CurrentOcclusionObject = NULL; -} - - -/** - * Callback for deleting a query object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_queryobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_query_object *q= (struct gl_query_object *) data; - GLcontext *ctx = (GLcontext *)userData; - ctx->Driver.DeleteQuery(ctx, q); -} - - -/** - * Free the context state related to query objects. - */ -void -_mesa_free_queryobj_data(GLcontext *ctx) -{ - _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); - _mesa_DeleteHashTable(ctx->Query.QueryObjects); -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "context.h" +#include "hash.h" +#include "imports.h" +#include "queryobj.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_queryobj + + +/** + * Allocate a new query object. This is a fallback routine called via + * ctx->Driver.NewQueryObject(). + * \param ctx - rendering context + * \param id - the new object's ID + * \return pointer to new query_object object or NULL if out of memory. + */ +static struct gl_query_object * +_mesa_new_query_object(struct gl_context *ctx, GLuint id) +{ + struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); + (void) ctx; + if (q) { + q->Id = id; + q->Result = 0; + q->Active = GL_FALSE; + q->Ready = GL_TRUE; /* correct, see spec */ + } + return q; +} + + +/** + * Begin a query. Software driver fallback. + * Called via ctx->Driver.BeginQuery(). + */ +static void +_mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* no-op */ +} + + +/** + * End a query. Software driver fallback. + * Called via ctx->Driver.EndQuery(). + */ +static void +_mesa_end_query(struct gl_context *ctx, struct gl_query_object *q) +{ + q->Ready = GL_TRUE; +} + + +/** + * Wait for query to complete. Software driver fallback. + * Called via ctx->Driver.WaitQuery(). + */ +static void +_mesa_wait_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* For software drivers, _mesa_end_query() should have completed the query. + * For real hardware, implement a proper WaitQuery() driver function, + * which may require issuing a flush. + */ + assert(q->Ready); +} + + +/** + * Check if a query results are ready. Software driver fallback. + * Called via ctx->Driver.CheckQuery(). + */ +static void +_mesa_check_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* No-op for sw rendering. + * HW drivers may need to flush at this time. + */ +} + + +/** + * Delete a query object. Called via ctx->Driver.DeleteQuery(). + * Not removed from hash table here. + */ +static void +_mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q) +{ + free(q); +} + + +void +_mesa_init_query_object_functions(struct dd_function_table *driver) +{ + driver->NewQueryObject = _mesa_new_query_object; + driver->DeleteQuery = _mesa_delete_query; + driver->BeginQuery = _mesa_begin_query; + driver->EndQuery = _mesa_end_query; + driver->WaitQuery = _mesa_wait_query; + driver->CheckQuery = _mesa_check_query; +} + + +/** + * Return pointer to the query object binding point for the given target. + * \return NULL if invalid target, else the address of binding point + */ +static struct gl_query_object ** +get_query_binding_point(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_SAMPLES_PASSED_ARB: + if (ctx->Extensions.ARB_occlusion_query) + return &ctx->Query.CurrentOcclusionObject; + else + return NULL; + case GL_ANY_SAMPLES_PASSED: + if (ctx->Extensions.ARB_occlusion_query2) + return &ctx->Query.CurrentOcclusionObject; + else + return NULL; + case GL_TIME_ELAPSED_EXT: + if (ctx->Extensions.EXT_timer_query) + return &ctx->Query.CurrentTimerObject; + else + return NULL; +#if FEATURE_EXT_transform_feedback + case GL_PRIMITIVES_GENERATED: + if (ctx->Extensions.EXT_transform_feedback) + return &ctx->Query.PrimitivesGenerated; + else + return NULL; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + if (ctx->Extensions.EXT_transform_feedback) + return &ctx->Query.PrimitivesWritten; + else + return NULL; +#endif + default: + return NULL; + } +} + + +void GLAPIENTRY +_mesa_GenQueriesARB(GLsizei n, GLuint *ids) +{ + GLuint first; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); + return; + } + + /* No query objects can be active at this time! */ + if (ctx->Query.CurrentOcclusionObject || + ctx->Query.CurrentTimerObject) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB"); + return; + } + + first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n); + if (first) { + GLsizei i; + for (i = 0; i < n; i++) { + struct gl_query_object *q + = ctx->Driver.NewQueryObject(ctx, first + i); + if (!q) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB"); + return; + } + ids[i] = first + i; + _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q); + } + } +} + + +void GLAPIENTRY +_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)"); + return; + } + + /* No query objects can be active at this time! */ + if (ctx->Query.CurrentOcclusionObject || + ctx->Query.CurrentTimerObject) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB"); + return; + } + + for (i = 0; i < n; i++) { + if (ids[i] > 0) { + struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]); + if (q) { + ASSERT(!q->Active); /* should be caught earlier */ + _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]); + ctx->Driver.DeleteQuery(ctx, q); + } + } + } +} + + +GLboolean GLAPIENTRY +_mesa_IsQueryARB(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (id && _mesa_lookup_query_object(ctx, id)) + return GL_TRUE; + else + return GL_FALSE; +} + + +static void GLAPIENTRY +_mesa_BeginQueryARB(GLenum target, GLuint id) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)"); + return; + } + + if (id == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)"); + return; + } + + q = _mesa_lookup_query_object(ctx, id); + if (!q) { + /* create new object */ + q = ctx->Driver.NewQueryObject(ctx, id); + if (!q) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB"); + return; + } + _mesa_HashInsert(ctx->Query.QueryObjects, id, q); + } + else { + /* pre-existing object */ + if (q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginQueryARB(query already active)"); + return; + } + } + + q->Target = target; + q->Active = GL_TRUE; + q->Result = 0; + q->Ready = GL_FALSE; + + /* XXX should probably refcount query objects */ + *bindpt = q; + + ctx->Driver.BeginQuery(ctx, q); +} + + +static void GLAPIENTRY +_mesa_EndQueryARB(GLenum target) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)"); + return; + } + + /* XXX should probably refcount query objects */ + q = *bindpt; + *bindpt = NULL; + + if (!q || !q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndQueryARB(no matching glBeginQueryARB)"); + return; + } + + q->Active = GL_FALSE; + ctx->Driver.EndQuery(ctx, q); +} + + +void GLAPIENTRY +_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); + return; + } + + q = *bindpt; + + switch (pname) { + case GL_QUERY_COUNTER_BITS_ARB: + *params = 8 * sizeof(q->Result); + break; + case GL_CURRENT_QUERY_ARB: + *params = q ? q->Id : 0; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)"); + return; + } +} + + +void GLAPIENTRY +_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectivARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + /* if result is too large for returned type, clamp to max value */ + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0x7fffffff) { + *params = 0x7fffffff; + } + else { + *params = (GLint)q->Result; + } + } + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)"); + return; + } +} + + +void GLAPIENTRY +_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectuivARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + /* if result is too large for returned type, clamp to max value */ + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0xffffffff) { + *params = 0xffffffff; + } + else { + *params = (GLuint)q->Result; + } + } + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)"); + return; + } +} + + +/** + * New with GL_EXT_timer_query + */ +static void GLAPIENTRY +_mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectui64vARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + *params = q->Result; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)"); + return; + } +} + + +/** + * New with GL_EXT_timer_query + */ +static void GLAPIENTRY +_mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + *params = q->Result; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)"); + return; + } +} + + +void +_mesa_init_queryobj_dispatch(struct _glapi_table *disp) +{ + SET_GenQueriesARB(disp, _mesa_GenQueriesARB); + SET_DeleteQueriesARB(disp, _mesa_DeleteQueriesARB); + SET_IsQueryARB(disp, _mesa_IsQueryARB); + SET_BeginQueryARB(disp, _mesa_BeginQueryARB); + SET_EndQueryARB(disp, _mesa_EndQueryARB); + SET_GetQueryivARB(disp, _mesa_GetQueryivARB); + SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB); + SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB); + + SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT); + SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT); +} + + +#endif /* FEATURE_queryobj */ + + +/** + * Allocate/init the context state related to query objects. + */ +void +_mesa_init_queryobj(struct gl_context *ctx) +{ + ctx->Query.QueryObjects = _mesa_NewHashTable(); + ctx->Query.CurrentOcclusionObject = NULL; +} + + +/** + * Callback for deleting a query object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_queryobj_cb(GLuint id, void *data, void *userData) +{ + struct gl_query_object *q= (struct gl_query_object *) data; + struct gl_context *ctx = (struct gl_context *)userData; + ctx->Driver.DeleteQuery(ctx, q); +} + + +/** + * Free the context state related to query objects. + */ +void +_mesa_free_queryobj_data(struct gl_context *ctx) +{ + _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); + _mesa_DeleteHashTable(ctx->Query.QueryObjects); +} diff --git a/mesalib/src/mesa/main/queryobj.h b/mesalib/src/mesa/main/queryobj.h index 8746ed15e..71a93de85 100644 --- a/mesalib/src/mesa/main/queryobj.h +++ b/mesalib/src/mesa/main/queryobj.h @@ -1,95 +1,95 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef QUERYOBJ_H -#define QUERYOBJ_H - - -#include "main/mtypes.h" -#include "main/hash.h" - - -#if FEATURE_queryobj - -static INLINE struct gl_query_object * -_mesa_lookup_query_object(GLcontext *ctx, GLuint id) -{ - return (struct gl_query_object *) - _mesa_HashLookup(ctx->Query.QueryObjects, id); -} - - -extern void GLAPIENTRY -_mesa_GenQueriesARB(GLsizei n, GLuint *ids); - -extern void GLAPIENTRY -_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids); - -extern GLboolean GLAPIENTRY -_mesa_IsQueryARB(GLuint id); - -extern void GLAPIENTRY -_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params); - -extern void -_mesa_init_query_object_functions(struct dd_function_table *driver); - -extern void -_mesa_init_queryobj_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_queryobj */ - -static INLINE struct gl_query_object * -_mesa_lookup_query_object(GLcontext *ctx, GLuint id) -{ - return NULL; -} - -static INLINE void -_mesa_init_query_object_functions(struct dd_function_table *driver) -{ -} - -static INLINE void -_mesa_init_queryobj_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_queryobj */ - -extern void -_mesa_init_queryobj(GLcontext *ctx); - -extern void -_mesa_free_queryobj_data(GLcontext *ctx); - - -#endif /* QUERYOBJ_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef QUERYOBJ_H +#define QUERYOBJ_H + + +#include "main/mtypes.h" +#include "main/hash.h" + + +#if FEATURE_queryobj + +static INLINE struct gl_query_object * +_mesa_lookup_query_object(struct gl_context *ctx, GLuint id) +{ + return (struct gl_query_object *) + _mesa_HashLookup(ctx->Query.QueryObjects, id); +} + + +extern void GLAPIENTRY +_mesa_GenQueriesARB(GLsizei n, GLuint *ids); + +extern void GLAPIENTRY +_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids); + +extern GLboolean GLAPIENTRY +_mesa_IsQueryARB(GLuint id); + +extern void GLAPIENTRY +_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params); + +extern void +_mesa_init_query_object_functions(struct dd_function_table *driver); + +extern void +_mesa_init_queryobj_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_queryobj */ + +static INLINE struct gl_query_object * +_mesa_lookup_query_object(struct gl_context *ctx, GLuint id) +{ + return NULL; +} + +static INLINE void +_mesa_init_query_object_functions(struct dd_function_table *driver) +{ +} + +static INLINE void +_mesa_init_queryobj_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_queryobj */ + +extern void +_mesa_init_queryobj(struct gl_context *ctx); + +extern void +_mesa_free_queryobj_data(struct gl_context *ctx); + + +#endif /* QUERYOBJ_H */ diff --git a/mesalib/src/mesa/main/rastpos.c b/mesalib/src/mesa/main/rastpos.c index 75c67f269..372b177c4 100644 --- a/mesalib/src/mesa/main/rastpos.c +++ b/mesalib/src/mesa/main/rastpos.c @@ -1,564 +1,564 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file rastpos.c - * Raster position operations. - */ - -#include "glheader.h" -#include "context.h" -#include "feedback.h" -#include "macros.h" -#include "rastpos.h" -#include "state.h" -#include "main/dispatch.h" - - -#if FEATURE_rastpos - - -/** - * Helper function for all the RasterPos functions. - */ -static void -rasterpos(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat p[4]; - - p[0] = x; - p[1] = y; - p[2] = z; - p[3] = w; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) - _mesa_update_state( ctx ); - - ctx->Driver.RasterPos(ctx, p); -} - - -static void GLAPIENTRY -_mesa_RasterPos2d(GLdouble x, GLdouble y) -{ - rasterpos((GLfloat)x, (GLfloat)y, (GLfloat)0.0, (GLfloat)1.0); -} - -static void GLAPIENTRY -_mesa_RasterPos2f(GLfloat x, GLfloat y) -{ - rasterpos(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2i(GLint x, GLint y) -{ - rasterpos((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2s(GLshort x, GLshort y) -{ - rasterpos(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - rasterpos(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3i(GLint x, GLint y, GLint z) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - rasterpos(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - rasterpos(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - rasterpos(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_RasterPos2dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos2sv(const GLshort *v) -{ - rasterpos(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos3sv(const GLshort *v) -{ - rasterpos(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_RasterPos4dv(const GLdouble *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4fv(const GLfloat *v) -{ - rasterpos(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4iv(const GLint *v) -{ - rasterpos((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_RasterPos4sv(const GLshort *v) -{ - rasterpos(v[0], v[1], v[2], v[3]); -} - - -/**********************************************************************/ -/*** GL_ARB_window_pos / GL_MESA_window_pos ***/ -/**********************************************************************/ - - -/** - * All glWindowPosMESA and glWindowPosARB commands call this function to - * update the current raster position. - */ -static void -window_pos3f(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat z2; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT(ctx, 0); - - z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near) - + ctx->Viewport.Near; - - /* set raster position */ - ctx->Current.RasterPos[0] = x; - ctx->Current.RasterPos[1] = y; - ctx->Current.RasterPos[2] = z2; - ctx->Current.RasterPos[3] = 1.0F; - - ctx->Current.RasterPosValid = GL_TRUE; - - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else - ctx->Current.RasterDistance = 0.0; - - /* raster color = current color or index */ - ctx->Current.RasterColor[0] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F); - ctx->Current.RasterColor[1] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F); - ctx->Current.RasterColor[2] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F); - ctx->Current.RasterColor[3] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F); - ctx->Current.RasterSecondaryColor[0] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F); - ctx->Current.RasterSecondaryColor[1] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F); - ctx->Current.RasterSecondaryColor[2] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F); - ctx->Current.RasterSecondaryColor[3] - = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F); - - /* raster texcoord = current texcoord */ - { - GLuint texSet; - for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { - assert(texSet < Elements(ctx->Current.RasterTexCoords)); - COPY_4FV( ctx->Current.RasterTexCoords[texSet], - ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); - } - } - - if (ctx->RenderMode==GL_SELECT) { - _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); - } -} - - -/* This is just to support the GL_MESA_window_pos version */ -static void -window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - window_pos3f(x, y, z); - ctx->Current.RasterPos[3] = w; -} - - -static void GLAPIENTRY -_mesa_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - window_pos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2iMESA(GLint x, GLint y) -{ - window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2sMESA(GLshort x, GLshort y) -{ - window_pos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - window_pos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - window_pos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - window_pos4f(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - window_pos4f(x, y, z, w); -} - -static void GLAPIENTRY -_mesa_WindowPos2dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos2svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], v[2], 1.0); -} - -static void GLAPIENTRY -_mesa_WindowPos3ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos3svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -_mesa_WindowPos4dvMESA(const GLdouble *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4fvMESA(const GLfloat *v) -{ - window_pos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4ivMESA(const GLint *v) -{ - window_pos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -_mesa_WindowPos4svMESA(const GLshort *v) -{ - window_pos4f(v[0], v[1], v[2], v[3]); -} - - -#if 0 - -/* - * OpenGL implementation of glWindowPos*MESA() - */ -void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - GLfloat fx, fy; - - /* Push current matrix mode and viewport attributes */ - glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT ); - - /* Setup projection parameters */ - glMatrixMode( GL_PROJECTION ); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode( GL_MODELVIEW ); - glPushMatrix(); - glLoadIdentity(); - - glDepthRange( z, z ); - glViewport( (int) x - 1, (int) y - 1, 2, 2 ); - - /* set the raster (window) position */ - fx = x - (int) x; - fy = y - (int) y; - glRasterPos4f( fx, fy, 0.0, w ); - - /* restore matrices, viewport and matrix mode */ - glPopMatrix(); - glMatrixMode( GL_PROJECTION ); - glPopMatrix(); - - glPopAttrib(); -} - -#endif - - -void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp) -{ - SET_RasterPos2f(disp, _mesa_RasterPos2f); - SET_RasterPos2fv(disp, _mesa_RasterPos2fv); - SET_RasterPos2i(disp, _mesa_RasterPos2i); - SET_RasterPos2iv(disp, _mesa_RasterPos2iv); - SET_RasterPos2d(disp, _mesa_RasterPos2d); - SET_RasterPos2dv(disp, _mesa_RasterPos2dv); - SET_RasterPos2s(disp, _mesa_RasterPos2s); - SET_RasterPos2sv(disp, _mesa_RasterPos2sv); - SET_RasterPos3d(disp, _mesa_RasterPos3d); - SET_RasterPos3dv(disp, _mesa_RasterPos3dv); - SET_RasterPos3f(disp, _mesa_RasterPos3f); - SET_RasterPos3fv(disp, _mesa_RasterPos3fv); - SET_RasterPos3i(disp, _mesa_RasterPos3i); - SET_RasterPos3iv(disp, _mesa_RasterPos3iv); - SET_RasterPos3s(disp, _mesa_RasterPos3s); - SET_RasterPos3sv(disp, _mesa_RasterPos3sv); - SET_RasterPos4d(disp, _mesa_RasterPos4d); - SET_RasterPos4dv(disp, _mesa_RasterPos4dv); - SET_RasterPos4f(disp, _mesa_RasterPos4f); - SET_RasterPos4fv(disp, _mesa_RasterPos4fv); - SET_RasterPos4i(disp, _mesa_RasterPos4i); - SET_RasterPos4iv(disp, _mesa_RasterPos4iv); - SET_RasterPos4s(disp, _mesa_RasterPos4s); - SET_RasterPos4sv(disp, _mesa_RasterPos4sv); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(disp, _mesa_WindowPos2dMESA); - SET_WindowPos2dvMESA(disp, _mesa_WindowPos2dvMESA); - SET_WindowPos2fMESA(disp, _mesa_WindowPos2fMESA); - SET_WindowPos2fvMESA(disp, _mesa_WindowPos2fvMESA); - SET_WindowPos2iMESA(disp, _mesa_WindowPos2iMESA); - SET_WindowPos2ivMESA(disp, _mesa_WindowPos2ivMESA); - SET_WindowPos2sMESA(disp, _mesa_WindowPos2sMESA); - SET_WindowPos2svMESA(disp, _mesa_WindowPos2svMESA); - SET_WindowPos3dMESA(disp, _mesa_WindowPos3dMESA); - SET_WindowPos3dvMESA(disp, _mesa_WindowPos3dvMESA); - SET_WindowPos3fMESA(disp, _mesa_WindowPos3fMESA); - SET_WindowPos3fvMESA(disp, _mesa_WindowPos3fvMESA); - SET_WindowPos3iMESA(disp, _mesa_WindowPos3iMESA); - SET_WindowPos3ivMESA(disp, _mesa_WindowPos3ivMESA); - SET_WindowPos3sMESA(disp, _mesa_WindowPos3sMESA); - SET_WindowPos3svMESA(disp, _mesa_WindowPos3svMESA); - SET_WindowPos4dMESA(disp, _mesa_WindowPos4dMESA); - SET_WindowPos4dvMESA(disp, _mesa_WindowPos4dvMESA); - SET_WindowPos4fMESA(disp, _mesa_WindowPos4fMESA); - SET_WindowPos4fvMESA(disp, _mesa_WindowPos4fvMESA); - SET_WindowPos4iMESA(disp, _mesa_WindowPos4iMESA); - SET_WindowPos4ivMESA(disp, _mesa_WindowPos4ivMESA); - SET_WindowPos4sMESA(disp, _mesa_WindowPos4sMESA); - SET_WindowPos4svMESA(disp, _mesa_WindowPos4svMESA); -} - - -#endif /* FEATURE_rastpos */ - - -/**********************************************************************/ -/** \name Initialization */ -/**********************************************************************/ -/*@{*/ - -/** - * Initialize the context current raster position information. - * - * \param ctx GL context. - * - * Initialize the current raster position information in - * __GLcontextRec::Current, and adds the extension entry points to the - * dispatcher. - */ -void _mesa_init_rastpos( GLcontext * ctx ) -{ - int i; - - ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 ); - ctx->Current.RasterDistance = 0.0; - ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); - ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); - for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++) - ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); - ctx->Current.RasterPosValid = GL_TRUE; -} - -/*@}*/ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file rastpos.c + * Raster position operations. + */ + +#include "glheader.h" +#include "context.h" +#include "feedback.h" +#include "macros.h" +#include "rastpos.h" +#include "state.h" +#include "main/dispatch.h" + + +#if FEATURE_rastpos + + +/** + * Helper function for all the RasterPos functions. + */ +static void +rasterpos(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat p[4]; + + p[0] = x; + p[1] = y; + p[2] = z; + p[3] = w; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) + _mesa_update_state( ctx ); + + ctx->Driver.RasterPos(ctx, p); +} + + +static void GLAPIENTRY +_mesa_RasterPos2d(GLdouble x, GLdouble y) +{ + rasterpos((GLfloat)x, (GLfloat)y, (GLfloat)0.0, (GLfloat)1.0); +} + +static void GLAPIENTRY +_mesa_RasterPos2f(GLfloat x, GLfloat y) +{ + rasterpos(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos2i(GLint x, GLint y) +{ + rasterpos((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos2s(GLshort x, GLshort y) +{ + rasterpos(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + rasterpos(x, y, z, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3i(GLint x, GLint y, GLint z) +{ + rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + rasterpos(x, y, z, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + rasterpos(x, y, z, w); +} + +static void GLAPIENTRY +_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + rasterpos(x, y, z, w); +} + +static void GLAPIENTRY +_mesa_RasterPos2dv(const GLdouble *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos2fv(const GLfloat *v) +{ + rasterpos(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos2iv(const GLint *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos2sv(const GLshort *v) +{ + rasterpos(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3dv(const GLdouble *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3fv(const GLfloat *v) +{ + rasterpos(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3iv(const GLint *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos3sv(const GLshort *v) +{ + rasterpos(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_RasterPos4dv(const GLdouble *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +_mesa_RasterPos4fv(const GLfloat *v) +{ + rasterpos(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +_mesa_RasterPos4iv(const GLint *v) +{ + rasterpos((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +_mesa_RasterPos4sv(const GLshort *v) +{ + rasterpos(v[0], v[1], v[2], v[3]); +} + + +/**********************************************************************/ +/*** GL_ARB_window_pos / GL_MESA_window_pos ***/ +/**********************************************************************/ + + +/** + * All glWindowPosMESA and glWindowPosARB commands call this function to + * update the current raster position. + */ +static void +window_pos3f(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat z2; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + FLUSH_CURRENT(ctx, 0); + + z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near) + + ctx->Viewport.Near; + + /* set raster position */ + ctx->Current.RasterPos[0] = x; + ctx->Current.RasterPos[1] = y; + ctx->Current.RasterPos[2] = z2; + ctx->Current.RasterPos[3] = 1.0F; + + ctx->Current.RasterPosValid = GL_TRUE; + + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; + else + ctx->Current.RasterDistance = 0.0; + + /* raster color = current color or index */ + ctx->Current.RasterColor[0] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F); + ctx->Current.RasterColor[1] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F); + ctx->Current.RasterColor[2] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F); + ctx->Current.RasterColor[3] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F); + ctx->Current.RasterSecondaryColor[0] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F); + ctx->Current.RasterSecondaryColor[1] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F); + ctx->Current.RasterSecondaryColor[2] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F); + ctx->Current.RasterSecondaryColor[3] + = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F); + + /* raster texcoord = current texcoord */ + { + GLuint texSet; + for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { + assert(texSet < Elements(ctx->Current.RasterTexCoords)); + COPY_4FV( ctx->Current.RasterTexCoords[texSet], + ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); + } + } + + if (ctx->RenderMode==GL_SELECT) { + _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); + } +} + + +/* This is just to support the GL_MESA_window_pos version */ +static void +window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + window_pos3f(x, y, z); + ctx->Current.RasterPos[3] = w; +} + + +static void GLAPIENTRY +_mesa_WindowPos2dMESA(GLdouble x, GLdouble y) +{ + window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2fMESA(GLfloat x, GLfloat y) +{ + window_pos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2iMESA(GLint x, GLint y) +{ + window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2sMESA(GLshort x, GLshort y) +{ + window_pos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) +{ + window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) +{ + window_pos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z) +{ + window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) +{ + window_pos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + window_pos4f(x, y, z, w); +} + +static void GLAPIENTRY +_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) +{ + window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) +{ + window_pos4f(x, y, z, w); +} + +static void GLAPIENTRY +_mesa_WindowPos2dvMESA(const GLdouble *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2fvMESA(const GLfloat *v) +{ + window_pos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2ivMESA(const GLint *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos2svMESA(const GLshort *v) +{ + window_pos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3dvMESA(const GLdouble *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3fvMESA(const GLfloat *v) +{ + window_pos4f(v[0], v[1], v[2], 1.0); +} + +static void GLAPIENTRY +_mesa_WindowPos3ivMESA(const GLint *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos3svMESA(const GLshort *v) +{ + window_pos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +_mesa_WindowPos4dvMESA(const GLdouble *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +_mesa_WindowPos4fvMESA(const GLfloat *v) +{ + window_pos4f(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +_mesa_WindowPos4ivMESA(const GLint *v) +{ + window_pos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +_mesa_WindowPos4svMESA(const GLshort *v) +{ + window_pos4f(v[0], v[1], v[2], v[3]); +} + + +#if 0 + +/* + * OpenGL implementation of glWindowPos*MESA() + */ +void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +{ + GLfloat fx, fy; + + /* Push current matrix mode and viewport attributes */ + glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT ); + + /* Setup projection parameters */ + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); + + glDepthRange( z, z ); + glViewport( (int) x - 1, (int) y - 1, 2, 2 ); + + /* set the raster (window) position */ + fx = x - (int) x; + fy = y - (int) y; + glRasterPos4f( fx, fy, 0.0, w ); + + /* restore matrices, viewport and matrix mode */ + glPopMatrix(); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + + glPopAttrib(); +} + +#endif + + +void +_mesa_init_rastpos_dispatch(struct _glapi_table *disp) +{ + SET_RasterPos2f(disp, _mesa_RasterPos2f); + SET_RasterPos2fv(disp, _mesa_RasterPos2fv); + SET_RasterPos2i(disp, _mesa_RasterPos2i); + SET_RasterPos2iv(disp, _mesa_RasterPos2iv); + SET_RasterPos2d(disp, _mesa_RasterPos2d); + SET_RasterPos2dv(disp, _mesa_RasterPos2dv); + SET_RasterPos2s(disp, _mesa_RasterPos2s); + SET_RasterPos2sv(disp, _mesa_RasterPos2sv); + SET_RasterPos3d(disp, _mesa_RasterPos3d); + SET_RasterPos3dv(disp, _mesa_RasterPos3dv); + SET_RasterPos3f(disp, _mesa_RasterPos3f); + SET_RasterPos3fv(disp, _mesa_RasterPos3fv); + SET_RasterPos3i(disp, _mesa_RasterPos3i); + SET_RasterPos3iv(disp, _mesa_RasterPos3iv); + SET_RasterPos3s(disp, _mesa_RasterPos3s); + SET_RasterPos3sv(disp, _mesa_RasterPos3sv); + SET_RasterPos4d(disp, _mesa_RasterPos4d); + SET_RasterPos4dv(disp, _mesa_RasterPos4dv); + SET_RasterPos4f(disp, _mesa_RasterPos4f); + SET_RasterPos4fv(disp, _mesa_RasterPos4fv); + SET_RasterPos4i(disp, _mesa_RasterPos4i); + SET_RasterPos4iv(disp, _mesa_RasterPos4iv); + SET_RasterPos4s(disp, _mesa_RasterPos4s); + SET_RasterPos4sv(disp, _mesa_RasterPos4sv); + + /* 197. GL_MESA_window_pos */ + SET_WindowPos2dMESA(disp, _mesa_WindowPos2dMESA); + SET_WindowPos2dvMESA(disp, _mesa_WindowPos2dvMESA); + SET_WindowPos2fMESA(disp, _mesa_WindowPos2fMESA); + SET_WindowPos2fvMESA(disp, _mesa_WindowPos2fvMESA); + SET_WindowPos2iMESA(disp, _mesa_WindowPos2iMESA); + SET_WindowPos2ivMESA(disp, _mesa_WindowPos2ivMESA); + SET_WindowPos2sMESA(disp, _mesa_WindowPos2sMESA); + SET_WindowPos2svMESA(disp, _mesa_WindowPos2svMESA); + SET_WindowPos3dMESA(disp, _mesa_WindowPos3dMESA); + SET_WindowPos3dvMESA(disp, _mesa_WindowPos3dvMESA); + SET_WindowPos3fMESA(disp, _mesa_WindowPos3fMESA); + SET_WindowPos3fvMESA(disp, _mesa_WindowPos3fvMESA); + SET_WindowPos3iMESA(disp, _mesa_WindowPos3iMESA); + SET_WindowPos3ivMESA(disp, _mesa_WindowPos3ivMESA); + SET_WindowPos3sMESA(disp, _mesa_WindowPos3sMESA); + SET_WindowPos3svMESA(disp, _mesa_WindowPos3svMESA); + SET_WindowPos4dMESA(disp, _mesa_WindowPos4dMESA); + SET_WindowPos4dvMESA(disp, _mesa_WindowPos4dvMESA); + SET_WindowPos4fMESA(disp, _mesa_WindowPos4fMESA); + SET_WindowPos4fvMESA(disp, _mesa_WindowPos4fvMESA); + SET_WindowPos4iMESA(disp, _mesa_WindowPos4iMESA); + SET_WindowPos4ivMESA(disp, _mesa_WindowPos4ivMESA); + SET_WindowPos4sMESA(disp, _mesa_WindowPos4sMESA); + SET_WindowPos4svMESA(disp, _mesa_WindowPos4svMESA); +} + + +#endif /* FEATURE_rastpos */ + + +/**********************************************************************/ +/** \name Initialization */ +/**********************************************************************/ +/*@{*/ + +/** + * Initialize the context current raster position information. + * + * \param ctx GL context. + * + * Initialize the current raster position information in + * __struct gl_contextRec::Current, and adds the extension entry points to the + * dispatcher. + */ +void _mesa_init_rastpos( struct gl_context * ctx ) +{ + int i; + + ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 ); + ctx->Current.RasterDistance = 0.0; + ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); + ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); + for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++) + ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); + ctx->Current.RasterPosValid = GL_TRUE; +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/rastpos.h b/mesalib/src/mesa/main/rastpos.h index 4994616d4..a530ddd76 100644 --- a/mesalib/src/mesa/main/rastpos.h +++ b/mesalib/src/mesa/main/rastpos.h @@ -1,57 +1,60 @@ -/** - * \file rastpos.h - * Raster position operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef RASTPOS_H -#define RASTPOS_H - - -#include "main/mtypes.h" - - -#if FEATURE_rastpos - -extern void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_rastpos */ - -static INLINE void -_mesa_init_rastpos_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_rastpos */ - -extern void -_mesa_init_rastpos(GLcontext *ctx); - -/*@}*/ - -#endif /* RASTPOS_H */ +/** + * \file rastpos.h + * Raster position operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef RASTPOS_H +#define RASTPOS_H + + +#include "compiler.h" +#include "mfeatures.h" + +struct _glapi_table; +struct gl_context; + +#if FEATURE_rastpos + +extern void +_mesa_init_rastpos_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_rastpos */ + +static INLINE void +_mesa_init_rastpos_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_rastpos */ + +extern void +_mesa_init_rastpos(struct gl_context *ctx); + +/*@}*/ + +#endif /* RASTPOS_H */ diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 93f2bd31c..986dbb60a 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -1,208 +1,234 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "glheader.h" -#include "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "readpix.h" -#include "framebuffer.h" -#include "image.h" -#include "state.h" - - -/** - * Do error checking of the format/type parameters to glReadPixels and - * glDrawPixels. - * \param drawing if GL_TRUE do checking for DrawPixels, else do checking - * for ReadPixels. - * \return GL_TRUE if error detected, GL_FALSE if no errors - */ -GLboolean -_mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type, - GLboolean drawing) -{ - const char *readDraw = drawing ? "Draw" : "Read"; - const GLboolean reading = !drawing; - - /* state validation should have already been done */ - ASSERT(ctx->NewState == 0x0); - - if (ctx->Extensions.EXT_packed_depth_stencil - && type == GL_UNSIGNED_INT_24_8_EXT - && format != GL_DEPTH_STENCIL_EXT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); - return GL_TRUE; - } - - /* basic combinations test */ - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sPixels(format or type)", readDraw); - return GL_TRUE; - } - - /* additional checks */ - switch (format) { - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - if (!drawing) { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - } - break; - case GL_COLOR_INDEX: - if (drawing) { - if (ctx->PixelMaps.ItoR.Size == 0 || - ctx->PixelMaps.ItoG.Size == 0 || - ctx->PixelMaps.ItoB.Size == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(drawing color index pixels into RGB buffer)"); - return GL_TRUE; - } - } - else { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - /* We no longer support CI-mode color buffers so trying to read - * GL_COLOR_INDEX pixels is always an error. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(color buffer is RGB)"); - return GL_TRUE; - } - break; - case GL_STENCIL_INDEX: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no stencil buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_COMPONENT: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_STENCIL_EXT: - if (!ctx->Extensions.EXT_packed_depth_stencil || - type != GL_UNSIGNED_INT_24_8_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth or stencil buffer)", readDraw); - return GL_TRUE; - } - break; - default: - /* this should have been caught in _mesa_is_legal_format_type() */ - _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); - return GL_TRUE; - } - - /* no errors */ - return GL_FALSE; -} - - - -void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glReadPixels(width=%d height=%d)", width, height ); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { - /* found an error */ - return; - } - - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glReadPixels(incomplete framebuffer)" ); - return; - } - - if (!_mesa_source_buffer_exists(ctx, format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)"); - return; - } - - if (width == 0 || height == 0) - return; /* nothing to do */ - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(invalid PBO access)"); - return; - } - - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); - return; - } - } - - ctx->Driver.ReadPixels(ctx, x, y, width, height, - format, type, &ctx->Pack, pixels); -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "glheader.h" +#include "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "readpix.h" +#include "framebuffer.h" +#include "formats.h" +#include "image.h" +#include "state.h" + + +/** + * Do error checking of the format/type parameters to glReadPixels and + * glDrawPixels. + * \param drawing if GL_TRUE do checking for DrawPixels, else do checking + * for ReadPixels. + * \return GL_TRUE if error detected, GL_FALSE if no errors + */ +GLboolean +_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type, + GLboolean drawing) +{ + const char *readDraw = drawing ? "Draw" : "Read"; + const GLboolean reading = !drawing; + + /* state validation should have already been done */ + ASSERT(ctx->NewState == 0x0); + + if (ctx->Extensions.EXT_packed_depth_stencil + && type == GL_UNSIGNED_INT_24_8_EXT + && format != GL_DEPTH_STENCIL_EXT) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); + return GL_TRUE; + } + + /* basic combinations test */ + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "gl%sPixels(format or type)", readDraw); + return GL_TRUE; + } + + /* additional checks */ + switch (format) { + case GL_RG: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + if (!drawing) { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } + } + break; + case GL_COLOR_INDEX: + if (drawing) { + if (ctx->PixelMaps.ItoR.Size == 0 || + ctx->PixelMaps.ItoG.Size == 0 || + ctx->PixelMaps.ItoB.Size == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(drawing color index pixels into RGB buffer)"); + return GL_TRUE; + } + } + else { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } + /* We no longer support CI-mode color buffers so trying to read + * GL_COLOR_INDEX pixels is always an error. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(color buffer is RGB)"); + return GL_TRUE; + } + break; + case GL_STENCIL_INDEX: + if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || + (reading && !_mesa_source_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no stencil buffer)", readDraw); + return GL_TRUE; + } + break; + case GL_DEPTH_COMPONENT: + if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no depth buffer)", readDraw); + return GL_TRUE; + } + break; + case GL_DEPTH_STENCIL_EXT: + if (!ctx->Extensions.EXT_packed_depth_stencil || + type != GL_UNSIGNED_INT_24_8_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); + return GL_TRUE; + } + if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || + (reading && !_mesa_source_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no depth or stencil buffer)", readDraw); + return GL_TRUE; + } + break; + default: + /* this should have been caught in _mesa_is_legal_format_type() */ + _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); + return GL_TRUE; + } + + /* no errors */ + return GL_FALSE; +} + + + +void GLAPIENTRY +_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + "glReadPixels(width=%d height=%d)", width, height ); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { + /* found an error */ + return; + } + + /* Check that the destination format and source buffer are both + * integer-valued or both non-integer-valued. + */ + if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) { + const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format); + const GLboolean dstInteger = _mesa_is_integer_format(format); + if (dstInteger != srcInteger) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(integer / non-integer format mismatch"); + return; + } + } + + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glReadPixels(incomplete framebuffer)" ); + return; + } + + if (!_mesa_source_buffer_exists(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)"); + return; + } + + if (width == 0 || height == 0) + return; /* nothing to do */ + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(invalid PBO access)"); + return; + } + + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); + return; + } + } + + ctx->Driver.ReadPixels(ctx, x, y, width, height, + format, type, &ctx->Pack, pixels); +} diff --git a/mesalib/src/mesa/main/readpix.h b/mesalib/src/mesa/main/readpix.h index 1bf02fb8e..4ed5eb5a4 100644 --- a/mesalib/src/mesa/main/readpix.h +++ b/mesalib/src/mesa/main/readpix.h @@ -1,42 +1,43 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef READPIXELS_H -#define READPIXELS_H - - -#include "main/mtypes.h" - - -extern GLboolean -_mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type, - GLboolean drawing); - -extern void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef READPIXELS_H +#define READPIXELS_H + + +#include "glheader.h" + +struct gl_context; + +extern GLboolean +_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type, + GLboolean drawing); + +extern void GLAPIENTRY +_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ); + + +#endif diff --git a/mesalib/src/mesa/main/remap.c b/mesalib/src/mesa/main/remap.c index 2341f8488..6da31deb3 100644 --- a/mesalib/src/mesa/main/remap.c +++ b/mesalib/src/mesa/main/remap.c @@ -1,190 +1,226 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - - -/** - * \file remap.c - * Remap table management. - * - * Entries in the dispatch table are either static or dynamic. The - * dispatch table is shared by mesa core and glapi. When they are - * built separately, it is possible that a static entry in mesa core - * is dynamic, or assigned a different static offset, in glapi. The - * remap table is in charge of mapping a static entry in mesa core to - * a dynamic entry, or the corresponding static entry, in glapi. - */ - -#include "mfeatures.h" - -#if FEATURE_remap_table - -#include "remap.h" -#include "imports.h" -#include "glapi/glapi.h" - -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) -#define MAX_ENTRY_POINTS 16 - -static const char *_mesa_function_pool; - -/** - * Return the spec string associated with the given function index. - * The index is available from including remap_helper.h. - * - * \param func_index an opaque function index. - * - * \return the spec string associated with the function index, or NULL. - */ -const char * -_mesa_get_function_spec(GLint func_index) -{ - return _mesa_function_pool + func_index; -} - - -/** - * Map a function by its spec. The function will be added to glapi, - * and the dispatch offset will be returned. - * - * \param spec a '\0'-separated string array specifying a function. - * It begins with the parameter signature of the function, - * followed by the names of the entry points. An empty entry - * point name terminates the array. - * - * \return the offset of the (re-)mapped function in the dispatch - * table, or -1. - */ -GLint -_mesa_map_function_spec(const char *spec) -{ - const char *signature; - const char *names[MAX_ENTRY_POINTS + 1]; - GLint num_names = 0; - - if (!spec) - return -1; - - signature = spec; - spec += strlen(spec) + 1; - - /* spec is terminated by an empty string */ - while (*spec) { - names[num_names] = spec; - num_names++; - if (num_names >= MAX_ENTRY_POINTS) - break; - spec += strlen(spec) + 1; - } - if (!num_names) - return -1; - - names[num_names] = NULL; - - /* add the entry points to the dispatch table */ - return _glapi_add_dispatch(names, signature); -} - - -/** - * Map an array of functions. This is a convenient function for - * use with arrays available from including remap_helper.h. - * - * Note that the dispatch offsets of the functions are not returned. - * If they are needed, _mesa_map_function_spec() should be used. - * - * \param func_array an array of function remaps. - */ -void -_mesa_map_function_array(const struct gl_function_remap *func_array) -{ - GLint i; - - if (!func_array) - return; - - for (i = 0; func_array[i].func_index != -1; i++) { - const char *spec; - GLint offset; - - spec = _mesa_get_function_spec(func_array[i].func_index); - if (!spec) { - _mesa_problem(NULL, "invalid function index %d", - func_array[i].func_index); - continue; - } - - offset = _mesa_map_function_spec(spec); - /* error checks */ - if (offset < 0) { - const char *name = spec + strlen(spec) + 1; - _mesa_warning(NULL, "failed to remap %s", name); - } - else if (func_array[i].dispatch_offset >= 0 && - offset != func_array[i].dispatch_offset) { - const char *name = spec + strlen(spec) + 1; - _mesa_problem(NULL, "%s should be mapped to %d, not %d", - name, func_array[i].dispatch_offset, offset); - } - } -} - - -/** - * Initialize the remap table. This is called in one_time_init(). - * The remap table needs to be initialized before calling the - * CALL/GET/SET macros defined in main/dispatch.h. - */ -void -_mesa_do_init_remap_table(const char *pool, - int size, - const struct gl_function_pool_remap *remap) -{ - static GLboolean initialized = GL_FALSE; - GLint i; - - if (initialized) - return; - initialized = GL_TRUE; - _mesa_function_pool = pool; - - /* initialize the remap table */ - for (i = 0; i < size; i++) { - GLint offset; - const char *spec; - - /* sanity check */ - ASSERT(i == remap[i].remap_index); - spec = _mesa_function_pool + remap[i].pool_index; - - offset = _mesa_map_function_spec(spec); - /* store the dispatch offset in the remap table */ - driDispatchRemapTable[i] = offset; - if (offset < 0) - _mesa_warning(NULL, "failed to remap index %d", i); - } -} - - -#endif /* FEATURE_remap_table */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + + +/** + * \file remap.c + * Remap table management. + * + * Entries in the dispatch table are either static or dynamic. The + * dispatch table is shared by mesa core and glapi. When they are + * built separately, it is possible that a static entry in mesa core + * is dynamic, or assigned a different static offset, in glapi. The + * remap table is in charge of mapping a static entry in mesa core to + * a dynamic entry, or the corresponding static entry, in glapi. + */ + +#include "mfeatures.h" + +#if FEATURE_remap_table + +#include "remap.h" +#include "imports.h" +#include "glapi/glapi.h" + +#define MAX_ENTRY_POINTS 16 + +#define need_MESA_remap_table +#include "main/remap_helper.h" + + +/* this is global for quick access */ +int driDispatchRemapTable[driDispatchRemapTable_size]; + + +/** + * Return the spec string associated with the given function index. + * The index is available from including remap_helper.h. + * + * \param func_index an opaque function index. + * + * \return the spec string associated with the function index, or NULL. + */ +const char * +_mesa_get_function_spec(GLint func_index) +{ + if (func_index < Elements(_mesa_function_pool)) + return _mesa_function_pool + func_index; + else + return NULL; +} + + +/** + * Map a function by its spec. The function will be added to glapi, + * and the dispatch offset will be returned. + * + * \param spec a '\0'-separated string array specifying a function. + * It begins with the parameter signature of the function, + * followed by the names of the entry points. An empty entry + * point name terminates the array. + * + * \return the offset of the (re-)mapped function in the dispatch + * table, or -1. + */ +GLint +_mesa_map_function_spec(const char *spec) +{ + const char *signature; + const char *names[MAX_ENTRY_POINTS + 1]; + GLint num_names = 0; + + if (!spec) + return -1; + + signature = spec; + spec += strlen(spec) + 1; + + /* spec is terminated by an empty string */ + while (*spec) { + names[num_names] = spec; + num_names++; + if (num_names >= MAX_ENTRY_POINTS) + break; + spec += strlen(spec) + 1; + } + if (!num_names) + return -1; + + names[num_names] = NULL; + + /* add the entry points to the dispatch table */ + return _glapi_add_dispatch(names, signature); +} + + +/** + * Map an array of functions. This is a convenient function for + * use with arrays available from including remap_helper.h. + * + * Note that the dispatch offsets of the functions are not returned. + * If they are needed, _mesa_map_function_spec() should be used. + * + * \param func_array an array of function remaps. + */ +void +_mesa_map_function_array(const struct gl_function_remap *func_array) +{ + GLint i; + + if (!func_array) + return; + + for (i = 0; func_array[i].func_index != -1; i++) { + const char *spec; + GLint offset; + + spec = _mesa_get_function_spec(func_array[i].func_index); + if (!spec) { + _mesa_problem(NULL, "invalid function index %d", + func_array[i].func_index); + continue; + } + + offset = _mesa_map_function_spec(spec); + /* error checks */ + if (offset < 0) { + const char *name = spec + strlen(spec) + 1; + _mesa_warning(NULL, "failed to remap %s", name); + } + else if (func_array[i].dispatch_offset >= 0 && + offset != func_array[i].dispatch_offset) { + const char *name = spec + strlen(spec) + 1; + _mesa_problem(NULL, "%s should be mapped to %d, not %d", + name, func_array[i].dispatch_offset, offset); + } + } +} + + +/** + * Map the functions which are already static. + * + * When a extension function are incorporated into the ABI, the + * extension suffix is usually stripped. Mapping such functions + * makes sure the alternative names are available. + * + * Note that functions mapped by _mesa_init_remap_table() are + * excluded. + */ +void +_mesa_map_static_functions(void) +{ + /* Remap static functions which have alternative names and are in the ABI. + * This is to be on the safe side. glapi should have defined those names. + */ + _mesa_map_function_array(MESA_alt_functions); +} + + +/** + * Initialize the remap table. This is called in one_time_init(). + * The remap table needs to be initialized before calling the + * CALL/GET/SET macros defined in main/dispatch.h. + */ +static void +_mesa_do_init_remap_table(const char *pool, + int size, + const struct gl_function_pool_remap *remap) +{ + static GLboolean initialized = GL_FALSE; + GLint i; + + if (initialized) + return; + initialized = GL_TRUE; + + /* initialize the remap table */ + for (i = 0; i < size; i++) { + GLint offset; + const char *spec; + + /* sanity check */ + ASSERT(i == remap[i].remap_index); + spec = _mesa_function_pool + remap[i].pool_index; + + offset = _mesa_map_function_spec(spec); + /* store the dispatch offset in the remap table */ + driDispatchRemapTable[i] = offset; + if (offset < 0) + _mesa_warning(NULL, "failed to remap index %d", i); + } +} + + +void +_mesa_init_remap_table(void) +{ + _mesa_do_init_remap_table(_mesa_function_pool, + driDispatchRemapTable_size, + MESA_remap_table_functions); +} + + +#endif /* FEATURE_remap_table */ diff --git a/mesalib/src/mesa/main/remap.h b/mesalib/src/mesa/main/remap.h index a2a55f615..ae91a35d9 100644 --- a/mesalib/src/mesa/main/remap.h +++ b/mesalib/src/mesa/main/remap.h @@ -1,142 +1,98 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - - -#ifndef REMAP_H -#define REMAP_H - - -#include "main/compiler.h" -#include "main/mfeatures.h" - -struct gl_function_pool_remap { - int pool_index; - int remap_index; -}; - -struct gl_function_remap { - int func_index; - int dispatch_offset; /* for sanity check */ -}; - - -#if FEATURE_remap_table - -extern int -driDispatchRemapTable[]; - -extern const char * -_mesa_get_function_spec(int func_index); - -extern int -_mesa_map_function_spec(const char *spec); - -extern void -_mesa_map_function_array(const struct gl_function_remap *func_array); - -extern void -_mesa_map_static_functions(void); - -extern void -_mesa_map_static_functions_es1(void); - -extern void -_mesa_map_static_functions_es2(void); - -extern void -_mesa_do_init_remap_table(const char *pool, - int size, - const struct gl_function_pool_remap *remap); - -extern void -_mesa_init_remap_table(void); - -extern void -_mesa_init_remap_table_es1(void); - -extern void -_mesa_init_remap_table_es2(void); - -#else /* FEATURE_remap_table */ - -static INLINE const char * -_mesa_get_function_spec(int func_index) -{ - return NULL; -} - -static INLINE int -_mesa_map_function_spec(const char *spec) -{ - return -1; -} - -static INLINE void -_mesa_map_function_array(const struct gl_function_remap *func_array) -{ -} - -static INLINE void -_mesa_map_static_functions(void) -{ -} - - -static INLINE void -_mesa_map_static_functions_es1(void) -{ -} - -static INLINE void -_mesa_map_static_functions_es2(void) -{ -} - -static INLINE void -_mesa_do_init_remap_table(const char *pool, - int size, - const struct gl_function_pool_remap *remap) -{ -} - -static INLINE void -_mesa_init_remap_table(void) -{ -} - -static INLINE void -_mesa_init_remap_table_es1(void) -{ -} - -static INLINE void -_mesa_init_remap_table_es2(void) -{ -} - -#endif /* FEATURE_remap_table */ - - -#endif /* REMAP_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + + +#ifndef REMAP_H +#define REMAP_H + + +#include "main/compiler.h" +#include "main/mfeatures.h" + +struct gl_function_pool_remap { + int pool_index; + int remap_index; +}; + +struct gl_function_remap { + int func_index; + int dispatch_offset; /* for sanity check */ +}; + + +#if FEATURE_remap_table + +extern int +driDispatchRemapTable[]; + +extern const char * +_mesa_get_function_spec(int func_index); + +extern int +_mesa_map_function_spec(const char *spec); + +extern void +_mesa_map_function_array(const struct gl_function_remap *func_array); + +extern void +_mesa_map_static_functions(void); + +extern void +_mesa_init_remap_table(void); + +#else /* FEATURE_remap_table */ + +static INLINE const char * +_mesa_get_function_spec(int func_index) +{ + return NULL; +} + +static INLINE int +_mesa_map_function_spec(const char *spec) +{ + return -1; +} + +static INLINE void +_mesa_map_function_array(const struct gl_function_remap *func_array) +{ +} + +static INLINE void +_mesa_map_static_functions(void) +{ +} + + +static INLINE void +_mesa_init_remap_table(void) +{ +} + +#endif /* FEATURE_remap_table */ + + +#endif /* REMAP_H */ diff --git a/mesalib/src/mesa/main/remap_helper.h b/mesalib/src/mesa/main/remap_helper.h index 631cc9015..962b08217 100644 --- a/mesalib/src/mesa/main/remap_helper.h +++ b/mesalib/src/mesa/main/remap_helper.h @@ -1,6136 +1,6504 @@ -/* DO NOT EDIT - This file generated automatically by remap_helper.py (from Mesa) script */ - -/* - * Copyright (C) 2009 Chia-I Wu - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * Chia-I Wu, - * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "main/dispatch.h" -#include "main/remap.h" - -/* this is internal to remap.c */ -#ifdef need_MESA_remap_table - -static const char _mesa_function_pool[] = - /* _mesa_function_pool[0]: MapGrid1d (offset 224) */ - "idd\0" - "glMapGrid1d\0" - "\0" - /* _mesa_function_pool[17]: UniformMatrix3fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix3fv\0" - "glUniformMatrix3fvARB\0" - "\0" - /* _mesa_function_pool[64]: MapGrid1f (offset 225) */ - "iff\0" - "glMapGrid1f\0" - "\0" - /* _mesa_function_pool[81]: RasterPos4i (offset 82) */ - "iiii\0" - "glRasterPos4i\0" - "\0" - /* _mesa_function_pool[101]: RasterPos4d (offset 78) */ - "dddd\0" - "glRasterPos4d\0" - "\0" - /* _mesa_function_pool[121]: NewList (dynamic) */ - "ii\0" - "glNewList\0" - "\0" - /* _mesa_function_pool[135]: RasterPos4f (offset 80) */ - "ffff\0" - "glRasterPos4f\0" - "\0" - /* _mesa_function_pool[155]: LoadIdentity (offset 290) */ - "\0" - "glLoadIdentity\0" - "\0" - /* _mesa_function_pool[172]: SampleCoverageARB (will be remapped) */ - "fi\0" - "glSampleCoverage\0" - "glSampleCoverageARB\0" - "\0" - /* _mesa_function_pool[213]: ConvolutionFilter1D (offset 348) */ - "iiiiip\0" - "glConvolutionFilter1D\0" - "glConvolutionFilter1DEXT\0" - "\0" - /* _mesa_function_pool[268]: BeginQueryARB (will be remapped) */ - "ii\0" - "glBeginQuery\0" - "glBeginQueryARB\0" - "\0" - /* _mesa_function_pool[301]: RasterPos3dv (offset 71) */ - "p\0" - "glRasterPos3dv\0" - "\0" - /* _mesa_function_pool[319]: PointParameteriNV (will be remapped) */ - "ii\0" - "glPointParameteri\0" - "glPointParameteriNV\0" - "\0" - /* _mesa_function_pool[361]: GetProgramiv (will be remapped) */ - "iip\0" - "glGetProgramiv\0" - "\0" - /* _mesa_function_pool[381]: MultiTexCoord3sARB (offset 398) */ - "iiii\0" - "glMultiTexCoord3s\0" - "glMultiTexCoord3sARB\0" - "\0" - /* _mesa_function_pool[426]: SecondaryColor3iEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3i\0" - "glSecondaryColor3iEXT\0" - "\0" - /* _mesa_function_pool[472]: WindowPos3fMESA (will be remapped) */ - "fff\0" - "glWindowPos3f\0" - "glWindowPos3fARB\0" - "glWindowPos3fMESA\0" - "\0" - /* _mesa_function_pool[526]: TexCoord1iv (offset 99) */ - "p\0" - "glTexCoord1iv\0" - "\0" - /* _mesa_function_pool[543]: TexCoord4sv (offset 125) */ - "p\0" - "glTexCoord4sv\0" - "\0" - /* _mesa_function_pool[560]: RasterPos4s (offset 84) */ - "iiii\0" - "glRasterPos4s\0" - "\0" - /* _mesa_function_pool[580]: PixelTexGenParameterfvSGIS (will be remapped) */ - "ip\0" - "glPixelTexGenParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[613]: ActiveTextureARB (offset 374) */ - "i\0" - "glActiveTexture\0" - "glActiveTextureARB\0" - "\0" - /* _mesa_function_pool[651]: BlitFramebufferEXT (will be remapped) */ - "iiiiiiiiii\0" - "glBlitFramebuffer\0" - "glBlitFramebufferEXT\0" - "\0" - /* _mesa_function_pool[702]: TexCoord1f (offset 96) */ - "f\0" - "glTexCoord1f\0" - "\0" - /* _mesa_function_pool[718]: TexCoord1d (offset 94) */ - "d\0" - "glTexCoord1d\0" - "\0" - /* _mesa_function_pool[734]: VertexAttrib4ubvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4ubvNV\0" - "\0" - /* _mesa_function_pool[759]: TexCoord1i (offset 98) */ - "i\0" - "glTexCoord1i\0" - "\0" - /* _mesa_function_pool[775]: GetProgramNamedParameterdvNV (will be remapped) */ - "iipp\0" - "glGetProgramNamedParameterdvNV\0" - "\0" - /* _mesa_function_pool[812]: Histogram (offset 367) */ - "iiii\0" - "glHistogram\0" - "glHistogramEXT\0" - "\0" - /* _mesa_function_pool[845]: TexCoord1s (offset 100) */ - "i\0" - "glTexCoord1s\0" - "\0" - /* _mesa_function_pool[861]: GetMapfv (offset 267) */ - "iip\0" - "glGetMapfv\0" - "\0" - /* _mesa_function_pool[877]: EvalCoord1f (offset 230) */ - "f\0" - "glEvalCoord1f\0" - "\0" - /* _mesa_function_pool[894]: TexImage4DSGIS (dynamic) */ - "iiiiiiiiiip\0" - "glTexImage4DSGIS\0" - "\0" - /* _mesa_function_pool[924]: PolygonStipple (offset 175) */ - "p\0" - "glPolygonStipple\0" - "\0" - /* _mesa_function_pool[944]: WindowPos2dvMESA (will be remapped) */ - "p\0" - "glWindowPos2dv\0" - "glWindowPos2dvARB\0" - "glWindowPos2dvMESA\0" - "\0" - /* _mesa_function_pool[999]: ReplacementCodeuiColor3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1043]: BlendEquationSeparateEXT (will be remapped) */ - "ii\0" - "glBlendEquationSeparate\0" - "glBlendEquationSeparateEXT\0" - "glBlendEquationSeparateATI\0" - "\0" - /* _mesa_function_pool[1125]: ListParameterfSGIX (dynamic) */ - "iif\0" - "glListParameterfSGIX\0" - "\0" - /* _mesa_function_pool[1151]: SecondaryColor3bEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3b\0" - "glSecondaryColor3bEXT\0" - "\0" - /* _mesa_function_pool[1197]: TexCoord4fColor4fNormal3fVertex4fvSUN (dynamic) */ - "pppp\0" - "glTexCoord4fColor4fNormal3fVertex4fvSUN\0" - "\0" - /* _mesa_function_pool[1243]: GetPixelMapfv (offset 271) */ - "ip\0" - "glGetPixelMapfv\0" - "\0" - /* _mesa_function_pool[1263]: Color3uiv (offset 22) */ - "p\0" - "glColor3uiv\0" - "\0" - /* _mesa_function_pool[1278]: IsEnabled (offset 286) */ - "i\0" - "glIsEnabled\0" - "\0" - /* _mesa_function_pool[1293]: VertexAttrib4svNV (will be remapped) */ - "ip\0" - "glVertexAttrib4svNV\0" - "\0" - /* _mesa_function_pool[1317]: EvalCoord2fv (offset 235) */ - "p\0" - "glEvalCoord2fv\0" - "\0" - /* _mesa_function_pool[1335]: GetBufferSubDataARB (will be remapped) */ - "iiip\0" - "glGetBufferSubData\0" - "glGetBufferSubDataARB\0" - "\0" - /* _mesa_function_pool[1382]: BufferSubDataARB (will be remapped) */ - "iiip\0" - "glBufferSubData\0" - "glBufferSubDataARB\0" - "\0" - /* _mesa_function_pool[1423]: TexCoord2fColor4ubVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1461]: AttachShader (will be remapped) */ - "ii\0" - "glAttachShader\0" - "\0" - /* _mesa_function_pool[1480]: VertexAttrib2fARB (will be remapped) */ - "iff\0" - "glVertexAttrib2f\0" - "glVertexAttrib2fARB\0" - "\0" - /* _mesa_function_pool[1522]: GetDebugLogLengthMESA (dynamic) */ - "iii\0" - "glGetDebugLogLengthMESA\0" - "\0" - /* _mesa_function_pool[1551]: GetMapiv (offset 268) */ - "iip\0" - "glGetMapiv\0" - "\0" - /* _mesa_function_pool[1567]: VertexAttrib3fARB (will be remapped) */ - "ifff\0" - "glVertexAttrib3f\0" - "glVertexAttrib3fARB\0" - "\0" - /* _mesa_function_pool[1610]: Indexubv (offset 316) */ - "p\0" - "glIndexubv\0" - "\0" - /* _mesa_function_pool[1624]: GetQueryivARB (will be remapped) */ - "iip\0" - "glGetQueryiv\0" - "glGetQueryivARB\0" - "\0" - /* _mesa_function_pool[1658]: TexImage3D (offset 371) */ - "iiiiiiiiip\0" - "glTexImage3D\0" - "glTexImage3DEXT\0" - "\0" - /* _mesa_function_pool[1699]: ReplacementCodeuiVertex3fvSUN (dynamic) */ - "pp\0" - "glReplacementCodeuiVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1735]: EdgeFlagPointer (offset 312) */ - "ip\0" - "glEdgeFlagPointer\0" - "\0" - /* _mesa_function_pool[1757]: Color3ubv (offset 20) */ - "p\0" - "glColor3ubv\0" - "\0" - /* _mesa_function_pool[1772]: GetQueryObjectivARB (will be remapped) */ - "iip\0" - "glGetQueryObjectiv\0" - "glGetQueryObjectivARB\0" - "\0" - /* _mesa_function_pool[1818]: Vertex3dv (offset 135) */ - "p\0" - "glVertex3dv\0" - "\0" - /* _mesa_function_pool[1833]: ReplacementCodeuiTexCoord2fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiTexCoord2fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1880]: CompressedTexSubImage2DARB (will be remapped) */ - "iiiiiiiip\0" - "glCompressedTexSubImage2D\0" - "glCompressedTexSubImage2DARB\0" - "\0" - /* _mesa_function_pool[1946]: CombinerOutputNV (will be remapped) */ - "iiiiiiiiii\0" - "glCombinerOutputNV\0" - "\0" - /* _mesa_function_pool[1977]: VertexAttribs3fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs3fvNV\0" - "\0" - /* _mesa_function_pool[2003]: Uniform2fARB (will be remapped) */ - "iff\0" - "glUniform2f\0" - "glUniform2fARB\0" - "\0" - /* _mesa_function_pool[2035]: LightModeliv (offset 166) */ - "ip\0" - "glLightModeliv\0" - "\0" - /* _mesa_function_pool[2054]: VertexAttrib1svARB (will be remapped) */ - "ip\0" - "glVertexAttrib1sv\0" - "glVertexAttrib1svARB\0" - "\0" - /* _mesa_function_pool[2097]: VertexAttribs1dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs1dvNV\0" - "\0" - /* _mesa_function_pool[2123]: Uniform2ivARB (will be remapped) */ - "iip\0" - "glUniform2iv\0" - "glUniform2ivARB\0" - "\0" - /* _mesa_function_pool[2157]: GetImageTransformParameterfvHP (dynamic) */ - "iip\0" - "glGetImageTransformParameterfvHP\0" - "\0" - /* _mesa_function_pool[2195]: Normal3bv (offset 53) */ - "p\0" - "glNormal3bv\0" - "\0" - /* _mesa_function_pool[2210]: TexGeniv (offset 193) */ - "iip\0" - "glTexGeniv\0" - "\0" - /* _mesa_function_pool[2226]: WeightubvARB (dynamic) */ - "ip\0" - "glWeightubvARB\0" - "\0" - /* _mesa_function_pool[2245]: VertexAttrib1fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib1fvNV\0" - "\0" - /* _mesa_function_pool[2269]: Vertex3iv (offset 139) */ - "p\0" - "glVertex3iv\0" - "\0" - /* _mesa_function_pool[2284]: CopyConvolutionFilter1D (offset 354) */ - "iiiii\0" - "glCopyConvolutionFilter1D\0" - "glCopyConvolutionFilter1DEXT\0" - "\0" - /* _mesa_function_pool[2346]: ReplacementCodeuiNormal3fVertex3fSUN (dynamic) */ - "iffffff\0" - "glReplacementCodeuiNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[2394]: DeleteSync (will be remapped) */ - "i\0" - "glDeleteSync\0" - "\0" - /* _mesa_function_pool[2410]: FragmentMaterialfvSGIX (dynamic) */ - "iip\0" - "glFragmentMaterialfvSGIX\0" - "\0" - /* _mesa_function_pool[2440]: BlendColor (offset 336) */ - "ffff\0" - "glBlendColor\0" - "glBlendColorEXT\0" - "\0" - /* _mesa_function_pool[2475]: UniformMatrix4fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix4fv\0" - "glUniformMatrix4fvARB\0" - "\0" - /* _mesa_function_pool[2522]: DeleteVertexArraysAPPLE (will be remapped) */ - "ip\0" - "glDeleteVertexArrays\0" - "glDeleteVertexArraysAPPLE\0" - "\0" - /* _mesa_function_pool[2573]: ReadInstrumentsSGIX (dynamic) */ - "i\0" - "glReadInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[2598]: CallLists (offset 3) */ - "iip\0" - "glCallLists\0" - "\0" - /* _mesa_function_pool[2615]: UniformMatrix2x4fv (will be remapped) */ - "iiip\0" - "glUniformMatrix2x4fv\0" - "\0" - /* _mesa_function_pool[2642]: Color4ubVertex3fvSUN (dynamic) */ - "pp\0" - "glColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[2669]: Normal3iv (offset 59) */ - "p\0" - "glNormal3iv\0" - "\0" - /* _mesa_function_pool[2684]: PassThrough (offset 199) */ - "f\0" - "glPassThrough\0" - "\0" - /* _mesa_function_pool[2701]: FramebufferTextureLayerEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTextureLayer\0" - "glFramebufferTextureLayerEXT\0" - "\0" - /* _mesa_function_pool[2763]: GetListParameterfvSGIX (dynamic) */ - "iip\0" - "glGetListParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[2793]: Viewport (offset 305) */ - "iiii\0" - "glViewport\0" - "\0" - /* _mesa_function_pool[2810]: VertexAttrib4NusvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nusv\0" - "glVertexAttrib4NusvARB\0" - "\0" - /* _mesa_function_pool[2857]: WindowPos4svMESA (will be remapped) */ - "p\0" - "glWindowPos4svMESA\0" - "\0" - /* _mesa_function_pool[2879]: CreateProgramObjectARB (will be remapped) */ - "\0" - "glCreateProgramObjectARB\0" - "\0" - /* _mesa_function_pool[2906]: DeleteTransformFeedbacks (will be remapped) */ - "ip\0" - "glDeleteTransformFeedbacks\0" - "\0" - /* _mesa_function_pool[2937]: UniformMatrix4x3fv (will be remapped) */ - "iiip\0" - "glUniformMatrix4x3fv\0" - "\0" - /* _mesa_function_pool[2964]: PrioritizeTextures (offset 331) */ - "ipp\0" - "glPrioritizeTextures\0" - "glPrioritizeTexturesEXT\0" - "\0" - /* _mesa_function_pool[3014]: AsyncMarkerSGIX (dynamic) */ - "i\0" - "glAsyncMarkerSGIX\0" - "\0" - /* _mesa_function_pool[3035]: GlobalAlphaFactorubSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorubSUN\0" - "\0" - /* _mesa_function_pool[3063]: ClearDebugLogMESA (dynamic) */ - "iii\0" - "glClearDebugLogMESA\0" - "\0" - /* _mesa_function_pool[3088]: ResetHistogram (offset 369) */ - "i\0" - "glResetHistogram\0" - "glResetHistogramEXT\0" - "\0" - /* _mesa_function_pool[3128]: GetProgramNamedParameterfvNV (will be remapped) */ - "iipp\0" - "glGetProgramNamedParameterfvNV\0" - "\0" - /* _mesa_function_pool[3165]: PointParameterfEXT (will be remapped) */ - "if\0" - "glPointParameterf\0" - "glPointParameterfARB\0" - "glPointParameterfEXT\0" - "glPointParameterfSGIS\0" - "\0" - /* _mesa_function_pool[3251]: LoadIdentityDeformationMapSGIX (dynamic) */ - "i\0" - "glLoadIdentityDeformationMapSGIX\0" - "\0" - /* _mesa_function_pool[3287]: GenFencesNV (will be remapped) */ - "ip\0" - "glGenFencesNV\0" - "\0" - /* _mesa_function_pool[3305]: ImageTransformParameterfHP (dynamic) */ - "iif\0" - "glImageTransformParameterfHP\0" - "\0" - /* _mesa_function_pool[3339]: MatrixIndexusvARB (dynamic) */ - "ip\0" - "glMatrixIndexusvARB\0" - "\0" - /* _mesa_function_pool[3363]: DrawElementsBaseVertex (will be remapped) */ - "iiipi\0" - "glDrawElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[3395]: DisableVertexAttribArrayARB (will be remapped) */ - "i\0" - "glDisableVertexAttribArray\0" - "glDisableVertexAttribArrayARB\0" - "\0" - /* _mesa_function_pool[3455]: TexCoord2sv (offset 109) */ - "p\0" - "glTexCoord2sv\0" - "\0" - /* _mesa_function_pool[3472]: Vertex4dv (offset 143) */ - "p\0" - "glVertex4dv\0" - "\0" - /* _mesa_function_pool[3487]: StencilMaskSeparate (will be remapped) */ - "ii\0" - "glStencilMaskSeparate\0" - "\0" - /* _mesa_function_pool[3513]: ProgramLocalParameter4dARB (will be remapped) */ - "iidddd\0" - "glProgramLocalParameter4dARB\0" - "\0" - /* _mesa_function_pool[3550]: CompressedTexImage3DARB (will be remapped) */ - "iiiiiiiip\0" - "glCompressedTexImage3D\0" - "glCompressedTexImage3DARB\0" - "\0" - /* _mesa_function_pool[3610]: Color3sv (offset 18) */ - "p\0" - "glColor3sv\0" - "\0" - /* _mesa_function_pool[3624]: GetConvolutionParameteriv (offset 358) */ - "iip\0" - "glGetConvolutionParameteriv\0" - "glGetConvolutionParameterivEXT\0" - "\0" - /* _mesa_function_pool[3688]: VertexAttrib1fARB (will be remapped) */ - "if\0" - "glVertexAttrib1f\0" - "glVertexAttrib1fARB\0" - "\0" - /* _mesa_function_pool[3729]: Vertex2dv (offset 127) */ - "p\0" - "glVertex2dv\0" - "\0" - /* _mesa_function_pool[3744]: TestFenceNV (will be remapped) */ - "i\0" - "glTestFenceNV\0" - "\0" - /* _mesa_function_pool[3761]: MultiTexCoord1fvARB (offset 379) */ - "ip\0" - "glMultiTexCoord1fv\0" - "glMultiTexCoord1fvARB\0" - "\0" - /* _mesa_function_pool[3806]: TexCoord3iv (offset 115) */ - "p\0" - "glTexCoord3iv\0" - "\0" - /* _mesa_function_pool[3823]: ColorFragmentOp2ATI (will be remapped) */ - "iiiiiiiiii\0" - "glColorFragmentOp2ATI\0" - "\0" - /* _mesa_function_pool[3857]: SecondaryColorPointerListIBM (dynamic) */ - "iiipi\0" - "glSecondaryColorPointerListIBM\0" - "\0" - /* _mesa_function_pool[3895]: GetPixelTexGenParameterivSGIS (will be remapped) */ - "ip\0" - "glGetPixelTexGenParameterivSGIS\0" - "\0" - /* _mesa_function_pool[3931]: Color3fv (offset 14) */ - "p\0" - "glColor3fv\0" - "\0" - /* _mesa_function_pool[3945]: VertexAttrib4fNV (will be remapped) */ - "iffff\0" - "glVertexAttrib4fNV\0" - "\0" - /* _mesa_function_pool[3971]: ReplacementCodeubSUN (dynamic) */ - "i\0" - "glReplacementCodeubSUN\0" - "\0" - /* _mesa_function_pool[3997]: FinishAsyncSGIX (dynamic) */ - "p\0" - "glFinishAsyncSGIX\0" - "\0" - /* _mesa_function_pool[4018]: GetDebugLogMESA (dynamic) */ - "iiiipp\0" - "glGetDebugLogMESA\0" - "\0" - /* _mesa_function_pool[4044]: FogCoorddEXT (will be remapped) */ - "d\0" - "glFogCoordd\0" - "glFogCoorddEXT\0" - "\0" - /* _mesa_function_pool[4074]: BeginConditionalRenderNV (will be remapped) */ - "ii\0" - "glBeginConditionalRenderNV\0" - "\0" - /* _mesa_function_pool[4105]: Color4ubVertex3fSUN (dynamic) */ - "iiiifff\0" - "glColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[4136]: FogCoordfEXT (will be remapped) */ - "f\0" - "glFogCoordf\0" - "glFogCoordfEXT\0" - "\0" - /* _mesa_function_pool[4166]: PointSize (offset 173) */ - "f\0" - "glPointSize\0" - "\0" - /* _mesa_function_pool[4181]: TexCoord2fVertex3fSUN (dynamic) */ - "fffff\0" - "glTexCoord2fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[4212]: PopName (offset 200) */ - "\0" - "glPopName\0" - "\0" - /* _mesa_function_pool[4224]: GlobalAlphaFactoriSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactoriSUN\0" - "\0" - /* _mesa_function_pool[4251]: VertexAttrib2dNV (will be remapped) */ - "idd\0" - "glVertexAttrib2dNV\0" - "\0" - /* _mesa_function_pool[4275]: GetProgramInfoLog (will be remapped) */ - "iipp\0" - "glGetProgramInfoLog\0" - "\0" - /* _mesa_function_pool[4301]: VertexAttrib4NbvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nbv\0" - "glVertexAttrib4NbvARB\0" - "\0" - /* _mesa_function_pool[4346]: GetActiveAttribARB (will be remapped) */ - "iiipppp\0" - "glGetActiveAttrib\0" - "glGetActiveAttribARB\0" - "\0" - /* _mesa_function_pool[4394]: Vertex4sv (offset 149) */ - "p\0" - "glVertex4sv\0" - "\0" - /* _mesa_function_pool[4409]: VertexAttrib4ubNV (will be remapped) */ - "iiiii\0" - "glVertexAttrib4ubNV\0" - "\0" - /* _mesa_function_pool[4436]: TextureRangeAPPLE (will be remapped) */ - "iip\0" - "glTextureRangeAPPLE\0" - "\0" - /* _mesa_function_pool[4461]: GetTexEnvfv (offset 276) */ - "iip\0" - "glGetTexEnvfv\0" - "\0" - /* _mesa_function_pool[4480]: BindTransformFeedback (will be remapped) */ - "ii\0" - "glBindTransformFeedback\0" - "\0" - /* _mesa_function_pool[4508]: TexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ - "ffffffffffff\0" - "glTexCoord2fColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[4561]: Indexub (offset 315) */ - "i\0" - "glIndexub\0" - "\0" - /* _mesa_function_pool[4574]: TexEnvi (offset 186) */ - "iii\0" - "glTexEnvi\0" - "\0" - /* _mesa_function_pool[4589]: GetClipPlane (offset 259) */ - "ip\0" - "glGetClipPlane\0" - "\0" - /* _mesa_function_pool[4608]: CombinerParameterfvNV (will be remapped) */ - "ip\0" - "glCombinerParameterfvNV\0" - "\0" - /* _mesa_function_pool[4636]: VertexAttribs3dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs3dvNV\0" - "\0" - /* _mesa_function_pool[4662]: VertexAttribs4fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4fvNV\0" - "\0" - /* _mesa_function_pool[4688]: VertexArrayRangeNV (will be remapped) */ - "ip\0" - "glVertexArrayRangeNV\0" - "\0" - /* _mesa_function_pool[4713]: FragmentLightiSGIX (dynamic) */ - "iii\0" - "glFragmentLightiSGIX\0" - "\0" - /* _mesa_function_pool[4739]: PolygonOffsetEXT (will be remapped) */ - "ff\0" - "glPolygonOffsetEXT\0" - "\0" - /* _mesa_function_pool[4762]: PollAsyncSGIX (dynamic) */ - "p\0" - "glPollAsyncSGIX\0" - "\0" - /* _mesa_function_pool[4781]: DeleteFragmentShaderATI (will be remapped) */ - "i\0" - "glDeleteFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[4810]: Scaled (offset 301) */ - "ddd\0" - "glScaled\0" - "\0" - /* _mesa_function_pool[4824]: ResumeTransformFeedback (will be remapped) */ - "\0" - "glResumeTransformFeedback\0" - "\0" - /* _mesa_function_pool[4852]: Scalef (offset 302) */ - "fff\0" - "glScalef\0" - "\0" - /* _mesa_function_pool[4866]: TexCoord2fNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[4904]: MultTransposeMatrixdARB (will be remapped) */ - "p\0" - "glMultTransposeMatrixd\0" - "glMultTransposeMatrixdARB\0" - "\0" - /* _mesa_function_pool[4956]: ColorMaskIndexedEXT (will be remapped) */ - "iiiii\0" - "glColorMaskIndexedEXT\0" - "\0" - /* _mesa_function_pool[4985]: ObjectUnpurgeableAPPLE (will be remapped) */ - "iii\0" - "glObjectUnpurgeableAPPLE\0" - "\0" - /* _mesa_function_pool[5015]: AlphaFunc (offset 240) */ - "if\0" - "glAlphaFunc\0" - "\0" - /* _mesa_function_pool[5031]: WindowPos2svMESA (will be remapped) */ - "p\0" - "glWindowPos2sv\0" - "glWindowPos2svARB\0" - "glWindowPos2svMESA\0" - "\0" - /* _mesa_function_pool[5086]: EdgeFlag (offset 41) */ - "i\0" - "glEdgeFlag\0" - "\0" - /* _mesa_function_pool[5100]: TexCoord2iv (offset 107) */ - "p\0" - "glTexCoord2iv\0" - "\0" - /* _mesa_function_pool[5117]: CompressedTexImage1DARB (will be remapped) */ - "iiiiiip\0" - "glCompressedTexImage1D\0" - "glCompressedTexImage1DARB\0" - "\0" - /* _mesa_function_pool[5175]: Rotated (offset 299) */ - "dddd\0" - "glRotated\0" - "\0" - /* _mesa_function_pool[5191]: VertexAttrib2sNV (will be remapped) */ - "iii\0" - "glVertexAttrib2sNV\0" - "\0" - /* _mesa_function_pool[5215]: ReadPixels (offset 256) */ - "iiiiiip\0" - "glReadPixels\0" - "\0" - /* _mesa_function_pool[5237]: EdgeFlagv (offset 42) */ - "p\0" - "glEdgeFlagv\0" - "\0" - /* _mesa_function_pool[5252]: NormalPointerListIBM (dynamic) */ - "iipi\0" - "glNormalPointerListIBM\0" - "\0" - /* _mesa_function_pool[5281]: IndexPointerEXT (will be remapped) */ - "iiip\0" - "glIndexPointerEXT\0" - "\0" - /* _mesa_function_pool[5305]: Color4iv (offset 32) */ - "p\0" - "glColor4iv\0" - "\0" - /* _mesa_function_pool[5319]: TexParameterf (offset 178) */ - "iif\0" - "glTexParameterf\0" - "\0" - /* _mesa_function_pool[5340]: TexParameteri (offset 180) */ - "iii\0" - "glTexParameteri\0" - "\0" - /* _mesa_function_pool[5361]: NormalPointerEXT (will be remapped) */ - "iiip\0" - "glNormalPointerEXT\0" - "\0" - /* _mesa_function_pool[5386]: MultiTexCoord3dARB (offset 392) */ - "iddd\0" - "glMultiTexCoord3d\0" - "glMultiTexCoord3dARB\0" - "\0" - /* _mesa_function_pool[5431]: MultiTexCoord2iARB (offset 388) */ - "iii\0" - "glMultiTexCoord2i\0" - "glMultiTexCoord2iARB\0" - "\0" - /* _mesa_function_pool[5475]: DrawPixels (offset 257) */ - "iiiip\0" - "glDrawPixels\0" - "\0" - /* _mesa_function_pool[5495]: ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (dynamic) */ - "iffffffff\0" - "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[5555]: MultiTexCoord2svARB (offset 391) */ - "ip\0" - "glMultiTexCoord2sv\0" - "glMultiTexCoord2svARB\0" - "\0" - /* _mesa_function_pool[5600]: ReplacementCodeubvSUN (dynamic) */ - "p\0" - "glReplacementCodeubvSUN\0" - "\0" - /* _mesa_function_pool[5627]: Uniform3iARB (will be remapped) */ - "iiii\0" - "glUniform3i\0" - "glUniform3iARB\0" - "\0" - /* _mesa_function_pool[5660]: DrawTransformFeedback (will be remapped) */ - "ii\0" - "glDrawTransformFeedback\0" - "\0" - /* _mesa_function_pool[5688]: GetFragmentMaterialfvSGIX (dynamic) */ - "iip\0" - "glGetFragmentMaterialfvSGIX\0" - "\0" - /* _mesa_function_pool[5721]: GetShaderInfoLog (will be remapped) */ - "iipp\0" - "glGetShaderInfoLog\0" - "\0" - /* _mesa_function_pool[5746]: WeightivARB (dynamic) */ - "ip\0" - "glWeightivARB\0" - "\0" - /* _mesa_function_pool[5764]: PollInstrumentsSGIX (dynamic) */ - "p\0" - "glPollInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[5789]: GlobalAlphaFactordSUN (dynamic) */ - "d\0" - "glGlobalAlphaFactordSUN\0" - "\0" - /* _mesa_function_pool[5816]: GetFinalCombinerInputParameterfvNV (will be remapped) */ - "iip\0" - "glGetFinalCombinerInputParameterfvNV\0" - "\0" - /* _mesa_function_pool[5858]: GenerateMipmapEXT (will be remapped) */ - "i\0" - "glGenerateMipmap\0" - "glGenerateMipmapEXT\0" - "\0" - /* _mesa_function_pool[5898]: GenLists (offset 5) */ - "i\0" - "glGenLists\0" - "\0" - /* _mesa_function_pool[5912]: SetFragmentShaderConstantATI (will be remapped) */ - "ip\0" - "glSetFragmentShaderConstantATI\0" - "\0" - /* _mesa_function_pool[5947]: GetMapAttribParameterivNV (dynamic) */ - "iiip\0" - "glGetMapAttribParameterivNV\0" - "\0" - /* _mesa_function_pool[5981]: CreateShaderObjectARB (will be remapped) */ - "i\0" - "glCreateShaderObjectARB\0" - "\0" - /* _mesa_function_pool[6008]: GetSharpenTexFuncSGIS (dynamic) */ - "ip\0" - "glGetSharpenTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[6036]: BufferDataARB (will be remapped) */ - "iipi\0" - "glBufferData\0" - "glBufferDataARB\0" - "\0" - /* _mesa_function_pool[6071]: FlushVertexArrayRangeNV (will be remapped) */ - "\0" - "glFlushVertexArrayRangeNV\0" - "\0" - /* _mesa_function_pool[6099]: MapGrid2d (offset 226) */ - "iddidd\0" - "glMapGrid2d\0" - "\0" - /* _mesa_function_pool[6119]: MapGrid2f (offset 227) */ - "iffiff\0" - "glMapGrid2f\0" - "\0" - /* _mesa_function_pool[6139]: SampleMapATI (will be remapped) */ - "iii\0" - "glSampleMapATI\0" - "\0" - /* _mesa_function_pool[6159]: VertexPointerEXT (will be remapped) */ - "iiiip\0" - "glVertexPointerEXT\0" - "\0" - /* _mesa_function_pool[6185]: GetTexFilterFuncSGIS (dynamic) */ - "iip\0" - "glGetTexFilterFuncSGIS\0" - "\0" - /* _mesa_function_pool[6213]: Scissor (offset 176) */ - "iiii\0" - "glScissor\0" - "\0" - /* _mesa_function_pool[6229]: Fogf (offset 153) */ - "if\0" - "glFogf\0" - "\0" - /* _mesa_function_pool[6240]: ReplacementCodeuiColor4ubVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[6285]: TexSubImage1D (offset 332) */ - "iiiiiip\0" - "glTexSubImage1D\0" - "glTexSubImage1DEXT\0" - "\0" - /* _mesa_function_pool[6329]: VertexAttrib1sARB (will be remapped) */ - "ii\0" - "glVertexAttrib1s\0" - "glVertexAttrib1sARB\0" - "\0" - /* _mesa_function_pool[6370]: FenceSync (will be remapped) */ - "ii\0" - "glFenceSync\0" - "\0" - /* _mesa_function_pool[6386]: Color4usv (offset 40) */ - "p\0" - "glColor4usv\0" - "\0" - /* _mesa_function_pool[6401]: Fogi (offset 155) */ - "ii\0" - "glFogi\0" - "\0" - /* _mesa_function_pool[6412]: DepthRange (offset 288) */ - "dd\0" - "glDepthRange\0" - "\0" - /* _mesa_function_pool[6429]: RasterPos3iv (offset 75) */ - "p\0" - "glRasterPos3iv\0" - "\0" - /* _mesa_function_pool[6447]: FinalCombinerInputNV (will be remapped) */ - "iiii\0" - "glFinalCombinerInputNV\0" - "\0" - /* _mesa_function_pool[6476]: TexCoord2i (offset 106) */ - "ii\0" - "glTexCoord2i\0" - "\0" - /* _mesa_function_pool[6493]: PixelMapfv (offset 251) */ - "iip\0" - "glPixelMapfv\0" - "\0" - /* _mesa_function_pool[6511]: Color4ui (offset 37) */ - "iiii\0" - "glColor4ui\0" - "\0" - /* _mesa_function_pool[6528]: RasterPos3s (offset 76) */ - "iii\0" - "glRasterPos3s\0" - "\0" - /* _mesa_function_pool[6547]: Color3usv (offset 24) */ - "p\0" - "glColor3usv\0" - "\0" - /* _mesa_function_pool[6562]: FlushRasterSGIX (dynamic) */ - "\0" - "glFlushRasterSGIX\0" - "\0" - /* _mesa_function_pool[6582]: TexCoord2f (offset 104) */ - "ff\0" - "glTexCoord2f\0" - "\0" - /* _mesa_function_pool[6599]: ReplacementCodeuiTexCoord2fVertex3fSUN (dynamic) */ - "ifffff\0" - "glReplacementCodeuiTexCoord2fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[6648]: TexCoord2d (offset 102) */ - "dd\0" - "glTexCoord2d\0" - "\0" - /* _mesa_function_pool[6665]: RasterPos3d (offset 70) */ - "ddd\0" - "glRasterPos3d\0" - "\0" - /* _mesa_function_pool[6684]: RasterPos3f (offset 72) */ - "fff\0" - "glRasterPos3f\0" - "\0" - /* _mesa_function_pool[6703]: Uniform1fARB (will be remapped) */ - "if\0" - "glUniform1f\0" - "glUniform1fARB\0" - "\0" - /* _mesa_function_pool[6734]: AreTexturesResident (offset 322) */ - "ipp\0" - "glAreTexturesResident\0" - "glAreTexturesResidentEXT\0" - "\0" - /* _mesa_function_pool[6786]: TexCoord2s (offset 108) */ - "ii\0" - "glTexCoord2s\0" - "\0" - /* _mesa_function_pool[6803]: StencilOpSeparate (will be remapped) */ - "iiii\0" - "glStencilOpSeparate\0" - "glStencilOpSeparateATI\0" - "\0" - /* _mesa_function_pool[6852]: ColorTableParameteriv (offset 341) */ - "iip\0" - "glColorTableParameteriv\0" - "glColorTableParameterivSGI\0" - "\0" - /* _mesa_function_pool[6908]: FogCoordPointerListIBM (dynamic) */ - "iipi\0" - "glFogCoordPointerListIBM\0" - "\0" - /* _mesa_function_pool[6939]: WindowPos3dMESA (will be remapped) */ - "ddd\0" - "glWindowPos3d\0" - "glWindowPos3dARB\0" - "glWindowPos3dMESA\0" - "\0" - /* _mesa_function_pool[6993]: Color4us (offset 39) */ - "iiii\0" - "glColor4us\0" - "\0" - /* _mesa_function_pool[7010]: PointParameterfvEXT (will be remapped) */ - "ip\0" - "glPointParameterfv\0" - "glPointParameterfvARB\0" - "glPointParameterfvEXT\0" - "glPointParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[7100]: Color3bv (offset 10) */ - "p\0" - "glColor3bv\0" - "\0" - /* _mesa_function_pool[7114]: WindowPos2fvMESA (will be remapped) */ - "p\0" - "glWindowPos2fv\0" - "glWindowPos2fvARB\0" - "glWindowPos2fvMESA\0" - "\0" - /* _mesa_function_pool[7169]: SecondaryColor3bvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3bv\0" - "glSecondaryColor3bvEXT\0" - "\0" - /* _mesa_function_pool[7215]: VertexPointerListIBM (dynamic) */ - "iiipi\0" - "glVertexPointerListIBM\0" - "\0" - /* _mesa_function_pool[7245]: GetProgramLocalParameterfvARB (will be remapped) */ - "iip\0" - "glGetProgramLocalParameterfvARB\0" - "\0" - /* _mesa_function_pool[7282]: FragmentMaterialfSGIX (dynamic) */ - "iif\0" - "glFragmentMaterialfSGIX\0" - "\0" - /* _mesa_function_pool[7311]: TexCoord2fNormal3fVertex3fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord2fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[7353]: RenderbufferStorageEXT (will be remapped) */ - "iiii\0" - "glRenderbufferStorage\0" - "glRenderbufferStorageEXT\0" - "\0" - /* _mesa_function_pool[7406]: IsFenceNV (will be remapped) */ - "i\0" - "glIsFenceNV\0" - "\0" - /* _mesa_function_pool[7421]: AttachObjectARB (will be remapped) */ - "ii\0" - "glAttachObjectARB\0" - "\0" - /* _mesa_function_pool[7443]: GetFragmentLightivSGIX (dynamic) */ - "iip\0" - "glGetFragmentLightivSGIX\0" - "\0" - /* _mesa_function_pool[7473]: UniformMatrix2fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix2fv\0" - "glUniformMatrix2fvARB\0" - "\0" - /* _mesa_function_pool[7520]: MultiTexCoord2fARB (offset 386) */ - "iff\0" - "glMultiTexCoord2f\0" - "glMultiTexCoord2fARB\0" - "\0" - /* _mesa_function_pool[7564]: ColorTable (offset 339) */ - "iiiiip\0" - "glColorTable\0" - "glColorTableSGI\0" - "glColorTableEXT\0" - "\0" - /* _mesa_function_pool[7617]: IndexPointer (offset 314) */ - "iip\0" - "glIndexPointer\0" - "\0" - /* _mesa_function_pool[7637]: Accum (offset 213) */ - "if\0" - "glAccum\0" - "\0" - /* _mesa_function_pool[7649]: GetTexImage (offset 281) */ - "iiiip\0" - "glGetTexImage\0" - "\0" - /* _mesa_function_pool[7670]: MapControlPointsNV (dynamic) */ - "iiiiiiiip\0" - "glMapControlPointsNV\0" - "\0" - /* _mesa_function_pool[7702]: ConvolutionFilter2D (offset 349) */ - "iiiiiip\0" - "glConvolutionFilter2D\0" - "glConvolutionFilter2DEXT\0" - "\0" - /* _mesa_function_pool[7758]: Finish (offset 216) */ - "\0" - "glFinish\0" - "\0" - /* _mesa_function_pool[7769]: MapParameterfvNV (dynamic) */ - "iip\0" - "glMapParameterfvNV\0" - "\0" - /* _mesa_function_pool[7793]: ClearStencil (offset 207) */ - "i\0" - "glClearStencil\0" - "\0" - /* _mesa_function_pool[7811]: VertexAttrib3dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib3dv\0" - "glVertexAttrib3dvARB\0" - "\0" - /* _mesa_function_pool[7854]: HintPGI (dynamic) */ - "ii\0" - "glHintPGI\0" - "\0" - /* _mesa_function_pool[7868]: ConvolutionParameteriv (offset 353) */ - "iip\0" - "glConvolutionParameteriv\0" - "glConvolutionParameterivEXT\0" - "\0" - /* _mesa_function_pool[7926]: Color4s (offset 33) */ - "iiii\0" - "glColor4s\0" - "\0" - /* _mesa_function_pool[7942]: InterleavedArrays (offset 317) */ - "iip\0" - "glInterleavedArrays\0" - "\0" - /* _mesa_function_pool[7967]: RasterPos2fv (offset 65) */ - "p\0" - "glRasterPos2fv\0" - "\0" - /* _mesa_function_pool[7985]: TexCoord1fv (offset 97) */ - "p\0" - "glTexCoord1fv\0" - "\0" - /* _mesa_function_pool[8002]: Vertex2d (offset 126) */ - "dd\0" - "glVertex2d\0" - "\0" - /* _mesa_function_pool[8017]: CullParameterdvEXT (will be remapped) */ - "ip\0" - "glCullParameterdvEXT\0" - "\0" - /* _mesa_function_pool[8042]: ProgramNamedParameter4fNV (will be remapped) */ - "iipffff\0" - "glProgramNamedParameter4fNV\0" - "\0" - /* _mesa_function_pool[8079]: Color3fVertex3fSUN (dynamic) */ - "ffffff\0" - "glColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[8108]: ProgramEnvParameter4fvARB (will be remapped) */ - "iip\0" - "glProgramEnvParameter4fvARB\0" - "glProgramParameter4fvNV\0" - "\0" - /* _mesa_function_pool[8165]: Color4i (offset 31) */ - "iiii\0" - "glColor4i\0" - "\0" - /* _mesa_function_pool[8181]: Color4f (offset 29) */ - "ffff\0" - "glColor4f\0" - "\0" - /* _mesa_function_pool[8197]: RasterPos4fv (offset 81) */ - "p\0" - "glRasterPos4fv\0" - "\0" - /* _mesa_function_pool[8215]: Color4d (offset 27) */ - "dddd\0" - "glColor4d\0" - "\0" - /* _mesa_function_pool[8231]: ClearIndex (offset 205) */ - "f\0" - "glClearIndex\0" - "\0" - /* _mesa_function_pool[8247]: Color4b (offset 25) */ - "iiii\0" - "glColor4b\0" - "\0" - /* _mesa_function_pool[8263]: LoadMatrixd (offset 292) */ - "p\0" - "glLoadMatrixd\0" - "\0" - /* _mesa_function_pool[8280]: FragmentLightModeliSGIX (dynamic) */ - "ii\0" - "glFragmentLightModeliSGIX\0" - "\0" - /* _mesa_function_pool[8310]: RasterPos2dv (offset 63) */ - "p\0" - "glRasterPos2dv\0" - "\0" - /* _mesa_function_pool[8328]: ConvolutionParameterfv (offset 351) */ - "iip\0" - "glConvolutionParameterfv\0" - "glConvolutionParameterfvEXT\0" - "\0" - /* _mesa_function_pool[8386]: TbufferMask3DFX (dynamic) */ - "i\0" - "glTbufferMask3DFX\0" - "\0" - /* _mesa_function_pool[8407]: GetTexGendv (offset 278) */ - "iip\0" - "glGetTexGendv\0" - "\0" - /* _mesa_function_pool[8426]: GetVertexAttribfvNV (will be remapped) */ - "iip\0" - "glGetVertexAttribfvNV\0" - "\0" - /* _mesa_function_pool[8453]: BeginTransformFeedbackEXT (will be remapped) */ - "i\0" - "glBeginTransformFeedbackEXT\0" - "glBeginTransformFeedback\0" - "\0" - /* _mesa_function_pool[8509]: LoadProgramNV (will be remapped) */ - "iiip\0" - "glLoadProgramNV\0" - "\0" - /* _mesa_function_pool[8531]: WaitSync (will be remapped) */ - "iii\0" - "glWaitSync\0" - "\0" - /* _mesa_function_pool[8547]: EndList (offset 1) */ - "\0" - "glEndList\0" - "\0" - /* _mesa_function_pool[8559]: VertexAttrib4fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4fvNV\0" - "\0" - /* _mesa_function_pool[8583]: GetAttachedObjectsARB (will be remapped) */ - "iipp\0" - "glGetAttachedObjectsARB\0" - "\0" - /* _mesa_function_pool[8613]: Uniform3fvARB (will be remapped) */ - "iip\0" - "glUniform3fv\0" - "glUniform3fvARB\0" - "\0" - /* _mesa_function_pool[8647]: EvalCoord1fv (offset 231) */ - "p\0" - "glEvalCoord1fv\0" - "\0" - /* _mesa_function_pool[8665]: DrawRangeElements (offset 338) */ - "iiiiip\0" - "glDrawRangeElements\0" - "glDrawRangeElementsEXT\0" - "\0" - /* _mesa_function_pool[8716]: EvalMesh2 (offset 238) */ - "iiiii\0" - "glEvalMesh2\0" - "\0" - /* _mesa_function_pool[8735]: Vertex4fv (offset 145) */ - "p\0" - "glVertex4fv\0" - "\0" - /* _mesa_function_pool[8750]: GenTransformFeedbacks (will be remapped) */ - "ip\0" - "glGenTransformFeedbacks\0" - "\0" - /* _mesa_function_pool[8778]: SpriteParameterfvSGIX (dynamic) */ - "ip\0" - "glSpriteParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[8806]: CheckFramebufferStatusEXT (will be remapped) */ - "i\0" - "glCheckFramebufferStatus\0" - "glCheckFramebufferStatusEXT\0" - "\0" - /* _mesa_function_pool[8862]: GlobalAlphaFactoruiSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactoruiSUN\0" - "\0" - /* _mesa_function_pool[8890]: GetHandleARB (will be remapped) */ - "i\0" - "glGetHandleARB\0" - "\0" - /* _mesa_function_pool[8908]: GetVertexAttribivARB (will be remapped) */ - "iip\0" - "glGetVertexAttribiv\0" - "glGetVertexAttribivARB\0" - "\0" - /* _mesa_function_pool[8956]: GetCombinerInputParameterfvNV (will be remapped) */ - "iiiip\0" - "glGetCombinerInputParameterfvNV\0" - "\0" - /* _mesa_function_pool[8995]: CreateProgram (will be remapped) */ - "\0" - "glCreateProgram\0" - "\0" - /* _mesa_function_pool[9013]: LoadTransposeMatrixdARB (will be remapped) */ - "p\0" - "glLoadTransposeMatrixd\0" - "glLoadTransposeMatrixdARB\0" - "\0" - /* _mesa_function_pool[9065]: GetMinmax (offset 364) */ - "iiiip\0" - "glGetMinmax\0" - "glGetMinmaxEXT\0" - "\0" - /* _mesa_function_pool[9099]: StencilFuncSeparate (will be remapped) */ - "iiii\0" - "glStencilFuncSeparate\0" - "\0" - /* _mesa_function_pool[9127]: SecondaryColor3sEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3s\0" - "glSecondaryColor3sEXT\0" - "\0" - /* _mesa_function_pool[9173]: Color3fVertex3fvSUN (dynamic) */ - "pp\0" - "glColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[9199]: Normal3fv (offset 57) */ - "p\0" - "glNormal3fv\0" - "\0" - /* _mesa_function_pool[9214]: GlobalAlphaFactorbSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorbSUN\0" - "\0" - /* _mesa_function_pool[9241]: Color3us (offset 23) */ - "iii\0" - "glColor3us\0" - "\0" - /* _mesa_function_pool[9257]: ImageTransformParameterfvHP (dynamic) */ - "iip\0" - "glImageTransformParameterfvHP\0" - "\0" - /* _mesa_function_pool[9292]: VertexAttrib4ivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4iv\0" - "glVertexAttrib4ivARB\0" - "\0" - /* _mesa_function_pool[9335]: End (offset 43) */ - "\0" - "glEnd\0" - "\0" - /* _mesa_function_pool[9343]: VertexAttrib3fNV (will be remapped) */ - "ifff\0" - "glVertexAttrib3fNV\0" - "\0" - /* _mesa_function_pool[9368]: VertexAttribs2dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs2dvNV\0" - "\0" - /* _mesa_function_pool[9394]: GetQueryObjectui64vEXT (will be remapped) */ - "iip\0" - "glGetQueryObjectui64vEXT\0" - "\0" - /* _mesa_function_pool[9424]: MultiTexCoord3fvARB (offset 395) */ - "ip\0" - "glMultiTexCoord3fv\0" - "glMultiTexCoord3fvARB\0" - "\0" - /* _mesa_function_pool[9469]: SecondaryColor3dEXT (will be remapped) */ - "ddd\0" - "glSecondaryColor3d\0" - "glSecondaryColor3dEXT\0" - "\0" - /* _mesa_function_pool[9515]: Color3ub (offset 19) */ - "iii\0" - "glColor3ub\0" - "\0" - /* _mesa_function_pool[9531]: GetProgramParameterfvNV (will be remapped) */ - "iiip\0" - "glGetProgramParameterfvNV\0" - "\0" - /* _mesa_function_pool[9563]: TangentPointerEXT (dynamic) */ - "iip\0" - "glTangentPointerEXT\0" - "\0" - /* _mesa_function_pool[9588]: Color4fNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[9623]: GetInstrumentsSGIX (dynamic) */ - "\0" - "glGetInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[9646]: Color3ui (offset 21) */ - "iii\0" - "glColor3ui\0" - "\0" - /* _mesa_function_pool[9662]: EvalMapsNV (dynamic) */ - "ii\0" - "glEvalMapsNV\0" - "\0" - /* _mesa_function_pool[9679]: TexSubImage2D (offset 333) */ - "iiiiiiiip\0" - "glTexSubImage2D\0" - "glTexSubImage2DEXT\0" - "\0" - /* _mesa_function_pool[9725]: FragmentLightivSGIX (dynamic) */ - "iip\0" - "glFragmentLightivSGIX\0" - "\0" - /* _mesa_function_pool[9752]: GetTexParameterPointervAPPLE (will be remapped) */ - "iip\0" - "glGetTexParameterPointervAPPLE\0" - "\0" - /* _mesa_function_pool[9788]: TexGenfv (offset 191) */ - "iip\0" - "glTexGenfv\0" - "\0" - /* _mesa_function_pool[9804]: GetTransformFeedbackVaryingEXT (will be remapped) */ - "iiipppp\0" - "glGetTransformFeedbackVaryingEXT\0" - "glGetTransformFeedbackVarying\0" - "\0" - /* _mesa_function_pool[9876]: VertexAttrib4bvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4bv\0" - "glVertexAttrib4bvARB\0" - "\0" - /* _mesa_function_pool[9919]: AlphaFragmentOp2ATI (will be remapped) */ - "iiiiiiiii\0" - "glAlphaFragmentOp2ATI\0" - "\0" - /* _mesa_function_pool[9952]: GetIntegerIndexedvEXT (will be remapped) */ - "iip\0" - "glGetIntegerIndexedvEXT\0" - "\0" - /* _mesa_function_pool[9981]: MultiTexCoord4sARB (offset 406) */ - "iiiii\0" - "glMultiTexCoord4s\0" - "glMultiTexCoord4sARB\0" - "\0" - /* _mesa_function_pool[10027]: GetFragmentMaterialivSGIX (dynamic) */ - "iip\0" - "glGetFragmentMaterialivSGIX\0" - "\0" - /* _mesa_function_pool[10060]: WindowPos4dMESA (will be remapped) */ - "dddd\0" - "glWindowPos4dMESA\0" - "\0" - /* _mesa_function_pool[10084]: WeightPointerARB (dynamic) */ - "iiip\0" - "glWeightPointerARB\0" - "\0" - /* _mesa_function_pool[10109]: WindowPos2dMESA (will be remapped) */ - "dd\0" - "glWindowPos2d\0" - "glWindowPos2dARB\0" - "glWindowPos2dMESA\0" - "\0" - /* _mesa_function_pool[10162]: FramebufferTexture3DEXT (will be remapped) */ - "iiiiii\0" - "glFramebufferTexture3D\0" - "glFramebufferTexture3DEXT\0" - "\0" - /* _mesa_function_pool[10219]: BlendEquation (offset 337) */ - "i\0" - "glBlendEquation\0" - "glBlendEquationEXT\0" - "\0" - /* _mesa_function_pool[10257]: VertexAttrib3dNV (will be remapped) */ - "iddd\0" - "glVertexAttrib3dNV\0" - "\0" - /* _mesa_function_pool[10282]: VertexAttrib3dARB (will be remapped) */ - "iddd\0" - "glVertexAttrib3d\0" - "glVertexAttrib3dARB\0" - "\0" - /* _mesa_function_pool[10325]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ - "ppppp\0" - "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[10389]: VertexAttrib4fARB (will be remapped) */ - "iffff\0" - "glVertexAttrib4f\0" - "glVertexAttrib4fARB\0" - "\0" - /* _mesa_function_pool[10433]: GetError (offset 261) */ - "\0" - "glGetError\0" - "\0" - /* _mesa_function_pool[10446]: IndexFuncEXT (dynamic) */ - "if\0" - "glIndexFuncEXT\0" - "\0" - /* _mesa_function_pool[10465]: TexCoord3dv (offset 111) */ - "p\0" - "glTexCoord3dv\0" - "\0" - /* _mesa_function_pool[10482]: Indexdv (offset 45) */ - "p\0" - "glIndexdv\0" - "\0" - /* _mesa_function_pool[10495]: FramebufferTexture2DEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTexture2D\0" - "glFramebufferTexture2DEXT\0" - "\0" - /* _mesa_function_pool[10551]: Normal3s (offset 60) */ - "iii\0" - "glNormal3s\0" - "\0" - /* _mesa_function_pool[10567]: GetObjectParameterivAPPLE (will be remapped) */ - "iiip\0" - "glGetObjectParameterivAPPLE\0" - "\0" - /* _mesa_function_pool[10601]: PushName (offset 201) */ - "i\0" - "glPushName\0" - "\0" - /* _mesa_function_pool[10615]: MultiTexCoord2dvARB (offset 385) */ - "ip\0" - "glMultiTexCoord2dv\0" - "glMultiTexCoord2dvARB\0" - "\0" - /* _mesa_function_pool[10660]: CullParameterfvEXT (will be remapped) */ - "ip\0" - "glCullParameterfvEXT\0" - "\0" - /* _mesa_function_pool[10685]: Normal3i (offset 58) */ - "iii\0" - "glNormal3i\0" - "\0" - /* _mesa_function_pool[10701]: ProgramNamedParameter4fvNV (will be remapped) */ - "iipp\0" - "glProgramNamedParameter4fvNV\0" - "\0" - /* _mesa_function_pool[10736]: SecondaryColorPointerEXT (will be remapped) */ - "iiip\0" - "glSecondaryColorPointer\0" - "glSecondaryColorPointerEXT\0" - "\0" - /* _mesa_function_pool[10793]: VertexAttrib4fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4fv\0" - "glVertexAttrib4fvARB\0" - "\0" - /* _mesa_function_pool[10836]: ColorPointerListIBM (dynamic) */ - "iiipi\0" - "glColorPointerListIBM\0" - "\0" - /* _mesa_function_pool[10865]: GetActiveUniformARB (will be remapped) */ - "iiipppp\0" - "glGetActiveUniform\0" - "glGetActiveUniformARB\0" - "\0" - /* _mesa_function_pool[10915]: ImageTransformParameteriHP (dynamic) */ - "iii\0" - "glImageTransformParameteriHP\0" - "\0" - /* _mesa_function_pool[10949]: Normal3b (offset 52) */ - "iii\0" - "glNormal3b\0" - "\0" - /* _mesa_function_pool[10965]: Normal3d (offset 54) */ - "ddd\0" - "glNormal3d\0" - "\0" - /* _mesa_function_pool[10981]: Normal3f (offset 56) */ - "fff\0" - "glNormal3f\0" - "\0" - /* _mesa_function_pool[10997]: MultiTexCoord1svARB (offset 383) */ - "ip\0" - "glMultiTexCoord1sv\0" - "glMultiTexCoord1svARB\0" - "\0" - /* _mesa_function_pool[11042]: Indexi (offset 48) */ - "i\0" - "glIndexi\0" - "\0" - /* _mesa_function_pool[11054]: EGLImageTargetTexture2DOES (will be remapped) */ - "ip\0" - "glEGLImageTargetTexture2DOES\0" - "\0" - /* _mesa_function_pool[11087]: EndQueryARB (will be remapped) */ - "i\0" - "glEndQuery\0" - "glEndQueryARB\0" - "\0" - /* _mesa_function_pool[11115]: DeleteFencesNV (will be remapped) */ - "ip\0" - "glDeleteFencesNV\0" - "\0" - /* _mesa_function_pool[11136]: BindBufferRangeEXT (will be remapped) */ - "iiiii\0" - "glBindBufferRangeEXT\0" - "glBindBufferRange\0" - "\0" - /* _mesa_function_pool[11182]: DepthMask (offset 211) */ - "i\0" - "glDepthMask\0" - "\0" - /* _mesa_function_pool[11197]: IsShader (will be remapped) */ - "i\0" - "glIsShader\0" - "\0" - /* _mesa_function_pool[11211]: Indexf (offset 46) */ - "f\0" - "glIndexf\0" - "\0" - /* _mesa_function_pool[11223]: GetImageTransformParameterivHP (dynamic) */ - "iip\0" - "glGetImageTransformParameterivHP\0" - "\0" - /* _mesa_function_pool[11261]: Indexd (offset 44) */ - "d\0" - "glIndexd\0" - "\0" - /* _mesa_function_pool[11273]: GetMaterialiv (offset 270) */ - "iip\0" - "glGetMaterialiv\0" - "\0" - /* _mesa_function_pool[11294]: StencilOp (offset 244) */ - "iii\0" - "glStencilOp\0" - "\0" - /* _mesa_function_pool[11311]: WindowPos4ivMESA (will be remapped) */ - "p\0" - "glWindowPos4ivMESA\0" - "\0" - /* _mesa_function_pool[11333]: FramebufferTextureLayer (dynamic) */ - "iiiii\0" - "glFramebufferTextureLayerARB\0" - "\0" - /* _mesa_function_pool[11369]: MultiTexCoord3svARB (offset 399) */ - "ip\0" - "glMultiTexCoord3sv\0" - "glMultiTexCoord3svARB\0" - "\0" - /* _mesa_function_pool[11414]: TexEnvfv (offset 185) */ - "iip\0" - "glTexEnvfv\0" - "\0" - /* _mesa_function_pool[11430]: MultiTexCoord4iARB (offset 404) */ - "iiiii\0" - "glMultiTexCoord4i\0" - "glMultiTexCoord4iARB\0" - "\0" - /* _mesa_function_pool[11476]: Indexs (offset 50) */ - "i\0" - "glIndexs\0" - "\0" - /* _mesa_function_pool[11488]: Binormal3ivEXT (dynamic) */ - "p\0" - "glBinormal3ivEXT\0" - "\0" - /* _mesa_function_pool[11508]: ResizeBuffersMESA (will be remapped) */ - "\0" - "glResizeBuffersMESA\0" - "\0" - /* _mesa_function_pool[11530]: GetUniformivARB (will be remapped) */ - "iip\0" - "glGetUniformiv\0" - "glGetUniformivARB\0" - "\0" - /* _mesa_function_pool[11568]: PixelTexGenParameteriSGIS (will be remapped) */ - "ii\0" - "glPixelTexGenParameteriSGIS\0" - "\0" - /* _mesa_function_pool[11600]: VertexPointervINTEL (dynamic) */ - "iip\0" - "glVertexPointervINTEL\0" - "\0" - /* _mesa_function_pool[11627]: Vertex2i (offset 130) */ - "ii\0" - "glVertex2i\0" - "\0" - /* _mesa_function_pool[11642]: LoadMatrixf (offset 291) */ - "p\0" - "glLoadMatrixf\0" - "\0" - /* _mesa_function_pool[11659]: Vertex2f (offset 128) */ - "ff\0" - "glVertex2f\0" - "\0" - /* _mesa_function_pool[11674]: ReplacementCodeuiColor4fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[11727]: Color4bv (offset 26) */ - "p\0" - "glColor4bv\0" - "\0" - /* _mesa_function_pool[11741]: VertexPointer (offset 321) */ - "iiip\0" - "glVertexPointer\0" - "\0" - /* _mesa_function_pool[11763]: SecondaryColor3uiEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3ui\0" - "glSecondaryColor3uiEXT\0" - "\0" - /* _mesa_function_pool[11811]: StartInstrumentsSGIX (dynamic) */ - "\0" - "glStartInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[11836]: SecondaryColor3usvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3usv\0" - "glSecondaryColor3usvEXT\0" - "\0" - /* _mesa_function_pool[11884]: VertexAttrib2fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib2fvNV\0" - "\0" - /* _mesa_function_pool[11908]: ProgramLocalParameter4dvARB (will be remapped) */ - "iip\0" - "glProgramLocalParameter4dvARB\0" - "\0" - /* _mesa_function_pool[11943]: DeleteLists (offset 4) */ - "ii\0" - "glDeleteLists\0" - "\0" - /* _mesa_function_pool[11961]: LogicOp (offset 242) */ - "i\0" - "glLogicOp\0" - "\0" - /* _mesa_function_pool[11974]: MatrixIndexuivARB (dynamic) */ - "ip\0" - "glMatrixIndexuivARB\0" - "\0" - /* _mesa_function_pool[11998]: Vertex2s (offset 132) */ - "ii\0" - "glVertex2s\0" - "\0" - /* _mesa_function_pool[12013]: RenderbufferStorageMultisample (will be remapped) */ - "iiiii\0" - "glRenderbufferStorageMultisample\0" - "glRenderbufferStorageMultisampleEXT\0" - "\0" - /* _mesa_function_pool[12089]: TexCoord4fv (offset 121) */ - "p\0" - "glTexCoord4fv\0" - "\0" - /* _mesa_function_pool[12106]: Tangent3sEXT (dynamic) */ - "iii\0" - "glTangent3sEXT\0" - "\0" - /* _mesa_function_pool[12126]: GlobalAlphaFactorfSUN (dynamic) */ - "f\0" - "glGlobalAlphaFactorfSUN\0" - "\0" - /* _mesa_function_pool[12153]: MultiTexCoord3iARB (offset 396) */ - "iiii\0" - "glMultiTexCoord3i\0" - "glMultiTexCoord3iARB\0" - "\0" - /* _mesa_function_pool[12198]: IsProgram (will be remapped) */ - "i\0" - "glIsProgram\0" - "\0" - /* _mesa_function_pool[12213]: TexCoordPointerListIBM (dynamic) */ - "iiipi\0" - "glTexCoordPointerListIBM\0" - "\0" - /* _mesa_function_pool[12245]: GlobalAlphaFactorusSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorusSUN\0" - "\0" - /* _mesa_function_pool[12273]: VertexAttrib2dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib2dvNV\0" - "\0" - /* _mesa_function_pool[12297]: FramebufferRenderbufferEXT (will be remapped) */ - "iiii\0" - "glFramebufferRenderbuffer\0" - "glFramebufferRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[12358]: VertexAttrib1dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib1dvNV\0" - "\0" - /* _mesa_function_pool[12382]: GenTextures (offset 328) */ - "ip\0" - "glGenTextures\0" - "glGenTexturesEXT\0" - "\0" - /* _mesa_function_pool[12417]: FramebufferTextureARB (will be remapped) */ - "iiii\0" - "glFramebufferTextureARB\0" - "\0" - /* _mesa_function_pool[12447]: SetFenceNV (will be remapped) */ - "ii\0" - "glSetFenceNV\0" - "\0" - /* _mesa_function_pool[12464]: FramebufferTexture1DEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTexture1D\0" - "glFramebufferTexture1DEXT\0" - "\0" - /* _mesa_function_pool[12520]: GetCombinerOutputParameterivNV (will be remapped) */ - "iiip\0" - "glGetCombinerOutputParameterivNV\0" - "\0" - /* _mesa_function_pool[12559]: MultiModeDrawArraysIBM (will be remapped) */ - "pppii\0" - "glMultiModeDrawArraysIBM\0" - "\0" - /* _mesa_function_pool[12591]: PixelTexGenParameterivSGIS (will be remapped) */ - "ip\0" - "glPixelTexGenParameterivSGIS\0" - "\0" - /* _mesa_function_pool[12624]: TextureNormalEXT (dynamic) */ - "i\0" - "glTextureNormalEXT\0" - "\0" - /* _mesa_function_pool[12646]: IndexPointerListIBM (dynamic) */ - "iipi\0" - "glIndexPointerListIBM\0" - "\0" - /* _mesa_function_pool[12674]: WeightfvARB (dynamic) */ - "ip\0" - "glWeightfvARB\0" - "\0" - /* _mesa_function_pool[12692]: GetCombinerOutputParameterfvNV (will be remapped) */ - "iiip\0" - "glGetCombinerOutputParameterfvNV\0" - "\0" - /* _mesa_function_pool[12731]: RasterPos2sv (offset 69) */ - "p\0" - "glRasterPos2sv\0" - "\0" - /* _mesa_function_pool[12749]: Color4ubv (offset 36) */ - "p\0" - "glColor4ubv\0" - "\0" - /* _mesa_function_pool[12764]: DrawBuffer (offset 202) */ - "i\0" - "glDrawBuffer\0" - "\0" - /* _mesa_function_pool[12780]: TexCoord2fv (offset 105) */ - "p\0" - "glTexCoord2fv\0" - "\0" - /* _mesa_function_pool[12797]: WindowPos4fMESA (will be remapped) */ - "ffff\0" - "glWindowPos4fMESA\0" - "\0" - /* _mesa_function_pool[12821]: TexCoord1sv (offset 101) */ - "p\0" - "glTexCoord1sv\0" - "\0" - /* _mesa_function_pool[12838]: WindowPos3dvMESA (will be remapped) */ - "p\0" - "glWindowPos3dv\0" - "glWindowPos3dvARB\0" - "glWindowPos3dvMESA\0" - "\0" - /* _mesa_function_pool[12893]: DepthFunc (offset 245) */ - "i\0" - "glDepthFunc\0" - "\0" - /* _mesa_function_pool[12908]: PixelMapusv (offset 253) */ - "iip\0" - "glPixelMapusv\0" - "\0" - /* _mesa_function_pool[12927]: GetQueryObjecti64vEXT (will be remapped) */ - "iip\0" - "glGetQueryObjecti64vEXT\0" - "\0" - /* _mesa_function_pool[12956]: MultiTexCoord1dARB (offset 376) */ - "id\0" - "glMultiTexCoord1d\0" - "glMultiTexCoord1dARB\0" - "\0" - /* _mesa_function_pool[12999]: PointParameterivNV (will be remapped) */ - "ip\0" - "glPointParameteriv\0" - "glPointParameterivNV\0" - "\0" - /* _mesa_function_pool[13043]: BlendFunc (offset 241) */ - "ii\0" - "glBlendFunc\0" - "\0" - /* _mesa_function_pool[13059]: EndTransformFeedbackEXT (will be remapped) */ - "\0" - "glEndTransformFeedbackEXT\0" - "glEndTransformFeedback\0" - "\0" - /* _mesa_function_pool[13110]: Uniform2fvARB (will be remapped) */ - "iip\0" - "glUniform2fv\0" - "glUniform2fvARB\0" - "\0" - /* _mesa_function_pool[13144]: BufferParameteriAPPLE (will be remapped) */ - "iii\0" - "glBufferParameteriAPPLE\0" - "\0" - /* _mesa_function_pool[13173]: MultiTexCoord3dvARB (offset 393) */ - "ip\0" - "glMultiTexCoord3dv\0" - "glMultiTexCoord3dvARB\0" - "\0" - /* _mesa_function_pool[13218]: ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[13274]: DeleteObjectARB (will be remapped) */ - "i\0" - "glDeleteObjectARB\0" - "\0" - /* _mesa_function_pool[13295]: MatrixIndexPointerARB (dynamic) */ - "iiip\0" - "glMatrixIndexPointerARB\0" - "\0" - /* _mesa_function_pool[13325]: ProgramNamedParameter4dvNV (will be remapped) */ - "iipp\0" - "glProgramNamedParameter4dvNV\0" - "\0" - /* _mesa_function_pool[13360]: Tangent3fvEXT (dynamic) */ - "p\0" - "glTangent3fvEXT\0" - "\0" - /* _mesa_function_pool[13379]: Flush (offset 217) */ - "\0" - "glFlush\0" - "\0" - /* _mesa_function_pool[13389]: Color4uiv (offset 38) */ - "p\0" - "glColor4uiv\0" - "\0" - /* _mesa_function_pool[13404]: GenVertexArrays (will be remapped) */ - "ip\0" - "glGenVertexArrays\0" - "\0" - /* _mesa_function_pool[13426]: RasterPos3sv (offset 77) */ - "p\0" - "glRasterPos3sv\0" - "\0" - /* _mesa_function_pool[13444]: BindFramebufferEXT (will be remapped) */ - "ii\0" - "glBindFramebuffer\0" - "glBindFramebufferEXT\0" - "\0" - /* _mesa_function_pool[13487]: ReferencePlaneSGIX (dynamic) */ - "p\0" - "glReferencePlaneSGIX\0" - "\0" - /* _mesa_function_pool[13511]: PushAttrib (offset 219) */ - "i\0" - "glPushAttrib\0" - "\0" - /* _mesa_function_pool[13527]: RasterPos2i (offset 66) */ - "ii\0" - "glRasterPos2i\0" - "\0" - /* _mesa_function_pool[13545]: ValidateProgramARB (will be remapped) */ - "i\0" - "glValidateProgram\0" - "glValidateProgramARB\0" - "\0" - /* _mesa_function_pool[13587]: TexParameteriv (offset 181) */ - "iip\0" - "glTexParameteriv\0" - "\0" - /* _mesa_function_pool[13609]: UnlockArraysEXT (will be remapped) */ - "\0" - "glUnlockArraysEXT\0" - "\0" - /* _mesa_function_pool[13629]: TexCoord2fColor3fVertex3fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord2fColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[13670]: WindowPos3fvMESA (will be remapped) */ - "p\0" - "glWindowPos3fv\0" - "glWindowPos3fvARB\0" - "glWindowPos3fvMESA\0" - "\0" - /* _mesa_function_pool[13725]: RasterPos2f (offset 64) */ - "ff\0" - "glRasterPos2f\0" - "\0" - /* _mesa_function_pool[13743]: VertexAttrib1svNV (will be remapped) */ - "ip\0" - "glVertexAttrib1svNV\0" - "\0" - /* _mesa_function_pool[13767]: RasterPos2d (offset 62) */ - "dd\0" - "glRasterPos2d\0" - "\0" - /* _mesa_function_pool[13785]: RasterPos3fv (offset 73) */ - "p\0" - "glRasterPos3fv\0" - "\0" - /* _mesa_function_pool[13803]: CopyTexSubImage3D (offset 373) */ - "iiiiiiiii\0" - "glCopyTexSubImage3D\0" - "glCopyTexSubImage3DEXT\0" - "\0" - /* _mesa_function_pool[13857]: VertexAttrib2dARB (will be remapped) */ - "idd\0" - "glVertexAttrib2d\0" - "glVertexAttrib2dARB\0" - "\0" - /* _mesa_function_pool[13899]: Color4ub (offset 35) */ - "iiii\0" - "glColor4ub\0" - "\0" - /* _mesa_function_pool[13916]: GetInteger64v (will be remapped) */ - "ip\0" - "glGetInteger64v\0" - "\0" - /* _mesa_function_pool[13936]: TextureColorMaskSGIS (dynamic) */ - "iiii\0" - "glTextureColorMaskSGIS\0" - "\0" - /* _mesa_function_pool[13965]: RasterPos2s (offset 68) */ - "ii\0" - "glRasterPos2s\0" - "\0" - /* _mesa_function_pool[13983]: GetColorTable (offset 343) */ - "iiip\0" - "glGetColorTable\0" - "glGetColorTableSGI\0" - "glGetColorTableEXT\0" - "\0" - /* _mesa_function_pool[14043]: SelectBuffer (offset 195) */ - "ip\0" - "glSelectBuffer\0" - "\0" - /* _mesa_function_pool[14062]: Indexiv (offset 49) */ - "p\0" - "glIndexiv\0" - "\0" - /* _mesa_function_pool[14075]: TexCoord3i (offset 114) */ - "iii\0" - "glTexCoord3i\0" - "\0" - /* _mesa_function_pool[14093]: CopyColorTable (offset 342) */ - "iiiii\0" - "glCopyColorTable\0" - "glCopyColorTableSGI\0" - "\0" - /* _mesa_function_pool[14137]: GetHistogramParameterfv (offset 362) */ - "iip\0" - "glGetHistogramParameterfv\0" - "glGetHistogramParameterfvEXT\0" - "\0" - /* _mesa_function_pool[14197]: Frustum (offset 289) */ - "dddddd\0" - "glFrustum\0" - "\0" - /* _mesa_function_pool[14215]: GetString (offset 275) */ - "i\0" - "glGetString\0" - "\0" - /* _mesa_function_pool[14230]: ColorPointervINTEL (dynamic) */ - "iip\0" - "glColorPointervINTEL\0" - "\0" - /* _mesa_function_pool[14256]: TexEnvf (offset 184) */ - "iif\0" - "glTexEnvf\0" - "\0" - /* _mesa_function_pool[14271]: TexCoord3d (offset 110) */ - "ddd\0" - "glTexCoord3d\0" - "\0" - /* _mesa_function_pool[14289]: AlphaFragmentOp1ATI (will be remapped) */ - "iiiiii\0" - "glAlphaFragmentOp1ATI\0" - "\0" - /* _mesa_function_pool[14319]: TexCoord3f (offset 112) */ - "fff\0" - "glTexCoord3f\0" - "\0" - /* _mesa_function_pool[14337]: MultiTexCoord3ivARB (offset 397) */ - "ip\0" - "glMultiTexCoord3iv\0" - "glMultiTexCoord3ivARB\0" - "\0" - /* _mesa_function_pool[14382]: MultiTexCoord2sARB (offset 390) */ - "iii\0" - "glMultiTexCoord2s\0" - "glMultiTexCoord2sARB\0" - "\0" - /* _mesa_function_pool[14426]: VertexAttrib1dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib1dv\0" - "glVertexAttrib1dvARB\0" - "\0" - /* _mesa_function_pool[14469]: DeleteTextures (offset 327) */ - "ip\0" - "glDeleteTextures\0" - "glDeleteTexturesEXT\0" - "\0" - /* _mesa_function_pool[14510]: TexCoordPointerEXT (will be remapped) */ - "iiiip\0" - "glTexCoordPointerEXT\0" - "\0" - /* _mesa_function_pool[14538]: TexSubImage4DSGIS (dynamic) */ - "iiiiiiiiiiiip\0" - "glTexSubImage4DSGIS\0" - "\0" - /* _mesa_function_pool[14573]: TexCoord3s (offset 116) */ - "iii\0" - "glTexCoord3s\0" - "\0" - /* _mesa_function_pool[14591]: GetTexLevelParameteriv (offset 285) */ - "iiip\0" - "glGetTexLevelParameteriv\0" - "\0" - /* _mesa_function_pool[14622]: DrawArraysInstanced (will be remapped) */ - "iiii\0" - "glDrawArraysInstanced\0" - "glDrawArraysInstancedARB\0" - "glDrawArraysInstancedEXT\0" - "\0" - /* _mesa_function_pool[14700]: CombinerStageParameterfvNV (dynamic) */ - "iip\0" - "glCombinerStageParameterfvNV\0" - "\0" - /* _mesa_function_pool[14734]: StopInstrumentsSGIX (dynamic) */ - "i\0" - "glStopInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[14759]: TexCoord4fColor4fNormal3fVertex4fSUN (dynamic) */ - "fffffffffffffff\0" - "glTexCoord4fColor4fNormal3fVertex4fSUN\0" - "\0" - /* _mesa_function_pool[14815]: ClearAccum (offset 204) */ - "ffff\0" - "glClearAccum\0" - "\0" - /* _mesa_function_pool[14834]: DeformSGIX (dynamic) */ - "i\0" - "glDeformSGIX\0" - "\0" - /* _mesa_function_pool[14850]: GetVertexAttribfvARB (will be remapped) */ - "iip\0" - "glGetVertexAttribfv\0" - "glGetVertexAttribfvARB\0" - "\0" - /* _mesa_function_pool[14898]: SecondaryColor3ivEXT (will be remapped) */ - "p\0" - "glSecondaryColor3iv\0" - "glSecondaryColor3ivEXT\0" - "\0" - /* _mesa_function_pool[14944]: TexCoord4iv (offset 123) */ - "p\0" - "glTexCoord4iv\0" - "\0" - /* _mesa_function_pool[14961]: UniformMatrix4x2fv (will be remapped) */ - "iiip\0" - "glUniformMatrix4x2fv\0" - "\0" - /* _mesa_function_pool[14988]: GetDetailTexFuncSGIS (dynamic) */ - "ip\0" - "glGetDetailTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[15015]: GetCombinerStageParameterfvNV (dynamic) */ - "iip\0" - "glGetCombinerStageParameterfvNV\0" - "\0" - /* _mesa_function_pool[15052]: PolygonOffset (offset 319) */ - "ff\0" - "glPolygonOffset\0" - "\0" - /* _mesa_function_pool[15072]: BindVertexArray (will be remapped) */ - "i\0" - "glBindVertexArray\0" - "\0" - /* _mesa_function_pool[15093]: Color4ubVertex2fvSUN (dynamic) */ - "pp\0" - "glColor4ubVertex2fvSUN\0" - "\0" - /* _mesa_function_pool[15120]: Rectd (offset 86) */ - "dddd\0" - "glRectd\0" - "\0" - /* _mesa_function_pool[15134]: TexFilterFuncSGIS (dynamic) */ - "iiip\0" - "glTexFilterFuncSGIS\0" - "\0" - /* _mesa_function_pool[15160]: SampleMaskSGIS (will be remapped) */ - "fi\0" - "glSampleMaskSGIS\0" - "glSampleMaskEXT\0" - "\0" - /* _mesa_function_pool[15197]: GetAttribLocationARB (will be remapped) */ - "ip\0" - "glGetAttribLocation\0" - "glGetAttribLocationARB\0" - "\0" - /* _mesa_function_pool[15244]: RasterPos3i (offset 74) */ - "iii\0" - "glRasterPos3i\0" - "\0" - /* _mesa_function_pool[15263]: VertexAttrib4ubvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4ubv\0" - "glVertexAttrib4ubvARB\0" - "\0" - /* _mesa_function_pool[15308]: DetailTexFuncSGIS (dynamic) */ - "iip\0" - "glDetailTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[15333]: Normal3fVertex3fSUN (dynamic) */ - "ffffff\0" - "glNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[15363]: CopyTexImage2D (offset 324) */ - "iiiiiiii\0" - "glCopyTexImage2D\0" - "glCopyTexImage2DEXT\0" - "\0" - /* _mesa_function_pool[15410]: GetBufferPointervARB (will be remapped) */ - "iip\0" - "glGetBufferPointerv\0" - "glGetBufferPointervARB\0" - "\0" - /* _mesa_function_pool[15458]: ProgramEnvParameter4fARB (will be remapped) */ - "iiffff\0" - "glProgramEnvParameter4fARB\0" - "glProgramParameter4fNV\0" - "\0" - /* _mesa_function_pool[15516]: Uniform3ivARB (will be remapped) */ - "iip\0" - "glUniform3iv\0" - "glUniform3ivARB\0" - "\0" - /* _mesa_function_pool[15550]: Lightfv (offset 160) */ - "iip\0" - "glLightfv\0" - "\0" - /* _mesa_function_pool[15565]: ClearDepth (offset 208) */ - "d\0" - "glClearDepth\0" - "\0" - /* _mesa_function_pool[15581]: GetFenceivNV (will be remapped) */ - "iip\0" - "glGetFenceivNV\0" - "\0" - /* _mesa_function_pool[15601]: WindowPos4dvMESA (will be remapped) */ - "p\0" - "glWindowPos4dvMESA\0" - "\0" - /* _mesa_function_pool[15623]: ColorSubTable (offset 346) */ - "iiiiip\0" - "glColorSubTable\0" - "glColorSubTableEXT\0" - "\0" - /* _mesa_function_pool[15666]: Color4fv (offset 30) */ - "p\0" - "glColor4fv\0" - "\0" - /* _mesa_function_pool[15680]: MultiTexCoord4ivARB (offset 405) */ - "ip\0" - "glMultiTexCoord4iv\0" - "glMultiTexCoord4ivARB\0" - "\0" - /* _mesa_function_pool[15725]: DrawElementsInstanced (will be remapped) */ - "iiipi\0" - "glDrawElementsInstanced\0" - "glDrawElementsInstancedARB\0" - "glDrawElementsInstancedEXT\0" - "\0" - /* _mesa_function_pool[15810]: ColorPointer (offset 308) */ - "iiip\0" - "glColorPointer\0" - "\0" - /* _mesa_function_pool[15831]: Rects (offset 92) */ - "iiii\0" - "glRects\0" - "\0" - /* _mesa_function_pool[15845]: GetMapAttribParameterfvNV (dynamic) */ - "iiip\0" - "glGetMapAttribParameterfvNV\0" - "\0" - /* _mesa_function_pool[15879]: Lightiv (offset 162) */ - "iip\0" - "glLightiv\0" - "\0" - /* _mesa_function_pool[15894]: VertexAttrib4sARB (will be remapped) */ - "iiiii\0" - "glVertexAttrib4s\0" - "glVertexAttrib4sARB\0" - "\0" - /* _mesa_function_pool[15938]: GetQueryObjectuivARB (will be remapped) */ - "iip\0" - "glGetQueryObjectuiv\0" - "glGetQueryObjectuivARB\0" - "\0" - /* _mesa_function_pool[15986]: GetTexParameteriv (offset 283) */ - "iip\0" - "glGetTexParameteriv\0" - "\0" - /* _mesa_function_pool[16011]: MapParameterivNV (dynamic) */ - "iip\0" - "glMapParameterivNV\0" - "\0" - /* _mesa_function_pool[16035]: GenRenderbuffersEXT (will be remapped) */ - "ip\0" - "glGenRenderbuffers\0" - "glGenRenderbuffersEXT\0" - "\0" - /* _mesa_function_pool[16080]: VertexAttrib2dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib2dv\0" - "glVertexAttrib2dvARB\0" - "\0" - /* _mesa_function_pool[16123]: EdgeFlagPointerEXT (will be remapped) */ - "iip\0" - "glEdgeFlagPointerEXT\0" - "\0" - /* _mesa_function_pool[16149]: VertexAttribs2svNV (will be remapped) */ - "iip\0" - "glVertexAttribs2svNV\0" - "\0" - /* _mesa_function_pool[16175]: WeightbvARB (dynamic) */ - "ip\0" - "glWeightbvARB\0" - "\0" - /* _mesa_function_pool[16193]: VertexAttrib2fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib2fv\0" - "glVertexAttrib2fvARB\0" - "\0" - /* _mesa_function_pool[16236]: GetBufferParameterivARB (will be remapped) */ - "iip\0" - "glGetBufferParameteriv\0" - "glGetBufferParameterivARB\0" - "\0" - /* _mesa_function_pool[16290]: Rectdv (offset 87) */ - "pp\0" - "glRectdv\0" - "\0" - /* _mesa_function_pool[16303]: ListParameteriSGIX (dynamic) */ - "iii\0" - "glListParameteriSGIX\0" - "\0" - /* _mesa_function_pool[16329]: ReplacementCodeuiColor4fNormal3fVertex3fSUN (dynamic) */ - "iffffffffff\0" - "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[16388]: InstrumentsBufferSGIX (dynamic) */ - "ip\0" - "glInstrumentsBufferSGIX\0" - "\0" - /* _mesa_function_pool[16416]: VertexAttrib4NivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Niv\0" - "glVertexAttrib4NivARB\0" - "\0" - /* _mesa_function_pool[16461]: GetAttachedShaders (will be remapped) */ - "iipp\0" - "glGetAttachedShaders\0" - "\0" - /* _mesa_function_pool[16488]: GenVertexArraysAPPLE (will be remapped) */ - "ip\0" - "glGenVertexArraysAPPLE\0" - "\0" - /* _mesa_function_pool[16515]: Materialiv (offset 172) */ - "iip\0" - "glMaterialiv\0" - "\0" - /* _mesa_function_pool[16533]: PushClientAttrib (offset 335) */ - "i\0" - "glPushClientAttrib\0" - "\0" - /* _mesa_function_pool[16555]: ProgramEnvParameters4fvEXT (will be remapped) */ - "iiip\0" - "glProgramEnvParameters4fvEXT\0" - "\0" - /* _mesa_function_pool[16590]: TexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glTexCoord2fColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[16636]: WindowPos2iMESA (will be remapped) */ - "ii\0" - "glWindowPos2i\0" - "glWindowPos2iARB\0" - "glWindowPos2iMESA\0" - "\0" - /* _mesa_function_pool[16689]: SecondaryColor3fvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3fv\0" - "glSecondaryColor3fvEXT\0" - "\0" - /* _mesa_function_pool[16735]: PolygonMode (offset 174) */ - "ii\0" - "glPolygonMode\0" - "\0" - /* _mesa_function_pool[16753]: CompressedTexSubImage1DARB (will be remapped) */ - "iiiiiip\0" - "glCompressedTexSubImage1D\0" - "glCompressedTexSubImage1DARB\0" - "\0" - /* _mesa_function_pool[16817]: GetVertexAttribivNV (will be remapped) */ - "iip\0" - "glGetVertexAttribivNV\0" - "\0" - /* _mesa_function_pool[16844]: GetProgramStringARB (will be remapped) */ - "iip\0" - "glGetProgramStringARB\0" - "\0" - /* _mesa_function_pool[16871]: TexBumpParameterfvATI (will be remapped) */ - "ip\0" - "glTexBumpParameterfvATI\0" - "\0" - /* _mesa_function_pool[16899]: CompileShaderARB (will be remapped) */ - "i\0" - "glCompileShader\0" - "glCompileShaderARB\0" - "\0" - /* _mesa_function_pool[16937]: DeleteShader (will be remapped) */ - "i\0" - "glDeleteShader\0" - "\0" - /* _mesa_function_pool[16955]: DisableClientState (offset 309) */ - "i\0" - "glDisableClientState\0" - "\0" - /* _mesa_function_pool[16979]: TexGeni (offset 192) */ - "iii\0" - "glTexGeni\0" - "\0" - /* _mesa_function_pool[16994]: TexGenf (offset 190) */ - "iif\0" - "glTexGenf\0" - "\0" - /* _mesa_function_pool[17009]: Uniform3fARB (will be remapped) */ - "ifff\0" - "glUniform3f\0" - "glUniform3fARB\0" - "\0" - /* _mesa_function_pool[17042]: TexGend (offset 188) */ - "iid\0" - "glTexGend\0" - "\0" - /* _mesa_function_pool[17057]: ListParameterfvSGIX (dynamic) */ - "iip\0" - "glListParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[17084]: GetPolygonStipple (offset 274) */ - "p\0" - "glGetPolygonStipple\0" - "\0" - /* _mesa_function_pool[17107]: Tangent3dvEXT (dynamic) */ - "p\0" - "glTangent3dvEXT\0" - "\0" - /* _mesa_function_pool[17126]: BindBufferOffsetEXT (will be remapped) */ - "iiii\0" - "glBindBufferOffsetEXT\0" - "\0" - /* _mesa_function_pool[17154]: WindowPos3sMESA (will be remapped) */ - "iii\0" - "glWindowPos3s\0" - "glWindowPos3sARB\0" - "glWindowPos3sMESA\0" - "\0" - /* _mesa_function_pool[17208]: VertexAttrib2svNV (will be remapped) */ - "ip\0" - "glVertexAttrib2svNV\0" - "\0" - /* _mesa_function_pool[17232]: DisableIndexedEXT (will be remapped) */ - "ii\0" - "glDisableIndexedEXT\0" - "\0" - /* _mesa_function_pool[17256]: BindBufferBaseEXT (will be remapped) */ - "iii\0" - "glBindBufferBaseEXT\0" - "glBindBufferBase\0" - "\0" - /* _mesa_function_pool[17298]: TexCoord2fVertex3fvSUN (dynamic) */ - "pp\0" - "glTexCoord2fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[17327]: WindowPos4sMESA (will be remapped) */ - "iiii\0" - "glWindowPos4sMESA\0" - "\0" - /* _mesa_function_pool[17351]: VertexAttrib4NuivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nuiv\0" - "glVertexAttrib4NuivARB\0" - "\0" - /* _mesa_function_pool[17398]: ClientActiveTextureARB (offset 375) */ - "i\0" - "glClientActiveTexture\0" - "glClientActiveTextureARB\0" - "\0" - /* _mesa_function_pool[17448]: PixelTexGenSGIX (will be remapped) */ - "i\0" - "glPixelTexGenSGIX\0" - "\0" - /* _mesa_function_pool[17469]: ReplacementCodeusvSUN (dynamic) */ - "p\0" - "glReplacementCodeusvSUN\0" - "\0" - /* _mesa_function_pool[17496]: Uniform4fARB (will be remapped) */ - "iffff\0" - "glUniform4f\0" - "glUniform4fARB\0" - "\0" - /* _mesa_function_pool[17530]: Color4sv (offset 34) */ - "p\0" - "glColor4sv\0" - "\0" - /* _mesa_function_pool[17544]: FlushMappedBufferRange (will be remapped) */ - "iii\0" - "glFlushMappedBufferRange\0" - "\0" - /* _mesa_function_pool[17574]: IsProgramNV (will be remapped) */ - "i\0" - "glIsProgramARB\0" - "glIsProgramNV\0" - "\0" - /* _mesa_function_pool[17606]: FlushMappedBufferRangeAPPLE (will be remapped) */ - "iii\0" - "glFlushMappedBufferRangeAPPLE\0" - "\0" - /* _mesa_function_pool[17641]: PixelZoom (offset 246) */ - "ff\0" - "glPixelZoom\0" - "\0" - /* _mesa_function_pool[17657]: ReplacementCodePointerSUN (dynamic) */ - "iip\0" - "glReplacementCodePointerSUN\0" - "\0" - /* _mesa_function_pool[17690]: ProgramEnvParameter4dARB (will be remapped) */ - "iidddd\0" - "glProgramEnvParameter4dARB\0" - "glProgramParameter4dNV\0" - "\0" - /* _mesa_function_pool[17748]: ColorTableParameterfv (offset 340) */ - "iip\0" - "glColorTableParameterfv\0" - "glColorTableParameterfvSGI\0" - "\0" - /* _mesa_function_pool[17804]: FragmentLightModelfSGIX (dynamic) */ - "if\0" - "glFragmentLightModelfSGIX\0" - "\0" - /* _mesa_function_pool[17834]: Binormal3bvEXT (dynamic) */ - "p\0" - "glBinormal3bvEXT\0" - "\0" - /* _mesa_function_pool[17854]: PixelMapuiv (offset 252) */ - "iip\0" - "glPixelMapuiv\0" - "\0" - /* _mesa_function_pool[17873]: Color3dv (offset 12) */ - "p\0" - "glColor3dv\0" - "\0" - /* _mesa_function_pool[17887]: IsTexture (offset 330) */ - "i\0" - "glIsTexture\0" - "glIsTextureEXT\0" - "\0" - /* _mesa_function_pool[17917]: VertexWeightfvEXT (dynamic) */ - "p\0" - "glVertexWeightfvEXT\0" - "\0" - /* _mesa_function_pool[17940]: VertexAttrib1dARB (will be remapped) */ - "id\0" - "glVertexAttrib1d\0" - "glVertexAttrib1dARB\0" - "\0" - /* _mesa_function_pool[17981]: ImageTransformParameterivHP (dynamic) */ - "iip\0" - "glImageTransformParameterivHP\0" - "\0" - /* _mesa_function_pool[18016]: TexCoord4i (offset 122) */ - "iiii\0" - "glTexCoord4i\0" - "\0" - /* _mesa_function_pool[18035]: DeleteQueriesARB (will be remapped) */ - "ip\0" - "glDeleteQueries\0" - "glDeleteQueriesARB\0" - "\0" - /* _mesa_function_pool[18074]: Color4ubVertex2fSUN (dynamic) */ - "iiiiff\0" - "glColor4ubVertex2fSUN\0" - "\0" - /* _mesa_function_pool[18104]: FragmentColorMaterialSGIX (dynamic) */ - "ii\0" - "glFragmentColorMaterialSGIX\0" - "\0" - /* _mesa_function_pool[18136]: CurrentPaletteMatrixARB (dynamic) */ - "i\0" - "glCurrentPaletteMatrixARB\0" - "\0" - /* _mesa_function_pool[18165]: GetMapdv (offset 266) */ - "iip\0" - "glGetMapdv\0" - "\0" - /* _mesa_function_pool[18181]: ObjectPurgeableAPPLE (will be remapped) */ - "iii\0" - "glObjectPurgeableAPPLE\0" - "\0" - /* _mesa_function_pool[18209]: SamplePatternSGIS (will be remapped) */ - "i\0" - "glSamplePatternSGIS\0" - "glSamplePatternEXT\0" - "\0" - /* _mesa_function_pool[18251]: PixelStoref (offset 249) */ - "if\0" - "glPixelStoref\0" - "\0" - /* _mesa_function_pool[18269]: IsQueryARB (will be remapped) */ - "i\0" - "glIsQuery\0" - "glIsQueryARB\0" - "\0" - /* _mesa_function_pool[18295]: ReplacementCodeuiColor4ubVertex3fSUN (dynamic) */ - "iiiiifff\0" - "glReplacementCodeuiColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[18344]: PixelStorei (offset 250) */ - "ii\0" - "glPixelStorei\0" - "\0" - /* _mesa_function_pool[18362]: VertexAttrib4usvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4usv\0" - "glVertexAttrib4usvARB\0" - "\0" - /* _mesa_function_pool[18407]: LinkProgramARB (will be remapped) */ - "i\0" - "glLinkProgram\0" - "glLinkProgramARB\0" - "\0" - /* _mesa_function_pool[18441]: VertexAttrib2fNV (will be remapped) */ - "iff\0" - "glVertexAttrib2fNV\0" - "\0" - /* _mesa_function_pool[18465]: ShaderSourceARB (will be remapped) */ - "iipp\0" - "glShaderSource\0" - "glShaderSourceARB\0" - "\0" - /* _mesa_function_pool[18504]: FragmentMaterialiSGIX (dynamic) */ - "iii\0" - "glFragmentMaterialiSGIX\0" - "\0" - /* _mesa_function_pool[18533]: EvalCoord2dv (offset 233) */ - "p\0" - "glEvalCoord2dv\0" - "\0" - /* _mesa_function_pool[18551]: VertexAttrib3svARB (will be remapped) */ - "ip\0" - "glVertexAttrib3sv\0" - "glVertexAttrib3svARB\0" - "\0" - /* _mesa_function_pool[18594]: ColorMaterial (offset 151) */ - "ii\0" - "glColorMaterial\0" - "\0" - /* _mesa_function_pool[18614]: CompressedTexSubImage3DARB (will be remapped) */ - "iiiiiiiiiip\0" - "glCompressedTexSubImage3D\0" - "glCompressedTexSubImage3DARB\0" - "\0" - /* _mesa_function_pool[18682]: WindowPos2ivMESA (will be remapped) */ - "p\0" - "glWindowPos2iv\0" - "glWindowPos2ivARB\0" - "glWindowPos2ivMESA\0" - "\0" - /* _mesa_function_pool[18737]: IsFramebufferEXT (will be remapped) */ - "i\0" - "glIsFramebuffer\0" - "glIsFramebufferEXT\0" - "\0" - /* _mesa_function_pool[18775]: Uniform4ivARB (will be remapped) */ - "iip\0" - "glUniform4iv\0" - "glUniform4ivARB\0" - "\0" - /* _mesa_function_pool[18809]: GetVertexAttribdvARB (will be remapped) */ - "iip\0" - "glGetVertexAttribdv\0" - "glGetVertexAttribdvARB\0" - "\0" - /* _mesa_function_pool[18857]: TexBumpParameterivATI (will be remapped) */ - "ip\0" - "glTexBumpParameterivATI\0" - "\0" - /* _mesa_function_pool[18885]: GetSeparableFilter (offset 359) */ - "iiippp\0" - "glGetSeparableFilter\0" - "glGetSeparableFilterEXT\0" - "\0" - /* _mesa_function_pool[18938]: Binormal3dEXT (dynamic) */ - "ddd\0" - "glBinormal3dEXT\0" - "\0" - /* _mesa_function_pool[18959]: SpriteParameteriSGIX (dynamic) */ - "ii\0" - "glSpriteParameteriSGIX\0" - "\0" - /* _mesa_function_pool[18986]: RequestResidentProgramsNV (will be remapped) */ - "ip\0" - "glRequestResidentProgramsNV\0" - "\0" - /* _mesa_function_pool[19018]: TagSampleBufferSGIX (dynamic) */ - "\0" - "glTagSampleBufferSGIX\0" - "\0" - /* _mesa_function_pool[19042]: TransformFeedbackVaryingsEXT (will be remapped) */ - "iipi\0" - "glTransformFeedbackVaryingsEXT\0" - "glTransformFeedbackVaryings\0" - "\0" - /* _mesa_function_pool[19107]: FeedbackBuffer (offset 194) */ - "iip\0" - "glFeedbackBuffer\0" - "\0" - /* _mesa_function_pool[19129]: RasterPos2iv (offset 67) */ - "p\0" - "glRasterPos2iv\0" - "\0" - /* _mesa_function_pool[19147]: TexImage1D (offset 182) */ - "iiiiiiip\0" - "glTexImage1D\0" - "\0" - /* _mesa_function_pool[19170]: ListParameterivSGIX (dynamic) */ - "iip\0" - "glListParameterivSGIX\0" - "\0" - /* _mesa_function_pool[19197]: MultiDrawElementsEXT (will be remapped) */ - "ipipi\0" - "glMultiDrawElements\0" - "glMultiDrawElementsEXT\0" - "\0" - /* _mesa_function_pool[19247]: Color3s (offset 17) */ - "iii\0" - "glColor3s\0" - "\0" - /* _mesa_function_pool[19262]: Uniform1ivARB (will be remapped) */ - "iip\0" - "glUniform1iv\0" - "glUniform1ivARB\0" - "\0" - /* _mesa_function_pool[19296]: WindowPos2sMESA (will be remapped) */ - "ii\0" - "glWindowPos2s\0" - "glWindowPos2sARB\0" - "glWindowPos2sMESA\0" - "\0" - /* _mesa_function_pool[19349]: WeightusvARB (dynamic) */ - "ip\0" - "glWeightusvARB\0" - "\0" - /* _mesa_function_pool[19368]: TexCoordPointer (offset 320) */ - "iiip\0" - "glTexCoordPointer\0" - "\0" - /* _mesa_function_pool[19392]: FogCoordPointerEXT (will be remapped) */ - "iip\0" - "glFogCoordPointer\0" - "glFogCoordPointerEXT\0" - "\0" - /* _mesa_function_pool[19436]: IndexMaterialEXT (dynamic) */ - "ii\0" - "glIndexMaterialEXT\0" - "\0" - /* _mesa_function_pool[19459]: Color3i (offset 15) */ - "iii\0" - "glColor3i\0" - "\0" - /* _mesa_function_pool[19474]: FrontFace (offset 157) */ - "i\0" - "glFrontFace\0" - "\0" - /* _mesa_function_pool[19489]: EvalCoord2d (offset 232) */ - "dd\0" - "glEvalCoord2d\0" - "\0" - /* _mesa_function_pool[19507]: SecondaryColor3ubvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3ubv\0" - "glSecondaryColor3ubvEXT\0" - "\0" - /* _mesa_function_pool[19555]: EvalCoord2f (offset 234) */ - "ff\0" - "glEvalCoord2f\0" - "\0" - /* _mesa_function_pool[19573]: VertexAttrib4dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4dv\0" - "glVertexAttrib4dvARB\0" - "\0" - /* _mesa_function_pool[19616]: BindAttribLocationARB (will be remapped) */ - "iip\0" - "glBindAttribLocation\0" - "glBindAttribLocationARB\0" - "\0" - /* _mesa_function_pool[19666]: Color3b (offset 9) */ - "iii\0" - "glColor3b\0" - "\0" - /* _mesa_function_pool[19681]: MultiTexCoord2dARB (offset 384) */ - "idd\0" - "glMultiTexCoord2d\0" - "glMultiTexCoord2dARB\0" - "\0" - /* _mesa_function_pool[19725]: ExecuteProgramNV (will be remapped) */ - "iip\0" - "glExecuteProgramNV\0" - "\0" - /* _mesa_function_pool[19749]: Color3f (offset 13) */ - "fff\0" - "glColor3f\0" - "\0" - /* _mesa_function_pool[19764]: LightEnviSGIX (dynamic) */ - "ii\0" - "glLightEnviSGIX\0" - "\0" - /* _mesa_function_pool[19784]: Color3d (offset 11) */ - "ddd\0" - "glColor3d\0" - "\0" - /* _mesa_function_pool[19799]: Normal3dv (offset 55) */ - "p\0" - "glNormal3dv\0" - "\0" - /* _mesa_function_pool[19814]: Lightf (offset 159) */ - "iif\0" - "glLightf\0" - "\0" - /* _mesa_function_pool[19828]: ReplacementCodeuiSUN (dynamic) */ - "i\0" - "glReplacementCodeuiSUN\0" - "\0" - /* _mesa_function_pool[19854]: MatrixMode (offset 293) */ - "i\0" - "glMatrixMode\0" - "\0" - /* _mesa_function_pool[19870]: GetPixelMapusv (offset 273) */ - "ip\0" - "glGetPixelMapusv\0" - "\0" - /* _mesa_function_pool[19891]: Lighti (offset 161) */ - "iii\0" - "glLighti\0" - "\0" - /* _mesa_function_pool[19905]: VertexAttribPointerNV (will be remapped) */ - "iiiip\0" - "glVertexAttribPointerNV\0" - "\0" - /* _mesa_function_pool[19936]: ProgramLocalParameters4fvEXT (will be remapped) */ - "iiip\0" - "glProgramLocalParameters4fvEXT\0" - "\0" - /* _mesa_function_pool[19973]: GetBooleanIndexedvEXT (will be remapped) */ - "iip\0" - "glGetBooleanIndexedvEXT\0" - "\0" - /* _mesa_function_pool[20002]: GetFramebufferAttachmentParameterivEXT (will be remapped) */ - "iiip\0" - "glGetFramebufferAttachmentParameteriv\0" - "glGetFramebufferAttachmentParameterivEXT\0" - "\0" - /* _mesa_function_pool[20087]: PixelTransformParameterfEXT (dynamic) */ - "iif\0" - "glPixelTransformParameterfEXT\0" - "\0" - /* _mesa_function_pool[20122]: MultiTexCoord4dvARB (offset 401) */ - "ip\0" - "glMultiTexCoord4dv\0" - "glMultiTexCoord4dvARB\0" - "\0" - /* _mesa_function_pool[20167]: PixelTransformParameteriEXT (dynamic) */ - "iii\0" - "glPixelTransformParameteriEXT\0" - "\0" - /* _mesa_function_pool[20202]: GetDoublev (offset 260) */ - "ip\0" - "glGetDoublev\0" - "\0" - /* _mesa_function_pool[20219]: MultMatrixd (offset 295) */ - "p\0" - "glMultMatrixd\0" - "\0" - /* _mesa_function_pool[20236]: MultMatrixf (offset 294) */ - "p\0" - "glMultMatrixf\0" - "\0" - /* _mesa_function_pool[20253]: TexCoord2fColor4ubVertex3fSUN (dynamic) */ - "ffiiiifff\0" - "glTexCoord2fColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[20296]: Uniform1iARB (will be remapped) */ - "ii\0" - "glUniform1i\0" - "glUniform1iARB\0" - "\0" - /* _mesa_function_pool[20327]: VertexAttribPointerARB (will be remapped) */ - "iiiiip\0" - "glVertexAttribPointer\0" - "glVertexAttribPointerARB\0" - "\0" - /* _mesa_function_pool[20382]: VertexAttrib3sNV (will be remapped) */ - "iiii\0" - "glVertexAttrib3sNV\0" - "\0" - /* _mesa_function_pool[20407]: SharpenTexFuncSGIS (dynamic) */ - "iip\0" - "glSharpenTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[20433]: MultiTexCoord4fvARB (offset 403) */ - "ip\0" - "glMultiTexCoord4fv\0" - "glMultiTexCoord4fvARB\0" - "\0" - /* _mesa_function_pool[20478]: UniformMatrix2x3fv (will be remapped) */ - "iiip\0" - "glUniformMatrix2x3fv\0" - "\0" - /* _mesa_function_pool[20505]: TrackMatrixNV (will be remapped) */ - "iiii\0" - "glTrackMatrixNV\0" - "\0" - /* _mesa_function_pool[20527]: CombinerParameteriNV (will be remapped) */ - "ii\0" - "glCombinerParameteriNV\0" - "\0" - /* _mesa_function_pool[20554]: DeleteAsyncMarkersSGIX (dynamic) */ - "ii\0" - "glDeleteAsyncMarkersSGIX\0" - "\0" - /* _mesa_function_pool[20583]: ReplacementCodeusSUN (dynamic) */ - "i\0" - "glReplacementCodeusSUN\0" - "\0" - /* _mesa_function_pool[20609]: IsAsyncMarkerSGIX (dynamic) */ - "i\0" - "glIsAsyncMarkerSGIX\0" - "\0" - /* _mesa_function_pool[20632]: FrameZoomSGIX (dynamic) */ - "i\0" - "glFrameZoomSGIX\0" - "\0" - /* _mesa_function_pool[20651]: Normal3fVertex3fvSUN (dynamic) */ - "pp\0" - "glNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[20678]: RasterPos4sv (offset 85) */ - "p\0" - "glRasterPos4sv\0" - "\0" - /* _mesa_function_pool[20696]: VertexAttrib4NsvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nsv\0" - "glVertexAttrib4NsvARB\0" - "\0" - /* _mesa_function_pool[20741]: VertexAttrib3fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib3fv\0" - "glVertexAttrib3fvARB\0" - "\0" - /* _mesa_function_pool[20784]: ClearColor (offset 206) */ - "ffff\0" - "glClearColor\0" - "\0" - /* _mesa_function_pool[20803]: GetSynciv (will be remapped) */ - "iiipp\0" - "glGetSynciv\0" - "\0" - /* _mesa_function_pool[20822]: DeleteFramebuffersEXT (will be remapped) */ - "ip\0" - "glDeleteFramebuffers\0" - "glDeleteFramebuffersEXT\0" - "\0" - /* _mesa_function_pool[20871]: GlobalAlphaFactorsSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorsSUN\0" - "\0" - /* _mesa_function_pool[20898]: IsEnabledIndexedEXT (will be remapped) */ - "ii\0" - "glIsEnabledIndexedEXT\0" - "\0" - /* _mesa_function_pool[20924]: TexEnviv (offset 187) */ - "iip\0" - "glTexEnviv\0" - "\0" - /* _mesa_function_pool[20940]: TexSubImage3D (offset 372) */ - "iiiiiiiiiip\0" - "glTexSubImage3D\0" - "glTexSubImage3DEXT\0" - "\0" - /* _mesa_function_pool[20988]: Tangent3fEXT (dynamic) */ - "fff\0" - "glTangent3fEXT\0" - "\0" - /* _mesa_function_pool[21008]: SecondaryColor3uivEXT (will be remapped) */ - "p\0" - "glSecondaryColor3uiv\0" - "glSecondaryColor3uivEXT\0" - "\0" - /* _mesa_function_pool[21056]: MatrixIndexubvARB (dynamic) */ - "ip\0" - "glMatrixIndexubvARB\0" - "\0" - /* _mesa_function_pool[21080]: Color4fNormal3fVertex3fSUN (dynamic) */ - "ffffffffff\0" - "glColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[21121]: PixelTexGenParameterfSGIS (will be remapped) */ - "if\0" - "glPixelTexGenParameterfSGIS\0" - "\0" - /* _mesa_function_pool[21153]: CreateShader (will be remapped) */ - "i\0" - "glCreateShader\0" - "\0" - /* _mesa_function_pool[21171]: GetColorTableParameterfv (offset 344) */ - "iip\0" - "glGetColorTableParameterfv\0" - "glGetColorTableParameterfvSGI\0" - "glGetColorTableParameterfvEXT\0" - "\0" - /* _mesa_function_pool[21263]: FragmentLightModelfvSGIX (dynamic) */ - "ip\0" - "glFragmentLightModelfvSGIX\0" - "\0" - /* _mesa_function_pool[21294]: Bitmap (offset 8) */ - "iiffffp\0" - "glBitmap\0" - "\0" - /* _mesa_function_pool[21312]: MultiTexCoord3fARB (offset 394) */ - "ifff\0" - "glMultiTexCoord3f\0" - "glMultiTexCoord3fARB\0" - "\0" - /* _mesa_function_pool[21357]: GetTexLevelParameterfv (offset 284) */ - "iiip\0" - "glGetTexLevelParameterfv\0" - "\0" - /* _mesa_function_pool[21388]: GetPixelTexGenParameterfvSGIS (will be remapped) */ - "ip\0" - "glGetPixelTexGenParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[21424]: GenFramebuffersEXT (will be remapped) */ - "ip\0" - "glGenFramebuffers\0" - "glGenFramebuffersEXT\0" - "\0" - /* _mesa_function_pool[21467]: GetProgramParameterdvNV (will be remapped) */ - "iiip\0" - "glGetProgramParameterdvNV\0" - "\0" - /* _mesa_function_pool[21499]: Vertex2sv (offset 133) */ - "p\0" - "glVertex2sv\0" - "\0" - /* _mesa_function_pool[21514]: GetIntegerv (offset 263) */ - "ip\0" - "glGetIntegerv\0" - "\0" - /* _mesa_function_pool[21532]: IsVertexArrayAPPLE (will be remapped) */ - "i\0" - "glIsVertexArray\0" - "glIsVertexArrayAPPLE\0" - "\0" - /* _mesa_function_pool[21572]: FragmentLightfvSGIX (dynamic) */ - "iip\0" - "glFragmentLightfvSGIX\0" - "\0" - /* _mesa_function_pool[21599]: DetachShader (will be remapped) */ - "ii\0" - "glDetachShader\0" - "\0" - /* _mesa_function_pool[21618]: VertexAttrib4NubARB (will be remapped) */ - "iiiii\0" - "glVertexAttrib4Nub\0" - "glVertexAttrib4NubARB\0" - "\0" - /* _mesa_function_pool[21666]: GetProgramEnvParameterfvARB (will be remapped) */ - "iip\0" - "glGetProgramEnvParameterfvARB\0" - "\0" - /* _mesa_function_pool[21701]: GetTrackMatrixivNV (will be remapped) */ - "iiip\0" - "glGetTrackMatrixivNV\0" - "\0" - /* _mesa_function_pool[21728]: VertexAttrib3svNV (will be remapped) */ - "ip\0" - "glVertexAttrib3svNV\0" - "\0" - /* _mesa_function_pool[21752]: Uniform4fvARB (will be remapped) */ - "iip\0" - "glUniform4fv\0" - "glUniform4fvARB\0" - "\0" - /* _mesa_function_pool[21786]: MultTransposeMatrixfARB (will be remapped) */ - "p\0" - "glMultTransposeMatrixf\0" - "glMultTransposeMatrixfARB\0" - "\0" - /* _mesa_function_pool[21838]: GetTexEnviv (offset 277) */ - "iip\0" - "glGetTexEnviv\0" - "\0" - /* _mesa_function_pool[21857]: ColorFragmentOp1ATI (will be remapped) */ - "iiiiiii\0" - "glColorFragmentOp1ATI\0" - "\0" - /* _mesa_function_pool[21888]: GetUniformfvARB (will be remapped) */ - "iip\0" - "glGetUniformfv\0" - "glGetUniformfvARB\0" - "\0" - /* _mesa_function_pool[21926]: EGLImageTargetRenderbufferStorageOES (will be remapped) */ - "ip\0" - "glEGLImageTargetRenderbufferStorageOES\0" - "\0" - /* _mesa_function_pool[21969]: PopClientAttrib (offset 334) */ - "\0" - "glPopClientAttrib\0" - "\0" - /* _mesa_function_pool[21989]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ - "iffffffffffff\0" - "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[22060]: DetachObjectARB (will be remapped) */ - "ii\0" - "glDetachObjectARB\0" - "\0" - /* _mesa_function_pool[22082]: VertexBlendARB (dynamic) */ - "i\0" - "glVertexBlendARB\0" - "\0" - /* _mesa_function_pool[22102]: WindowPos3iMESA (will be remapped) */ - "iii\0" - "glWindowPos3i\0" - "glWindowPos3iARB\0" - "glWindowPos3iMESA\0" - "\0" - /* _mesa_function_pool[22156]: SeparableFilter2D (offset 360) */ - "iiiiiipp\0" - "glSeparableFilter2D\0" - "glSeparableFilter2DEXT\0" - "\0" - /* _mesa_function_pool[22209]: ProgramParameteriARB (will be remapped) */ - "iii\0" - "glProgramParameteriARB\0" - "\0" - /* _mesa_function_pool[22237]: Map1d (offset 220) */ - "iddiip\0" - "glMap1d\0" - "\0" - /* _mesa_function_pool[22253]: Map1f (offset 221) */ - "iffiip\0" - "glMap1f\0" - "\0" - /* _mesa_function_pool[22269]: CompressedTexImage2DARB (will be remapped) */ - "iiiiiiip\0" - "glCompressedTexImage2D\0" - "glCompressedTexImage2DARB\0" - "\0" - /* _mesa_function_pool[22328]: ArrayElement (offset 306) */ - "i\0" - "glArrayElement\0" - "glArrayElementEXT\0" - "\0" - /* _mesa_function_pool[22364]: TexImage2D (offset 183) */ - "iiiiiiiip\0" - "glTexImage2D\0" - "\0" - /* _mesa_function_pool[22388]: DepthBoundsEXT (will be remapped) */ - "dd\0" - "glDepthBoundsEXT\0" - "\0" - /* _mesa_function_pool[22409]: ProgramParameters4fvNV (will be remapped) */ - "iiip\0" - "glProgramParameters4fvNV\0" - "\0" - /* _mesa_function_pool[22440]: DeformationMap3fSGIX (dynamic) */ - "iffiiffiiffiip\0" - "glDeformationMap3fSGIX\0" - "\0" - /* _mesa_function_pool[22479]: GetProgramivNV (will be remapped) */ - "iip\0" - "glGetProgramivNV\0" - "\0" - /* _mesa_function_pool[22501]: GetMinmaxParameteriv (offset 366) */ - "iip\0" - "glGetMinmaxParameteriv\0" - "glGetMinmaxParameterivEXT\0" - "\0" - /* _mesa_function_pool[22555]: PixelTransferf (offset 247) */ - "if\0" - "glPixelTransferf\0" - "\0" - /* _mesa_function_pool[22576]: CopyTexImage1D (offset 323) */ - "iiiiiii\0" - "glCopyTexImage1D\0" - "glCopyTexImage1DEXT\0" - "\0" - /* _mesa_function_pool[22622]: PushMatrix (offset 298) */ - "\0" - "glPushMatrix\0" - "\0" - /* _mesa_function_pool[22637]: Fogiv (offset 156) */ - "ip\0" - "glFogiv\0" - "\0" - /* _mesa_function_pool[22649]: TexCoord1dv (offset 95) */ - "p\0" - "glTexCoord1dv\0" - "\0" - /* _mesa_function_pool[22666]: AlphaFragmentOp3ATI (will be remapped) */ - "iiiiiiiiiiii\0" - "glAlphaFragmentOp3ATI\0" - "\0" - /* _mesa_function_pool[22702]: PixelTransferi (offset 248) */ - "ii\0" - "glPixelTransferi\0" - "\0" - /* _mesa_function_pool[22723]: GetVertexAttribdvNV (will be remapped) */ - "iip\0" - "glGetVertexAttribdvNV\0" - "\0" - /* _mesa_function_pool[22750]: VertexAttrib3fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib3fvNV\0" - "\0" - /* _mesa_function_pool[22774]: Rotatef (offset 300) */ - "ffff\0" - "glRotatef\0" - "\0" - /* _mesa_function_pool[22790]: GetFinalCombinerInputParameterivNV (will be remapped) */ - "iip\0" - "glGetFinalCombinerInputParameterivNV\0" - "\0" - /* _mesa_function_pool[22832]: Vertex3i (offset 138) */ - "iii\0" - "glVertex3i\0" - "\0" - /* _mesa_function_pool[22848]: Vertex3f (offset 136) */ - "fff\0" - "glVertex3f\0" - "\0" - /* _mesa_function_pool[22864]: Clear (offset 203) */ - "i\0" - "glClear\0" - "\0" - /* _mesa_function_pool[22875]: Vertex3d (offset 134) */ - "ddd\0" - "glVertex3d\0" - "\0" - /* _mesa_function_pool[22891]: GetMapParameterivNV (dynamic) */ - "iip\0" - "glGetMapParameterivNV\0" - "\0" - /* _mesa_function_pool[22918]: Uniform4iARB (will be remapped) */ - "iiiii\0" - "glUniform4i\0" - "glUniform4iARB\0" - "\0" - /* _mesa_function_pool[22952]: ReadBuffer (offset 254) */ - "i\0" - "glReadBuffer\0" - "\0" - /* _mesa_function_pool[22968]: ConvolutionParameteri (offset 352) */ - "iii\0" - "glConvolutionParameteri\0" - "glConvolutionParameteriEXT\0" - "\0" - /* _mesa_function_pool[23024]: Ortho (offset 296) */ - "dddddd\0" - "glOrtho\0" - "\0" - /* _mesa_function_pool[23040]: Binormal3sEXT (dynamic) */ - "iii\0" - "glBinormal3sEXT\0" - "\0" - /* _mesa_function_pool[23061]: ListBase (offset 6) */ - "i\0" - "glListBase\0" - "\0" - /* _mesa_function_pool[23075]: Vertex3s (offset 140) */ - "iii\0" - "glVertex3s\0" - "\0" - /* _mesa_function_pool[23091]: ConvolutionParameterf (offset 350) */ - "iif\0" - "glConvolutionParameterf\0" - "glConvolutionParameterfEXT\0" - "\0" - /* _mesa_function_pool[23147]: GetColorTableParameteriv (offset 345) */ - "iip\0" - "glGetColorTableParameteriv\0" - "glGetColorTableParameterivSGI\0" - "glGetColorTableParameterivEXT\0" - "\0" - /* _mesa_function_pool[23239]: ProgramEnvParameter4dvARB (will be remapped) */ - "iip\0" - "glProgramEnvParameter4dvARB\0" - "glProgramParameter4dvNV\0" - "\0" - /* _mesa_function_pool[23296]: ShadeModel (offset 177) */ - "i\0" - "glShadeModel\0" - "\0" - /* _mesa_function_pool[23312]: VertexAttribs2fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs2fvNV\0" - "\0" - /* _mesa_function_pool[23338]: Rectiv (offset 91) */ - "pp\0" - "glRectiv\0" - "\0" - /* _mesa_function_pool[23351]: UseProgramObjectARB (will be remapped) */ - "i\0" - "glUseProgram\0" - "glUseProgramObjectARB\0" - "\0" - /* _mesa_function_pool[23389]: GetMapParameterfvNV (dynamic) */ - "iip\0" - "glGetMapParameterfvNV\0" - "\0" - /* _mesa_function_pool[23416]: EndConditionalRenderNV (will be remapped) */ - "\0" - "glEndConditionalRenderNV\0" - "\0" - /* _mesa_function_pool[23443]: PassTexCoordATI (will be remapped) */ - "iii\0" - "glPassTexCoordATI\0" - "\0" - /* _mesa_function_pool[23466]: DeleteProgram (will be remapped) */ - "i\0" - "glDeleteProgram\0" - "\0" - /* _mesa_function_pool[23485]: Tangent3ivEXT (dynamic) */ - "p\0" - "glTangent3ivEXT\0" - "\0" - /* _mesa_function_pool[23504]: Tangent3dEXT (dynamic) */ - "ddd\0" - "glTangent3dEXT\0" - "\0" - /* _mesa_function_pool[23524]: SecondaryColor3dvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3dv\0" - "glSecondaryColor3dvEXT\0" - "\0" - /* _mesa_function_pool[23570]: Vertex2fv (offset 129) */ - "p\0" - "glVertex2fv\0" - "\0" - /* _mesa_function_pool[23585]: MultiDrawArraysEXT (will be remapped) */ - "ippi\0" - "glMultiDrawArrays\0" - "glMultiDrawArraysEXT\0" - "\0" - /* _mesa_function_pool[23630]: BindRenderbufferEXT (will be remapped) */ - "ii\0" - "glBindRenderbuffer\0" - "glBindRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[23675]: MultiTexCoord4dARB (offset 400) */ - "idddd\0" - "glMultiTexCoord4d\0" - "glMultiTexCoord4dARB\0" - "\0" - /* _mesa_function_pool[23721]: FramebufferTextureFaceARB (will be remapped) */ - "iiiii\0" - "glFramebufferTextureFaceARB\0" - "\0" - /* _mesa_function_pool[23756]: Vertex3sv (offset 141) */ - "p\0" - "glVertex3sv\0" - "\0" - /* _mesa_function_pool[23771]: SecondaryColor3usEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3us\0" - "glSecondaryColor3usEXT\0" - "\0" - /* _mesa_function_pool[23819]: ProgramLocalParameter4fvARB (will be remapped) */ - "iip\0" - "glProgramLocalParameter4fvARB\0" - "\0" - /* _mesa_function_pool[23854]: DeleteProgramsNV (will be remapped) */ - "ip\0" - "glDeleteProgramsARB\0" - "glDeleteProgramsNV\0" - "\0" - /* _mesa_function_pool[23897]: EvalMesh1 (offset 236) */ - "iii\0" - "glEvalMesh1\0" - "\0" - /* _mesa_function_pool[23914]: PauseTransformFeedback (will be remapped) */ - "\0" - "glPauseTransformFeedback\0" - "\0" - /* _mesa_function_pool[23941]: MultiTexCoord1sARB (offset 382) */ - "ii\0" - "glMultiTexCoord1s\0" - "glMultiTexCoord1sARB\0" - "\0" - /* _mesa_function_pool[23984]: ReplacementCodeuiColor3fVertex3fSUN (dynamic) */ - "iffffff\0" - "glReplacementCodeuiColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[24031]: GetVertexAttribPointervNV (will be remapped) */ - "iip\0" - "glGetVertexAttribPointerv\0" - "glGetVertexAttribPointervARB\0" - "glGetVertexAttribPointervNV\0" - "\0" - /* _mesa_function_pool[24119]: VertexAttribs1fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs1fvNV\0" - "\0" - /* _mesa_function_pool[24145]: MultiTexCoord1dvARB (offset 377) */ - "ip\0" - "glMultiTexCoord1dv\0" - "glMultiTexCoord1dvARB\0" - "\0" - /* _mesa_function_pool[24190]: Uniform2iARB (will be remapped) */ - "iii\0" - "glUniform2i\0" - "glUniform2iARB\0" - "\0" - /* _mesa_function_pool[24222]: Vertex2iv (offset 131) */ - "p\0" - "glVertex2iv\0" - "\0" - /* _mesa_function_pool[24237]: GetProgramStringNV (will be remapped) */ - "iip\0" - "glGetProgramStringNV\0" - "\0" - /* _mesa_function_pool[24263]: ColorPointerEXT (will be remapped) */ - "iiiip\0" - "glColorPointerEXT\0" - "\0" - /* _mesa_function_pool[24288]: LineWidth (offset 168) */ - "f\0" - "glLineWidth\0" - "\0" - /* _mesa_function_pool[24303]: MapBufferARB (will be remapped) */ - "ii\0" - "glMapBuffer\0" - "glMapBufferARB\0" - "\0" - /* _mesa_function_pool[24334]: MultiDrawElementsBaseVertex (will be remapped) */ - "ipipip\0" - "glMultiDrawElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[24372]: Binormal3svEXT (dynamic) */ - "p\0" - "glBinormal3svEXT\0" - "\0" - /* _mesa_function_pool[24392]: ApplyTextureEXT (dynamic) */ - "i\0" - "glApplyTextureEXT\0" - "\0" - /* _mesa_function_pool[24413]: TexGendv (offset 189) */ - "iip\0" - "glTexGendv\0" - "\0" - /* _mesa_function_pool[24429]: EnableIndexedEXT (will be remapped) */ - "ii\0" - "glEnableIndexedEXT\0" - "\0" - /* _mesa_function_pool[24452]: TextureMaterialEXT (dynamic) */ - "ii\0" - "glTextureMaterialEXT\0" - "\0" - /* _mesa_function_pool[24477]: TextureLightEXT (dynamic) */ - "i\0" - "glTextureLightEXT\0" - "\0" - /* _mesa_function_pool[24498]: ResetMinmax (offset 370) */ - "i\0" - "glResetMinmax\0" - "glResetMinmaxEXT\0" - "\0" - /* _mesa_function_pool[24532]: SpriteParameterfSGIX (dynamic) */ - "if\0" - "glSpriteParameterfSGIX\0" - "\0" - /* _mesa_function_pool[24559]: EnableClientState (offset 313) */ - "i\0" - "glEnableClientState\0" - "\0" - /* _mesa_function_pool[24582]: VertexAttrib4sNV (will be remapped) */ - "iiiii\0" - "glVertexAttrib4sNV\0" - "\0" - /* _mesa_function_pool[24608]: GetConvolutionParameterfv (offset 357) */ - "iip\0" - "glGetConvolutionParameterfv\0" - "glGetConvolutionParameterfvEXT\0" - "\0" - /* _mesa_function_pool[24672]: VertexAttribs4dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4dvNV\0" - "\0" - /* _mesa_function_pool[24698]: VertexAttrib4dARB (will be remapped) */ - "idddd\0" - "glVertexAttrib4d\0" - "glVertexAttrib4dARB\0" - "\0" - /* _mesa_function_pool[24742]: GetTexBumpParameterfvATI (will be remapped) */ - "ip\0" - "glGetTexBumpParameterfvATI\0" - "\0" - /* _mesa_function_pool[24773]: ProgramNamedParameter4dNV (will be remapped) */ - "iipdddd\0" - "glProgramNamedParameter4dNV\0" - "\0" - /* _mesa_function_pool[24810]: GetMaterialfv (offset 269) */ - "iip\0" - "glGetMaterialfv\0" - "\0" - /* _mesa_function_pool[24831]: VertexWeightfEXT (dynamic) */ - "f\0" - "glVertexWeightfEXT\0" - "\0" - /* _mesa_function_pool[24853]: Binormal3fEXT (dynamic) */ - "fff\0" - "glBinormal3fEXT\0" - "\0" - /* _mesa_function_pool[24874]: CallList (offset 2) */ - "i\0" - "glCallList\0" - "\0" - /* _mesa_function_pool[24888]: Materialfv (offset 170) */ - "iip\0" - "glMaterialfv\0" - "\0" - /* _mesa_function_pool[24906]: TexCoord3fv (offset 113) */ - "p\0" - "glTexCoord3fv\0" - "\0" - /* _mesa_function_pool[24923]: FogCoordfvEXT (will be remapped) */ - "p\0" - "glFogCoordfv\0" - "glFogCoordfvEXT\0" - "\0" - /* _mesa_function_pool[24955]: MultiTexCoord1ivARB (offset 381) */ - "ip\0" - "glMultiTexCoord1iv\0" - "glMultiTexCoord1ivARB\0" - "\0" - /* _mesa_function_pool[25000]: SecondaryColor3ubEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3ub\0" - "glSecondaryColor3ubEXT\0" - "\0" - /* _mesa_function_pool[25048]: MultiTexCoord2ivARB (offset 389) */ - "ip\0" - "glMultiTexCoord2iv\0" - "glMultiTexCoord2ivARB\0" - "\0" - /* _mesa_function_pool[25093]: FogFuncSGIS (dynamic) */ - "ip\0" - "glFogFuncSGIS\0" - "\0" - /* _mesa_function_pool[25111]: CopyTexSubImage2D (offset 326) */ - "iiiiiiii\0" - "glCopyTexSubImage2D\0" - "glCopyTexSubImage2DEXT\0" - "\0" - /* _mesa_function_pool[25164]: GetObjectParameterivARB (will be remapped) */ - "iip\0" - "glGetObjectParameterivARB\0" - "\0" - /* _mesa_function_pool[25195]: Color3iv (offset 16) */ - "p\0" - "glColor3iv\0" - "\0" - /* _mesa_function_pool[25209]: TexCoord4fVertex4fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord4fVertex4fSUN\0" - "\0" - /* _mesa_function_pool[25243]: DrawElements (offset 311) */ - "iiip\0" - "glDrawElements\0" - "\0" - /* _mesa_function_pool[25264]: BindVertexArrayAPPLE (will be remapped) */ - "i\0" - "glBindVertexArrayAPPLE\0" - "\0" - /* _mesa_function_pool[25290]: GetProgramLocalParameterdvARB (will be remapped) */ - "iip\0" - "glGetProgramLocalParameterdvARB\0" - "\0" - /* _mesa_function_pool[25327]: GetHistogramParameteriv (offset 363) */ - "iip\0" - "glGetHistogramParameteriv\0" - "glGetHistogramParameterivEXT\0" - "\0" - /* _mesa_function_pool[25387]: MultiTexCoord1iARB (offset 380) */ - "ii\0" - "glMultiTexCoord1i\0" - "glMultiTexCoord1iARB\0" - "\0" - /* _mesa_function_pool[25430]: GetConvolutionFilter (offset 356) */ - "iiip\0" - "glGetConvolutionFilter\0" - "glGetConvolutionFilterEXT\0" - "\0" - /* _mesa_function_pool[25485]: GetProgramivARB (will be remapped) */ - "iip\0" - "glGetProgramivARB\0" - "\0" - /* _mesa_function_pool[25508]: BlendFuncSeparateEXT (will be remapped) */ - "iiii\0" - "glBlendFuncSeparate\0" - "glBlendFuncSeparateEXT\0" - "glBlendFuncSeparateINGR\0" - "\0" - /* _mesa_function_pool[25581]: MapBufferRange (will be remapped) */ - "iiii\0" - "glMapBufferRange\0" - "\0" - /* _mesa_function_pool[25604]: ProgramParameters4dvNV (will be remapped) */ - "iiip\0" - "glProgramParameters4dvNV\0" - "\0" - /* _mesa_function_pool[25635]: TexCoord2fColor3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[25672]: EvalPoint2 (offset 239) */ - "ii\0" - "glEvalPoint2\0" - "\0" - /* _mesa_function_pool[25689]: EvalPoint1 (offset 237) */ - "i\0" - "glEvalPoint1\0" - "\0" - /* _mesa_function_pool[25705]: Binormal3dvEXT (dynamic) */ - "p\0" - "glBinormal3dvEXT\0" - "\0" - /* _mesa_function_pool[25725]: PopMatrix (offset 297) */ - "\0" - "glPopMatrix\0" - "\0" - /* _mesa_function_pool[25739]: FinishFenceNV (will be remapped) */ - "i\0" - "glFinishFenceNV\0" - "\0" - /* _mesa_function_pool[25758]: GetFogFuncSGIS (dynamic) */ - "p\0" - "glGetFogFuncSGIS\0" - "\0" - /* _mesa_function_pool[25778]: GetUniformLocationARB (will be remapped) */ - "ip\0" - "glGetUniformLocation\0" - "glGetUniformLocationARB\0" - "\0" - /* _mesa_function_pool[25827]: SecondaryColor3fEXT (will be remapped) */ - "fff\0" - "glSecondaryColor3f\0" - "glSecondaryColor3fEXT\0" - "\0" - /* _mesa_function_pool[25873]: GetTexGeniv (offset 280) */ - "iip\0" - "glGetTexGeniv\0" - "\0" - /* _mesa_function_pool[25892]: CombinerInputNV (will be remapped) */ - "iiiiii\0" - "glCombinerInputNV\0" - "\0" - /* _mesa_function_pool[25918]: VertexAttrib3sARB (will be remapped) */ - "iiii\0" - "glVertexAttrib3s\0" - "glVertexAttrib3sARB\0" - "\0" - /* _mesa_function_pool[25961]: IsTransformFeedback (will be remapped) */ - "i\0" - "glIsTransformFeedback\0" - "\0" - /* _mesa_function_pool[25986]: ReplacementCodeuiNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[26031]: Map2d (offset 222) */ - "iddiiddiip\0" - "glMap2d\0" - "\0" - /* _mesa_function_pool[26051]: Map2f (offset 223) */ - "iffiiffiip\0" - "glMap2f\0" - "\0" - /* _mesa_function_pool[26071]: ProgramStringARB (will be remapped) */ - "iiip\0" - "glProgramStringARB\0" - "\0" - /* _mesa_function_pool[26096]: Vertex4s (offset 148) */ - "iiii\0" - "glVertex4s\0" - "\0" - /* _mesa_function_pool[26113]: TexCoord4fVertex4fvSUN (dynamic) */ - "pp\0" - "glTexCoord4fVertex4fvSUN\0" - "\0" - /* _mesa_function_pool[26142]: FragmentLightModelivSGIX (dynamic) */ - "ip\0" - "glFragmentLightModelivSGIX\0" - "\0" - /* _mesa_function_pool[26173]: VertexAttrib1fNV (will be remapped) */ - "if\0" - "glVertexAttrib1fNV\0" - "\0" - /* _mesa_function_pool[26196]: Vertex4f (offset 144) */ - "ffff\0" - "glVertex4f\0" - "\0" - /* _mesa_function_pool[26213]: EvalCoord1d (offset 228) */ - "d\0" - "glEvalCoord1d\0" - "\0" - /* _mesa_function_pool[26230]: Vertex4d (offset 142) */ - "dddd\0" - "glVertex4d\0" - "\0" - /* _mesa_function_pool[26247]: RasterPos4dv (offset 79) */ - "p\0" - "glRasterPos4dv\0" - "\0" - /* _mesa_function_pool[26265]: FragmentLightfSGIX (dynamic) */ - "iif\0" - "glFragmentLightfSGIX\0" - "\0" - /* _mesa_function_pool[26291]: GetCompressedTexImageARB (will be remapped) */ - "iip\0" - "glGetCompressedTexImage\0" - "glGetCompressedTexImageARB\0" - "\0" - /* _mesa_function_pool[26347]: GetTexGenfv (offset 279) */ - "iip\0" - "glGetTexGenfv\0" - "\0" - /* _mesa_function_pool[26366]: Vertex4i (offset 146) */ - "iiii\0" - "glVertex4i\0" - "\0" - /* _mesa_function_pool[26383]: VertexWeightPointerEXT (dynamic) */ - "iiip\0" - "glVertexWeightPointerEXT\0" - "\0" - /* _mesa_function_pool[26414]: GetHistogram (offset 361) */ - "iiiip\0" - "glGetHistogram\0" - "glGetHistogramEXT\0" - "\0" - /* _mesa_function_pool[26454]: ActiveStencilFaceEXT (will be remapped) */ - "i\0" - "glActiveStencilFaceEXT\0" - "\0" - /* _mesa_function_pool[26480]: StencilFuncSeparateATI (will be remapped) */ - "iiii\0" - "glStencilFuncSeparateATI\0" - "\0" - /* _mesa_function_pool[26511]: Materialf (offset 169) */ - "iif\0" - "glMaterialf\0" - "\0" - /* _mesa_function_pool[26528]: GetShaderSourceARB (will be remapped) */ - "iipp\0" - "glGetShaderSource\0" - "glGetShaderSourceARB\0" - "\0" - /* _mesa_function_pool[26573]: IglooInterfaceSGIX (dynamic) */ - "ip\0" - "glIglooInterfaceSGIX\0" - "\0" - /* _mesa_function_pool[26598]: Materiali (offset 171) */ - "iii\0" - "glMateriali\0" - "\0" - /* _mesa_function_pool[26615]: VertexAttrib4dNV (will be remapped) */ - "idddd\0" - "glVertexAttrib4dNV\0" - "\0" - /* _mesa_function_pool[26641]: MultiModeDrawElementsIBM (will be remapped) */ - "ppipii\0" - "glMultiModeDrawElementsIBM\0" - "\0" - /* _mesa_function_pool[26676]: Indexsv (offset 51) */ - "p\0" - "glIndexsv\0" - "\0" - /* _mesa_function_pool[26689]: MultiTexCoord4svARB (offset 407) */ - "ip\0" - "glMultiTexCoord4sv\0" - "glMultiTexCoord4svARB\0" - "\0" - /* _mesa_function_pool[26734]: LightModelfv (offset 164) */ - "ip\0" - "glLightModelfv\0" - "\0" - /* _mesa_function_pool[26753]: TexCoord2dv (offset 103) */ - "p\0" - "glTexCoord2dv\0" - "\0" - /* _mesa_function_pool[26770]: GenQueriesARB (will be remapped) */ - "ip\0" - "glGenQueries\0" - "glGenQueriesARB\0" - "\0" - /* _mesa_function_pool[26803]: EvalCoord1dv (offset 229) */ - "p\0" - "glEvalCoord1dv\0" - "\0" - /* _mesa_function_pool[26821]: ReplacementCodeuiVertex3fSUN (dynamic) */ - "ifff\0" - "glReplacementCodeuiVertex3fSUN\0" - "\0" - /* _mesa_function_pool[26858]: Translated (offset 303) */ - "ddd\0" - "glTranslated\0" - "\0" - /* _mesa_function_pool[26876]: Translatef (offset 304) */ - "fff\0" - "glTranslatef\0" - "\0" - /* _mesa_function_pool[26894]: StencilMask (offset 209) */ - "i\0" - "glStencilMask\0" - "\0" - /* _mesa_function_pool[26911]: Tangent3iEXT (dynamic) */ - "iii\0" - "glTangent3iEXT\0" - "\0" - /* _mesa_function_pool[26931]: GetLightiv (offset 265) */ - "iip\0" - "glGetLightiv\0" - "\0" - /* _mesa_function_pool[26949]: DrawMeshArraysSUN (dynamic) */ - "iiii\0" - "glDrawMeshArraysSUN\0" - "\0" - /* _mesa_function_pool[26975]: IsList (offset 287) */ - "i\0" - "glIsList\0" - "\0" - /* _mesa_function_pool[26987]: IsSync (will be remapped) */ - "i\0" - "glIsSync\0" - "\0" - /* _mesa_function_pool[26999]: RenderMode (offset 196) */ - "i\0" - "glRenderMode\0" - "\0" - /* _mesa_function_pool[27015]: GetMapControlPointsNV (dynamic) */ - "iiiiiip\0" - "glGetMapControlPointsNV\0" - "\0" - /* _mesa_function_pool[27048]: DrawBuffersARB (will be remapped) */ - "ip\0" - "glDrawBuffers\0" - "glDrawBuffersARB\0" - "glDrawBuffersATI\0" - "\0" - /* _mesa_function_pool[27100]: ProgramLocalParameter4fARB (will be remapped) */ - "iiffff\0" - "glProgramLocalParameter4fARB\0" - "\0" - /* _mesa_function_pool[27137]: SpriteParameterivSGIX (dynamic) */ - "ip\0" - "glSpriteParameterivSGIX\0" - "\0" - /* _mesa_function_pool[27165]: ProvokingVertexEXT (will be remapped) */ - "i\0" - "glProvokingVertexEXT\0" - "glProvokingVertex\0" - "\0" - /* _mesa_function_pool[27207]: MultiTexCoord1fARB (offset 378) */ - "if\0" - "glMultiTexCoord1f\0" - "glMultiTexCoord1fARB\0" - "\0" - /* _mesa_function_pool[27250]: LoadName (offset 198) */ - "i\0" - "glLoadName\0" - "\0" - /* _mesa_function_pool[27264]: VertexAttribs4ubvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4ubvNV\0" - "\0" - /* _mesa_function_pool[27291]: WeightsvARB (dynamic) */ - "ip\0" - "glWeightsvARB\0" - "\0" - /* _mesa_function_pool[27309]: Uniform1fvARB (will be remapped) */ - "iip\0" - "glUniform1fv\0" - "glUniform1fvARB\0" - "\0" - /* _mesa_function_pool[27343]: CopyTexSubImage1D (offset 325) */ - "iiiiii\0" - "glCopyTexSubImage1D\0" - "glCopyTexSubImage1DEXT\0" - "\0" - /* _mesa_function_pool[27394]: CullFace (offset 152) */ - "i\0" - "glCullFace\0" - "\0" - /* _mesa_function_pool[27408]: BindTexture (offset 307) */ - "ii\0" - "glBindTexture\0" - "glBindTextureEXT\0" - "\0" - /* _mesa_function_pool[27443]: BeginFragmentShaderATI (will be remapped) */ - "\0" - "glBeginFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[27470]: MultiTexCoord4fARB (offset 402) */ - "iffff\0" - "glMultiTexCoord4f\0" - "glMultiTexCoord4fARB\0" - "\0" - /* _mesa_function_pool[27516]: VertexAttribs3svNV (will be remapped) */ - "iip\0" - "glVertexAttribs3svNV\0" - "\0" - /* _mesa_function_pool[27542]: StencilFunc (offset 243) */ - "iii\0" - "glStencilFunc\0" - "\0" - /* _mesa_function_pool[27561]: CopyPixels (offset 255) */ - "iiiii\0" - "glCopyPixels\0" - "\0" - /* _mesa_function_pool[27581]: Rectsv (offset 93) */ - "pp\0" - "glRectsv\0" - "\0" - /* _mesa_function_pool[27594]: ReplacementCodeuivSUN (dynamic) */ - "p\0" - "glReplacementCodeuivSUN\0" - "\0" - /* _mesa_function_pool[27621]: EnableVertexAttribArrayARB (will be remapped) */ - "i\0" - "glEnableVertexAttribArray\0" - "glEnableVertexAttribArrayARB\0" - "\0" - /* _mesa_function_pool[27679]: NormalPointervINTEL (dynamic) */ - "ip\0" - "glNormalPointervINTEL\0" - "\0" - /* _mesa_function_pool[27705]: CopyConvolutionFilter2D (offset 355) */ - "iiiiii\0" - "glCopyConvolutionFilter2D\0" - "glCopyConvolutionFilter2DEXT\0" - "\0" - /* _mesa_function_pool[27768]: WindowPos3ivMESA (will be remapped) */ - "p\0" - "glWindowPos3iv\0" - "glWindowPos3ivARB\0" - "glWindowPos3ivMESA\0" - "\0" - /* _mesa_function_pool[27823]: CopyBufferSubData (will be remapped) */ - "iiiii\0" - "glCopyBufferSubData\0" - "\0" - /* _mesa_function_pool[27850]: NormalPointer (offset 318) */ - "iip\0" - "glNormalPointer\0" - "\0" - /* _mesa_function_pool[27871]: TexParameterfv (offset 179) */ - "iip\0" - "glTexParameterfv\0" - "\0" - /* _mesa_function_pool[27893]: IsBufferARB (will be remapped) */ - "i\0" - "glIsBuffer\0" - "glIsBufferARB\0" - "\0" - /* _mesa_function_pool[27921]: WindowPos4iMESA (will be remapped) */ - "iiii\0" - "glWindowPos4iMESA\0" - "\0" - /* _mesa_function_pool[27945]: VertexAttrib4uivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4uiv\0" - "glVertexAttrib4uivARB\0" - "\0" - /* _mesa_function_pool[27990]: Tangent3bvEXT (dynamic) */ - "p\0" - "glTangent3bvEXT\0" - "\0" - /* _mesa_function_pool[28009]: UniformMatrix3x4fv (will be remapped) */ - "iiip\0" - "glUniformMatrix3x4fv\0" - "\0" - /* _mesa_function_pool[28036]: ClipPlane (offset 150) */ - "ip\0" - "glClipPlane\0" - "\0" - /* _mesa_function_pool[28052]: Recti (offset 90) */ - "iiii\0" - "glRecti\0" - "\0" - /* _mesa_function_pool[28066]: DrawRangeElementsBaseVertex (will be remapped) */ - "iiiiipi\0" - "glDrawRangeElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[28105]: TexCoordPointervINTEL (dynamic) */ - "iip\0" - "glTexCoordPointervINTEL\0" - "\0" - /* _mesa_function_pool[28134]: DeleteBuffersARB (will be remapped) */ - "ip\0" - "glDeleteBuffers\0" - "glDeleteBuffersARB\0" - "\0" - /* _mesa_function_pool[28173]: PixelTransformParameterfvEXT (dynamic) */ - "iip\0" - "glPixelTransformParameterfvEXT\0" - "\0" - /* _mesa_function_pool[28209]: WindowPos4fvMESA (will be remapped) */ - "p\0" - "glWindowPos4fvMESA\0" - "\0" - /* _mesa_function_pool[28231]: GetPixelMapuiv (offset 272) */ - "ip\0" - "glGetPixelMapuiv\0" - "\0" - /* _mesa_function_pool[28252]: Rectf (offset 88) */ - "ffff\0" - "glRectf\0" - "\0" - /* _mesa_function_pool[28266]: VertexAttrib1sNV (will be remapped) */ - "ii\0" - "glVertexAttrib1sNV\0" - "\0" - /* _mesa_function_pool[28289]: Indexfv (offset 47) */ - "p\0" - "glIndexfv\0" - "\0" - /* _mesa_function_pool[28302]: SecondaryColor3svEXT (will be remapped) */ - "p\0" - "glSecondaryColor3sv\0" - "glSecondaryColor3svEXT\0" - "\0" - /* _mesa_function_pool[28348]: LoadTransposeMatrixfARB (will be remapped) */ - "p\0" - "glLoadTransposeMatrixf\0" - "glLoadTransposeMatrixfARB\0" - "\0" - /* _mesa_function_pool[28400]: GetPointerv (offset 329) */ - "ip\0" - "glGetPointerv\0" - "glGetPointervEXT\0" - "\0" - /* _mesa_function_pool[28435]: Tangent3bEXT (dynamic) */ - "iii\0" - "glTangent3bEXT\0" - "\0" - /* _mesa_function_pool[28455]: CombinerParameterfNV (will be remapped) */ - "if\0" - "glCombinerParameterfNV\0" - "\0" - /* _mesa_function_pool[28482]: IndexMask (offset 212) */ - "i\0" - "glIndexMask\0" - "\0" - /* _mesa_function_pool[28497]: BindProgramNV (will be remapped) */ - "ii\0" - "glBindProgramARB\0" - "glBindProgramNV\0" - "\0" - /* _mesa_function_pool[28534]: VertexAttrib4svARB (will be remapped) */ - "ip\0" - "glVertexAttrib4sv\0" - "glVertexAttrib4svARB\0" - "\0" - /* _mesa_function_pool[28577]: GetFloatv (offset 262) */ - "ip\0" - "glGetFloatv\0" - "\0" - /* _mesa_function_pool[28593]: CreateDebugObjectMESA (dynamic) */ - "\0" - "glCreateDebugObjectMESA\0" - "\0" - /* _mesa_function_pool[28619]: GetShaderiv (will be remapped) */ - "iip\0" - "glGetShaderiv\0" - "\0" - /* _mesa_function_pool[28638]: ClientWaitSync (will be remapped) */ - "iii\0" - "glClientWaitSync\0" - "\0" - /* _mesa_function_pool[28660]: TexCoord4s (offset 124) */ - "iiii\0" - "glTexCoord4s\0" - "\0" - /* _mesa_function_pool[28679]: TexCoord3sv (offset 117) */ - "p\0" - "glTexCoord3sv\0" - "\0" - /* _mesa_function_pool[28696]: BindFragmentShaderATI (will be remapped) */ - "i\0" - "glBindFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[28723]: PopAttrib (offset 218) */ - "\0" - "glPopAttrib\0" - "\0" - /* _mesa_function_pool[28737]: Fogfv (offset 154) */ - "ip\0" - "glFogfv\0" - "\0" - /* _mesa_function_pool[28749]: UnmapBufferARB (will be remapped) */ - "i\0" - "glUnmapBuffer\0" - "glUnmapBufferARB\0" - "\0" - /* _mesa_function_pool[28783]: InitNames (offset 197) */ - "\0" - "glInitNames\0" - "\0" - /* _mesa_function_pool[28797]: Normal3sv (offset 61) */ - "p\0" - "glNormal3sv\0" - "\0" - /* _mesa_function_pool[28812]: Minmax (offset 368) */ - "iii\0" - "glMinmax\0" - "glMinmaxEXT\0" - "\0" - /* _mesa_function_pool[28838]: TexCoord4d (offset 118) */ - "dddd\0" - "glTexCoord4d\0" - "\0" - /* _mesa_function_pool[28857]: DeformationMap3dSGIX (dynamic) */ - "iddiiddiiddiip\0" - "glDeformationMap3dSGIX\0" - "\0" - /* _mesa_function_pool[28896]: TexCoord4f (offset 120) */ - "ffff\0" - "glTexCoord4f\0" - "\0" - /* _mesa_function_pool[28915]: FogCoorddvEXT (will be remapped) */ - "p\0" - "glFogCoorddv\0" - "glFogCoorddvEXT\0" - "\0" - /* _mesa_function_pool[28947]: FinishTextureSUNX (dynamic) */ - "\0" - "glFinishTextureSUNX\0" - "\0" - /* _mesa_function_pool[28969]: GetFragmentLightfvSGIX (dynamic) */ - "iip\0" - "glGetFragmentLightfvSGIX\0" - "\0" - /* _mesa_function_pool[28999]: Binormal3fvEXT (dynamic) */ - "p\0" - "glBinormal3fvEXT\0" - "\0" - /* _mesa_function_pool[29019]: GetBooleanv (offset 258) */ - "ip\0" - "glGetBooleanv\0" - "\0" - /* _mesa_function_pool[29037]: ColorFragmentOp3ATI (will be remapped) */ - "iiiiiiiiiiiii\0" - "glColorFragmentOp3ATI\0" - "\0" - /* _mesa_function_pool[29074]: Hint (offset 158) */ - "ii\0" - "glHint\0" - "\0" - /* _mesa_function_pool[29085]: Color4dv (offset 28) */ - "p\0" - "glColor4dv\0" - "\0" - /* _mesa_function_pool[29099]: VertexAttrib2svARB (will be remapped) */ - "ip\0" - "glVertexAttrib2sv\0" - "glVertexAttrib2svARB\0" - "\0" - /* _mesa_function_pool[29142]: AreProgramsResidentNV (will be remapped) */ - "ipp\0" - "glAreProgramsResidentNV\0" - "\0" - /* _mesa_function_pool[29171]: WindowPos3svMESA (will be remapped) */ - "p\0" - "glWindowPos3sv\0" - "glWindowPos3svARB\0" - "glWindowPos3svMESA\0" - "\0" - /* _mesa_function_pool[29226]: CopyColorSubTable (offset 347) */ - "iiiii\0" - "glCopyColorSubTable\0" - "glCopyColorSubTableEXT\0" - "\0" - /* _mesa_function_pool[29276]: WeightdvARB (dynamic) */ - "ip\0" - "glWeightdvARB\0" - "\0" - /* _mesa_function_pool[29294]: DeleteRenderbuffersEXT (will be remapped) */ - "ip\0" - "glDeleteRenderbuffers\0" - "glDeleteRenderbuffersEXT\0" - "\0" - /* _mesa_function_pool[29345]: VertexAttrib4NubvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nubv\0" - "glVertexAttrib4NubvARB\0" - "\0" - /* _mesa_function_pool[29392]: VertexAttrib3dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib3dvNV\0" - "\0" - /* _mesa_function_pool[29416]: GetObjectParameterfvARB (will be remapped) */ - "iip\0" - "glGetObjectParameterfvARB\0" - "\0" - /* _mesa_function_pool[29447]: Vertex4iv (offset 147) */ - "p\0" - "glVertex4iv\0" - "\0" - /* _mesa_function_pool[29462]: GetProgramEnvParameterdvARB (will be remapped) */ - "iip\0" - "glGetProgramEnvParameterdvARB\0" - "\0" - /* _mesa_function_pool[29497]: TexCoord4dv (offset 119) */ - "p\0" - "glTexCoord4dv\0" - "\0" - /* _mesa_function_pool[29514]: LockArraysEXT (will be remapped) */ - "ii\0" - "glLockArraysEXT\0" - "\0" - /* _mesa_function_pool[29534]: Begin (offset 7) */ - "i\0" - "glBegin\0" - "\0" - /* _mesa_function_pool[29545]: LightModeli (offset 165) */ - "ii\0" - "glLightModeli\0" - "\0" - /* _mesa_function_pool[29563]: Rectfv (offset 89) */ - "pp\0" - "glRectfv\0" - "\0" - /* _mesa_function_pool[29576]: LightModelf (offset 163) */ - "if\0" - "glLightModelf\0" - "\0" - /* _mesa_function_pool[29594]: GetTexParameterfv (offset 282) */ - "iip\0" - "glGetTexParameterfv\0" - "\0" - /* _mesa_function_pool[29619]: GetLightfv (offset 264) */ - "iip\0" - "glGetLightfv\0" - "\0" - /* _mesa_function_pool[29637]: PixelTransformParameterivEXT (dynamic) */ - "iip\0" - "glPixelTransformParameterivEXT\0" - "\0" - /* _mesa_function_pool[29673]: BinormalPointerEXT (dynamic) */ - "iip\0" - "glBinormalPointerEXT\0" - "\0" - /* _mesa_function_pool[29699]: VertexAttrib1dNV (will be remapped) */ - "id\0" - "glVertexAttrib1dNV\0" - "\0" - /* _mesa_function_pool[29722]: GetCombinerInputParameterivNV (will be remapped) */ - "iiiip\0" - "glGetCombinerInputParameterivNV\0" - "\0" - /* _mesa_function_pool[29761]: Disable (offset 214) */ - "i\0" - "glDisable\0" - "\0" - /* _mesa_function_pool[29774]: MultiTexCoord2fvARB (offset 387) */ - "ip\0" - "glMultiTexCoord2fv\0" - "glMultiTexCoord2fvARB\0" - "\0" - /* _mesa_function_pool[29819]: GetRenderbufferParameterivEXT (will be remapped) */ - "iip\0" - "glGetRenderbufferParameteriv\0" - "glGetRenderbufferParameterivEXT\0" - "\0" - /* _mesa_function_pool[29885]: CombinerParameterivNV (will be remapped) */ - "ip\0" - "glCombinerParameterivNV\0" - "\0" - /* _mesa_function_pool[29913]: GenFragmentShadersATI (will be remapped) */ - "i\0" - "glGenFragmentShadersATI\0" - "\0" - /* _mesa_function_pool[29940]: DrawArrays (offset 310) */ - "iii\0" - "glDrawArrays\0" - "glDrawArraysEXT\0" - "\0" - /* _mesa_function_pool[29974]: WeightuivARB (dynamic) */ - "ip\0" - "glWeightuivARB\0" - "\0" - /* _mesa_function_pool[29993]: VertexAttrib2sARB (will be remapped) */ - "iii\0" - "glVertexAttrib2s\0" - "glVertexAttrib2sARB\0" - "\0" - /* _mesa_function_pool[30035]: ColorMask (offset 210) */ - "iiii\0" - "glColorMask\0" - "\0" - /* _mesa_function_pool[30053]: GenAsyncMarkersSGIX (dynamic) */ - "i\0" - "glGenAsyncMarkersSGIX\0" - "\0" - /* _mesa_function_pool[30078]: Tangent3svEXT (dynamic) */ - "p\0" - "glTangent3svEXT\0" - "\0" - /* _mesa_function_pool[30097]: GetListParameterivSGIX (dynamic) */ - "iip\0" - "glGetListParameterivSGIX\0" - "\0" - /* _mesa_function_pool[30127]: BindBufferARB (will be remapped) */ - "ii\0" - "glBindBuffer\0" - "glBindBufferARB\0" - "\0" - /* _mesa_function_pool[30160]: GetInfoLogARB (will be remapped) */ - "iipp\0" - "glGetInfoLogARB\0" - "\0" - /* _mesa_function_pool[30182]: RasterPos4iv (offset 83) */ - "p\0" - "glRasterPos4iv\0" - "\0" - /* _mesa_function_pool[30200]: Enable (offset 215) */ - "i\0" - "glEnable\0" - "\0" - /* _mesa_function_pool[30212]: LineStipple (offset 167) */ - "ii\0" - "glLineStipple\0" - "\0" - /* _mesa_function_pool[30230]: VertexAttribs4svNV (will be remapped) */ - "iip\0" - "glVertexAttribs4svNV\0" - "\0" - /* _mesa_function_pool[30256]: EdgeFlagPointerListIBM (dynamic) */ - "ipi\0" - "glEdgeFlagPointerListIBM\0" - "\0" - /* _mesa_function_pool[30286]: UniformMatrix3x2fv (will be remapped) */ - "iiip\0" - "glUniformMatrix3x2fv\0" - "\0" - /* _mesa_function_pool[30313]: GetMinmaxParameterfv (offset 365) */ - "iip\0" - "glGetMinmaxParameterfv\0" - "glGetMinmaxParameterfvEXT\0" - "\0" - /* _mesa_function_pool[30367]: VertexAttrib1fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib1fv\0" - "glVertexAttrib1fvARB\0" - "\0" - /* _mesa_function_pool[30410]: GenBuffersARB (will be remapped) */ - "ip\0" - "glGenBuffers\0" - "glGenBuffersARB\0" - "\0" - /* _mesa_function_pool[30443]: VertexAttribs1svNV (will be remapped) */ - "iip\0" - "glVertexAttribs1svNV\0" - "\0" - /* _mesa_function_pool[30469]: Vertex3fv (offset 137) */ - "p\0" - "glVertex3fv\0" - "\0" - /* _mesa_function_pool[30484]: GetTexBumpParameterivATI (will be remapped) */ - "ip\0" - "glGetTexBumpParameterivATI\0" - "\0" - /* _mesa_function_pool[30515]: Binormal3bEXT (dynamic) */ - "iii\0" - "glBinormal3bEXT\0" - "\0" - /* _mesa_function_pool[30536]: FragmentMaterialivSGIX (dynamic) */ - "iip\0" - "glFragmentMaterialivSGIX\0" - "\0" - /* _mesa_function_pool[30566]: IsRenderbufferEXT (will be remapped) */ - "i\0" - "glIsRenderbuffer\0" - "glIsRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[30606]: GenProgramsNV (will be remapped) */ - "ip\0" - "glGenProgramsARB\0" - "glGenProgramsNV\0" - "\0" - /* _mesa_function_pool[30643]: VertexAttrib4dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4dvNV\0" - "\0" - /* _mesa_function_pool[30667]: EndFragmentShaderATI (will be remapped) */ - "\0" - "glEndFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[30692]: Binormal3iEXT (dynamic) */ - "iii\0" - "glBinormal3iEXT\0" - "\0" - /* _mesa_function_pool[30713]: WindowPos2fMESA (will be remapped) */ - "ff\0" - "glWindowPos2f\0" - "glWindowPos2fARB\0" - "glWindowPos2fMESA\0" - "\0" - ; - -/* these functions need to be remapped */ -static const struct gl_function_pool_remap MESA_remap_table_functions[] = { - { 1461, AttachShader_remap_index }, - { 8995, CreateProgram_remap_index }, - { 21153, CreateShader_remap_index }, - { 23466, DeleteProgram_remap_index }, - { 16937, DeleteShader_remap_index }, - { 21599, DetachShader_remap_index }, - { 16461, GetAttachedShaders_remap_index }, - { 4275, GetProgramInfoLog_remap_index }, - { 361, GetProgramiv_remap_index }, - { 5721, GetShaderInfoLog_remap_index }, - { 28619, GetShaderiv_remap_index }, - { 12198, IsProgram_remap_index }, - { 11197, IsShader_remap_index }, - { 9099, StencilFuncSeparate_remap_index }, - { 3487, StencilMaskSeparate_remap_index }, - { 6803, StencilOpSeparate_remap_index }, - { 20478, UniformMatrix2x3fv_remap_index }, - { 2615, UniformMatrix2x4fv_remap_index }, - { 30286, UniformMatrix3x2fv_remap_index }, - { 28009, UniformMatrix3x4fv_remap_index }, - { 14961, UniformMatrix4x2fv_remap_index }, - { 2937, UniformMatrix4x3fv_remap_index }, - { 14622, DrawArraysInstanced_remap_index }, - { 15725, DrawElementsInstanced_remap_index }, - { 9013, LoadTransposeMatrixdARB_remap_index }, - { 28348, LoadTransposeMatrixfARB_remap_index }, - { 4904, MultTransposeMatrixdARB_remap_index }, - { 21786, MultTransposeMatrixfARB_remap_index }, - { 172, SampleCoverageARB_remap_index }, - { 5117, CompressedTexImage1DARB_remap_index }, - { 22269, CompressedTexImage2DARB_remap_index }, - { 3550, CompressedTexImage3DARB_remap_index }, - { 16753, CompressedTexSubImage1DARB_remap_index }, - { 1880, CompressedTexSubImage2DARB_remap_index }, - { 18614, CompressedTexSubImage3DARB_remap_index }, - { 26291, GetCompressedTexImageARB_remap_index }, - { 3395, DisableVertexAttribArrayARB_remap_index }, - { 27621, EnableVertexAttribArrayARB_remap_index }, - { 29462, GetProgramEnvParameterdvARB_remap_index }, - { 21666, GetProgramEnvParameterfvARB_remap_index }, - { 25290, GetProgramLocalParameterdvARB_remap_index }, - { 7245, GetProgramLocalParameterfvARB_remap_index }, - { 16844, GetProgramStringARB_remap_index }, - { 25485, GetProgramivARB_remap_index }, - { 18809, GetVertexAttribdvARB_remap_index }, - { 14850, GetVertexAttribfvARB_remap_index }, - { 8908, GetVertexAttribivARB_remap_index }, - { 17690, ProgramEnvParameter4dARB_remap_index }, - { 23239, ProgramEnvParameter4dvARB_remap_index }, - { 15458, ProgramEnvParameter4fARB_remap_index }, - { 8108, ProgramEnvParameter4fvARB_remap_index }, - { 3513, ProgramLocalParameter4dARB_remap_index }, - { 11908, ProgramLocalParameter4dvARB_remap_index }, - { 27100, ProgramLocalParameter4fARB_remap_index }, - { 23819, ProgramLocalParameter4fvARB_remap_index }, - { 26071, ProgramStringARB_remap_index }, - { 17940, VertexAttrib1dARB_remap_index }, - { 14426, VertexAttrib1dvARB_remap_index }, - { 3688, VertexAttrib1fARB_remap_index }, - { 30367, VertexAttrib1fvARB_remap_index }, - { 6329, VertexAttrib1sARB_remap_index }, - { 2054, VertexAttrib1svARB_remap_index }, - { 13857, VertexAttrib2dARB_remap_index }, - { 16080, VertexAttrib2dvARB_remap_index }, - { 1480, VertexAttrib2fARB_remap_index }, - { 16193, VertexAttrib2fvARB_remap_index }, - { 29993, VertexAttrib2sARB_remap_index }, - { 29099, VertexAttrib2svARB_remap_index }, - { 10282, VertexAttrib3dARB_remap_index }, - { 7811, VertexAttrib3dvARB_remap_index }, - { 1567, VertexAttrib3fARB_remap_index }, - { 20741, VertexAttrib3fvARB_remap_index }, - { 25918, VertexAttrib3sARB_remap_index }, - { 18551, VertexAttrib3svARB_remap_index }, - { 4301, VertexAttrib4NbvARB_remap_index }, - { 16416, VertexAttrib4NivARB_remap_index }, - { 20696, VertexAttrib4NsvARB_remap_index }, - { 21618, VertexAttrib4NubARB_remap_index }, - { 29345, VertexAttrib4NubvARB_remap_index }, - { 17351, VertexAttrib4NuivARB_remap_index }, - { 2810, VertexAttrib4NusvARB_remap_index }, - { 9876, VertexAttrib4bvARB_remap_index }, - { 24698, VertexAttrib4dARB_remap_index }, - { 19573, VertexAttrib4dvARB_remap_index }, - { 10389, VertexAttrib4fARB_remap_index }, - { 10793, VertexAttrib4fvARB_remap_index }, - { 9292, VertexAttrib4ivARB_remap_index }, - { 15894, VertexAttrib4sARB_remap_index }, - { 28534, VertexAttrib4svARB_remap_index }, - { 15263, VertexAttrib4ubvARB_remap_index }, - { 27945, VertexAttrib4uivARB_remap_index }, - { 18362, VertexAttrib4usvARB_remap_index }, - { 20327, VertexAttribPointerARB_remap_index }, - { 30127, BindBufferARB_remap_index }, - { 6036, BufferDataARB_remap_index }, - { 1382, BufferSubDataARB_remap_index }, - { 28134, DeleteBuffersARB_remap_index }, - { 30410, GenBuffersARB_remap_index }, - { 16236, GetBufferParameterivARB_remap_index }, - { 15410, GetBufferPointervARB_remap_index }, - { 1335, GetBufferSubDataARB_remap_index }, - { 27893, IsBufferARB_remap_index }, - { 24303, MapBufferARB_remap_index }, - { 28749, UnmapBufferARB_remap_index }, - { 268, BeginQueryARB_remap_index }, - { 18035, DeleteQueriesARB_remap_index }, - { 11087, EndQueryARB_remap_index }, - { 26770, GenQueriesARB_remap_index }, - { 1772, GetQueryObjectivARB_remap_index }, - { 15938, GetQueryObjectuivARB_remap_index }, - { 1624, GetQueryivARB_remap_index }, - { 18269, IsQueryARB_remap_index }, - { 7421, AttachObjectARB_remap_index }, - { 16899, CompileShaderARB_remap_index }, - { 2879, CreateProgramObjectARB_remap_index }, - { 5981, CreateShaderObjectARB_remap_index }, - { 13274, DeleteObjectARB_remap_index }, - { 22060, DetachObjectARB_remap_index }, - { 10865, GetActiveUniformARB_remap_index }, - { 8583, GetAttachedObjectsARB_remap_index }, - { 8890, GetHandleARB_remap_index }, - { 30160, GetInfoLogARB_remap_index }, - { 29416, GetObjectParameterfvARB_remap_index }, - { 25164, GetObjectParameterivARB_remap_index }, - { 26528, GetShaderSourceARB_remap_index }, - { 25778, GetUniformLocationARB_remap_index }, - { 21888, GetUniformfvARB_remap_index }, - { 11530, GetUniformivARB_remap_index }, - { 18407, LinkProgramARB_remap_index }, - { 18465, ShaderSourceARB_remap_index }, - { 6703, Uniform1fARB_remap_index }, - { 27309, Uniform1fvARB_remap_index }, - { 20296, Uniform1iARB_remap_index }, - { 19262, Uniform1ivARB_remap_index }, - { 2003, Uniform2fARB_remap_index }, - { 13110, Uniform2fvARB_remap_index }, - { 24190, Uniform2iARB_remap_index }, - { 2123, Uniform2ivARB_remap_index }, - { 17009, Uniform3fARB_remap_index }, - { 8613, Uniform3fvARB_remap_index }, - { 5627, Uniform3iARB_remap_index }, - { 15516, Uniform3ivARB_remap_index }, - { 17496, Uniform4fARB_remap_index }, - { 21752, Uniform4fvARB_remap_index }, - { 22918, Uniform4iARB_remap_index }, - { 18775, Uniform4ivARB_remap_index }, - { 7473, UniformMatrix2fvARB_remap_index }, - { 17, UniformMatrix3fvARB_remap_index }, - { 2475, UniformMatrix4fvARB_remap_index }, - { 23351, UseProgramObjectARB_remap_index }, - { 13545, ValidateProgramARB_remap_index }, - { 19616, BindAttribLocationARB_remap_index }, - { 4346, GetActiveAttribARB_remap_index }, - { 15197, GetAttribLocationARB_remap_index }, - { 27048, DrawBuffersARB_remap_index }, - { 12013, RenderbufferStorageMultisample_remap_index }, - { 12417, FramebufferTextureARB_remap_index }, - { 23721, FramebufferTextureFaceARB_remap_index }, - { 22209, ProgramParameteriARB_remap_index }, - { 17544, FlushMappedBufferRange_remap_index }, - { 25581, MapBufferRange_remap_index }, - { 15072, BindVertexArray_remap_index }, - { 13404, GenVertexArrays_remap_index }, - { 27823, CopyBufferSubData_remap_index }, - { 28638, ClientWaitSync_remap_index }, - { 2394, DeleteSync_remap_index }, - { 6370, FenceSync_remap_index }, - { 13916, GetInteger64v_remap_index }, - { 20803, GetSynciv_remap_index }, - { 26987, IsSync_remap_index }, - { 8531, WaitSync_remap_index }, - { 3363, DrawElementsBaseVertex_remap_index }, - { 28066, DrawRangeElementsBaseVertex_remap_index }, - { 24334, MultiDrawElementsBaseVertex_remap_index }, - { 4480, BindTransformFeedback_remap_index }, - { 2906, DeleteTransformFeedbacks_remap_index }, - { 5660, DrawTransformFeedback_remap_index }, - { 8750, GenTransformFeedbacks_remap_index }, - { 25961, IsTransformFeedback_remap_index }, - { 23914, PauseTransformFeedback_remap_index }, - { 4824, ResumeTransformFeedback_remap_index }, - { 4739, PolygonOffsetEXT_remap_index }, - { 21388, GetPixelTexGenParameterfvSGIS_remap_index }, - { 3895, GetPixelTexGenParameterivSGIS_remap_index }, - { 21121, PixelTexGenParameterfSGIS_remap_index }, - { 580, PixelTexGenParameterfvSGIS_remap_index }, - { 11568, PixelTexGenParameteriSGIS_remap_index }, - { 12591, PixelTexGenParameterivSGIS_remap_index }, - { 15160, SampleMaskSGIS_remap_index }, - { 18209, SamplePatternSGIS_remap_index }, - { 24263, ColorPointerEXT_remap_index }, - { 16123, EdgeFlagPointerEXT_remap_index }, - { 5281, IndexPointerEXT_remap_index }, - { 5361, NormalPointerEXT_remap_index }, - { 14510, TexCoordPointerEXT_remap_index }, - { 6159, VertexPointerEXT_remap_index }, - { 3165, PointParameterfEXT_remap_index }, - { 7010, PointParameterfvEXT_remap_index }, - { 29514, LockArraysEXT_remap_index }, - { 13609, UnlockArraysEXT_remap_index }, - { 8017, CullParameterdvEXT_remap_index }, - { 10660, CullParameterfvEXT_remap_index }, - { 1151, SecondaryColor3bEXT_remap_index }, - { 7169, SecondaryColor3bvEXT_remap_index }, - { 9469, SecondaryColor3dEXT_remap_index }, - { 23524, SecondaryColor3dvEXT_remap_index }, - { 25827, SecondaryColor3fEXT_remap_index }, - { 16689, SecondaryColor3fvEXT_remap_index }, - { 426, SecondaryColor3iEXT_remap_index }, - { 14898, SecondaryColor3ivEXT_remap_index }, - { 9127, SecondaryColor3sEXT_remap_index }, - { 28302, SecondaryColor3svEXT_remap_index }, - { 25000, SecondaryColor3ubEXT_remap_index }, - { 19507, SecondaryColor3ubvEXT_remap_index }, - { 11763, SecondaryColor3uiEXT_remap_index }, - { 21008, SecondaryColor3uivEXT_remap_index }, - { 23771, SecondaryColor3usEXT_remap_index }, - { 11836, SecondaryColor3usvEXT_remap_index }, - { 10736, SecondaryColorPointerEXT_remap_index }, - { 23585, MultiDrawArraysEXT_remap_index }, - { 19197, MultiDrawElementsEXT_remap_index }, - { 19392, FogCoordPointerEXT_remap_index }, - { 4044, FogCoorddEXT_remap_index }, - { 28915, FogCoorddvEXT_remap_index }, - { 4136, FogCoordfEXT_remap_index }, - { 24923, FogCoordfvEXT_remap_index }, - { 17448, PixelTexGenSGIX_remap_index }, - { 25508, BlendFuncSeparateEXT_remap_index }, - { 6071, FlushVertexArrayRangeNV_remap_index }, - { 4688, VertexArrayRangeNV_remap_index }, - { 25892, CombinerInputNV_remap_index }, - { 1946, CombinerOutputNV_remap_index }, - { 28455, CombinerParameterfNV_remap_index }, - { 4608, CombinerParameterfvNV_remap_index }, - { 20527, CombinerParameteriNV_remap_index }, - { 29885, CombinerParameterivNV_remap_index }, - { 6447, FinalCombinerInputNV_remap_index }, - { 8956, GetCombinerInputParameterfvNV_remap_index }, - { 29722, GetCombinerInputParameterivNV_remap_index }, - { 12692, GetCombinerOutputParameterfvNV_remap_index }, - { 12520, GetCombinerOutputParameterivNV_remap_index }, - { 5816, GetFinalCombinerInputParameterfvNV_remap_index }, - { 22790, GetFinalCombinerInputParameterivNV_remap_index }, - { 11508, ResizeBuffersMESA_remap_index }, - { 10109, WindowPos2dMESA_remap_index }, - { 944, WindowPos2dvMESA_remap_index }, - { 30713, WindowPos2fMESA_remap_index }, - { 7114, WindowPos2fvMESA_remap_index }, - { 16636, WindowPos2iMESA_remap_index }, - { 18682, WindowPos2ivMESA_remap_index }, - { 19296, WindowPos2sMESA_remap_index }, - { 5031, WindowPos2svMESA_remap_index }, - { 6939, WindowPos3dMESA_remap_index }, - { 12838, WindowPos3dvMESA_remap_index }, - { 472, WindowPos3fMESA_remap_index }, - { 13670, WindowPos3fvMESA_remap_index }, - { 22102, WindowPos3iMESA_remap_index }, - { 27768, WindowPos3ivMESA_remap_index }, - { 17154, WindowPos3sMESA_remap_index }, - { 29171, WindowPos3svMESA_remap_index }, - { 10060, WindowPos4dMESA_remap_index }, - { 15601, WindowPos4dvMESA_remap_index }, - { 12797, WindowPos4fMESA_remap_index }, - { 28209, WindowPos4fvMESA_remap_index }, - { 27921, WindowPos4iMESA_remap_index }, - { 11311, WindowPos4ivMESA_remap_index }, - { 17327, WindowPos4sMESA_remap_index }, - { 2857, WindowPos4svMESA_remap_index }, - { 12559, MultiModeDrawArraysIBM_remap_index }, - { 26641, MultiModeDrawElementsIBM_remap_index }, - { 11115, DeleteFencesNV_remap_index }, - { 25739, FinishFenceNV_remap_index }, - { 3287, GenFencesNV_remap_index }, - { 15581, GetFenceivNV_remap_index }, - { 7406, IsFenceNV_remap_index }, - { 12447, SetFenceNV_remap_index }, - { 3744, TestFenceNV_remap_index }, - { 29142, AreProgramsResidentNV_remap_index }, - { 28497, BindProgramNV_remap_index }, - { 23854, DeleteProgramsNV_remap_index }, - { 19725, ExecuteProgramNV_remap_index }, - { 30606, GenProgramsNV_remap_index }, - { 21467, GetProgramParameterdvNV_remap_index }, - { 9531, GetProgramParameterfvNV_remap_index }, - { 24237, GetProgramStringNV_remap_index }, - { 22479, GetProgramivNV_remap_index }, - { 21701, GetTrackMatrixivNV_remap_index }, - { 24031, GetVertexAttribPointervNV_remap_index }, - { 22723, GetVertexAttribdvNV_remap_index }, - { 8426, GetVertexAttribfvNV_remap_index }, - { 16817, GetVertexAttribivNV_remap_index }, - { 17574, IsProgramNV_remap_index }, - { 8509, LoadProgramNV_remap_index }, - { 25604, ProgramParameters4dvNV_remap_index }, - { 22409, ProgramParameters4fvNV_remap_index }, - { 18986, RequestResidentProgramsNV_remap_index }, - { 20505, TrackMatrixNV_remap_index }, - { 29699, VertexAttrib1dNV_remap_index }, - { 12358, VertexAttrib1dvNV_remap_index }, - { 26173, VertexAttrib1fNV_remap_index }, - { 2245, VertexAttrib1fvNV_remap_index }, - { 28266, VertexAttrib1sNV_remap_index }, - { 13743, VertexAttrib1svNV_remap_index }, - { 4251, VertexAttrib2dNV_remap_index }, - { 12273, VertexAttrib2dvNV_remap_index }, - { 18441, VertexAttrib2fNV_remap_index }, - { 11884, VertexAttrib2fvNV_remap_index }, - { 5191, VertexAttrib2sNV_remap_index }, - { 17208, VertexAttrib2svNV_remap_index }, - { 10257, VertexAttrib3dNV_remap_index }, - { 29392, VertexAttrib3dvNV_remap_index }, - { 9343, VertexAttrib3fNV_remap_index }, - { 22750, VertexAttrib3fvNV_remap_index }, - { 20382, VertexAttrib3sNV_remap_index }, - { 21728, VertexAttrib3svNV_remap_index }, - { 26615, VertexAttrib4dNV_remap_index }, - { 30643, VertexAttrib4dvNV_remap_index }, - { 3945, VertexAttrib4fNV_remap_index }, - { 8559, VertexAttrib4fvNV_remap_index }, - { 24582, VertexAttrib4sNV_remap_index }, - { 1293, VertexAttrib4svNV_remap_index }, - { 4409, VertexAttrib4ubNV_remap_index }, - { 734, VertexAttrib4ubvNV_remap_index }, - { 19905, VertexAttribPointerNV_remap_index }, - { 2097, VertexAttribs1dvNV_remap_index }, - { 24119, VertexAttribs1fvNV_remap_index }, - { 30443, VertexAttribs1svNV_remap_index }, - { 9368, VertexAttribs2dvNV_remap_index }, - { 23312, VertexAttribs2fvNV_remap_index }, - { 16149, VertexAttribs2svNV_remap_index }, - { 4636, VertexAttribs3dvNV_remap_index }, - { 1977, VertexAttribs3fvNV_remap_index }, - { 27516, VertexAttribs3svNV_remap_index }, - { 24672, VertexAttribs4dvNV_remap_index }, - { 4662, VertexAttribs4fvNV_remap_index }, - { 30230, VertexAttribs4svNV_remap_index }, - { 27264, VertexAttribs4ubvNV_remap_index }, - { 24742, GetTexBumpParameterfvATI_remap_index }, - { 30484, GetTexBumpParameterivATI_remap_index }, - { 16871, TexBumpParameterfvATI_remap_index }, - { 18857, TexBumpParameterivATI_remap_index }, - { 14289, AlphaFragmentOp1ATI_remap_index }, - { 9919, AlphaFragmentOp2ATI_remap_index }, - { 22666, AlphaFragmentOp3ATI_remap_index }, - { 27443, BeginFragmentShaderATI_remap_index }, - { 28696, BindFragmentShaderATI_remap_index }, - { 21857, ColorFragmentOp1ATI_remap_index }, - { 3823, ColorFragmentOp2ATI_remap_index }, - { 29037, ColorFragmentOp3ATI_remap_index }, - { 4781, DeleteFragmentShaderATI_remap_index }, - { 30667, EndFragmentShaderATI_remap_index }, - { 29913, GenFragmentShadersATI_remap_index }, - { 23443, PassTexCoordATI_remap_index }, - { 6139, SampleMapATI_remap_index }, - { 5912, SetFragmentShaderConstantATI_remap_index }, - { 319, PointParameteriNV_remap_index }, - { 12999, PointParameterivNV_remap_index }, - { 26454, ActiveStencilFaceEXT_remap_index }, - { 25264, BindVertexArrayAPPLE_remap_index }, - { 2522, DeleteVertexArraysAPPLE_remap_index }, - { 16488, GenVertexArraysAPPLE_remap_index }, - { 21532, IsVertexArrayAPPLE_remap_index }, - { 775, GetProgramNamedParameterdvNV_remap_index }, - { 3128, GetProgramNamedParameterfvNV_remap_index }, - { 24773, ProgramNamedParameter4dNV_remap_index }, - { 13325, ProgramNamedParameter4dvNV_remap_index }, - { 8042, ProgramNamedParameter4fNV_remap_index }, - { 10701, ProgramNamedParameter4fvNV_remap_index }, - { 22388, DepthBoundsEXT_remap_index }, - { 1043, BlendEquationSeparateEXT_remap_index }, - { 13444, BindFramebufferEXT_remap_index }, - { 23630, BindRenderbufferEXT_remap_index }, - { 8806, CheckFramebufferStatusEXT_remap_index }, - { 20822, DeleteFramebuffersEXT_remap_index }, - { 29294, DeleteRenderbuffersEXT_remap_index }, - { 12297, FramebufferRenderbufferEXT_remap_index }, - { 12464, FramebufferTexture1DEXT_remap_index }, - { 10495, FramebufferTexture2DEXT_remap_index }, - { 10162, FramebufferTexture3DEXT_remap_index }, - { 21424, GenFramebuffersEXT_remap_index }, - { 16035, GenRenderbuffersEXT_remap_index }, - { 5858, GenerateMipmapEXT_remap_index }, - { 20002, GetFramebufferAttachmentParameterivEXT_remap_index }, - { 29819, GetRenderbufferParameterivEXT_remap_index }, - { 18737, IsFramebufferEXT_remap_index }, - { 30566, IsRenderbufferEXT_remap_index }, - { 7353, RenderbufferStorageEXT_remap_index }, - { 651, BlitFramebufferEXT_remap_index }, - { 13144, BufferParameteriAPPLE_remap_index }, - { 17606, FlushMappedBufferRangeAPPLE_remap_index }, - { 2701, FramebufferTextureLayerEXT_remap_index }, - { 4956, ColorMaskIndexedEXT_remap_index }, - { 17232, DisableIndexedEXT_remap_index }, - { 24429, EnableIndexedEXT_remap_index }, - { 19973, GetBooleanIndexedvEXT_remap_index }, - { 9952, GetIntegerIndexedvEXT_remap_index }, - { 20898, IsEnabledIndexedEXT_remap_index }, - { 4074, BeginConditionalRenderNV_remap_index }, - { 23416, EndConditionalRenderNV_remap_index }, - { 8453, BeginTransformFeedbackEXT_remap_index }, - { 17256, BindBufferBaseEXT_remap_index }, - { 17126, BindBufferOffsetEXT_remap_index }, - { 11136, BindBufferRangeEXT_remap_index }, - { 13059, EndTransformFeedbackEXT_remap_index }, - { 9804, GetTransformFeedbackVaryingEXT_remap_index }, - { 19042, TransformFeedbackVaryingsEXT_remap_index }, - { 27165, ProvokingVertexEXT_remap_index }, - { 9752, GetTexParameterPointervAPPLE_remap_index }, - { 4436, TextureRangeAPPLE_remap_index }, - { 10567, GetObjectParameterivAPPLE_remap_index }, - { 18181, ObjectPurgeableAPPLE_remap_index }, - { 4985, ObjectUnpurgeableAPPLE_remap_index }, - { 26480, StencilFuncSeparateATI_remap_index }, - { 16555, ProgramEnvParameters4fvEXT_remap_index }, - { 19936, ProgramLocalParameters4fvEXT_remap_index }, - { 12927, GetQueryObjecti64vEXT_remap_index }, - { 9394, GetQueryObjectui64vEXT_remap_index }, - { 21926, EGLImageTargetRenderbufferStorageOES_remap_index }, - { 11054, EGLImageTargetTexture2DOES_remap_index }, - { -1, -1 } -}; - -/* these functions are in the ABI, but have alternative names */ -static const struct gl_function_remap MESA_alt_functions[] = { - /* from GL_EXT_blend_color */ - { 2440, _gloffset_BlendColor }, - /* from GL_EXT_blend_minmax */ - { 10219, _gloffset_BlendEquation }, - /* from GL_EXT_color_subtable */ - { 15623, _gloffset_ColorSubTable }, - { 29226, _gloffset_CopyColorSubTable }, - /* from GL_EXT_convolution */ - { 213, _gloffset_ConvolutionFilter1D }, - { 2284, _gloffset_CopyConvolutionFilter1D }, - { 3624, _gloffset_GetConvolutionParameteriv }, - { 7702, _gloffset_ConvolutionFilter2D }, - { 7868, _gloffset_ConvolutionParameteriv }, - { 8328, _gloffset_ConvolutionParameterfv }, - { 18885, _gloffset_GetSeparableFilter }, - { 22156, _gloffset_SeparableFilter2D }, - { 22968, _gloffset_ConvolutionParameteri }, - { 23091, _gloffset_ConvolutionParameterf }, - { 24608, _gloffset_GetConvolutionParameterfv }, - { 25430, _gloffset_GetConvolutionFilter }, - { 27705, _gloffset_CopyConvolutionFilter2D }, - /* from GL_EXT_copy_texture */ - { 13803, _gloffset_CopyTexSubImage3D }, - { 15363, _gloffset_CopyTexImage2D }, - { 22576, _gloffset_CopyTexImage1D }, - { 25111, _gloffset_CopyTexSubImage2D }, - { 27343, _gloffset_CopyTexSubImage1D }, - /* from GL_EXT_draw_range_elements */ - { 8665, _gloffset_DrawRangeElements }, - /* from GL_EXT_histogram */ - { 812, _gloffset_Histogram }, - { 3088, _gloffset_ResetHistogram }, - { 9065, _gloffset_GetMinmax }, - { 14137, _gloffset_GetHistogramParameterfv }, - { 22501, _gloffset_GetMinmaxParameteriv }, - { 24498, _gloffset_ResetMinmax }, - { 25327, _gloffset_GetHistogramParameteriv }, - { 26414, _gloffset_GetHistogram }, - { 28812, _gloffset_Minmax }, - { 30313, _gloffset_GetMinmaxParameterfv }, - /* from GL_EXT_paletted_texture */ - { 7564, _gloffset_ColorTable }, - { 13983, _gloffset_GetColorTable }, - { 21171, _gloffset_GetColorTableParameterfv }, - { 23147, _gloffset_GetColorTableParameteriv }, - /* from GL_EXT_subtexture */ - { 6285, _gloffset_TexSubImage1D }, - { 9679, _gloffset_TexSubImage2D }, - /* from GL_EXT_texture3D */ - { 1658, _gloffset_TexImage3D }, - { 20940, _gloffset_TexSubImage3D }, - /* from GL_EXT_texture_object */ - { 2964, _gloffset_PrioritizeTextures }, - { 6734, _gloffset_AreTexturesResident }, - { 12382, _gloffset_GenTextures }, - { 14469, _gloffset_DeleteTextures }, - { 17887, _gloffset_IsTexture }, - { 27408, _gloffset_BindTexture }, - /* from GL_EXT_vertex_array */ - { 22328, _gloffset_ArrayElement }, - { 28400, _gloffset_GetPointerv }, - { 29940, _gloffset_DrawArrays }, - /* from GL_SGI_color_table */ - { 6852, _gloffset_ColorTableParameteriv }, - { 7564, _gloffset_ColorTable }, - { 13983, _gloffset_GetColorTable }, - { 14093, _gloffset_CopyColorTable }, - { 17748, _gloffset_ColorTableParameterfv }, - { 21171, _gloffset_GetColorTableParameterfv }, - { 23147, _gloffset_GetColorTableParameteriv }, - /* from GL_VERSION_1_3 */ - { 381, _gloffset_MultiTexCoord3sARB }, - { 613, _gloffset_ActiveTextureARB }, - { 3761, _gloffset_MultiTexCoord1fvARB }, - { 5386, _gloffset_MultiTexCoord3dARB }, - { 5431, _gloffset_MultiTexCoord2iARB }, - { 5555, _gloffset_MultiTexCoord2svARB }, - { 7520, _gloffset_MultiTexCoord2fARB }, - { 9424, _gloffset_MultiTexCoord3fvARB }, - { 9981, _gloffset_MultiTexCoord4sARB }, - { 10615, _gloffset_MultiTexCoord2dvARB }, - { 10997, _gloffset_MultiTexCoord1svARB }, - { 11369, _gloffset_MultiTexCoord3svARB }, - { 11430, _gloffset_MultiTexCoord4iARB }, - { 12153, _gloffset_MultiTexCoord3iARB }, - { 12956, _gloffset_MultiTexCoord1dARB }, - { 13173, _gloffset_MultiTexCoord3dvARB }, - { 14337, _gloffset_MultiTexCoord3ivARB }, - { 14382, _gloffset_MultiTexCoord2sARB }, - { 15680, _gloffset_MultiTexCoord4ivARB }, - { 17398, _gloffset_ClientActiveTextureARB }, - { 19681, _gloffset_MultiTexCoord2dARB }, - { 20122, _gloffset_MultiTexCoord4dvARB }, - { 20433, _gloffset_MultiTexCoord4fvARB }, - { 21312, _gloffset_MultiTexCoord3fARB }, - { 23675, _gloffset_MultiTexCoord4dARB }, - { 23941, _gloffset_MultiTexCoord1sARB }, - { 24145, _gloffset_MultiTexCoord1dvARB }, - { 24955, _gloffset_MultiTexCoord1ivARB }, - { 25048, _gloffset_MultiTexCoord2ivARB }, - { 25387, _gloffset_MultiTexCoord1iARB }, - { 26689, _gloffset_MultiTexCoord4svARB }, - { 27207, _gloffset_MultiTexCoord1fARB }, - { 27470, _gloffset_MultiTexCoord4fARB }, - { 29774, _gloffset_MultiTexCoord2fvARB }, - { -1, -1 } -}; - -#endif /* need_MESA_remap_table */ - -#if defined(need_GL_3DFX_tbuffer) -static const struct gl_function_remap GL_3DFX_tbuffer_functions[] = { - { 8386, -1 }, /* TbufferMask3DFX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_flush_buffer_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_flush_buffer_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_object_purgeable) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_object_purgeable_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_texture_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_texture_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_vertex_array_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_vertex_array_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_copy_buffer) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_copy_buffer_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_elements_base_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_elements_base_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_instanced) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_instanced_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_framebuffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_framebuffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_geometry_shader4) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_geometry_shader4_functions[] = { - { 11333, -1 }, /* FramebufferTextureLayer */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_map_buffer_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_map_buffer_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_matrix_palette) -static const struct gl_function_remap GL_ARB_matrix_palette_functions[] = { - { 3339, -1 }, /* MatrixIndexusvARB */ - { 11974, -1 }, /* MatrixIndexuivARB */ - { 13295, -1 }, /* MatrixIndexPointerARB */ - { 18136, -1 }, /* CurrentPaletteMatrixARB */ - { 21056, -1 }, /* MatrixIndexubvARB */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_occlusion_query) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_occlusion_query_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_provoking_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_provoking_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_shader_objects) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_shader_objects_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_sync) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_sync_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_texture_compression) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_texture_compression_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_transform_feedback2) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_transform_feedback2_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_transpose_matrix) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_transpose_matrix_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_array_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_array_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_blend) -static const struct gl_function_remap GL_ARB_vertex_blend_functions[] = { - { 2226, -1 }, /* WeightubvARB */ - { 5746, -1 }, /* WeightivARB */ - { 10084, -1 }, /* WeightPointerARB */ - { 12674, -1 }, /* WeightfvARB */ - { 16175, -1 }, /* WeightbvARB */ - { 19349, -1 }, /* WeightusvARB */ - { 22082, -1 }, /* VertexBlendARB */ - { 27291, -1 }, /* WeightsvARB */ - { 29276, -1 }, /* WeightdvARB */ - { 29974, -1 }, /* WeightuivARB */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_buffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_buffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_shader) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_shader_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_window_pos) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_window_pos_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_blend_equation_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_blend_equation_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_draw_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_draw_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_envmap_bumpmap) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_envmap_bumpmap_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_fragment_shader) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_fragment_shader_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_separate_stencil) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_separate_stencil_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_color) -static const struct gl_function_remap GL_EXT_blend_color_functions[] = { - { 2440, _gloffset_BlendColor }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_equation_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_blend_equation_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_func_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_blend_func_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_minmax) -static const struct gl_function_remap GL_EXT_blend_minmax_functions[] = { - { 10219, _gloffset_BlendEquation }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_color_subtable) -static const struct gl_function_remap GL_EXT_color_subtable_functions[] = { - { 15623, _gloffset_ColorSubTable }, - { 29226, _gloffset_CopyColorSubTable }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_compiled_vertex_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_compiled_vertex_array_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_convolution) -static const struct gl_function_remap GL_EXT_convolution_functions[] = { - { 213, _gloffset_ConvolutionFilter1D }, - { 2284, _gloffset_CopyConvolutionFilter1D }, - { 3624, _gloffset_GetConvolutionParameteriv }, - { 7702, _gloffset_ConvolutionFilter2D }, - { 7868, _gloffset_ConvolutionParameteriv }, - { 8328, _gloffset_ConvolutionParameterfv }, - { 18885, _gloffset_GetSeparableFilter }, - { 22156, _gloffset_SeparableFilter2D }, - { 22968, _gloffset_ConvolutionParameteri }, - { 23091, _gloffset_ConvolutionParameterf }, - { 24608, _gloffset_GetConvolutionParameterfv }, - { 25430, _gloffset_GetConvolutionFilter }, - { 27705, _gloffset_CopyConvolutionFilter2D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_coordinate_frame) -static const struct gl_function_remap GL_EXT_coordinate_frame_functions[] = { - { 9563, -1 }, /* TangentPointerEXT */ - { 11488, -1 }, /* Binormal3ivEXT */ - { 12106, -1 }, /* Tangent3sEXT */ - { 13360, -1 }, /* Tangent3fvEXT */ - { 17107, -1 }, /* Tangent3dvEXT */ - { 17834, -1 }, /* Binormal3bvEXT */ - { 18938, -1 }, /* Binormal3dEXT */ - { 20988, -1 }, /* Tangent3fEXT */ - { 23040, -1 }, /* Binormal3sEXT */ - { 23485, -1 }, /* Tangent3ivEXT */ - { 23504, -1 }, /* Tangent3dEXT */ - { 24372, -1 }, /* Binormal3svEXT */ - { 24853, -1 }, /* Binormal3fEXT */ - { 25705, -1 }, /* Binormal3dvEXT */ - { 26911, -1 }, /* Tangent3iEXT */ - { 27990, -1 }, /* Tangent3bvEXT */ - { 28435, -1 }, /* Tangent3bEXT */ - { 28999, -1 }, /* Binormal3fvEXT */ - { 29673, -1 }, /* BinormalPointerEXT */ - { 30078, -1 }, /* Tangent3svEXT */ - { 30515, -1 }, /* Binormal3bEXT */ - { 30692, -1 }, /* Binormal3iEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_copy_texture) -static const struct gl_function_remap GL_EXT_copy_texture_functions[] = { - { 13803, _gloffset_CopyTexSubImage3D }, - { 15363, _gloffset_CopyTexImage2D }, - { 22576, _gloffset_CopyTexImage1D }, - { 25111, _gloffset_CopyTexSubImage2D }, - { 27343, _gloffset_CopyTexSubImage1D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_cull_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_cull_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_depth_bounds_test) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_depth_bounds_test_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_buffers2) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_draw_buffers2_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_instanced) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_draw_instanced_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_range_elements) -static const struct gl_function_remap GL_EXT_draw_range_elements_functions[] = { - { 8665, _gloffset_DrawRangeElements }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_fog_coord) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_fog_coord_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_blit) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_blit_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_gpu_program_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_gpu_program_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_histogram) -static const struct gl_function_remap GL_EXT_histogram_functions[] = { - { 812, _gloffset_Histogram }, - { 3088, _gloffset_ResetHistogram }, - { 9065, _gloffset_GetMinmax }, - { 14137, _gloffset_GetHistogramParameterfv }, - { 22501, _gloffset_GetMinmaxParameteriv }, - { 24498, _gloffset_ResetMinmax }, - { 25327, _gloffset_GetHistogramParameteriv }, - { 26414, _gloffset_GetHistogram }, - { 28812, _gloffset_Minmax }, - { 30313, _gloffset_GetMinmaxParameterfv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_index_func) -static const struct gl_function_remap GL_EXT_index_func_functions[] = { - { 10446, -1 }, /* IndexFuncEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_index_material) -static const struct gl_function_remap GL_EXT_index_material_functions[] = { - { 19436, -1 }, /* IndexMaterialEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_light_texture) -static const struct gl_function_remap GL_EXT_light_texture_functions[] = { - { 24392, -1 }, /* ApplyTextureEXT */ - { 24452, -1 }, /* TextureMaterialEXT */ - { 24477, -1 }, /* TextureLightEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_multi_draw_arrays) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_multi_draw_arrays_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_paletted_texture) -static const struct gl_function_remap GL_EXT_paletted_texture_functions[] = { - { 7564, _gloffset_ColorTable }, - { 13983, _gloffset_GetColorTable }, - { 21171, _gloffset_GetColorTableParameterfv }, - { 23147, _gloffset_GetColorTableParameteriv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_pixel_transform) -static const struct gl_function_remap GL_EXT_pixel_transform_functions[] = { - { 20087, -1 }, /* PixelTransformParameterfEXT */ - { 20167, -1 }, /* PixelTransformParameteriEXT */ - { 28173, -1 }, /* PixelTransformParameterfvEXT */ - { 29637, -1 }, /* PixelTransformParameterivEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_polygon_offset) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_polygon_offset_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_provoking_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_provoking_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_secondary_color) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_secondary_color_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_stencil_two_side) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_stencil_two_side_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_subtexture) -static const struct gl_function_remap GL_EXT_subtexture_functions[] = { - { 6285, _gloffset_TexSubImage1D }, - { 9679, _gloffset_TexSubImage2D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture3D) -static const struct gl_function_remap GL_EXT_texture3D_functions[] = { - { 1658, _gloffset_TexImage3D }, - { 20940, _gloffset_TexSubImage3D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_texture_array_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_object) -static const struct gl_function_remap GL_EXT_texture_object_functions[] = { - { 2964, _gloffset_PrioritizeTextures }, - { 6734, _gloffset_AreTexturesResident }, - { 12382, _gloffset_GenTextures }, - { 14469, _gloffset_DeleteTextures }, - { 17887, _gloffset_IsTexture }, - { 27408, _gloffset_BindTexture }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_perturb_normal) -static const struct gl_function_remap GL_EXT_texture_perturb_normal_functions[] = { - { 12624, -1 }, /* TextureNormalEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_timer_query) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_timer_query_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_transform_feedback) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_transform_feedback_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_vertex_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_vertex_array_functions[] = { - { 22328, _gloffset_ArrayElement }, - { 28400, _gloffset_GetPointerv }, - { 29940, _gloffset_DrawArrays }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_vertex_weighting) -static const struct gl_function_remap GL_EXT_vertex_weighting_functions[] = { - { 17917, -1 }, /* VertexWeightfvEXT */ - { 24831, -1 }, /* VertexWeightfEXT */ - { 26383, -1 }, /* VertexWeightPointerEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_HP_image_transform) -static const struct gl_function_remap GL_HP_image_transform_functions[] = { - { 2157, -1 }, /* GetImageTransformParameterfvHP */ - { 3305, -1 }, /* ImageTransformParameterfHP */ - { 9257, -1 }, /* ImageTransformParameterfvHP */ - { 10915, -1 }, /* ImageTransformParameteriHP */ - { 11223, -1 }, /* GetImageTransformParameterivHP */ - { 17981, -1 }, /* ImageTransformParameterivHP */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_IBM_multimode_draw_arrays) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_IBM_multimode_draw_arrays_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_IBM_vertex_array_lists) -static const struct gl_function_remap GL_IBM_vertex_array_lists_functions[] = { - { 3857, -1 }, /* SecondaryColorPointerListIBM */ - { 5252, -1 }, /* NormalPointerListIBM */ - { 6908, -1 }, /* FogCoordPointerListIBM */ - { 7215, -1 }, /* VertexPointerListIBM */ - { 10836, -1 }, /* ColorPointerListIBM */ - { 12213, -1 }, /* TexCoordPointerListIBM */ - { 12646, -1 }, /* IndexPointerListIBM */ - { 30256, -1 }, /* EdgeFlagPointerListIBM */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_INGR_blend_func_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_INGR_blend_func_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_INTEL_parallel_arrays) -static const struct gl_function_remap GL_INTEL_parallel_arrays_functions[] = { - { 11600, -1 }, /* VertexPointervINTEL */ - { 14230, -1 }, /* ColorPointervINTEL */ - { 27679, -1 }, /* NormalPointervINTEL */ - { 28105, -1 }, /* TexCoordPointervINTEL */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_resize_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_MESA_resize_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_shader_debug) -static const struct gl_function_remap GL_MESA_shader_debug_functions[] = { - { 1522, -1 }, /* GetDebugLogLengthMESA */ - { 3063, -1 }, /* ClearDebugLogMESA */ - { 4018, -1 }, /* GetDebugLogMESA */ - { 28593, -1 }, /* CreateDebugObjectMESA */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_window_pos) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_MESA_window_pos_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_condtitional_render) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_condtitional_render_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_evaluators) -static const struct gl_function_remap GL_NV_evaluators_functions[] = { - { 5947, -1 }, /* GetMapAttribParameterivNV */ - { 7670, -1 }, /* MapControlPointsNV */ - { 7769, -1 }, /* MapParameterfvNV */ - { 9662, -1 }, /* EvalMapsNV */ - { 15845, -1 }, /* GetMapAttribParameterfvNV */ - { 16011, -1 }, /* MapParameterivNV */ - { 22891, -1 }, /* GetMapParameterivNV */ - { 23389, -1 }, /* GetMapParameterfvNV */ - { 27015, -1 }, /* GetMapControlPointsNV */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_fence) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_fence_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_fragment_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_fragment_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_point_sprite) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_point_sprite_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_register_combiners) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_register_combiners_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_register_combiners2) -static const struct gl_function_remap GL_NV_register_combiners2_functions[] = { - { 14700, -1 }, /* CombinerStageParameterfvNV */ - { 15015, -1 }, /* GetCombinerStageParameterfvNV */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_vertex_array_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_vertex_array_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_vertex_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_vertex_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_OES_EGL_image) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_OES_EGL_image_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_PGI_misc_hints) -static const struct gl_function_remap GL_PGI_misc_hints_functions[] = { - { 7854, -1 }, /* HintPGI */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_detail_texture) -static const struct gl_function_remap GL_SGIS_detail_texture_functions[] = { - { 14988, -1 }, /* GetDetailTexFuncSGIS */ - { 15308, -1 }, /* DetailTexFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_fog_function) -static const struct gl_function_remap GL_SGIS_fog_function_functions[] = { - { 25093, -1 }, /* FogFuncSGIS */ - { 25758, -1 }, /* GetFogFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_pixel_texture) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_pixel_texture_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_sharpen_texture) -static const struct gl_function_remap GL_SGIS_sharpen_texture_functions[] = { - { 6008, -1 }, /* GetSharpenTexFuncSGIS */ - { 20407, -1 }, /* SharpenTexFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture4D) -static const struct gl_function_remap GL_SGIS_texture4D_functions[] = { - { 894, -1 }, /* TexImage4DSGIS */ - { 14538, -1 }, /* TexSubImage4DSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture_color_mask) -static const struct gl_function_remap GL_SGIS_texture_color_mask_functions[] = { - { 13936, -1 }, /* TextureColorMaskSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture_filter4) -static const struct gl_function_remap GL_SGIS_texture_filter4_functions[] = { - { 6185, -1 }, /* GetTexFilterFuncSGIS */ - { 15134, -1 }, /* TexFilterFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_async) -static const struct gl_function_remap GL_SGIX_async_functions[] = { - { 3014, -1 }, /* AsyncMarkerSGIX */ - { 3997, -1 }, /* FinishAsyncSGIX */ - { 4762, -1 }, /* PollAsyncSGIX */ - { 20554, -1 }, /* DeleteAsyncMarkersSGIX */ - { 20609, -1 }, /* IsAsyncMarkerSGIX */ - { 30053, -1 }, /* GenAsyncMarkersSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_flush_raster) -static const struct gl_function_remap GL_SGIX_flush_raster_functions[] = { - { 6562, -1 }, /* FlushRasterSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_fragment_lighting) -static const struct gl_function_remap GL_SGIX_fragment_lighting_functions[] = { - { 2410, -1 }, /* FragmentMaterialfvSGIX */ - { 4713, -1 }, /* FragmentLightiSGIX */ - { 5688, -1 }, /* GetFragmentMaterialfvSGIX */ - { 7282, -1 }, /* FragmentMaterialfSGIX */ - { 7443, -1 }, /* GetFragmentLightivSGIX */ - { 8280, -1 }, /* FragmentLightModeliSGIX */ - { 9725, -1 }, /* FragmentLightivSGIX */ - { 10027, -1 }, /* GetFragmentMaterialivSGIX */ - { 17804, -1 }, /* FragmentLightModelfSGIX */ - { 18104, -1 }, /* FragmentColorMaterialSGIX */ - { 18504, -1 }, /* FragmentMaterialiSGIX */ - { 19764, -1 }, /* LightEnviSGIX */ - { 21263, -1 }, /* FragmentLightModelfvSGIX */ - { 21572, -1 }, /* FragmentLightfvSGIX */ - { 26142, -1 }, /* FragmentLightModelivSGIX */ - { 26265, -1 }, /* FragmentLightfSGIX */ - { 28969, -1 }, /* GetFragmentLightfvSGIX */ - { 30536, -1 }, /* FragmentMaterialivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_framezoom) -static const struct gl_function_remap GL_SGIX_framezoom_functions[] = { - { 20632, -1 }, /* FrameZoomSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_igloo_interface) -static const struct gl_function_remap GL_SGIX_igloo_interface_functions[] = { - { 26573, -1 }, /* IglooInterfaceSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_instruments) -static const struct gl_function_remap GL_SGIX_instruments_functions[] = { - { 2573, -1 }, /* ReadInstrumentsSGIX */ - { 5764, -1 }, /* PollInstrumentsSGIX */ - { 9623, -1 }, /* GetInstrumentsSGIX */ - { 11811, -1 }, /* StartInstrumentsSGIX */ - { 14734, -1 }, /* StopInstrumentsSGIX */ - { 16388, -1 }, /* InstrumentsBufferSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_list_priority) -static const struct gl_function_remap GL_SGIX_list_priority_functions[] = { - { 1125, -1 }, /* ListParameterfSGIX */ - { 2763, -1 }, /* GetListParameterfvSGIX */ - { 16303, -1 }, /* ListParameteriSGIX */ - { 17057, -1 }, /* ListParameterfvSGIX */ - { 19170, -1 }, /* ListParameterivSGIX */ - { 30097, -1 }, /* GetListParameterivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_pixel_texture) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIX_pixel_texture_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_polynomial_ffd) -static const struct gl_function_remap GL_SGIX_polynomial_ffd_functions[] = { - { 3251, -1 }, /* LoadIdentityDeformationMapSGIX */ - { 14834, -1 }, /* DeformSGIX */ - { 22440, -1 }, /* DeformationMap3fSGIX */ - { 28857, -1 }, /* DeformationMap3dSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_reference_plane) -static const struct gl_function_remap GL_SGIX_reference_plane_functions[] = { - { 13487, -1 }, /* ReferencePlaneSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_sprite) -static const struct gl_function_remap GL_SGIX_sprite_functions[] = { - { 8778, -1 }, /* SpriteParameterfvSGIX */ - { 18959, -1 }, /* SpriteParameteriSGIX */ - { 24532, -1 }, /* SpriteParameterfSGIX */ - { 27137, -1 }, /* SpriteParameterivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_tag_sample_buffer) -static const struct gl_function_remap GL_SGIX_tag_sample_buffer_functions[] = { - { 19018, -1 }, /* TagSampleBufferSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGI_color_table) -static const struct gl_function_remap GL_SGI_color_table_functions[] = { - { 6852, _gloffset_ColorTableParameteriv }, - { 7564, _gloffset_ColorTable }, - { 13983, _gloffset_GetColorTable }, - { 14093, _gloffset_CopyColorTable }, - { 17748, _gloffset_ColorTableParameterfv }, - { 21171, _gloffset_GetColorTableParameterfv }, - { 23147, _gloffset_GetColorTableParameteriv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUNX_constant_data) -static const struct gl_function_remap GL_SUNX_constant_data_functions[] = { - { 28947, -1 }, /* FinishTextureSUNX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_global_alpha) -static const struct gl_function_remap GL_SUN_global_alpha_functions[] = { - { 3035, -1 }, /* GlobalAlphaFactorubSUN */ - { 4224, -1 }, /* GlobalAlphaFactoriSUN */ - { 5789, -1 }, /* GlobalAlphaFactordSUN */ - { 8862, -1 }, /* GlobalAlphaFactoruiSUN */ - { 9214, -1 }, /* GlobalAlphaFactorbSUN */ - { 12126, -1 }, /* GlobalAlphaFactorfSUN */ - { 12245, -1 }, /* GlobalAlphaFactorusSUN */ - { 20871, -1 }, /* GlobalAlphaFactorsSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_mesh_array) -static const struct gl_function_remap GL_SUN_mesh_array_functions[] = { - { 26949, -1 }, /* DrawMeshArraysSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_triangle_list) -static const struct gl_function_remap GL_SUN_triangle_list_functions[] = { - { 3971, -1 }, /* ReplacementCodeubSUN */ - { 5600, -1 }, /* ReplacementCodeubvSUN */ - { 17469, -1 }, /* ReplacementCodeusvSUN */ - { 17657, -1 }, /* ReplacementCodePointerSUN */ - { 19828, -1 }, /* ReplacementCodeuiSUN */ - { 20583, -1 }, /* ReplacementCodeusSUN */ - { 27594, -1 }, /* ReplacementCodeuivSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_vertex) -static const struct gl_function_remap GL_SUN_vertex_functions[] = { - { 999, -1 }, /* ReplacementCodeuiColor3fVertex3fvSUN */ - { 1197, -1 }, /* TexCoord4fColor4fNormal3fVertex4fvSUN */ - { 1423, -1 }, /* TexCoord2fColor4ubVertex3fvSUN */ - { 1699, -1 }, /* ReplacementCodeuiVertex3fvSUN */ - { 1833, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fvSUN */ - { 2346, -1 }, /* ReplacementCodeuiNormal3fVertex3fSUN */ - { 2642, -1 }, /* Color4ubVertex3fvSUN */ - { 4105, -1 }, /* Color4ubVertex3fSUN */ - { 4181, -1 }, /* TexCoord2fVertex3fSUN */ - { 4508, -1 }, /* TexCoord2fColor4fNormal3fVertex3fSUN */ - { 4866, -1 }, /* TexCoord2fNormal3fVertex3fvSUN */ - { 5495, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN */ - { 6240, -1 }, /* ReplacementCodeuiColor4ubVertex3fvSUN */ - { 6599, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fSUN */ - { 7311, -1 }, /* TexCoord2fNormal3fVertex3fSUN */ - { 8079, -1 }, /* Color3fVertex3fSUN */ - { 9173, -1 }, /* Color3fVertex3fvSUN */ - { 9588, -1 }, /* Color4fNormal3fVertex3fvSUN */ - { 10325, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN */ - { 11674, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fvSUN */ - { 13218, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN */ - { 13629, -1 }, /* TexCoord2fColor3fVertex3fSUN */ - { 14759, -1 }, /* TexCoord4fColor4fNormal3fVertex4fSUN */ - { 15093, -1 }, /* Color4ubVertex2fvSUN */ - { 15333, -1 }, /* Normal3fVertex3fSUN */ - { 16329, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fSUN */ - { 16590, -1 }, /* TexCoord2fColor4fNormal3fVertex3fvSUN */ - { 17298, -1 }, /* TexCoord2fVertex3fvSUN */ - { 18074, -1 }, /* Color4ubVertex2fSUN */ - { 18295, -1 }, /* ReplacementCodeuiColor4ubVertex3fSUN */ - { 20253, -1 }, /* TexCoord2fColor4ubVertex3fSUN */ - { 20651, -1 }, /* Normal3fVertex3fvSUN */ - { 21080, -1 }, /* Color4fNormal3fVertex3fSUN */ - { 21989, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN */ - { 23984, -1 }, /* ReplacementCodeuiColor3fVertex3fSUN */ - { 25209, -1 }, /* TexCoord4fVertex4fSUN */ - { 25635, -1 }, /* TexCoord2fColor3fVertex3fvSUN */ - { 25986, -1 }, /* ReplacementCodeuiNormal3fVertex3fvSUN */ - { 26113, -1 }, /* TexCoord4fVertex4fvSUN */ - { 26821, -1 }, /* ReplacementCodeuiVertex3fSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_3) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_3_functions[] = { - { 381, _gloffset_MultiTexCoord3sARB }, - { 613, _gloffset_ActiveTextureARB }, - { 3761, _gloffset_MultiTexCoord1fvARB }, - { 5386, _gloffset_MultiTexCoord3dARB }, - { 5431, _gloffset_MultiTexCoord2iARB }, - { 5555, _gloffset_MultiTexCoord2svARB }, - { 7520, _gloffset_MultiTexCoord2fARB }, - { 9424, _gloffset_MultiTexCoord3fvARB }, - { 9981, _gloffset_MultiTexCoord4sARB }, - { 10615, _gloffset_MultiTexCoord2dvARB }, - { 10997, _gloffset_MultiTexCoord1svARB }, - { 11369, _gloffset_MultiTexCoord3svARB }, - { 11430, _gloffset_MultiTexCoord4iARB }, - { 12153, _gloffset_MultiTexCoord3iARB }, - { 12956, _gloffset_MultiTexCoord1dARB }, - { 13173, _gloffset_MultiTexCoord3dvARB }, - { 14337, _gloffset_MultiTexCoord3ivARB }, - { 14382, _gloffset_MultiTexCoord2sARB }, - { 15680, _gloffset_MultiTexCoord4ivARB }, - { 17398, _gloffset_ClientActiveTextureARB }, - { 19681, _gloffset_MultiTexCoord2dARB }, - { 20122, _gloffset_MultiTexCoord4dvARB }, - { 20433, _gloffset_MultiTexCoord4fvARB }, - { 21312, _gloffset_MultiTexCoord3fARB }, - { 23675, _gloffset_MultiTexCoord4dARB }, - { 23941, _gloffset_MultiTexCoord1sARB }, - { 24145, _gloffset_MultiTexCoord1dvARB }, - { 24955, _gloffset_MultiTexCoord1ivARB }, - { 25048, _gloffset_MultiTexCoord2ivARB }, - { 25387, _gloffset_MultiTexCoord1iARB }, - { 26689, _gloffset_MultiTexCoord4svARB }, - { 27207, _gloffset_MultiTexCoord1fARB }, - { 27470, _gloffset_MultiTexCoord4fARB }, - { 29774, _gloffset_MultiTexCoord2fvARB }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_4) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_4_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_5) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_5_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_2_0) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_2_0_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_2_1) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_2_1_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_0) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_0_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_1) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_1_functions[] = { - { -1, -1 } -}; -#endif - +/* DO NOT EDIT - This file generated automatically by remap_helper.py (from Mesa) script */ + +/* + * Copyright (C) 2009 Chia-I Wu + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * Chia-I Wu, + * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "main/dispatch.h" +#include "main/remap.h" + +/* this is internal to remap.c */ +#ifdef need_MESA_remap_table + +static const char _mesa_function_pool[] = + /* _mesa_function_pool[0]: MapGrid1d (offset 224) */ + "idd\0" + "glMapGrid1d\0" + "\0" + /* _mesa_function_pool[17]: UniformMatrix3fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix3fv\0" + "glUniformMatrix3fvARB\0" + "\0" + /* _mesa_function_pool[64]: MapGrid1f (offset 225) */ + "iff\0" + "glMapGrid1f\0" + "\0" + /* _mesa_function_pool[81]: VertexAttribI2iEXT (will be remapped) */ + "iii\0" + "glVertexAttribI2iEXT\0" + "glVertexAttribI2i\0" + "\0" + /* _mesa_function_pool[125]: RasterPos4i (offset 82) */ + "iiii\0" + "glRasterPos4i\0" + "\0" + /* _mesa_function_pool[145]: RasterPos4d (offset 78) */ + "dddd\0" + "glRasterPos4d\0" + "\0" + /* _mesa_function_pool[165]: NewList (dynamic) */ + "ii\0" + "glNewList\0" + "\0" + /* _mesa_function_pool[179]: RasterPos4f (offset 80) */ + "ffff\0" + "glRasterPos4f\0" + "\0" + /* _mesa_function_pool[199]: LoadIdentity (offset 290) */ + "\0" + "glLoadIdentity\0" + "\0" + /* _mesa_function_pool[216]: SampleCoverageARB (will be remapped) */ + "fi\0" + "glSampleCoverage\0" + "glSampleCoverageARB\0" + "\0" + /* _mesa_function_pool[257]: ConvolutionFilter1D (offset 348) */ + "iiiiip\0" + "glConvolutionFilter1D\0" + "glConvolutionFilter1DEXT\0" + "\0" + /* _mesa_function_pool[312]: BeginQueryARB (will be remapped) */ + "ii\0" + "glBeginQuery\0" + "glBeginQueryARB\0" + "\0" + /* _mesa_function_pool[345]: RasterPos3dv (offset 71) */ + "p\0" + "glRasterPos3dv\0" + "\0" + /* _mesa_function_pool[363]: PointParameteriNV (will be remapped) */ + "ii\0" + "glPointParameteri\0" + "glPointParameteriNV\0" + "\0" + /* _mesa_function_pool[405]: GetProgramiv (will be remapped) */ + "iip\0" + "glGetProgramiv\0" + "\0" + /* _mesa_function_pool[425]: MultiTexCoord3sARB (offset 398) */ + "iiii\0" + "glMultiTexCoord3s\0" + "glMultiTexCoord3sARB\0" + "\0" + /* _mesa_function_pool[470]: SecondaryColor3iEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3i\0" + "glSecondaryColor3iEXT\0" + "\0" + /* _mesa_function_pool[516]: WindowPos3fMESA (will be remapped) */ + "fff\0" + "glWindowPos3f\0" + "glWindowPos3fARB\0" + "glWindowPos3fMESA\0" + "\0" + /* _mesa_function_pool[570]: TexCoord1iv (offset 99) */ + "p\0" + "glTexCoord1iv\0" + "\0" + /* _mesa_function_pool[587]: TexCoord4sv (offset 125) */ + "p\0" + "glTexCoord4sv\0" + "\0" + /* _mesa_function_pool[604]: RasterPos4s (offset 84) */ + "iiii\0" + "glRasterPos4s\0" + "\0" + /* _mesa_function_pool[624]: PixelTexGenParameterfvSGIS (will be remapped) */ + "ip\0" + "glPixelTexGenParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[657]: ActiveTextureARB (offset 374) */ + "i\0" + "glActiveTexture\0" + "glActiveTextureARB\0" + "\0" + /* _mesa_function_pool[695]: BlitFramebufferEXT (will be remapped) */ + "iiiiiiiiii\0" + "glBlitFramebuffer\0" + "glBlitFramebufferEXT\0" + "\0" + /* _mesa_function_pool[746]: TexCoord1f (offset 96) */ + "f\0" + "glTexCoord1f\0" + "\0" + /* _mesa_function_pool[762]: TexCoord1d (offset 94) */ + "d\0" + "glTexCoord1d\0" + "\0" + /* _mesa_function_pool[778]: VertexAttrib4ubvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4ubvNV\0" + "\0" + /* _mesa_function_pool[803]: TexCoord1i (offset 98) */ + "i\0" + "glTexCoord1i\0" + "\0" + /* _mesa_function_pool[819]: GetProgramNamedParameterdvNV (will be remapped) */ + "iipp\0" + "glGetProgramNamedParameterdvNV\0" + "\0" + /* _mesa_function_pool[856]: Histogram (offset 367) */ + "iiii\0" + "glHistogram\0" + "glHistogramEXT\0" + "\0" + /* _mesa_function_pool[889]: TexCoord1s (offset 100) */ + "i\0" + "glTexCoord1s\0" + "\0" + /* _mesa_function_pool[905]: GetMapfv (offset 267) */ + "iip\0" + "glGetMapfv\0" + "\0" + /* _mesa_function_pool[921]: EvalCoord1f (offset 230) */ + "f\0" + "glEvalCoord1f\0" + "\0" + /* _mesa_function_pool[938]: FramebufferTexture (will be remapped) */ + "iiii\0" + "glFramebufferTexture\0" + "\0" + /* _mesa_function_pool[965]: VertexAttribI1ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI1ivEXT\0" + "glVertexAttribI1iv\0" + "\0" + /* _mesa_function_pool[1010]: TexImage4DSGIS (dynamic) */ + "iiiiiiiiiip\0" + "glTexImage4DSGIS\0" + "\0" + /* _mesa_function_pool[1040]: PolygonStipple (offset 175) */ + "p\0" + "glPolygonStipple\0" + "\0" + /* _mesa_function_pool[1060]: WindowPos2dvMESA (will be remapped) */ + "p\0" + "glWindowPos2dv\0" + "glWindowPos2dvARB\0" + "glWindowPos2dvMESA\0" + "\0" + /* _mesa_function_pool[1115]: ReplacementCodeuiColor3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[1159]: BlendEquationSeparateEXT (will be remapped) */ + "ii\0" + "glBlendEquationSeparate\0" + "glBlendEquationSeparateEXT\0" + "glBlendEquationSeparateATI\0" + "\0" + /* _mesa_function_pool[1241]: ListParameterfSGIX (dynamic) */ + "iif\0" + "glListParameterfSGIX\0" + "\0" + /* _mesa_function_pool[1267]: SecondaryColor3bEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3b\0" + "glSecondaryColor3bEXT\0" + "\0" + /* _mesa_function_pool[1313]: TexCoord4fColor4fNormal3fVertex4fvSUN (dynamic) */ + "pppp\0" + "glTexCoord4fColor4fNormal3fVertex4fvSUN\0" + "\0" + /* _mesa_function_pool[1359]: GetPixelMapfv (offset 271) */ + "ip\0" + "glGetPixelMapfv\0" + "\0" + /* _mesa_function_pool[1379]: Color3uiv (offset 22) */ + "p\0" + "glColor3uiv\0" + "\0" + /* _mesa_function_pool[1394]: IsEnabled (offset 286) */ + "i\0" + "glIsEnabled\0" + "\0" + /* _mesa_function_pool[1409]: VertexAttrib4svNV (will be remapped) */ + "ip\0" + "glVertexAttrib4svNV\0" + "\0" + /* _mesa_function_pool[1433]: EvalCoord2fv (offset 235) */ + "p\0" + "glEvalCoord2fv\0" + "\0" + /* _mesa_function_pool[1451]: GetBufferSubDataARB (will be remapped) */ + "iiip\0" + "glGetBufferSubData\0" + "glGetBufferSubDataARB\0" + "\0" + /* _mesa_function_pool[1498]: BufferSubDataARB (will be remapped) */ + "iiip\0" + "glBufferSubData\0" + "glBufferSubDataARB\0" + "\0" + /* _mesa_function_pool[1539]: TexCoord2fColor4ubVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[1577]: AttachShader (will be remapped) */ + "ii\0" + "glAttachShader\0" + "\0" + /* _mesa_function_pool[1596]: VertexAttrib2fARB (will be remapped) */ + "iff\0" + "glVertexAttrib2f\0" + "glVertexAttrib2fARB\0" + "\0" + /* _mesa_function_pool[1638]: GetDebugLogLengthMESA (dynamic) */ + "iii\0" + "glGetDebugLogLengthMESA\0" + "\0" + /* _mesa_function_pool[1667]: GetMapiv (offset 268) */ + "iip\0" + "glGetMapiv\0" + "\0" + /* _mesa_function_pool[1683]: VertexAttrib3fARB (will be remapped) */ + "ifff\0" + "glVertexAttrib3f\0" + "glVertexAttrib3fARB\0" + "\0" + /* _mesa_function_pool[1726]: Indexubv (offset 316) */ + "p\0" + "glIndexubv\0" + "\0" + /* _mesa_function_pool[1740]: GetQueryivARB (will be remapped) */ + "iip\0" + "glGetQueryiv\0" + "glGetQueryivARB\0" + "\0" + /* _mesa_function_pool[1774]: TexImage3D (offset 371) */ + "iiiiiiiiip\0" + "glTexImage3D\0" + "glTexImage3DEXT\0" + "\0" + /* _mesa_function_pool[1815]: BindFragDataLocationEXT (will be remapped) */ + "iip\0" + "glBindFragDataLocationEXT\0" + "glBindFragDataLocation\0" + "\0" + /* _mesa_function_pool[1869]: ReplacementCodeuiVertex3fvSUN (dynamic) */ + "pp\0" + "glReplacementCodeuiVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[1905]: EdgeFlagPointer (offset 312) */ + "ip\0" + "glEdgeFlagPointer\0" + "\0" + /* _mesa_function_pool[1927]: Color3ubv (offset 20) */ + "p\0" + "glColor3ubv\0" + "\0" + /* _mesa_function_pool[1942]: GetQueryObjectivARB (will be remapped) */ + "iip\0" + "glGetQueryObjectiv\0" + "glGetQueryObjectivARB\0" + "\0" + /* _mesa_function_pool[1988]: Vertex3dv (offset 135) */ + "p\0" + "glVertex3dv\0" + "\0" + /* _mesa_function_pool[2003]: ReplacementCodeuiTexCoord2fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiTexCoord2fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[2050]: CompressedTexSubImage2DARB (will be remapped) */ + "iiiiiiiip\0" + "glCompressedTexSubImage2D\0" + "glCompressedTexSubImage2DARB\0" + "\0" + /* _mesa_function_pool[2116]: CombinerOutputNV (will be remapped) */ + "iiiiiiiiii\0" + "glCombinerOutputNV\0" + "\0" + /* _mesa_function_pool[2147]: VertexAttribs3fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs3fvNV\0" + "\0" + /* _mesa_function_pool[2173]: Uniform2fARB (will be remapped) */ + "iff\0" + "glUniform2f\0" + "glUniform2fARB\0" + "\0" + /* _mesa_function_pool[2205]: LightModeliv (offset 166) */ + "ip\0" + "glLightModeliv\0" + "\0" + /* _mesa_function_pool[2224]: VertexAttrib1svARB (will be remapped) */ + "ip\0" + "glVertexAttrib1sv\0" + "glVertexAttrib1svARB\0" + "\0" + /* _mesa_function_pool[2267]: VertexAttribs1dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs1dvNV\0" + "\0" + /* _mesa_function_pool[2293]: Uniform2ivARB (will be remapped) */ + "iip\0" + "glUniform2iv\0" + "glUniform2ivARB\0" + "\0" + /* _mesa_function_pool[2327]: GetImageTransformParameterfvHP (dynamic) */ + "iip\0" + "glGetImageTransformParameterfvHP\0" + "\0" + /* _mesa_function_pool[2365]: Normal3bv (offset 53) */ + "p\0" + "glNormal3bv\0" + "\0" + /* _mesa_function_pool[2380]: TexGeniv (offset 193) */ + "iip\0" + "glTexGeniv\0" + "\0" + /* _mesa_function_pool[2396]: WeightubvARB (dynamic) */ + "ip\0" + "glWeightubvARB\0" + "\0" + /* _mesa_function_pool[2415]: VertexAttrib1fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib1fvNV\0" + "\0" + /* _mesa_function_pool[2439]: Vertex3iv (offset 139) */ + "p\0" + "glVertex3iv\0" + "\0" + /* _mesa_function_pool[2454]: CopyConvolutionFilter1D (offset 354) */ + "iiiii\0" + "glCopyConvolutionFilter1D\0" + "glCopyConvolutionFilter1DEXT\0" + "\0" + /* _mesa_function_pool[2516]: VertexAttribI1uiEXT (will be remapped) */ + "ii\0" + "glVertexAttribI1uiEXT\0" + "glVertexAttribI1ui\0" + "\0" + /* _mesa_function_pool[2561]: ReplacementCodeuiNormal3fVertex3fSUN (dynamic) */ + "iffffff\0" + "glReplacementCodeuiNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[2609]: DeleteSync (will be remapped) */ + "i\0" + "glDeleteSync\0" + "\0" + /* _mesa_function_pool[2625]: FragmentMaterialfvSGIX (dynamic) */ + "iip\0" + "glFragmentMaterialfvSGIX\0" + "\0" + /* _mesa_function_pool[2655]: BlendColor (offset 336) */ + "ffff\0" + "glBlendColor\0" + "glBlendColorEXT\0" + "\0" + /* _mesa_function_pool[2690]: UniformMatrix4fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix4fv\0" + "glUniformMatrix4fvARB\0" + "\0" + /* _mesa_function_pool[2737]: DeleteVertexArraysAPPLE (will be remapped) */ + "ip\0" + "glDeleteVertexArrays\0" + "glDeleteVertexArraysAPPLE\0" + "\0" + /* _mesa_function_pool[2788]: TexBuffer (will be remapped) */ + "iii\0" + "glTexBuffer\0" + "\0" + /* _mesa_function_pool[2805]: ReadInstrumentsSGIX (dynamic) */ + "i\0" + "glReadInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[2830]: CallLists (offset 3) */ + "iip\0" + "glCallLists\0" + "\0" + /* _mesa_function_pool[2847]: UniformMatrix2x4fv (will be remapped) */ + "iiip\0" + "glUniformMatrix2x4fv\0" + "\0" + /* _mesa_function_pool[2874]: Color4ubVertex3fvSUN (dynamic) */ + "pp\0" + "glColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[2901]: Normal3iv (offset 59) */ + "p\0" + "glNormal3iv\0" + "\0" + /* _mesa_function_pool[2916]: PassThrough (offset 199) */ + "f\0" + "glPassThrough\0" + "\0" + /* _mesa_function_pool[2933]: GetVertexAttribIivEXT (will be remapped) */ + "iip\0" + "glGetVertexAttribIivEXT\0" + "glGetVertexAttribIiv\0" + "\0" + /* _mesa_function_pool[2983]: TexParameterIivEXT (will be remapped) */ + "iip\0" + "glTexParameterIivEXT\0" + "glTexParameterIiv\0" + "\0" + /* _mesa_function_pool[3027]: FramebufferTextureLayerEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTextureLayer\0" + "glFramebufferTextureLayerEXT\0" + "\0" + /* _mesa_function_pool[3089]: GetListParameterfvSGIX (dynamic) */ + "iip\0" + "glGetListParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[3119]: Viewport (offset 305) */ + "iiii\0" + "glViewport\0" + "\0" + /* _mesa_function_pool[3136]: VertexAttrib4NusvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nusv\0" + "glVertexAttrib4NusvARB\0" + "\0" + /* _mesa_function_pool[3183]: WindowPos4svMESA (will be remapped) */ + "p\0" + "glWindowPos4svMESA\0" + "\0" + /* _mesa_function_pool[3205]: CreateProgramObjectARB (will be remapped) */ + "\0" + "glCreateProgramObjectARB\0" + "\0" + /* _mesa_function_pool[3232]: DeleteTransformFeedbacks (will be remapped) */ + "ip\0" + "glDeleteTransformFeedbacks\0" + "\0" + /* _mesa_function_pool[3263]: UniformMatrix4x3fv (will be remapped) */ + "iiip\0" + "glUniformMatrix4x3fv\0" + "\0" + /* _mesa_function_pool[3290]: PrioritizeTextures (offset 331) */ + "ipp\0" + "glPrioritizeTextures\0" + "glPrioritizeTexturesEXT\0" + "\0" + /* _mesa_function_pool[3340]: VertexAttribI3uiEXT (will be remapped) */ + "iiii\0" + "glVertexAttribI3uiEXT\0" + "glVertexAttribI3ui\0" + "\0" + /* _mesa_function_pool[3387]: AsyncMarkerSGIX (dynamic) */ + "i\0" + "glAsyncMarkerSGIX\0" + "\0" + /* _mesa_function_pool[3408]: GlobalAlphaFactorubSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorubSUN\0" + "\0" + /* _mesa_function_pool[3436]: ClearColorIuiEXT (will be remapped) */ + "iiii\0" + "glClearColorIuiEXT\0" + "\0" + /* _mesa_function_pool[3461]: ClearDebugLogMESA (dynamic) */ + "iii\0" + "glClearDebugLogMESA\0" + "\0" + /* _mesa_function_pool[3486]: Uniform4uiEXT (will be remapped) */ + "iiiii\0" + "glUniform4uiEXT\0" + "glUniform4ui\0" + "\0" + /* _mesa_function_pool[3522]: ResetHistogram (offset 369) */ + "i\0" + "glResetHistogram\0" + "glResetHistogramEXT\0" + "\0" + /* _mesa_function_pool[3562]: GetProgramNamedParameterfvNV (will be remapped) */ + "iipp\0" + "glGetProgramNamedParameterfvNV\0" + "\0" + /* _mesa_function_pool[3599]: PointParameterfEXT (will be remapped) */ + "if\0" + "glPointParameterf\0" + "glPointParameterfARB\0" + "glPointParameterfEXT\0" + "glPointParameterfSGIS\0" + "\0" + /* _mesa_function_pool[3685]: LoadIdentityDeformationMapSGIX (dynamic) */ + "i\0" + "glLoadIdentityDeformationMapSGIX\0" + "\0" + /* _mesa_function_pool[3721]: GenFencesNV (will be remapped) */ + "ip\0" + "glGenFencesNV\0" + "\0" + /* _mesa_function_pool[3739]: ImageTransformParameterfHP (dynamic) */ + "iif\0" + "glImageTransformParameterfHP\0" + "\0" + /* _mesa_function_pool[3773]: MatrixIndexusvARB (dynamic) */ + "ip\0" + "glMatrixIndexusvARB\0" + "\0" + /* _mesa_function_pool[3797]: DrawElementsBaseVertex (will be remapped) */ + "iiipi\0" + "glDrawElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[3829]: DisableVertexAttribArrayARB (will be remapped) */ + "i\0" + "glDisableVertexAttribArray\0" + "glDisableVertexAttribArrayARB\0" + "\0" + /* _mesa_function_pool[3889]: TexCoord2sv (offset 109) */ + "p\0" + "glTexCoord2sv\0" + "\0" + /* _mesa_function_pool[3906]: Vertex4dv (offset 143) */ + "p\0" + "glVertex4dv\0" + "\0" + /* _mesa_function_pool[3921]: StencilMaskSeparate (will be remapped) */ + "ii\0" + "glStencilMaskSeparate\0" + "\0" + /* _mesa_function_pool[3947]: ProgramLocalParameter4dARB (will be remapped) */ + "iidddd\0" + "glProgramLocalParameter4dARB\0" + "\0" + /* _mesa_function_pool[3984]: CompressedTexImage3DARB (will be remapped) */ + "iiiiiiiip\0" + "glCompressedTexImage3D\0" + "glCompressedTexImage3DARB\0" + "\0" + /* _mesa_function_pool[4044]: Color3sv (offset 18) */ + "p\0" + "glColor3sv\0" + "\0" + /* _mesa_function_pool[4058]: GetConvolutionParameteriv (offset 358) */ + "iip\0" + "glGetConvolutionParameteriv\0" + "glGetConvolutionParameterivEXT\0" + "\0" + /* _mesa_function_pool[4122]: VertexAttrib1fARB (will be remapped) */ + "if\0" + "glVertexAttrib1f\0" + "glVertexAttrib1fARB\0" + "\0" + /* _mesa_function_pool[4163]: Vertex2dv (offset 127) */ + "p\0" + "glVertex2dv\0" + "\0" + /* _mesa_function_pool[4178]: TestFenceNV (will be remapped) */ + "i\0" + "glTestFenceNV\0" + "\0" + /* _mesa_function_pool[4195]: GetVertexAttribIuivEXT (will be remapped) */ + "iip\0" + "glGetVertexAttribIuivEXT\0" + "glGetVertexAttribIuiv\0" + "\0" + /* _mesa_function_pool[4247]: MultiTexCoord1fvARB (offset 379) */ + "ip\0" + "glMultiTexCoord1fv\0" + "glMultiTexCoord1fvARB\0" + "\0" + /* _mesa_function_pool[4292]: TexCoord3iv (offset 115) */ + "p\0" + "glTexCoord3iv\0" + "\0" + /* _mesa_function_pool[4309]: Uniform2uivEXT (will be remapped) */ + "iip\0" + "glUniform2uivEXT\0" + "glUniform2uiv\0" + "\0" + /* _mesa_function_pool[4345]: ColorFragmentOp2ATI (will be remapped) */ + "iiiiiiiiii\0" + "glColorFragmentOp2ATI\0" + "\0" + /* _mesa_function_pool[4379]: SecondaryColorPointerListIBM (dynamic) */ + "iiipi\0" + "glSecondaryColorPointerListIBM\0" + "\0" + /* _mesa_function_pool[4417]: GetPixelTexGenParameterivSGIS (will be remapped) */ + "ip\0" + "glGetPixelTexGenParameterivSGIS\0" + "\0" + /* _mesa_function_pool[4453]: Color3fv (offset 14) */ + "p\0" + "glColor3fv\0" + "\0" + /* _mesa_function_pool[4467]: VertexAttrib4fNV (will be remapped) */ + "iffff\0" + "glVertexAttrib4fNV\0" + "\0" + /* _mesa_function_pool[4493]: ReplacementCodeubSUN (dynamic) */ + "i\0" + "glReplacementCodeubSUN\0" + "\0" + /* _mesa_function_pool[4519]: FinishAsyncSGIX (dynamic) */ + "p\0" + "glFinishAsyncSGIX\0" + "\0" + /* _mesa_function_pool[4540]: GetDebugLogMESA (dynamic) */ + "iiiipp\0" + "glGetDebugLogMESA\0" + "\0" + /* _mesa_function_pool[4566]: FogCoorddEXT (will be remapped) */ + "d\0" + "glFogCoordd\0" + "glFogCoorddEXT\0" + "\0" + /* _mesa_function_pool[4596]: BeginConditionalRenderNV (will be remapped) */ + "ii\0" + "glBeginConditionalRenderNV\0" + "glBeginConditionalRender\0" + "\0" + /* _mesa_function_pool[4652]: Color4ubVertex3fSUN (dynamic) */ + "iiiifff\0" + "glColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[4683]: FogCoordfEXT (will be remapped) */ + "f\0" + "glFogCoordf\0" + "glFogCoordfEXT\0" + "\0" + /* _mesa_function_pool[4713]: PointSize (offset 173) */ + "f\0" + "glPointSize\0" + "\0" + /* _mesa_function_pool[4728]: VertexAttribI2uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI2uivEXT\0" + "glVertexAttribI2uiv\0" + "\0" + /* _mesa_function_pool[4775]: TexCoord2fVertex3fSUN (dynamic) */ + "fffff\0" + "glTexCoord2fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[4806]: PopName (offset 200) */ + "\0" + "glPopName\0" + "\0" + /* _mesa_function_pool[4818]: GlobalAlphaFactoriSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactoriSUN\0" + "\0" + /* _mesa_function_pool[4845]: VertexAttrib2dNV (will be remapped) */ + "idd\0" + "glVertexAttrib2dNV\0" + "\0" + /* _mesa_function_pool[4869]: GetProgramInfoLog (will be remapped) */ + "iipp\0" + "glGetProgramInfoLog\0" + "\0" + /* _mesa_function_pool[4895]: VertexAttrib4NbvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nbv\0" + "glVertexAttrib4NbvARB\0" + "\0" + /* _mesa_function_pool[4940]: GetActiveAttribARB (will be remapped) */ + "iiipppp\0" + "glGetActiveAttrib\0" + "glGetActiveAttribARB\0" + "\0" + /* _mesa_function_pool[4988]: Vertex4sv (offset 149) */ + "p\0" + "glVertex4sv\0" + "\0" + /* _mesa_function_pool[5003]: VertexAttrib4ubNV (will be remapped) */ + "iiiii\0" + "glVertexAttrib4ubNV\0" + "\0" + /* _mesa_function_pool[5030]: ClampColor (will be remapped) */ + "ii\0" + "glClampColor\0" + "\0" + /* _mesa_function_pool[5047]: TextureRangeAPPLE (will be remapped) */ + "iip\0" + "glTextureRangeAPPLE\0" + "\0" + /* _mesa_function_pool[5072]: GetTexEnvfv (offset 276) */ + "iip\0" + "glGetTexEnvfv\0" + "\0" + /* _mesa_function_pool[5091]: BindTransformFeedback (will be remapped) */ + "ii\0" + "glBindTransformFeedback\0" + "\0" + /* _mesa_function_pool[5119]: TexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ + "ffffffffffff\0" + "glTexCoord2fColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[5172]: Indexub (offset 315) */ + "i\0" + "glIndexub\0" + "\0" + /* _mesa_function_pool[5185]: TexEnvi (offset 186) */ + "iii\0" + "glTexEnvi\0" + "\0" + /* _mesa_function_pool[5200]: GetClipPlane (offset 259) */ + "ip\0" + "glGetClipPlane\0" + "\0" + /* _mesa_function_pool[5219]: CombinerParameterfvNV (will be remapped) */ + "ip\0" + "glCombinerParameterfvNV\0" + "\0" + /* _mesa_function_pool[5247]: VertexAttribs3dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs3dvNV\0" + "\0" + /* _mesa_function_pool[5273]: VertexAttribI2uiEXT (will be remapped) */ + "iii\0" + "glVertexAttribI2uiEXT\0" + "glVertexAttribI2ui\0" + "\0" + /* _mesa_function_pool[5319]: VertexAttribs4fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4fvNV\0" + "\0" + /* _mesa_function_pool[5345]: VertexArrayRangeNV (will be remapped) */ + "ip\0" + "glVertexArrayRangeNV\0" + "\0" + /* _mesa_function_pool[5370]: FragmentLightiSGIX (dynamic) */ + "iii\0" + "glFragmentLightiSGIX\0" + "\0" + /* _mesa_function_pool[5396]: PolygonOffsetEXT (will be remapped) */ + "ff\0" + "glPolygonOffsetEXT\0" + "\0" + /* _mesa_function_pool[5419]: VertexAttribI4uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4uivEXT\0" + "glVertexAttribI4uiv\0" + "\0" + /* _mesa_function_pool[5466]: PollAsyncSGIX (dynamic) */ + "p\0" + "glPollAsyncSGIX\0" + "\0" + /* _mesa_function_pool[5485]: DeleteFragmentShaderATI (will be remapped) */ + "i\0" + "glDeleteFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[5514]: Scaled (offset 301) */ + "ddd\0" + "glScaled\0" + "\0" + /* _mesa_function_pool[5528]: ResumeTransformFeedback (will be remapped) */ + "\0" + "glResumeTransformFeedback\0" + "\0" + /* _mesa_function_pool[5556]: Scalef (offset 302) */ + "fff\0" + "glScalef\0" + "\0" + /* _mesa_function_pool[5570]: TexCoord2fNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[5608]: MultTransposeMatrixdARB (will be remapped) */ + "p\0" + "glMultTransposeMatrixd\0" + "glMultTransposeMatrixdARB\0" + "\0" + /* _mesa_function_pool[5660]: ColorMaskIndexedEXT (will be remapped) */ + "iiiii\0" + "glColorMaskIndexedEXT\0" + "glColorMaski\0" + "\0" + /* _mesa_function_pool[5702]: ObjectUnpurgeableAPPLE (will be remapped) */ + "iii\0" + "glObjectUnpurgeableAPPLE\0" + "\0" + /* _mesa_function_pool[5732]: AlphaFunc (offset 240) */ + "if\0" + "glAlphaFunc\0" + "\0" + /* _mesa_function_pool[5748]: WindowPos2svMESA (will be remapped) */ + "p\0" + "glWindowPos2sv\0" + "glWindowPos2svARB\0" + "glWindowPos2svMESA\0" + "\0" + /* _mesa_function_pool[5803]: EdgeFlag (offset 41) */ + "i\0" + "glEdgeFlag\0" + "\0" + /* _mesa_function_pool[5817]: TexCoord2iv (offset 107) */ + "p\0" + "glTexCoord2iv\0" + "\0" + /* _mesa_function_pool[5834]: CompressedTexImage1DARB (will be remapped) */ + "iiiiiip\0" + "glCompressedTexImage1D\0" + "glCompressedTexImage1DARB\0" + "\0" + /* _mesa_function_pool[5892]: Rotated (offset 299) */ + "dddd\0" + "glRotated\0" + "\0" + /* _mesa_function_pool[5908]: GetTexParameterIuivEXT (will be remapped) */ + "iip\0" + "glGetTexParameterIuivEXT\0" + "glGetTexParameterIuiv\0" + "\0" + /* _mesa_function_pool[5960]: VertexAttrib2sNV (will be remapped) */ + "iii\0" + "glVertexAttrib2sNV\0" + "\0" + /* _mesa_function_pool[5984]: ReadPixels (offset 256) */ + "iiiiiip\0" + "glReadPixels\0" + "\0" + /* _mesa_function_pool[6006]: EdgeFlagv (offset 42) */ + "p\0" + "glEdgeFlagv\0" + "\0" + /* _mesa_function_pool[6021]: NormalPointerListIBM (dynamic) */ + "iipi\0" + "glNormalPointerListIBM\0" + "\0" + /* _mesa_function_pool[6050]: IndexPointerEXT (will be remapped) */ + "iiip\0" + "glIndexPointerEXT\0" + "\0" + /* _mesa_function_pool[6074]: Color4iv (offset 32) */ + "p\0" + "glColor4iv\0" + "\0" + /* _mesa_function_pool[6088]: TexParameterf (offset 178) */ + "iif\0" + "glTexParameterf\0" + "\0" + /* _mesa_function_pool[6109]: TexParameteri (offset 180) */ + "iii\0" + "glTexParameteri\0" + "\0" + /* _mesa_function_pool[6130]: NormalPointerEXT (will be remapped) */ + "iiip\0" + "glNormalPointerEXT\0" + "\0" + /* _mesa_function_pool[6155]: MultiTexCoord3dARB (offset 392) */ + "iddd\0" + "glMultiTexCoord3d\0" + "glMultiTexCoord3dARB\0" + "\0" + /* _mesa_function_pool[6200]: MultiTexCoord2iARB (offset 388) */ + "iii\0" + "glMultiTexCoord2i\0" + "glMultiTexCoord2iARB\0" + "\0" + /* _mesa_function_pool[6244]: DrawPixels (offset 257) */ + "iiiip\0" + "glDrawPixels\0" + "\0" + /* _mesa_function_pool[6264]: ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (dynamic) */ + "iffffffff\0" + "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[6324]: MultiTexCoord2svARB (offset 391) */ + "ip\0" + "glMultiTexCoord2sv\0" + "glMultiTexCoord2svARB\0" + "\0" + /* _mesa_function_pool[6369]: ReplacementCodeubvSUN (dynamic) */ + "p\0" + "glReplacementCodeubvSUN\0" + "\0" + /* _mesa_function_pool[6396]: Uniform3iARB (will be remapped) */ + "iiii\0" + "glUniform3i\0" + "glUniform3iARB\0" + "\0" + /* _mesa_function_pool[6429]: DrawTransformFeedback (will be remapped) */ + "ii\0" + "glDrawTransformFeedback\0" + "\0" + /* _mesa_function_pool[6457]: DrawElementsInstancedARB (will be remapped) */ + "iiipi\0" + "glDrawElementsInstancedARB\0" + "glDrawElementsInstancedEXT\0" + "glDrawElementsInstanced\0" + "\0" + /* _mesa_function_pool[6542]: GetShaderInfoLog (will be remapped) */ + "iipp\0" + "glGetShaderInfoLog\0" + "\0" + /* _mesa_function_pool[6567]: WeightivARB (dynamic) */ + "ip\0" + "glWeightivARB\0" + "\0" + /* _mesa_function_pool[6585]: PollInstrumentsSGIX (dynamic) */ + "p\0" + "glPollInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[6610]: GlobalAlphaFactordSUN (dynamic) */ + "d\0" + "glGlobalAlphaFactordSUN\0" + "\0" + /* _mesa_function_pool[6637]: GetFinalCombinerInputParameterfvNV (will be remapped) */ + "iip\0" + "glGetFinalCombinerInputParameterfvNV\0" + "\0" + /* _mesa_function_pool[6679]: GenerateMipmapEXT (will be remapped) */ + "i\0" + "glGenerateMipmap\0" + "glGenerateMipmapEXT\0" + "\0" + /* _mesa_function_pool[6719]: GenLists (offset 5) */ + "i\0" + "glGenLists\0" + "\0" + /* _mesa_function_pool[6733]: SetFragmentShaderConstantATI (will be remapped) */ + "ip\0" + "glSetFragmentShaderConstantATI\0" + "\0" + /* _mesa_function_pool[6768]: GetMapAttribParameterivNV (dynamic) */ + "iiip\0" + "glGetMapAttribParameterivNV\0" + "\0" + /* _mesa_function_pool[6802]: CreateShaderObjectARB (will be remapped) */ + "i\0" + "glCreateShaderObjectARB\0" + "\0" + /* _mesa_function_pool[6829]: GetSharpenTexFuncSGIS (dynamic) */ + "ip\0" + "glGetSharpenTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[6857]: BufferDataARB (will be remapped) */ + "iipi\0" + "glBufferData\0" + "glBufferDataARB\0" + "\0" + /* _mesa_function_pool[6892]: FlushVertexArrayRangeNV (will be remapped) */ + "\0" + "glFlushVertexArrayRangeNV\0" + "\0" + /* _mesa_function_pool[6920]: MapGrid2d (offset 226) */ + "iddidd\0" + "glMapGrid2d\0" + "\0" + /* _mesa_function_pool[6940]: MapGrid2f (offset 227) */ + "iffiff\0" + "glMapGrid2f\0" + "\0" + /* _mesa_function_pool[6960]: SampleMapATI (will be remapped) */ + "iii\0" + "glSampleMapATI\0" + "\0" + /* _mesa_function_pool[6980]: VertexPointerEXT (will be remapped) */ + "iiiip\0" + "glVertexPointerEXT\0" + "\0" + /* _mesa_function_pool[7006]: GetTexFilterFuncSGIS (dynamic) */ + "iip\0" + "glGetTexFilterFuncSGIS\0" + "\0" + /* _mesa_function_pool[7034]: Scissor (offset 176) */ + "iiii\0" + "glScissor\0" + "\0" + /* _mesa_function_pool[7050]: Fogf (offset 153) */ + "if\0" + "glFogf\0" + "\0" + /* _mesa_function_pool[7061]: ReplacementCodeuiColor4ubVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[7106]: TexSubImage1D (offset 332) */ + "iiiiiip\0" + "glTexSubImage1D\0" + "glTexSubImage1DEXT\0" + "\0" + /* _mesa_function_pool[7150]: VertexAttrib1sARB (will be remapped) */ + "ii\0" + "glVertexAttrib1s\0" + "glVertexAttrib1sARB\0" + "\0" + /* _mesa_function_pool[7191]: FenceSync (will be remapped) */ + "ii\0" + "glFenceSync\0" + "\0" + /* _mesa_function_pool[7207]: Color4usv (offset 40) */ + "p\0" + "glColor4usv\0" + "\0" + /* _mesa_function_pool[7222]: Fogi (offset 155) */ + "ii\0" + "glFogi\0" + "\0" + /* _mesa_function_pool[7233]: DepthRange (offset 288) */ + "dd\0" + "glDepthRange\0" + "\0" + /* _mesa_function_pool[7250]: RasterPos3iv (offset 75) */ + "p\0" + "glRasterPos3iv\0" + "\0" + /* _mesa_function_pool[7268]: FinalCombinerInputNV (will be remapped) */ + "iiii\0" + "glFinalCombinerInputNV\0" + "\0" + /* _mesa_function_pool[7297]: TexCoord2i (offset 106) */ + "ii\0" + "glTexCoord2i\0" + "\0" + /* _mesa_function_pool[7314]: PixelMapfv (offset 251) */ + "iip\0" + "glPixelMapfv\0" + "\0" + /* _mesa_function_pool[7332]: Color4ui (offset 37) */ + "iiii\0" + "glColor4ui\0" + "\0" + /* _mesa_function_pool[7349]: RasterPos3s (offset 76) */ + "iii\0" + "glRasterPos3s\0" + "\0" + /* _mesa_function_pool[7368]: Color3usv (offset 24) */ + "p\0" + "glColor3usv\0" + "\0" + /* _mesa_function_pool[7383]: FlushRasterSGIX (dynamic) */ + "\0" + "glFlushRasterSGIX\0" + "\0" + /* _mesa_function_pool[7403]: TexCoord2f (offset 104) */ + "ff\0" + "glTexCoord2f\0" + "\0" + /* _mesa_function_pool[7420]: ReplacementCodeuiTexCoord2fVertex3fSUN (dynamic) */ + "ifffff\0" + "glReplacementCodeuiTexCoord2fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[7469]: TexCoord2d (offset 102) */ + "dd\0" + "glTexCoord2d\0" + "\0" + /* _mesa_function_pool[7486]: RasterPos3d (offset 70) */ + "ddd\0" + "glRasterPos3d\0" + "\0" + /* _mesa_function_pool[7505]: RasterPos3f (offset 72) */ + "fff\0" + "glRasterPos3f\0" + "\0" + /* _mesa_function_pool[7524]: Uniform1fARB (will be remapped) */ + "if\0" + "glUniform1f\0" + "glUniform1fARB\0" + "\0" + /* _mesa_function_pool[7555]: AreTexturesResident (offset 322) */ + "ipp\0" + "glAreTexturesResident\0" + "glAreTexturesResidentEXT\0" + "\0" + /* _mesa_function_pool[7607]: TexCoord2s (offset 108) */ + "ii\0" + "glTexCoord2s\0" + "\0" + /* _mesa_function_pool[7624]: StencilOpSeparate (will be remapped) */ + "iiii\0" + "glStencilOpSeparate\0" + "glStencilOpSeparateATI\0" + "\0" + /* _mesa_function_pool[7673]: ColorTableParameteriv (offset 341) */ + "iip\0" + "glColorTableParameteriv\0" + "glColorTableParameterivSGI\0" + "\0" + /* _mesa_function_pool[7729]: FogCoordPointerListIBM (dynamic) */ + "iipi\0" + "glFogCoordPointerListIBM\0" + "\0" + /* _mesa_function_pool[7760]: WindowPos3dMESA (will be remapped) */ + "ddd\0" + "glWindowPos3d\0" + "glWindowPos3dARB\0" + "glWindowPos3dMESA\0" + "\0" + /* _mesa_function_pool[7814]: Color4us (offset 39) */ + "iiii\0" + "glColor4us\0" + "\0" + /* _mesa_function_pool[7831]: PointParameterfvEXT (will be remapped) */ + "ip\0" + "glPointParameterfv\0" + "glPointParameterfvARB\0" + "glPointParameterfvEXT\0" + "glPointParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[7921]: Color3bv (offset 10) */ + "p\0" + "glColor3bv\0" + "\0" + /* _mesa_function_pool[7935]: WindowPos2fvMESA (will be remapped) */ + "p\0" + "glWindowPos2fv\0" + "glWindowPos2fvARB\0" + "glWindowPos2fvMESA\0" + "\0" + /* _mesa_function_pool[7990]: SecondaryColor3bvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3bv\0" + "glSecondaryColor3bvEXT\0" + "\0" + /* _mesa_function_pool[8036]: VertexPointerListIBM (dynamic) */ + "iiipi\0" + "glVertexPointerListIBM\0" + "\0" + /* _mesa_function_pool[8066]: GetProgramLocalParameterfvARB (will be remapped) */ + "iip\0" + "glGetProgramLocalParameterfvARB\0" + "\0" + /* _mesa_function_pool[8103]: FragmentMaterialfSGIX (dynamic) */ + "iif\0" + "glFragmentMaterialfSGIX\0" + "\0" + /* _mesa_function_pool[8132]: TexCoord2fNormal3fVertex3fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord2fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[8174]: RenderbufferStorageEXT (will be remapped) */ + "iiii\0" + "glRenderbufferStorage\0" + "glRenderbufferStorageEXT\0" + "\0" + /* _mesa_function_pool[8227]: IsFenceNV (will be remapped) */ + "i\0" + "glIsFenceNV\0" + "\0" + /* _mesa_function_pool[8242]: AttachObjectARB (will be remapped) */ + "ii\0" + "glAttachObjectARB\0" + "\0" + /* _mesa_function_pool[8264]: GetFragmentLightivSGIX (dynamic) */ + "iip\0" + "glGetFragmentLightivSGIX\0" + "\0" + /* _mesa_function_pool[8294]: UniformMatrix2fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix2fv\0" + "glUniformMatrix2fvARB\0" + "\0" + /* _mesa_function_pool[8341]: MultiTexCoord2fARB (offset 386) */ + "iff\0" + "glMultiTexCoord2f\0" + "glMultiTexCoord2fARB\0" + "\0" + /* _mesa_function_pool[8385]: ColorTable (offset 339) */ + "iiiiip\0" + "glColorTable\0" + "glColorTableSGI\0" + "glColorTableEXT\0" + "\0" + /* _mesa_function_pool[8438]: IndexPointer (offset 314) */ + "iip\0" + "glIndexPointer\0" + "\0" + /* _mesa_function_pool[8458]: Accum (offset 213) */ + "if\0" + "glAccum\0" + "\0" + /* _mesa_function_pool[8470]: GetTexImage (offset 281) */ + "iiiip\0" + "glGetTexImage\0" + "\0" + /* _mesa_function_pool[8491]: MapControlPointsNV (dynamic) */ + "iiiiiiiip\0" + "glMapControlPointsNV\0" + "\0" + /* _mesa_function_pool[8523]: ConvolutionFilter2D (offset 349) */ + "iiiiiip\0" + "glConvolutionFilter2D\0" + "glConvolutionFilter2DEXT\0" + "\0" + /* _mesa_function_pool[8579]: Finish (offset 216) */ + "\0" + "glFinish\0" + "\0" + /* _mesa_function_pool[8590]: MapParameterfvNV (dynamic) */ + "iip\0" + "glMapParameterfvNV\0" + "\0" + /* _mesa_function_pool[8614]: ClearStencil (offset 207) */ + "i\0" + "glClearStencil\0" + "\0" + /* _mesa_function_pool[8632]: VertexAttrib3dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib3dv\0" + "glVertexAttrib3dvARB\0" + "\0" + /* _mesa_function_pool[8675]: Uniform4uivEXT (will be remapped) */ + "iip\0" + "glUniform4uivEXT\0" + "glUniform4uiv\0" + "\0" + /* _mesa_function_pool[8711]: HintPGI (dynamic) */ + "ii\0" + "glHintPGI\0" + "\0" + /* _mesa_function_pool[8725]: ConvolutionParameteriv (offset 353) */ + "iip\0" + "glConvolutionParameteriv\0" + "glConvolutionParameterivEXT\0" + "\0" + /* _mesa_function_pool[8783]: Color4s (offset 33) */ + "iiii\0" + "glColor4s\0" + "\0" + /* _mesa_function_pool[8799]: InterleavedArrays (offset 317) */ + "iip\0" + "glInterleavedArrays\0" + "\0" + /* _mesa_function_pool[8824]: RasterPos2fv (offset 65) */ + "p\0" + "glRasterPos2fv\0" + "\0" + /* _mesa_function_pool[8842]: TexCoord1fv (offset 97) */ + "p\0" + "glTexCoord1fv\0" + "\0" + /* _mesa_function_pool[8859]: Vertex2d (offset 126) */ + "dd\0" + "glVertex2d\0" + "\0" + /* _mesa_function_pool[8874]: CullParameterdvEXT (dynamic) */ + "ip\0" + "glCullParameterdvEXT\0" + "\0" + /* _mesa_function_pool[8899]: ProgramNamedParameter4fNV (will be remapped) */ + "iipffff\0" + "glProgramNamedParameter4fNV\0" + "\0" + /* _mesa_function_pool[8936]: Color3fVertex3fSUN (dynamic) */ + "ffffff\0" + "glColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[8965]: ProgramEnvParameter4fvARB (will be remapped) */ + "iip\0" + "glProgramEnvParameter4fvARB\0" + "glProgramParameter4fvNV\0" + "\0" + /* _mesa_function_pool[9022]: Color4i (offset 31) */ + "iiii\0" + "glColor4i\0" + "\0" + /* _mesa_function_pool[9038]: Color4f (offset 29) */ + "ffff\0" + "glColor4f\0" + "\0" + /* _mesa_function_pool[9054]: RasterPos4fv (offset 81) */ + "p\0" + "glRasterPos4fv\0" + "\0" + /* _mesa_function_pool[9072]: Color4d (offset 27) */ + "dddd\0" + "glColor4d\0" + "\0" + /* _mesa_function_pool[9088]: ClearIndex (offset 205) */ + "f\0" + "glClearIndex\0" + "\0" + /* _mesa_function_pool[9104]: Color4b (offset 25) */ + "iiii\0" + "glColor4b\0" + "\0" + /* _mesa_function_pool[9120]: LoadMatrixd (offset 292) */ + "p\0" + "glLoadMatrixd\0" + "\0" + /* _mesa_function_pool[9137]: FragmentLightModeliSGIX (dynamic) */ + "ii\0" + "glFragmentLightModeliSGIX\0" + "\0" + /* _mesa_function_pool[9167]: RasterPos2dv (offset 63) */ + "p\0" + "glRasterPos2dv\0" + "\0" + /* _mesa_function_pool[9185]: ConvolutionParameterfv (offset 351) */ + "iip\0" + "glConvolutionParameterfv\0" + "glConvolutionParameterfvEXT\0" + "\0" + /* _mesa_function_pool[9243]: TbufferMask3DFX (dynamic) */ + "i\0" + "glTbufferMask3DFX\0" + "\0" + /* _mesa_function_pool[9264]: GetTexGendv (offset 278) */ + "iip\0" + "glGetTexGendv\0" + "\0" + /* _mesa_function_pool[9283]: GetVertexAttribfvNV (will be remapped) */ + "iip\0" + "glGetVertexAttribfvNV\0" + "\0" + /* _mesa_function_pool[9310]: BeginTransformFeedbackEXT (will be remapped) */ + "i\0" + "glBeginTransformFeedbackEXT\0" + "glBeginTransformFeedback\0" + "\0" + /* _mesa_function_pool[9366]: LoadProgramNV (will be remapped) */ + "iiip\0" + "glLoadProgramNV\0" + "\0" + /* _mesa_function_pool[9388]: WaitSync (will be remapped) */ + "iii\0" + "glWaitSync\0" + "\0" + /* _mesa_function_pool[9404]: EndList (offset 1) */ + "\0" + "glEndList\0" + "\0" + /* _mesa_function_pool[9416]: VertexAttrib4fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4fvNV\0" + "\0" + /* _mesa_function_pool[9440]: GetAttachedObjectsARB (will be remapped) */ + "iipp\0" + "glGetAttachedObjectsARB\0" + "\0" + /* _mesa_function_pool[9470]: Uniform3fvARB (will be remapped) */ + "iip\0" + "glUniform3fv\0" + "glUniform3fvARB\0" + "\0" + /* _mesa_function_pool[9504]: EvalCoord1fv (offset 231) */ + "p\0" + "glEvalCoord1fv\0" + "\0" + /* _mesa_function_pool[9522]: DrawRangeElements (offset 338) */ + "iiiiip\0" + "glDrawRangeElements\0" + "glDrawRangeElementsEXT\0" + "\0" + /* _mesa_function_pool[9573]: EvalMesh2 (offset 238) */ + "iiiii\0" + "glEvalMesh2\0" + "\0" + /* _mesa_function_pool[9592]: Vertex4fv (offset 145) */ + "p\0" + "glVertex4fv\0" + "\0" + /* _mesa_function_pool[9607]: GenTransformFeedbacks (will be remapped) */ + "ip\0" + "glGenTransformFeedbacks\0" + "\0" + /* _mesa_function_pool[9635]: SpriteParameterfvSGIX (dynamic) */ + "ip\0" + "glSpriteParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[9663]: CheckFramebufferStatusEXT (will be remapped) */ + "i\0" + "glCheckFramebufferStatus\0" + "glCheckFramebufferStatusEXT\0" + "\0" + /* _mesa_function_pool[9719]: GlobalAlphaFactoruiSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactoruiSUN\0" + "\0" + /* _mesa_function_pool[9747]: GetHandleARB (will be remapped) */ + "i\0" + "glGetHandleARB\0" + "\0" + /* _mesa_function_pool[9765]: GetVertexAttribivARB (will be remapped) */ + "iip\0" + "glGetVertexAttribiv\0" + "glGetVertexAttribivARB\0" + "\0" + /* _mesa_function_pool[9813]: GetCombinerInputParameterfvNV (will be remapped) */ + "iiiip\0" + "glGetCombinerInputParameterfvNV\0" + "\0" + /* _mesa_function_pool[9852]: GetTexParameterIivEXT (will be remapped) */ + "iip\0" + "glGetTexParameterIivEXT\0" + "glGetTexParameterIiv\0" + "\0" + /* _mesa_function_pool[9902]: CreateProgram (will be remapped) */ + "\0" + "glCreateProgram\0" + "\0" + /* _mesa_function_pool[9920]: LoadTransposeMatrixdARB (will be remapped) */ + "p\0" + "glLoadTransposeMatrixd\0" + "glLoadTransposeMatrixdARB\0" + "\0" + /* _mesa_function_pool[9972]: GetMinmax (offset 364) */ + "iiiip\0" + "glGetMinmax\0" + "glGetMinmaxEXT\0" + "\0" + /* _mesa_function_pool[10006]: StencilFuncSeparate (will be remapped) */ + "iiii\0" + "glStencilFuncSeparate\0" + "\0" + /* _mesa_function_pool[10034]: SecondaryColor3sEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3s\0" + "glSecondaryColor3sEXT\0" + "\0" + /* _mesa_function_pool[10080]: Color3fVertex3fvSUN (dynamic) */ + "pp\0" + "glColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[10106]: GetInteger64i_v (will be remapped) */ + "iip\0" + "glGetInteger64i_v\0" + "\0" + /* _mesa_function_pool[10129]: Normal3fv (offset 57) */ + "p\0" + "glNormal3fv\0" + "\0" + /* _mesa_function_pool[10144]: GlobalAlphaFactorbSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorbSUN\0" + "\0" + /* _mesa_function_pool[10171]: Color3us (offset 23) */ + "iii\0" + "glColor3us\0" + "\0" + /* _mesa_function_pool[10187]: ImageTransformParameterfvHP (dynamic) */ + "iip\0" + "glImageTransformParameterfvHP\0" + "\0" + /* _mesa_function_pool[10222]: VertexAttrib4ivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4iv\0" + "glVertexAttrib4ivARB\0" + "\0" + /* _mesa_function_pool[10265]: End (offset 43) */ + "\0" + "glEnd\0" + "\0" + /* _mesa_function_pool[10273]: VertexAttrib3fNV (will be remapped) */ + "ifff\0" + "glVertexAttrib3fNV\0" + "\0" + /* _mesa_function_pool[10298]: VertexAttribs2dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs2dvNV\0" + "\0" + /* _mesa_function_pool[10324]: GetQueryObjectui64vEXT (will be remapped) */ + "iip\0" + "glGetQueryObjectui64vEXT\0" + "\0" + /* _mesa_function_pool[10354]: MultiTexCoord3fvARB (offset 395) */ + "ip\0" + "glMultiTexCoord3fv\0" + "glMultiTexCoord3fvARB\0" + "\0" + /* _mesa_function_pool[10399]: SecondaryColor3dEXT (will be remapped) */ + "ddd\0" + "glSecondaryColor3d\0" + "glSecondaryColor3dEXT\0" + "\0" + /* _mesa_function_pool[10445]: Color3ub (offset 19) */ + "iii\0" + "glColor3ub\0" + "\0" + /* _mesa_function_pool[10461]: GetProgramParameterfvNV (will be remapped) */ + "iiip\0" + "glGetProgramParameterfvNV\0" + "\0" + /* _mesa_function_pool[10493]: TangentPointerEXT (dynamic) */ + "iip\0" + "glTangentPointerEXT\0" + "\0" + /* _mesa_function_pool[10518]: Color4fNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[10553]: GetInstrumentsSGIX (dynamic) */ + "\0" + "glGetInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[10576]: GetUniformuivEXT (will be remapped) */ + "iip\0" + "glGetUniformuivEXT\0" + "glGetUniformuiv\0" + "\0" + /* _mesa_function_pool[10616]: Color3ui (offset 21) */ + "iii\0" + "glColor3ui\0" + "\0" + /* _mesa_function_pool[10632]: EvalMapsNV (dynamic) */ + "ii\0" + "glEvalMapsNV\0" + "\0" + /* _mesa_function_pool[10649]: TexSubImage2D (offset 333) */ + "iiiiiiiip\0" + "glTexSubImage2D\0" + "glTexSubImage2DEXT\0" + "\0" + /* _mesa_function_pool[10695]: FragmentLightivSGIX (dynamic) */ + "iip\0" + "glFragmentLightivSGIX\0" + "\0" + /* _mesa_function_pool[10722]: GetTexParameterPointervAPPLE (will be remapped) */ + "iip\0" + "glGetTexParameterPointervAPPLE\0" + "\0" + /* _mesa_function_pool[10758]: TexGenfv (offset 191) */ + "iip\0" + "glTexGenfv\0" + "\0" + /* _mesa_function_pool[10774]: GetTransformFeedbackVaryingEXT (will be remapped) */ + "iiipppp\0" + "glGetTransformFeedbackVaryingEXT\0" + "glGetTransformFeedbackVarying\0" + "\0" + /* _mesa_function_pool[10846]: VertexAttrib4bvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4bv\0" + "glVertexAttrib4bvARB\0" + "\0" + /* _mesa_function_pool[10889]: AlphaFragmentOp2ATI (will be remapped) */ + "iiiiiiiii\0" + "glAlphaFragmentOp2ATI\0" + "\0" + /* _mesa_function_pool[10922]: GetIntegerIndexedvEXT (will be remapped) */ + "iip\0" + "glGetIntegerIndexedvEXT\0" + "glGetIntegeri_v\0" + "\0" + /* _mesa_function_pool[10967]: MultiTexCoord4sARB (offset 406) */ + "iiiii\0" + "glMultiTexCoord4s\0" + "glMultiTexCoord4sARB\0" + "\0" + /* _mesa_function_pool[11013]: GetFragmentMaterialivSGIX (dynamic) */ + "iip\0" + "glGetFragmentMaterialivSGIX\0" + "\0" + /* _mesa_function_pool[11046]: WindowPos4dMESA (will be remapped) */ + "dddd\0" + "glWindowPos4dMESA\0" + "\0" + /* _mesa_function_pool[11070]: WeightPointerARB (dynamic) */ + "iiip\0" + "glWeightPointerARB\0" + "\0" + /* _mesa_function_pool[11095]: WindowPos2dMESA (will be remapped) */ + "dd\0" + "glWindowPos2d\0" + "glWindowPos2dARB\0" + "glWindowPos2dMESA\0" + "\0" + /* _mesa_function_pool[11148]: FramebufferTexture3DEXT (will be remapped) */ + "iiiiii\0" + "glFramebufferTexture3D\0" + "glFramebufferTexture3DEXT\0" + "\0" + /* _mesa_function_pool[11205]: BlendEquation (offset 337) */ + "i\0" + "glBlendEquation\0" + "glBlendEquationEXT\0" + "\0" + /* _mesa_function_pool[11243]: VertexAttrib3dNV (will be remapped) */ + "iddd\0" + "glVertexAttrib3dNV\0" + "\0" + /* _mesa_function_pool[11268]: VertexAttrib3dARB (will be remapped) */ + "iddd\0" + "glVertexAttrib3d\0" + "glVertexAttrib3dARB\0" + "\0" + /* _mesa_function_pool[11311]: VertexAttribI4usvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4usvEXT\0" + "glVertexAttribI4usv\0" + "\0" + /* _mesa_function_pool[11358]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ + "ppppp\0" + "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[11422]: VertexAttrib4fARB (will be remapped) */ + "iffff\0" + "glVertexAttrib4f\0" + "glVertexAttrib4fARB\0" + "\0" + /* _mesa_function_pool[11466]: GetError (offset 261) */ + "\0" + "glGetError\0" + "\0" + /* _mesa_function_pool[11479]: IndexFuncEXT (dynamic) */ + "if\0" + "glIndexFuncEXT\0" + "\0" + /* _mesa_function_pool[11498]: TexCoord3dv (offset 111) */ + "p\0" + "glTexCoord3dv\0" + "\0" + /* _mesa_function_pool[11515]: Indexdv (offset 45) */ + "p\0" + "glIndexdv\0" + "\0" + /* _mesa_function_pool[11528]: FramebufferTexture2DEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTexture2D\0" + "glFramebufferTexture2DEXT\0" + "\0" + /* _mesa_function_pool[11584]: Normal3s (offset 60) */ + "iii\0" + "glNormal3s\0" + "\0" + /* _mesa_function_pool[11600]: GetObjectParameterivAPPLE (will be remapped) */ + "iiip\0" + "glGetObjectParameterivAPPLE\0" + "\0" + /* _mesa_function_pool[11634]: PushName (offset 201) */ + "i\0" + "glPushName\0" + "\0" + /* _mesa_function_pool[11648]: MultiTexCoord2dvARB (offset 385) */ + "ip\0" + "glMultiTexCoord2dv\0" + "glMultiTexCoord2dvARB\0" + "\0" + /* _mesa_function_pool[11693]: CullParameterfvEXT (dynamic) */ + "ip\0" + "glCullParameterfvEXT\0" + "\0" + /* _mesa_function_pool[11718]: Normal3i (offset 58) */ + "iii\0" + "glNormal3i\0" + "\0" + /* _mesa_function_pool[11734]: ProgramNamedParameter4fvNV (will be remapped) */ + "iipp\0" + "glProgramNamedParameter4fvNV\0" + "\0" + /* _mesa_function_pool[11769]: SecondaryColorPointerEXT (will be remapped) */ + "iiip\0" + "glSecondaryColorPointer\0" + "glSecondaryColorPointerEXT\0" + "\0" + /* _mesa_function_pool[11826]: VertexAttrib4fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4fv\0" + "glVertexAttrib4fvARB\0" + "\0" + /* _mesa_function_pool[11869]: ColorPointerListIBM (dynamic) */ + "iiipi\0" + "glColorPointerListIBM\0" + "\0" + /* _mesa_function_pool[11898]: GetActiveUniformARB (will be remapped) */ + "iiipppp\0" + "glGetActiveUniform\0" + "glGetActiveUniformARB\0" + "\0" + /* _mesa_function_pool[11948]: ImageTransformParameteriHP (dynamic) */ + "iii\0" + "glImageTransformParameteriHP\0" + "\0" + /* _mesa_function_pool[11982]: Normal3b (offset 52) */ + "iii\0" + "glNormal3b\0" + "\0" + /* _mesa_function_pool[11998]: Normal3d (offset 54) */ + "ddd\0" + "glNormal3d\0" + "\0" + /* _mesa_function_pool[12014]: Uniform1uiEXT (will be remapped) */ + "ii\0" + "glUniform1uiEXT\0" + "glUniform1ui\0" + "\0" + /* _mesa_function_pool[12047]: Normal3f (offset 56) */ + "fff\0" + "glNormal3f\0" + "\0" + /* _mesa_function_pool[12063]: MultiTexCoord1svARB (offset 383) */ + "ip\0" + "glMultiTexCoord1sv\0" + "glMultiTexCoord1svARB\0" + "\0" + /* _mesa_function_pool[12108]: Indexi (offset 48) */ + "i\0" + "glIndexi\0" + "\0" + /* _mesa_function_pool[12120]: EGLImageTargetTexture2DOES (will be remapped) */ + "ip\0" + "glEGLImageTargetTexture2DOES\0" + "\0" + /* _mesa_function_pool[12153]: EndQueryARB (will be remapped) */ + "i\0" + "glEndQuery\0" + "glEndQueryARB\0" + "\0" + /* _mesa_function_pool[12181]: DeleteFencesNV (will be remapped) */ + "ip\0" + "glDeleteFencesNV\0" + "\0" + /* _mesa_function_pool[12202]: BindBufferRangeEXT (will be remapped) */ + "iiiii\0" + "glBindBufferRangeEXT\0" + "glBindBufferRange\0" + "\0" + /* _mesa_function_pool[12248]: DepthMask (offset 211) */ + "i\0" + "glDepthMask\0" + "\0" + /* _mesa_function_pool[12263]: IsShader (will be remapped) */ + "i\0" + "glIsShader\0" + "\0" + /* _mesa_function_pool[12277]: Indexf (offset 46) */ + "f\0" + "glIndexf\0" + "\0" + /* _mesa_function_pool[12289]: GetImageTransformParameterivHP (dynamic) */ + "iip\0" + "glGetImageTransformParameterivHP\0" + "\0" + /* _mesa_function_pool[12327]: Indexd (offset 44) */ + "d\0" + "glIndexd\0" + "\0" + /* _mesa_function_pool[12339]: GetMaterialiv (offset 270) */ + "iip\0" + "glGetMaterialiv\0" + "\0" + /* _mesa_function_pool[12360]: StencilOp (offset 244) */ + "iii\0" + "glStencilOp\0" + "\0" + /* _mesa_function_pool[12377]: WindowPos4ivMESA (will be remapped) */ + "p\0" + "glWindowPos4ivMESA\0" + "\0" + /* _mesa_function_pool[12399]: FramebufferTextureLayer (dynamic) */ + "iiiii\0" + "glFramebufferTextureLayerARB\0" + "\0" + /* _mesa_function_pool[12435]: MultiTexCoord3svARB (offset 399) */ + "ip\0" + "glMultiTexCoord3sv\0" + "glMultiTexCoord3svARB\0" + "\0" + /* _mesa_function_pool[12480]: TexEnvfv (offset 185) */ + "iip\0" + "glTexEnvfv\0" + "\0" + /* _mesa_function_pool[12496]: MultiTexCoord4iARB (offset 404) */ + "iiiii\0" + "glMultiTexCoord4i\0" + "glMultiTexCoord4iARB\0" + "\0" + /* _mesa_function_pool[12542]: Indexs (offset 50) */ + "i\0" + "glIndexs\0" + "\0" + /* _mesa_function_pool[12554]: Binormal3ivEXT (dynamic) */ + "p\0" + "glBinormal3ivEXT\0" + "\0" + /* _mesa_function_pool[12574]: ResizeBuffersMESA (will be remapped) */ + "\0" + "glResizeBuffersMESA\0" + "\0" + /* _mesa_function_pool[12596]: GetUniformivARB (will be remapped) */ + "iip\0" + "glGetUniformiv\0" + "glGetUniformivARB\0" + "\0" + /* _mesa_function_pool[12634]: PixelTexGenParameteriSGIS (will be remapped) */ + "ii\0" + "glPixelTexGenParameteriSGIS\0" + "\0" + /* _mesa_function_pool[12666]: VertexPointervINTEL (dynamic) */ + "iip\0" + "glVertexPointervINTEL\0" + "\0" + /* _mesa_function_pool[12693]: Vertex2i (offset 130) */ + "ii\0" + "glVertex2i\0" + "\0" + /* _mesa_function_pool[12708]: LoadMatrixf (offset 291) */ + "p\0" + "glLoadMatrixf\0" + "\0" + /* _mesa_function_pool[12725]: VertexAttribI1uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI1uivEXT\0" + "glVertexAttribI1uiv\0" + "\0" + /* _mesa_function_pool[12772]: Vertex2f (offset 128) */ + "ff\0" + "glVertex2f\0" + "\0" + /* _mesa_function_pool[12787]: ReplacementCodeuiColor4fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[12840]: Color4bv (offset 26) */ + "p\0" + "glColor4bv\0" + "\0" + /* _mesa_function_pool[12854]: VertexPointer (offset 321) */ + "iiip\0" + "glVertexPointer\0" + "\0" + /* _mesa_function_pool[12876]: SecondaryColor3uiEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3ui\0" + "glSecondaryColor3uiEXT\0" + "\0" + /* _mesa_function_pool[12924]: StartInstrumentsSGIX (dynamic) */ + "\0" + "glStartInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[12949]: SecondaryColor3usvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3usv\0" + "glSecondaryColor3usvEXT\0" + "\0" + /* _mesa_function_pool[12997]: VertexAttrib2fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib2fvNV\0" + "\0" + /* _mesa_function_pool[13021]: ProgramLocalParameter4dvARB (will be remapped) */ + "iip\0" + "glProgramLocalParameter4dvARB\0" + "\0" + /* _mesa_function_pool[13056]: DeleteLists (offset 4) */ + "ii\0" + "glDeleteLists\0" + "\0" + /* _mesa_function_pool[13074]: LogicOp (offset 242) */ + "i\0" + "glLogicOp\0" + "\0" + /* _mesa_function_pool[13087]: MatrixIndexuivARB (dynamic) */ + "ip\0" + "glMatrixIndexuivARB\0" + "\0" + /* _mesa_function_pool[13111]: Vertex2s (offset 132) */ + "ii\0" + "glVertex2s\0" + "\0" + /* _mesa_function_pool[13126]: RenderbufferStorageMultisample (will be remapped) */ + "iiiii\0" + "glRenderbufferStorageMultisample\0" + "glRenderbufferStorageMultisampleEXT\0" + "\0" + /* _mesa_function_pool[13202]: TexCoord4fv (offset 121) */ + "p\0" + "glTexCoord4fv\0" + "\0" + /* _mesa_function_pool[13219]: Tangent3sEXT (dynamic) */ + "iii\0" + "glTangent3sEXT\0" + "\0" + /* _mesa_function_pool[13239]: GlobalAlphaFactorfSUN (dynamic) */ + "f\0" + "glGlobalAlphaFactorfSUN\0" + "\0" + /* _mesa_function_pool[13266]: MultiTexCoord3iARB (offset 396) */ + "iiii\0" + "glMultiTexCoord3i\0" + "glMultiTexCoord3iARB\0" + "\0" + /* _mesa_function_pool[13311]: IsProgram (will be remapped) */ + "i\0" + "glIsProgram\0" + "\0" + /* _mesa_function_pool[13326]: TexCoordPointerListIBM (dynamic) */ + "iiipi\0" + "glTexCoordPointerListIBM\0" + "\0" + /* _mesa_function_pool[13358]: VertexAttribI4svEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4svEXT\0" + "glVertexAttribI4sv\0" + "\0" + /* _mesa_function_pool[13403]: GlobalAlphaFactorusSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorusSUN\0" + "\0" + /* _mesa_function_pool[13431]: VertexAttrib2dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib2dvNV\0" + "\0" + /* _mesa_function_pool[13455]: FramebufferRenderbufferEXT (will be remapped) */ + "iiii\0" + "glFramebufferRenderbuffer\0" + "glFramebufferRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[13516]: ClearBufferuiv (will be remapped) */ + "iip\0" + "glClearBufferuiv\0" + "\0" + /* _mesa_function_pool[13538]: VertexAttrib1dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib1dvNV\0" + "\0" + /* _mesa_function_pool[13562]: GenTextures (offset 328) */ + "ip\0" + "glGenTextures\0" + "glGenTexturesEXT\0" + "\0" + /* _mesa_function_pool[13597]: FramebufferTextureARB (will be remapped) */ + "iiii\0" + "glFramebufferTextureARB\0" + "\0" + /* _mesa_function_pool[13627]: SetFenceNV (will be remapped) */ + "ii\0" + "glSetFenceNV\0" + "\0" + /* _mesa_function_pool[13644]: FramebufferTexture1DEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTexture1D\0" + "glFramebufferTexture1DEXT\0" + "\0" + /* _mesa_function_pool[13700]: GetCombinerOutputParameterivNV (will be remapped) */ + "iiip\0" + "glGetCombinerOutputParameterivNV\0" + "\0" + /* _mesa_function_pool[13739]: MultiModeDrawArraysIBM (will be remapped) */ + "pppii\0" + "glMultiModeDrawArraysIBM\0" + "\0" + /* _mesa_function_pool[13771]: PixelTexGenParameterivSGIS (will be remapped) */ + "ip\0" + "glPixelTexGenParameterivSGIS\0" + "\0" + /* _mesa_function_pool[13804]: TextureNormalEXT (dynamic) */ + "i\0" + "glTextureNormalEXT\0" + "\0" + /* _mesa_function_pool[13826]: IndexPointerListIBM (dynamic) */ + "iipi\0" + "glIndexPointerListIBM\0" + "\0" + /* _mesa_function_pool[13854]: WeightfvARB (dynamic) */ + "ip\0" + "glWeightfvARB\0" + "\0" + /* _mesa_function_pool[13872]: GetCombinerOutputParameterfvNV (will be remapped) */ + "iiip\0" + "glGetCombinerOutputParameterfvNV\0" + "\0" + /* _mesa_function_pool[13911]: RasterPos2sv (offset 69) */ + "p\0" + "glRasterPos2sv\0" + "\0" + /* _mesa_function_pool[13929]: Color4ubv (offset 36) */ + "p\0" + "glColor4ubv\0" + "\0" + /* _mesa_function_pool[13944]: DrawBuffer (offset 202) */ + "i\0" + "glDrawBuffer\0" + "\0" + /* _mesa_function_pool[13960]: TexCoord2fv (offset 105) */ + "p\0" + "glTexCoord2fv\0" + "\0" + /* _mesa_function_pool[13977]: WindowPos4fMESA (will be remapped) */ + "ffff\0" + "glWindowPos4fMESA\0" + "\0" + /* _mesa_function_pool[14001]: TexCoord1sv (offset 101) */ + "p\0" + "glTexCoord1sv\0" + "\0" + /* _mesa_function_pool[14018]: WindowPos3dvMESA (will be remapped) */ + "p\0" + "glWindowPos3dv\0" + "glWindowPos3dvARB\0" + "glWindowPos3dvMESA\0" + "\0" + /* _mesa_function_pool[14073]: DepthFunc (offset 245) */ + "i\0" + "glDepthFunc\0" + "\0" + /* _mesa_function_pool[14088]: PixelMapusv (offset 253) */ + "iip\0" + "glPixelMapusv\0" + "\0" + /* _mesa_function_pool[14107]: GetQueryObjecti64vEXT (will be remapped) */ + "iip\0" + "glGetQueryObjecti64vEXT\0" + "\0" + /* _mesa_function_pool[14136]: MultiTexCoord1dARB (offset 376) */ + "id\0" + "glMultiTexCoord1d\0" + "glMultiTexCoord1dARB\0" + "\0" + /* _mesa_function_pool[14179]: PointParameterivNV (will be remapped) */ + "ip\0" + "glPointParameteriv\0" + "glPointParameterivNV\0" + "\0" + /* _mesa_function_pool[14223]: BlendFunc (offset 241) */ + "ii\0" + "glBlendFunc\0" + "\0" + /* _mesa_function_pool[14239]: EndTransformFeedbackEXT (will be remapped) */ + "\0" + "glEndTransformFeedbackEXT\0" + "glEndTransformFeedback\0" + "\0" + /* _mesa_function_pool[14290]: Uniform2fvARB (will be remapped) */ + "iip\0" + "glUniform2fv\0" + "glUniform2fvARB\0" + "\0" + /* _mesa_function_pool[14324]: BufferParameteriAPPLE (will be remapped) */ + "iii\0" + "glBufferParameteriAPPLE\0" + "\0" + /* _mesa_function_pool[14353]: MultiTexCoord3dvARB (offset 393) */ + "ip\0" + "glMultiTexCoord3dv\0" + "glMultiTexCoord3dvARB\0" + "\0" + /* _mesa_function_pool[14398]: ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[14454]: DeleteObjectARB (will be remapped) */ + "i\0" + "glDeleteObjectARB\0" + "\0" + /* _mesa_function_pool[14475]: MatrixIndexPointerARB (dynamic) */ + "iiip\0" + "glMatrixIndexPointerARB\0" + "\0" + /* _mesa_function_pool[14505]: ProgramNamedParameter4dvNV (will be remapped) */ + "iipp\0" + "glProgramNamedParameter4dvNV\0" + "\0" + /* _mesa_function_pool[14540]: Tangent3fvEXT (dynamic) */ + "p\0" + "glTangent3fvEXT\0" + "\0" + /* _mesa_function_pool[14559]: Flush (offset 217) */ + "\0" + "glFlush\0" + "\0" + /* _mesa_function_pool[14569]: Color4uiv (offset 38) */ + "p\0" + "glColor4uiv\0" + "\0" + /* _mesa_function_pool[14584]: VertexAttribI4iEXT (will be remapped) */ + "iiiii\0" + "glVertexAttribI4iEXT\0" + "glVertexAttribI4i\0" + "\0" + /* _mesa_function_pool[14630]: GenVertexArrays (will be remapped) */ + "ip\0" + "glGenVertexArrays\0" + "\0" + /* _mesa_function_pool[14652]: Uniform3uivEXT (will be remapped) */ + "iip\0" + "glUniform3uivEXT\0" + "glUniform3uiv\0" + "\0" + /* _mesa_function_pool[14688]: RasterPos3sv (offset 77) */ + "p\0" + "glRasterPos3sv\0" + "\0" + /* _mesa_function_pool[14706]: BindFramebufferEXT (will be remapped) */ + "ii\0" + "glBindFramebuffer\0" + "glBindFramebufferEXT\0" + "\0" + /* _mesa_function_pool[14749]: ReferencePlaneSGIX (dynamic) */ + "p\0" + "glReferencePlaneSGIX\0" + "\0" + /* _mesa_function_pool[14773]: PushAttrib (offset 219) */ + "i\0" + "glPushAttrib\0" + "\0" + /* _mesa_function_pool[14789]: RasterPos2i (offset 66) */ + "ii\0" + "glRasterPos2i\0" + "\0" + /* _mesa_function_pool[14807]: ValidateProgramARB (will be remapped) */ + "i\0" + "glValidateProgram\0" + "glValidateProgramARB\0" + "\0" + /* _mesa_function_pool[14849]: TexParameteriv (offset 181) */ + "iip\0" + "glTexParameteriv\0" + "\0" + /* _mesa_function_pool[14871]: UnlockArraysEXT (will be remapped) */ + "\0" + "glUnlockArraysEXT\0" + "\0" + /* _mesa_function_pool[14891]: TexCoord2fColor3fVertex3fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord2fColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[14932]: WindowPos3fvMESA (will be remapped) */ + "p\0" + "glWindowPos3fv\0" + "glWindowPos3fvARB\0" + "glWindowPos3fvMESA\0" + "\0" + /* _mesa_function_pool[14987]: RasterPos2f (offset 64) */ + "ff\0" + "glRasterPos2f\0" + "\0" + /* _mesa_function_pool[15005]: VertexAttrib1svNV (will be remapped) */ + "ip\0" + "glVertexAttrib1svNV\0" + "\0" + /* _mesa_function_pool[15029]: RasterPos2d (offset 62) */ + "dd\0" + "glRasterPos2d\0" + "\0" + /* _mesa_function_pool[15047]: RasterPos3fv (offset 73) */ + "p\0" + "glRasterPos3fv\0" + "\0" + /* _mesa_function_pool[15065]: CopyTexSubImage3D (offset 373) */ + "iiiiiiiii\0" + "glCopyTexSubImage3D\0" + "glCopyTexSubImage3DEXT\0" + "\0" + /* _mesa_function_pool[15119]: VertexAttrib2dARB (will be remapped) */ + "idd\0" + "glVertexAttrib2d\0" + "glVertexAttrib2dARB\0" + "\0" + /* _mesa_function_pool[15161]: Color4ub (offset 35) */ + "iiii\0" + "glColor4ub\0" + "\0" + /* _mesa_function_pool[15178]: GetInteger64v (will be remapped) */ + "ip\0" + "glGetInteger64v\0" + "\0" + /* _mesa_function_pool[15198]: TextureColorMaskSGIS (dynamic) */ + "iiii\0" + "glTextureColorMaskSGIS\0" + "\0" + /* _mesa_function_pool[15227]: RasterPos2s (offset 68) */ + "ii\0" + "glRasterPos2s\0" + "\0" + /* _mesa_function_pool[15245]: GetColorTable (offset 343) */ + "iiip\0" + "glGetColorTable\0" + "glGetColorTableSGI\0" + "glGetColorTableEXT\0" + "\0" + /* _mesa_function_pool[15305]: SelectBuffer (offset 195) */ + "ip\0" + "glSelectBuffer\0" + "\0" + /* _mesa_function_pool[15324]: Indexiv (offset 49) */ + "p\0" + "glIndexiv\0" + "\0" + /* _mesa_function_pool[15337]: TexCoord3i (offset 114) */ + "iii\0" + "glTexCoord3i\0" + "\0" + /* _mesa_function_pool[15355]: CopyColorTable (offset 342) */ + "iiiii\0" + "glCopyColorTable\0" + "glCopyColorTableSGI\0" + "\0" + /* _mesa_function_pool[15399]: GetHistogramParameterfv (offset 362) */ + "iip\0" + "glGetHistogramParameterfv\0" + "glGetHistogramParameterfvEXT\0" + "\0" + /* _mesa_function_pool[15459]: Frustum (offset 289) */ + "dddddd\0" + "glFrustum\0" + "\0" + /* _mesa_function_pool[15477]: GetString (offset 275) */ + "i\0" + "glGetString\0" + "\0" + /* _mesa_function_pool[15492]: ColorPointervINTEL (dynamic) */ + "iip\0" + "glColorPointervINTEL\0" + "\0" + /* _mesa_function_pool[15518]: TexEnvf (offset 184) */ + "iif\0" + "glTexEnvf\0" + "\0" + /* _mesa_function_pool[15533]: TexCoord3d (offset 110) */ + "ddd\0" + "glTexCoord3d\0" + "\0" + /* _mesa_function_pool[15551]: AlphaFragmentOp1ATI (will be remapped) */ + "iiiiii\0" + "glAlphaFragmentOp1ATI\0" + "\0" + /* _mesa_function_pool[15581]: TexCoord3f (offset 112) */ + "fff\0" + "glTexCoord3f\0" + "\0" + /* _mesa_function_pool[15599]: MultiTexCoord3ivARB (offset 397) */ + "ip\0" + "glMultiTexCoord3iv\0" + "glMultiTexCoord3ivARB\0" + "\0" + /* _mesa_function_pool[15644]: MultiTexCoord2sARB (offset 390) */ + "iii\0" + "glMultiTexCoord2s\0" + "glMultiTexCoord2sARB\0" + "\0" + /* _mesa_function_pool[15688]: VertexAttrib1dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib1dv\0" + "glVertexAttrib1dvARB\0" + "\0" + /* _mesa_function_pool[15731]: DeleteTextures (offset 327) */ + "ip\0" + "glDeleteTextures\0" + "glDeleteTexturesEXT\0" + "\0" + /* _mesa_function_pool[15772]: TexCoordPointerEXT (will be remapped) */ + "iiiip\0" + "glTexCoordPointerEXT\0" + "\0" + /* _mesa_function_pool[15800]: TexSubImage4DSGIS (dynamic) */ + "iiiiiiiiiiiip\0" + "glTexSubImage4DSGIS\0" + "\0" + /* _mesa_function_pool[15835]: TexCoord3s (offset 116) */ + "iii\0" + "glTexCoord3s\0" + "\0" + /* _mesa_function_pool[15853]: GetTexLevelParameteriv (offset 285) */ + "iiip\0" + "glGetTexLevelParameteriv\0" + "\0" + /* _mesa_function_pool[15884]: CombinerStageParameterfvNV (dynamic) */ + "iip\0" + "glCombinerStageParameterfvNV\0" + "\0" + /* _mesa_function_pool[15918]: StopInstrumentsSGIX (dynamic) */ + "i\0" + "glStopInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[15943]: TexCoord4fColor4fNormal3fVertex4fSUN (dynamic) */ + "fffffffffffffff\0" + "glTexCoord4fColor4fNormal3fVertex4fSUN\0" + "\0" + /* _mesa_function_pool[15999]: ClearAccum (offset 204) */ + "ffff\0" + "glClearAccum\0" + "\0" + /* _mesa_function_pool[16018]: DeformSGIX (dynamic) */ + "i\0" + "glDeformSGIX\0" + "\0" + /* _mesa_function_pool[16034]: GetVertexAttribfvARB (will be remapped) */ + "iip\0" + "glGetVertexAttribfv\0" + "glGetVertexAttribfvARB\0" + "\0" + /* _mesa_function_pool[16082]: SecondaryColor3ivEXT (will be remapped) */ + "p\0" + "glSecondaryColor3iv\0" + "glSecondaryColor3ivEXT\0" + "\0" + /* _mesa_function_pool[16128]: TexCoord4iv (offset 123) */ + "p\0" + "glTexCoord4iv\0" + "\0" + /* _mesa_function_pool[16145]: VertexAttribI4uiEXT (will be remapped) */ + "iiiii\0" + "glVertexAttribI4uiEXT\0" + "glVertexAttribI4ui\0" + "\0" + /* _mesa_function_pool[16193]: GetFragmentMaterialfvSGIX (dynamic) */ + "iip\0" + "glGetFragmentMaterialfvSGIX\0" + "\0" + /* _mesa_function_pool[16226]: UniformMatrix4x2fv (will be remapped) */ + "iiip\0" + "glUniformMatrix4x2fv\0" + "\0" + /* _mesa_function_pool[16253]: GetDetailTexFuncSGIS (dynamic) */ + "ip\0" + "glGetDetailTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[16280]: GetCombinerStageParameterfvNV (dynamic) */ + "iip\0" + "glGetCombinerStageParameterfvNV\0" + "\0" + /* _mesa_function_pool[16317]: PolygonOffset (offset 319) */ + "ff\0" + "glPolygonOffset\0" + "\0" + /* _mesa_function_pool[16337]: BindVertexArray (will be remapped) */ + "i\0" + "glBindVertexArray\0" + "\0" + /* _mesa_function_pool[16358]: Color4ubVertex2fvSUN (dynamic) */ + "pp\0" + "glColor4ubVertex2fvSUN\0" + "\0" + /* _mesa_function_pool[16385]: Rectd (offset 86) */ + "dddd\0" + "glRectd\0" + "\0" + /* _mesa_function_pool[16399]: TexFilterFuncSGIS (dynamic) */ + "iiip\0" + "glTexFilterFuncSGIS\0" + "\0" + /* _mesa_function_pool[16425]: SampleMaskSGIS (will be remapped) */ + "fi\0" + "glSampleMaskSGIS\0" + "glSampleMaskEXT\0" + "\0" + /* _mesa_function_pool[16462]: VertexAttribI4ubvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4ubvEXT\0" + "glVertexAttribI4ubv\0" + "\0" + /* _mesa_function_pool[16509]: GetAttribLocationARB (will be remapped) */ + "ip\0" + "glGetAttribLocation\0" + "glGetAttribLocationARB\0" + "\0" + /* _mesa_function_pool[16556]: RasterPos3i (offset 74) */ + "iii\0" + "glRasterPos3i\0" + "\0" + /* _mesa_function_pool[16575]: VertexAttrib4ubvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4ubv\0" + "glVertexAttrib4ubvARB\0" + "\0" + /* _mesa_function_pool[16620]: DetailTexFuncSGIS (dynamic) */ + "iip\0" + "glDetailTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[16645]: Normal3fVertex3fSUN (dynamic) */ + "ffffff\0" + "glNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[16675]: CopyTexImage2D (offset 324) */ + "iiiiiiii\0" + "glCopyTexImage2D\0" + "glCopyTexImage2DEXT\0" + "\0" + /* _mesa_function_pool[16722]: GetBufferPointervARB (will be remapped) */ + "iip\0" + "glGetBufferPointerv\0" + "glGetBufferPointervARB\0" + "\0" + /* _mesa_function_pool[16770]: ProgramEnvParameter4fARB (will be remapped) */ + "iiffff\0" + "glProgramEnvParameter4fARB\0" + "glProgramParameter4fNV\0" + "\0" + /* _mesa_function_pool[16828]: Uniform3ivARB (will be remapped) */ + "iip\0" + "glUniform3iv\0" + "glUniform3ivARB\0" + "\0" + /* _mesa_function_pool[16862]: Lightfv (offset 160) */ + "iip\0" + "glLightfv\0" + "\0" + /* _mesa_function_pool[16877]: PrimitiveRestartIndexNV (will be remapped) */ + "i\0" + "glPrimitiveRestartIndexNV\0" + "glPrimitiveRestartIndex\0" + "\0" + /* _mesa_function_pool[16930]: ClearDepth (offset 208) */ + "d\0" + "glClearDepth\0" + "\0" + /* _mesa_function_pool[16946]: GetFenceivNV (will be remapped) */ + "iip\0" + "glGetFenceivNV\0" + "\0" + /* _mesa_function_pool[16966]: WindowPos4dvMESA (will be remapped) */ + "p\0" + "glWindowPos4dvMESA\0" + "\0" + /* _mesa_function_pool[16988]: ColorSubTable (offset 346) */ + "iiiiip\0" + "glColorSubTable\0" + "glColorSubTableEXT\0" + "\0" + /* _mesa_function_pool[17031]: Color4fv (offset 30) */ + "p\0" + "glColor4fv\0" + "\0" + /* _mesa_function_pool[17045]: MultiTexCoord4ivARB (offset 405) */ + "ip\0" + "glMultiTexCoord4iv\0" + "glMultiTexCoord4ivARB\0" + "\0" + /* _mesa_function_pool[17090]: ProgramLocalParameters4fvEXT (will be remapped) */ + "iiip\0" + "glProgramLocalParameters4fvEXT\0" + "\0" + /* _mesa_function_pool[17127]: ColorPointer (offset 308) */ + "iiip\0" + "glColorPointer\0" + "\0" + /* _mesa_function_pool[17148]: Rects (offset 92) */ + "iiii\0" + "glRects\0" + "\0" + /* _mesa_function_pool[17162]: GetMapAttribParameterfvNV (dynamic) */ + "iiip\0" + "glGetMapAttribParameterfvNV\0" + "\0" + /* _mesa_function_pool[17196]: CreateShaderProgramEXT (will be remapped) */ + "ip\0" + "glCreateShaderProgramEXT\0" + "\0" + /* _mesa_function_pool[17225]: ActiveProgramEXT (will be remapped) */ + "i\0" + "glActiveProgramEXT\0" + "\0" + /* _mesa_function_pool[17247]: Lightiv (offset 162) */ + "iip\0" + "glLightiv\0" + "\0" + /* _mesa_function_pool[17262]: VertexAttrib4sARB (will be remapped) */ + "iiiii\0" + "glVertexAttrib4s\0" + "glVertexAttrib4sARB\0" + "\0" + /* _mesa_function_pool[17306]: GetQueryObjectuivARB (will be remapped) */ + "iip\0" + "glGetQueryObjectuiv\0" + "glGetQueryObjectuivARB\0" + "\0" + /* _mesa_function_pool[17354]: GetTexParameteriv (offset 283) */ + "iip\0" + "glGetTexParameteriv\0" + "\0" + /* _mesa_function_pool[17379]: MapParameterivNV (dynamic) */ + "iip\0" + "glMapParameterivNV\0" + "\0" + /* _mesa_function_pool[17403]: GenRenderbuffersEXT (will be remapped) */ + "ip\0" + "glGenRenderbuffers\0" + "glGenRenderbuffersEXT\0" + "\0" + /* _mesa_function_pool[17448]: ClearBufferfv (will be remapped) */ + "iip\0" + "glClearBufferfv\0" + "\0" + /* _mesa_function_pool[17469]: VertexAttrib2dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib2dv\0" + "glVertexAttrib2dvARB\0" + "\0" + /* _mesa_function_pool[17512]: EdgeFlagPointerEXT (will be remapped) */ + "iip\0" + "glEdgeFlagPointerEXT\0" + "\0" + /* _mesa_function_pool[17538]: VertexAttribs2svNV (will be remapped) */ + "iip\0" + "glVertexAttribs2svNV\0" + "\0" + /* _mesa_function_pool[17564]: WeightbvARB (dynamic) */ + "ip\0" + "glWeightbvARB\0" + "\0" + /* _mesa_function_pool[17582]: VertexAttrib2fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib2fv\0" + "glVertexAttrib2fvARB\0" + "\0" + /* _mesa_function_pool[17625]: GetBufferParameterivARB (will be remapped) */ + "iip\0" + "glGetBufferParameteriv\0" + "glGetBufferParameterivARB\0" + "\0" + /* _mesa_function_pool[17679]: Rectdv (offset 87) */ + "pp\0" + "glRectdv\0" + "\0" + /* _mesa_function_pool[17692]: ListParameteriSGIX (dynamic) */ + "iii\0" + "glListParameteriSGIX\0" + "\0" + /* _mesa_function_pool[17718]: ReplacementCodeuiColor4fNormal3fVertex3fSUN (dynamic) */ + "iffffffffff\0" + "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[17777]: InstrumentsBufferSGIX (dynamic) */ + "ip\0" + "glInstrumentsBufferSGIX\0" + "\0" + /* _mesa_function_pool[17805]: VertexAttrib4NivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Niv\0" + "glVertexAttrib4NivARB\0" + "\0" + /* _mesa_function_pool[17850]: DrawArraysInstancedARB (will be remapped) */ + "iiii\0" + "glDrawArraysInstancedARB\0" + "glDrawArraysInstancedEXT\0" + "glDrawArraysInstanced\0" + "\0" + /* _mesa_function_pool[17928]: GetAttachedShaders (will be remapped) */ + "iipp\0" + "glGetAttachedShaders\0" + "\0" + /* _mesa_function_pool[17955]: GenVertexArraysAPPLE (will be remapped) */ + "ip\0" + "glGenVertexArraysAPPLE\0" + "\0" + /* _mesa_function_pool[17982]: ClearBufferfi (will be remapped) */ + "iifi\0" + "glClearBufferfi\0" + "\0" + /* _mesa_function_pool[18004]: Materialiv (offset 172) */ + "iip\0" + "glMaterialiv\0" + "\0" + /* _mesa_function_pool[18022]: PushClientAttrib (offset 335) */ + "i\0" + "glPushClientAttrib\0" + "\0" + /* _mesa_function_pool[18044]: ProgramEnvParameters4fvEXT (will be remapped) */ + "iiip\0" + "glProgramEnvParameters4fvEXT\0" + "\0" + /* _mesa_function_pool[18079]: TexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glTexCoord2fColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[18125]: WindowPos2iMESA (will be remapped) */ + "ii\0" + "glWindowPos2i\0" + "glWindowPos2iARB\0" + "glWindowPos2iMESA\0" + "\0" + /* _mesa_function_pool[18178]: SecondaryColor3fvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3fv\0" + "glSecondaryColor3fvEXT\0" + "\0" + /* _mesa_function_pool[18224]: PolygonMode (offset 174) */ + "ii\0" + "glPolygonMode\0" + "\0" + /* _mesa_function_pool[18242]: CompressedTexSubImage1DARB (will be remapped) */ + "iiiiiip\0" + "glCompressedTexSubImage1D\0" + "glCompressedTexSubImage1DARB\0" + "\0" + /* _mesa_function_pool[18306]: VertexAttribI1iEXT (will be remapped) */ + "ii\0" + "glVertexAttribI1iEXT\0" + "glVertexAttribI1i\0" + "\0" + /* _mesa_function_pool[18349]: GetVertexAttribivNV (will be remapped) */ + "iip\0" + "glGetVertexAttribivNV\0" + "\0" + /* _mesa_function_pool[18376]: GetProgramStringARB (will be remapped) */ + "iip\0" + "glGetProgramStringARB\0" + "\0" + /* _mesa_function_pool[18403]: VertexAttribIPointerEXT (will be remapped) */ + "iiiip\0" + "glVertexAttribIPointerEXT\0" + "glVertexAttribIPointer\0" + "\0" + /* _mesa_function_pool[18459]: TexBumpParameterfvATI (will be remapped) */ + "ip\0" + "glTexBumpParameterfvATI\0" + "\0" + /* _mesa_function_pool[18487]: CompileShaderARB (will be remapped) */ + "i\0" + "glCompileShader\0" + "glCompileShaderARB\0" + "\0" + /* _mesa_function_pool[18525]: DeleteShader (will be remapped) */ + "i\0" + "glDeleteShader\0" + "\0" + /* _mesa_function_pool[18543]: DisableClientState (offset 309) */ + "i\0" + "glDisableClientState\0" + "\0" + /* _mesa_function_pool[18567]: TexGeni (offset 192) */ + "iii\0" + "glTexGeni\0" + "\0" + /* _mesa_function_pool[18582]: TexGenf (offset 190) */ + "iif\0" + "glTexGenf\0" + "\0" + /* _mesa_function_pool[18597]: Uniform3fARB (will be remapped) */ + "ifff\0" + "glUniform3f\0" + "glUniform3fARB\0" + "\0" + /* _mesa_function_pool[18630]: TexGend (offset 188) */ + "iid\0" + "glTexGend\0" + "\0" + /* _mesa_function_pool[18645]: ListParameterfvSGIX (dynamic) */ + "iip\0" + "glListParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[18672]: GetPolygonStipple (offset 274) */ + "p\0" + "glGetPolygonStipple\0" + "\0" + /* _mesa_function_pool[18695]: Tangent3dvEXT (dynamic) */ + "p\0" + "glTangent3dvEXT\0" + "\0" + /* _mesa_function_pool[18714]: BindBufferOffsetEXT (will be remapped) */ + "iiii\0" + "glBindBufferOffsetEXT\0" + "\0" + /* _mesa_function_pool[18742]: WindowPos3sMESA (will be remapped) */ + "iii\0" + "glWindowPos3s\0" + "glWindowPos3sARB\0" + "glWindowPos3sMESA\0" + "\0" + /* _mesa_function_pool[18796]: VertexAttrib2svNV (will be remapped) */ + "ip\0" + "glVertexAttrib2svNV\0" + "\0" + /* _mesa_function_pool[18820]: DisableIndexedEXT (will be remapped) */ + "ii\0" + "glDisableIndexedEXT\0" + "glDisablei\0" + "\0" + /* _mesa_function_pool[18855]: BindBufferBaseEXT (will be remapped) */ + "iii\0" + "glBindBufferBaseEXT\0" + "glBindBufferBase\0" + "\0" + /* _mesa_function_pool[18897]: TexCoord2fVertex3fvSUN (dynamic) */ + "pp\0" + "glTexCoord2fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[18926]: WindowPos4sMESA (will be remapped) */ + "iiii\0" + "glWindowPos4sMESA\0" + "\0" + /* _mesa_function_pool[18950]: VertexAttrib4NuivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nuiv\0" + "glVertexAttrib4NuivARB\0" + "\0" + /* _mesa_function_pool[18997]: ClientActiveTextureARB (offset 375) */ + "i\0" + "glClientActiveTexture\0" + "glClientActiveTextureARB\0" + "\0" + /* _mesa_function_pool[19047]: PixelTexGenSGIX (will be remapped) */ + "i\0" + "glPixelTexGenSGIX\0" + "\0" + /* _mesa_function_pool[19068]: ReplacementCodeusvSUN (dynamic) */ + "p\0" + "glReplacementCodeusvSUN\0" + "\0" + /* _mesa_function_pool[19095]: Uniform4fARB (will be remapped) */ + "iffff\0" + "glUniform4f\0" + "glUniform4fARB\0" + "\0" + /* _mesa_function_pool[19129]: Color4sv (offset 34) */ + "p\0" + "glColor4sv\0" + "\0" + /* _mesa_function_pool[19143]: FlushMappedBufferRange (will be remapped) */ + "iii\0" + "glFlushMappedBufferRange\0" + "\0" + /* _mesa_function_pool[19173]: IsProgramNV (will be remapped) */ + "i\0" + "glIsProgramARB\0" + "glIsProgramNV\0" + "\0" + /* _mesa_function_pool[19205]: FlushMappedBufferRangeAPPLE (will be remapped) */ + "iii\0" + "glFlushMappedBufferRangeAPPLE\0" + "\0" + /* _mesa_function_pool[19240]: PixelZoom (offset 246) */ + "ff\0" + "glPixelZoom\0" + "\0" + /* _mesa_function_pool[19256]: ReplacementCodePointerSUN (dynamic) */ + "iip\0" + "glReplacementCodePointerSUN\0" + "\0" + /* _mesa_function_pool[19289]: ProgramEnvParameter4dARB (will be remapped) */ + "iidddd\0" + "glProgramEnvParameter4dARB\0" + "glProgramParameter4dNV\0" + "\0" + /* _mesa_function_pool[19347]: ColorTableParameterfv (offset 340) */ + "iip\0" + "glColorTableParameterfv\0" + "glColorTableParameterfvSGI\0" + "\0" + /* _mesa_function_pool[19403]: FragmentLightModelfSGIX (dynamic) */ + "if\0" + "glFragmentLightModelfSGIX\0" + "\0" + /* _mesa_function_pool[19433]: Binormal3bvEXT (dynamic) */ + "p\0" + "glBinormal3bvEXT\0" + "\0" + /* _mesa_function_pool[19453]: PixelMapuiv (offset 252) */ + "iip\0" + "glPixelMapuiv\0" + "\0" + /* _mesa_function_pool[19472]: Color3dv (offset 12) */ + "p\0" + "glColor3dv\0" + "\0" + /* _mesa_function_pool[19486]: IsTexture (offset 330) */ + "i\0" + "glIsTexture\0" + "glIsTextureEXT\0" + "\0" + /* _mesa_function_pool[19516]: VertexWeightfvEXT (dynamic) */ + "p\0" + "glVertexWeightfvEXT\0" + "\0" + /* _mesa_function_pool[19539]: VertexAttrib1dARB (will be remapped) */ + "id\0" + "glVertexAttrib1d\0" + "glVertexAttrib1dARB\0" + "\0" + /* _mesa_function_pool[19580]: ImageTransformParameterivHP (dynamic) */ + "iip\0" + "glImageTransformParameterivHP\0" + "\0" + /* _mesa_function_pool[19615]: TexCoord4i (offset 122) */ + "iiii\0" + "glTexCoord4i\0" + "\0" + /* _mesa_function_pool[19634]: DeleteQueriesARB (will be remapped) */ + "ip\0" + "glDeleteQueries\0" + "glDeleteQueriesARB\0" + "\0" + /* _mesa_function_pool[19673]: Color4ubVertex2fSUN (dynamic) */ + "iiiiff\0" + "glColor4ubVertex2fSUN\0" + "\0" + /* _mesa_function_pool[19703]: FragmentColorMaterialSGIX (dynamic) */ + "ii\0" + "glFragmentColorMaterialSGIX\0" + "\0" + /* _mesa_function_pool[19735]: CurrentPaletteMatrixARB (dynamic) */ + "i\0" + "glCurrentPaletteMatrixARB\0" + "\0" + /* _mesa_function_pool[19764]: GetMapdv (offset 266) */ + "iip\0" + "glGetMapdv\0" + "\0" + /* _mesa_function_pool[19780]: ObjectPurgeableAPPLE (will be remapped) */ + "iii\0" + "glObjectPurgeableAPPLE\0" + "\0" + /* _mesa_function_pool[19808]: GetStringi (will be remapped) */ + "ii\0" + "glGetStringi\0" + "\0" + /* _mesa_function_pool[19825]: SamplePatternSGIS (will be remapped) */ + "i\0" + "glSamplePatternSGIS\0" + "glSamplePatternEXT\0" + "\0" + /* _mesa_function_pool[19867]: PixelStoref (offset 249) */ + "if\0" + "glPixelStoref\0" + "\0" + /* _mesa_function_pool[19885]: IsQueryARB (will be remapped) */ + "i\0" + "glIsQuery\0" + "glIsQueryARB\0" + "\0" + /* _mesa_function_pool[19911]: ReplacementCodeuiColor4ubVertex3fSUN (dynamic) */ + "iiiiifff\0" + "glReplacementCodeuiColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[19960]: PixelStorei (offset 250) */ + "ii\0" + "glPixelStorei\0" + "\0" + /* _mesa_function_pool[19978]: VertexAttrib4usvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4usv\0" + "glVertexAttrib4usvARB\0" + "\0" + /* _mesa_function_pool[20023]: LinkProgramARB (will be remapped) */ + "i\0" + "glLinkProgram\0" + "glLinkProgramARB\0" + "\0" + /* _mesa_function_pool[20057]: VertexAttrib2fNV (will be remapped) */ + "iff\0" + "glVertexAttrib2fNV\0" + "\0" + /* _mesa_function_pool[20081]: ShaderSourceARB (will be remapped) */ + "iipp\0" + "glShaderSource\0" + "glShaderSourceARB\0" + "\0" + /* _mesa_function_pool[20120]: FragmentMaterialiSGIX (dynamic) */ + "iii\0" + "glFragmentMaterialiSGIX\0" + "\0" + /* _mesa_function_pool[20149]: EvalCoord2dv (offset 233) */ + "p\0" + "glEvalCoord2dv\0" + "\0" + /* _mesa_function_pool[20167]: VertexAttrib3svARB (will be remapped) */ + "ip\0" + "glVertexAttrib3sv\0" + "glVertexAttrib3svARB\0" + "\0" + /* _mesa_function_pool[20210]: ColorMaterial (offset 151) */ + "ii\0" + "glColorMaterial\0" + "\0" + /* _mesa_function_pool[20230]: CompressedTexSubImage3DARB (will be remapped) */ + "iiiiiiiiiip\0" + "glCompressedTexSubImage3D\0" + "glCompressedTexSubImage3DARB\0" + "\0" + /* _mesa_function_pool[20298]: WindowPos2ivMESA (will be remapped) */ + "p\0" + "glWindowPos2iv\0" + "glWindowPos2ivARB\0" + "glWindowPos2ivMESA\0" + "\0" + /* _mesa_function_pool[20353]: IsFramebufferEXT (will be remapped) */ + "i\0" + "glIsFramebuffer\0" + "glIsFramebufferEXT\0" + "\0" + /* _mesa_function_pool[20391]: Uniform4ivARB (will be remapped) */ + "iip\0" + "glUniform4iv\0" + "glUniform4ivARB\0" + "\0" + /* _mesa_function_pool[20425]: GetVertexAttribdvARB (will be remapped) */ + "iip\0" + "glGetVertexAttribdv\0" + "glGetVertexAttribdvARB\0" + "\0" + /* _mesa_function_pool[20473]: TexBumpParameterivATI (will be remapped) */ + "ip\0" + "glTexBumpParameterivATI\0" + "\0" + /* _mesa_function_pool[20501]: GetSeparableFilter (offset 359) */ + "iiippp\0" + "glGetSeparableFilter\0" + "glGetSeparableFilterEXT\0" + "\0" + /* _mesa_function_pool[20554]: Binormal3dEXT (dynamic) */ + "ddd\0" + "glBinormal3dEXT\0" + "\0" + /* _mesa_function_pool[20575]: SpriteParameteriSGIX (dynamic) */ + "ii\0" + "glSpriteParameteriSGIX\0" + "\0" + /* _mesa_function_pool[20602]: RequestResidentProgramsNV (will be remapped) */ + "ip\0" + "glRequestResidentProgramsNV\0" + "\0" + /* _mesa_function_pool[20634]: TagSampleBufferSGIX (dynamic) */ + "\0" + "glTagSampleBufferSGIX\0" + "\0" + /* _mesa_function_pool[20658]: TransformFeedbackVaryingsEXT (will be remapped) */ + "iipi\0" + "glTransformFeedbackVaryingsEXT\0" + "glTransformFeedbackVaryings\0" + "\0" + /* _mesa_function_pool[20723]: FeedbackBuffer (offset 194) */ + "iip\0" + "glFeedbackBuffer\0" + "\0" + /* _mesa_function_pool[20745]: RasterPos2iv (offset 67) */ + "p\0" + "glRasterPos2iv\0" + "\0" + /* _mesa_function_pool[20763]: TexImage1D (offset 182) */ + "iiiiiiip\0" + "glTexImage1D\0" + "\0" + /* _mesa_function_pool[20786]: ListParameterivSGIX (dynamic) */ + "iip\0" + "glListParameterivSGIX\0" + "\0" + /* _mesa_function_pool[20813]: MultiDrawElementsEXT (will be remapped) */ + "ipipi\0" + "glMultiDrawElements\0" + "glMultiDrawElementsEXT\0" + "\0" + /* _mesa_function_pool[20863]: Color3s (offset 17) */ + "iii\0" + "glColor3s\0" + "\0" + /* _mesa_function_pool[20878]: Uniform1ivARB (will be remapped) */ + "iip\0" + "glUniform1iv\0" + "glUniform1ivARB\0" + "\0" + /* _mesa_function_pool[20912]: WindowPos2sMESA (will be remapped) */ + "ii\0" + "glWindowPos2s\0" + "glWindowPos2sARB\0" + "glWindowPos2sMESA\0" + "\0" + /* _mesa_function_pool[20965]: WeightusvARB (dynamic) */ + "ip\0" + "glWeightusvARB\0" + "\0" + /* _mesa_function_pool[20984]: TexCoordPointer (offset 320) */ + "iiip\0" + "glTexCoordPointer\0" + "\0" + /* _mesa_function_pool[21008]: FogCoordPointerEXT (will be remapped) */ + "iip\0" + "glFogCoordPointer\0" + "glFogCoordPointerEXT\0" + "\0" + /* _mesa_function_pool[21052]: IndexMaterialEXT (dynamic) */ + "ii\0" + "glIndexMaterialEXT\0" + "\0" + /* _mesa_function_pool[21075]: Color3i (offset 15) */ + "iii\0" + "glColor3i\0" + "\0" + /* _mesa_function_pool[21090]: FrontFace (offset 157) */ + "i\0" + "glFrontFace\0" + "\0" + /* _mesa_function_pool[21105]: EvalCoord2d (offset 232) */ + "dd\0" + "glEvalCoord2d\0" + "\0" + /* _mesa_function_pool[21123]: SecondaryColor3ubvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3ubv\0" + "glSecondaryColor3ubvEXT\0" + "\0" + /* _mesa_function_pool[21171]: EvalCoord2f (offset 234) */ + "ff\0" + "glEvalCoord2f\0" + "\0" + /* _mesa_function_pool[21189]: VertexAttrib4dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4dv\0" + "glVertexAttrib4dvARB\0" + "\0" + /* _mesa_function_pool[21232]: BindAttribLocationARB (will be remapped) */ + "iip\0" + "glBindAttribLocation\0" + "glBindAttribLocationARB\0" + "\0" + /* _mesa_function_pool[21282]: Color3b (offset 9) */ + "iii\0" + "glColor3b\0" + "\0" + /* _mesa_function_pool[21297]: MultiTexCoord2dARB (offset 384) */ + "idd\0" + "glMultiTexCoord2d\0" + "glMultiTexCoord2dARB\0" + "\0" + /* _mesa_function_pool[21341]: ExecuteProgramNV (will be remapped) */ + "iip\0" + "glExecuteProgramNV\0" + "\0" + /* _mesa_function_pool[21365]: Color3f (offset 13) */ + "fff\0" + "glColor3f\0" + "\0" + /* _mesa_function_pool[21380]: LightEnviSGIX (dynamic) */ + "ii\0" + "glLightEnviSGIX\0" + "\0" + /* _mesa_function_pool[21400]: Color3d (offset 11) */ + "ddd\0" + "glColor3d\0" + "\0" + /* _mesa_function_pool[21415]: Normal3dv (offset 55) */ + "p\0" + "glNormal3dv\0" + "\0" + /* _mesa_function_pool[21430]: Lightf (offset 159) */ + "iif\0" + "glLightf\0" + "\0" + /* _mesa_function_pool[21444]: ReplacementCodeuiSUN (dynamic) */ + "i\0" + "glReplacementCodeuiSUN\0" + "\0" + /* _mesa_function_pool[21470]: MatrixMode (offset 293) */ + "i\0" + "glMatrixMode\0" + "\0" + /* _mesa_function_pool[21486]: GetPixelMapusv (offset 273) */ + "ip\0" + "glGetPixelMapusv\0" + "\0" + /* _mesa_function_pool[21507]: Lighti (offset 161) */ + "iii\0" + "glLighti\0" + "\0" + /* _mesa_function_pool[21521]: VertexAttribPointerNV (will be remapped) */ + "iiiip\0" + "glVertexAttribPointerNV\0" + "\0" + /* _mesa_function_pool[21552]: GetBooleanIndexedvEXT (will be remapped) */ + "iip\0" + "glGetBooleanIndexedvEXT\0" + "glGetBooleani_v\0" + "\0" + /* _mesa_function_pool[21597]: GetFramebufferAttachmentParameterivEXT (will be remapped) */ + "iiip\0" + "glGetFramebufferAttachmentParameteriv\0" + "glGetFramebufferAttachmentParameterivEXT\0" + "\0" + /* _mesa_function_pool[21682]: PixelTransformParameterfEXT (dynamic) */ + "iif\0" + "glPixelTransformParameterfEXT\0" + "\0" + /* _mesa_function_pool[21717]: MultiTexCoord4dvARB (offset 401) */ + "ip\0" + "glMultiTexCoord4dv\0" + "glMultiTexCoord4dvARB\0" + "\0" + /* _mesa_function_pool[21762]: PixelTransformParameteriEXT (dynamic) */ + "iii\0" + "glPixelTransformParameteriEXT\0" + "\0" + /* _mesa_function_pool[21797]: GetDoublev (offset 260) */ + "ip\0" + "glGetDoublev\0" + "\0" + /* _mesa_function_pool[21814]: MultMatrixd (offset 295) */ + "p\0" + "glMultMatrixd\0" + "\0" + /* _mesa_function_pool[21831]: MultMatrixf (offset 294) */ + "p\0" + "glMultMatrixf\0" + "\0" + /* _mesa_function_pool[21848]: VertexAttribI4bvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4bvEXT\0" + "glVertexAttribI4bv\0" + "\0" + /* _mesa_function_pool[21893]: TexCoord2fColor4ubVertex3fSUN (dynamic) */ + "ffiiiifff\0" + "glTexCoord2fColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[21936]: Uniform1iARB (will be remapped) */ + "ii\0" + "glUniform1i\0" + "glUniform1iARB\0" + "\0" + /* _mesa_function_pool[21967]: VertexAttribPointerARB (will be remapped) */ + "iiiiip\0" + "glVertexAttribPointer\0" + "glVertexAttribPointerARB\0" + "\0" + /* _mesa_function_pool[22022]: VertexAttrib3sNV (will be remapped) */ + "iiii\0" + "glVertexAttrib3sNV\0" + "\0" + /* _mesa_function_pool[22047]: SharpenTexFuncSGIS (dynamic) */ + "iip\0" + "glSharpenTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[22073]: MultiTexCoord4fvARB (offset 403) */ + "ip\0" + "glMultiTexCoord4fv\0" + "glMultiTexCoord4fvARB\0" + "\0" + /* _mesa_function_pool[22118]: Uniform2uiEXT (will be remapped) */ + "iii\0" + "glUniform2uiEXT\0" + "glUniform2ui\0" + "\0" + /* _mesa_function_pool[22152]: UniformMatrix2x3fv (will be remapped) */ + "iiip\0" + "glUniformMatrix2x3fv\0" + "\0" + /* _mesa_function_pool[22179]: TrackMatrixNV (will be remapped) */ + "iiii\0" + "glTrackMatrixNV\0" + "\0" + /* _mesa_function_pool[22201]: CombinerParameteriNV (will be remapped) */ + "ii\0" + "glCombinerParameteriNV\0" + "\0" + /* _mesa_function_pool[22228]: DeleteAsyncMarkersSGIX (dynamic) */ + "ii\0" + "glDeleteAsyncMarkersSGIX\0" + "\0" + /* _mesa_function_pool[22257]: ReplacementCodeusSUN (dynamic) */ + "i\0" + "glReplacementCodeusSUN\0" + "\0" + /* _mesa_function_pool[22283]: IsAsyncMarkerSGIX (dynamic) */ + "i\0" + "glIsAsyncMarkerSGIX\0" + "\0" + /* _mesa_function_pool[22306]: FrameZoomSGIX (dynamic) */ + "i\0" + "glFrameZoomSGIX\0" + "\0" + /* _mesa_function_pool[22325]: Normal3fVertex3fvSUN (dynamic) */ + "pp\0" + "glNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[22352]: RasterPos4sv (offset 85) */ + "p\0" + "glRasterPos4sv\0" + "\0" + /* _mesa_function_pool[22370]: VertexAttrib4NsvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nsv\0" + "glVertexAttrib4NsvARB\0" + "\0" + /* _mesa_function_pool[22415]: VertexAttrib3fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib3fv\0" + "glVertexAttrib3fvARB\0" + "\0" + /* _mesa_function_pool[22458]: ClearColor (offset 206) */ + "ffff\0" + "glClearColor\0" + "\0" + /* _mesa_function_pool[22477]: GetSynciv (will be remapped) */ + "iiipp\0" + "glGetSynciv\0" + "\0" + /* _mesa_function_pool[22496]: ClearColorIiEXT (will be remapped) */ + "iiii\0" + "glClearColorIiEXT\0" + "\0" + /* _mesa_function_pool[22520]: DeleteFramebuffersEXT (will be remapped) */ + "ip\0" + "glDeleteFramebuffers\0" + "glDeleteFramebuffersEXT\0" + "\0" + /* _mesa_function_pool[22569]: GlobalAlphaFactorsSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorsSUN\0" + "\0" + /* _mesa_function_pool[22596]: IsEnabledIndexedEXT (will be remapped) */ + "ii\0" + "glIsEnabledIndexedEXT\0" + "glIsEnabledi\0" + "\0" + /* _mesa_function_pool[22635]: TexEnviv (offset 187) */ + "iip\0" + "glTexEnviv\0" + "\0" + /* _mesa_function_pool[22651]: TexSubImage3D (offset 372) */ + "iiiiiiiiiip\0" + "glTexSubImage3D\0" + "glTexSubImage3DEXT\0" + "\0" + /* _mesa_function_pool[22699]: Tangent3fEXT (dynamic) */ + "fff\0" + "glTangent3fEXT\0" + "\0" + /* _mesa_function_pool[22719]: SecondaryColor3uivEXT (will be remapped) */ + "p\0" + "glSecondaryColor3uiv\0" + "glSecondaryColor3uivEXT\0" + "\0" + /* _mesa_function_pool[22767]: MatrixIndexubvARB (dynamic) */ + "ip\0" + "glMatrixIndexubvARB\0" + "\0" + /* _mesa_function_pool[22791]: Color4fNormal3fVertex3fSUN (dynamic) */ + "ffffffffff\0" + "glColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[22832]: PixelTexGenParameterfSGIS (will be remapped) */ + "if\0" + "glPixelTexGenParameterfSGIS\0" + "\0" + /* _mesa_function_pool[22864]: CreateShader (will be remapped) */ + "i\0" + "glCreateShader\0" + "\0" + /* _mesa_function_pool[22882]: GetColorTableParameterfv (offset 344) */ + "iip\0" + "glGetColorTableParameterfv\0" + "glGetColorTableParameterfvSGI\0" + "glGetColorTableParameterfvEXT\0" + "\0" + /* _mesa_function_pool[22974]: FragmentLightModelfvSGIX (dynamic) */ + "ip\0" + "glFragmentLightModelfvSGIX\0" + "\0" + /* _mesa_function_pool[23005]: Bitmap (offset 8) */ + "iiffffp\0" + "glBitmap\0" + "\0" + /* _mesa_function_pool[23023]: MultiTexCoord3fARB (offset 394) */ + "ifff\0" + "glMultiTexCoord3f\0" + "glMultiTexCoord3fARB\0" + "\0" + /* _mesa_function_pool[23068]: GetTexLevelParameterfv (offset 284) */ + "iiip\0" + "glGetTexLevelParameterfv\0" + "\0" + /* _mesa_function_pool[23099]: GetPixelTexGenParameterfvSGIS (will be remapped) */ + "ip\0" + "glGetPixelTexGenParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[23135]: GenFramebuffersEXT (will be remapped) */ + "ip\0" + "glGenFramebuffers\0" + "glGenFramebuffersEXT\0" + "\0" + /* _mesa_function_pool[23178]: VertexAttribDivisor (will be remapped) */ + "ii\0" + "glVertexAttribDivisor\0" + "\0" + /* _mesa_function_pool[23204]: GetProgramParameterdvNV (will be remapped) */ + "iiip\0" + "glGetProgramParameterdvNV\0" + "\0" + /* _mesa_function_pool[23236]: Vertex2sv (offset 133) */ + "p\0" + "glVertex2sv\0" + "\0" + /* _mesa_function_pool[23251]: GetIntegerv (offset 263) */ + "ip\0" + "glGetIntegerv\0" + "\0" + /* _mesa_function_pool[23269]: IsVertexArrayAPPLE (will be remapped) */ + "i\0" + "glIsVertexArray\0" + "glIsVertexArrayAPPLE\0" + "\0" + /* _mesa_function_pool[23309]: FragmentLightfvSGIX (dynamic) */ + "iip\0" + "glFragmentLightfvSGIX\0" + "\0" + /* _mesa_function_pool[23336]: DetachShader (will be remapped) */ + "ii\0" + "glDetachShader\0" + "\0" + /* _mesa_function_pool[23355]: VertexAttrib4NubARB (will be remapped) */ + "iiiii\0" + "glVertexAttrib4Nub\0" + "glVertexAttrib4NubARB\0" + "\0" + /* _mesa_function_pool[23403]: GetProgramEnvParameterfvARB (will be remapped) */ + "iip\0" + "glGetProgramEnvParameterfvARB\0" + "\0" + /* _mesa_function_pool[23438]: GetTrackMatrixivNV (will be remapped) */ + "iiip\0" + "glGetTrackMatrixivNV\0" + "\0" + /* _mesa_function_pool[23465]: VertexAttrib3svNV (will be remapped) */ + "ip\0" + "glVertexAttrib3svNV\0" + "\0" + /* _mesa_function_pool[23489]: Uniform4fvARB (will be remapped) */ + "iip\0" + "glUniform4fv\0" + "glUniform4fvARB\0" + "\0" + /* _mesa_function_pool[23523]: MultTransposeMatrixfARB (will be remapped) */ + "p\0" + "glMultTransposeMatrixf\0" + "glMultTransposeMatrixfARB\0" + "\0" + /* _mesa_function_pool[23575]: GetTexEnviv (offset 277) */ + "iip\0" + "glGetTexEnviv\0" + "\0" + /* _mesa_function_pool[23594]: ColorFragmentOp1ATI (will be remapped) */ + "iiiiiii\0" + "glColorFragmentOp1ATI\0" + "\0" + /* _mesa_function_pool[23625]: GetUniformfvARB (will be remapped) */ + "iip\0" + "glGetUniformfv\0" + "glGetUniformfvARB\0" + "\0" + /* _mesa_function_pool[23663]: EGLImageTargetRenderbufferStorageOES (will be remapped) */ + "ip\0" + "glEGLImageTargetRenderbufferStorageOES\0" + "\0" + /* _mesa_function_pool[23706]: VertexAttribI2ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI2ivEXT\0" + "glVertexAttribI2iv\0" + "\0" + /* _mesa_function_pool[23751]: PopClientAttrib (offset 334) */ + "\0" + "glPopClientAttrib\0" + "\0" + /* _mesa_function_pool[23771]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ + "iffffffffffff\0" + "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[23842]: DetachObjectARB (will be remapped) */ + "ii\0" + "glDetachObjectARB\0" + "\0" + /* _mesa_function_pool[23864]: VertexBlendARB (dynamic) */ + "i\0" + "glVertexBlendARB\0" + "\0" + /* _mesa_function_pool[23884]: WindowPos3iMESA (will be remapped) */ + "iii\0" + "glWindowPos3i\0" + "glWindowPos3iARB\0" + "glWindowPos3iMESA\0" + "\0" + /* _mesa_function_pool[23938]: SeparableFilter2D (offset 360) */ + "iiiiiipp\0" + "glSeparableFilter2D\0" + "glSeparableFilter2DEXT\0" + "\0" + /* _mesa_function_pool[23991]: ProgramParameteriARB (will be remapped) */ + "iii\0" + "glProgramParameteriARB\0" + "\0" + /* _mesa_function_pool[24019]: Map1d (offset 220) */ + "iddiip\0" + "glMap1d\0" + "\0" + /* _mesa_function_pool[24035]: Map1f (offset 221) */ + "iffiip\0" + "glMap1f\0" + "\0" + /* _mesa_function_pool[24051]: CompressedTexImage2DARB (will be remapped) */ + "iiiiiiip\0" + "glCompressedTexImage2D\0" + "glCompressedTexImage2DARB\0" + "\0" + /* _mesa_function_pool[24110]: ArrayElement (offset 306) */ + "i\0" + "glArrayElement\0" + "glArrayElementEXT\0" + "\0" + /* _mesa_function_pool[24146]: TexImage2D (offset 183) */ + "iiiiiiiip\0" + "glTexImage2D\0" + "\0" + /* _mesa_function_pool[24170]: DepthBoundsEXT (will be remapped) */ + "dd\0" + "glDepthBoundsEXT\0" + "\0" + /* _mesa_function_pool[24191]: ProgramParameters4fvNV (will be remapped) */ + "iiip\0" + "glProgramParameters4fvNV\0" + "\0" + /* _mesa_function_pool[24222]: DeformationMap3fSGIX (dynamic) */ + "iffiiffiiffiip\0" + "glDeformationMap3fSGIX\0" + "\0" + /* _mesa_function_pool[24261]: GetProgramivNV (will be remapped) */ + "iip\0" + "glGetProgramivNV\0" + "\0" + /* _mesa_function_pool[24283]: GetFragDataLocationEXT (will be remapped) */ + "ip\0" + "glGetFragDataLocationEXT\0" + "glGetFragDataLocation\0" + "\0" + /* _mesa_function_pool[24334]: GetMinmaxParameteriv (offset 366) */ + "iip\0" + "glGetMinmaxParameteriv\0" + "glGetMinmaxParameterivEXT\0" + "\0" + /* _mesa_function_pool[24388]: PixelTransferf (offset 247) */ + "if\0" + "glPixelTransferf\0" + "\0" + /* _mesa_function_pool[24409]: CopyTexImage1D (offset 323) */ + "iiiiiii\0" + "glCopyTexImage1D\0" + "glCopyTexImage1DEXT\0" + "\0" + /* _mesa_function_pool[24455]: PushMatrix (offset 298) */ + "\0" + "glPushMatrix\0" + "\0" + /* _mesa_function_pool[24470]: Fogiv (offset 156) */ + "ip\0" + "glFogiv\0" + "\0" + /* _mesa_function_pool[24482]: TexCoord1dv (offset 95) */ + "p\0" + "glTexCoord1dv\0" + "\0" + /* _mesa_function_pool[24499]: AlphaFragmentOp3ATI (will be remapped) */ + "iiiiiiiiiiii\0" + "glAlphaFragmentOp3ATI\0" + "\0" + /* _mesa_function_pool[24535]: PixelTransferi (offset 248) */ + "ii\0" + "glPixelTransferi\0" + "\0" + /* _mesa_function_pool[24556]: GetVertexAttribdvNV (will be remapped) */ + "iip\0" + "glGetVertexAttribdvNV\0" + "\0" + /* _mesa_function_pool[24583]: VertexAttrib3fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib3fvNV\0" + "\0" + /* _mesa_function_pool[24607]: Rotatef (offset 300) */ + "ffff\0" + "glRotatef\0" + "\0" + /* _mesa_function_pool[24623]: GetFinalCombinerInputParameterivNV (will be remapped) */ + "iip\0" + "glGetFinalCombinerInputParameterivNV\0" + "\0" + /* _mesa_function_pool[24665]: Vertex3i (offset 138) */ + "iii\0" + "glVertex3i\0" + "\0" + /* _mesa_function_pool[24681]: Vertex3f (offset 136) */ + "fff\0" + "glVertex3f\0" + "\0" + /* _mesa_function_pool[24697]: Clear (offset 203) */ + "i\0" + "glClear\0" + "\0" + /* _mesa_function_pool[24708]: Vertex3d (offset 134) */ + "ddd\0" + "glVertex3d\0" + "\0" + /* _mesa_function_pool[24724]: GetMapParameterivNV (dynamic) */ + "iip\0" + "glGetMapParameterivNV\0" + "\0" + /* _mesa_function_pool[24751]: Uniform4iARB (will be remapped) */ + "iiiii\0" + "glUniform4i\0" + "glUniform4iARB\0" + "\0" + /* _mesa_function_pool[24785]: ReadBuffer (offset 254) */ + "i\0" + "glReadBuffer\0" + "\0" + /* _mesa_function_pool[24801]: ConvolutionParameteri (offset 352) */ + "iii\0" + "glConvolutionParameteri\0" + "glConvolutionParameteriEXT\0" + "\0" + /* _mesa_function_pool[24857]: Ortho (offset 296) */ + "dddddd\0" + "glOrtho\0" + "\0" + /* _mesa_function_pool[24873]: Binormal3sEXT (dynamic) */ + "iii\0" + "glBinormal3sEXT\0" + "\0" + /* _mesa_function_pool[24894]: ListBase (offset 6) */ + "i\0" + "glListBase\0" + "\0" + /* _mesa_function_pool[24908]: Vertex3s (offset 140) */ + "iii\0" + "glVertex3s\0" + "\0" + /* _mesa_function_pool[24924]: ConvolutionParameterf (offset 350) */ + "iif\0" + "glConvolutionParameterf\0" + "glConvolutionParameterfEXT\0" + "\0" + /* _mesa_function_pool[24980]: GetColorTableParameteriv (offset 345) */ + "iip\0" + "glGetColorTableParameteriv\0" + "glGetColorTableParameterivSGI\0" + "glGetColorTableParameterivEXT\0" + "\0" + /* _mesa_function_pool[25072]: ProgramEnvParameter4dvARB (will be remapped) */ + "iip\0" + "glProgramEnvParameter4dvARB\0" + "glProgramParameter4dvNV\0" + "\0" + /* _mesa_function_pool[25129]: ShadeModel (offset 177) */ + "i\0" + "glShadeModel\0" + "\0" + /* _mesa_function_pool[25145]: VertexAttribs2fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs2fvNV\0" + "\0" + /* _mesa_function_pool[25171]: Rectiv (offset 91) */ + "pp\0" + "glRectiv\0" + "\0" + /* _mesa_function_pool[25184]: UseProgramObjectARB (will be remapped) */ + "i\0" + "glUseProgram\0" + "glUseProgramObjectARB\0" + "\0" + /* _mesa_function_pool[25222]: GetMapParameterfvNV (dynamic) */ + "iip\0" + "glGetMapParameterfvNV\0" + "\0" + /* _mesa_function_pool[25249]: EndConditionalRenderNV (will be remapped) */ + "\0" + "glEndConditionalRenderNV\0" + "glEndConditionalRender\0" + "\0" + /* _mesa_function_pool[25299]: PassTexCoordATI (will be remapped) */ + "iii\0" + "glPassTexCoordATI\0" + "\0" + /* _mesa_function_pool[25322]: DeleteProgram (will be remapped) */ + "i\0" + "glDeleteProgram\0" + "\0" + /* _mesa_function_pool[25341]: Tangent3ivEXT (dynamic) */ + "p\0" + "glTangent3ivEXT\0" + "\0" + /* _mesa_function_pool[25360]: Tangent3dEXT (dynamic) */ + "ddd\0" + "glTangent3dEXT\0" + "\0" + /* _mesa_function_pool[25380]: SecondaryColor3dvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3dv\0" + "glSecondaryColor3dvEXT\0" + "\0" + /* _mesa_function_pool[25426]: Vertex2fv (offset 129) */ + "p\0" + "glVertex2fv\0" + "\0" + /* _mesa_function_pool[25441]: MultiDrawArraysEXT (will be remapped) */ + "ippi\0" + "glMultiDrawArrays\0" + "glMultiDrawArraysEXT\0" + "\0" + /* _mesa_function_pool[25486]: BindRenderbufferEXT (will be remapped) */ + "ii\0" + "glBindRenderbuffer\0" + "glBindRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[25531]: MultiTexCoord4dARB (offset 400) */ + "idddd\0" + "glMultiTexCoord4d\0" + "glMultiTexCoord4dARB\0" + "\0" + /* _mesa_function_pool[25577]: FramebufferTextureFaceARB (will be remapped) */ + "iiiii\0" + "glFramebufferTextureFaceARB\0" + "\0" + /* _mesa_function_pool[25612]: Vertex3sv (offset 141) */ + "p\0" + "glVertex3sv\0" + "\0" + /* _mesa_function_pool[25627]: SecondaryColor3usEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3us\0" + "glSecondaryColor3usEXT\0" + "\0" + /* _mesa_function_pool[25675]: ProgramLocalParameter4fvARB (will be remapped) */ + "iip\0" + "glProgramLocalParameter4fvARB\0" + "\0" + /* _mesa_function_pool[25710]: DeleteProgramsNV (will be remapped) */ + "ip\0" + "glDeleteProgramsARB\0" + "glDeleteProgramsNV\0" + "\0" + /* _mesa_function_pool[25753]: EvalMesh1 (offset 236) */ + "iii\0" + "glEvalMesh1\0" + "\0" + /* _mesa_function_pool[25770]: PauseTransformFeedback (will be remapped) */ + "\0" + "glPauseTransformFeedback\0" + "\0" + /* _mesa_function_pool[25797]: MultiTexCoord1sARB (offset 382) */ + "ii\0" + "glMultiTexCoord1s\0" + "glMultiTexCoord1sARB\0" + "\0" + /* _mesa_function_pool[25840]: ReplacementCodeuiColor3fVertex3fSUN (dynamic) */ + "iffffff\0" + "glReplacementCodeuiColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[25887]: GetVertexAttribPointervNV (will be remapped) */ + "iip\0" + "glGetVertexAttribPointerv\0" + "glGetVertexAttribPointervARB\0" + "glGetVertexAttribPointervNV\0" + "\0" + /* _mesa_function_pool[25975]: VertexAttribs1fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs1fvNV\0" + "\0" + /* _mesa_function_pool[26001]: MultiTexCoord1dvARB (offset 377) */ + "ip\0" + "glMultiTexCoord1dv\0" + "glMultiTexCoord1dvARB\0" + "\0" + /* _mesa_function_pool[26046]: Uniform2iARB (will be remapped) */ + "iii\0" + "glUniform2i\0" + "glUniform2iARB\0" + "\0" + /* _mesa_function_pool[26078]: Vertex2iv (offset 131) */ + "p\0" + "glVertex2iv\0" + "\0" + /* _mesa_function_pool[26093]: GetProgramStringNV (will be remapped) */ + "iip\0" + "glGetProgramStringNV\0" + "\0" + /* _mesa_function_pool[26119]: ColorPointerEXT (will be remapped) */ + "iiiip\0" + "glColorPointerEXT\0" + "\0" + /* _mesa_function_pool[26144]: LineWidth (offset 168) */ + "f\0" + "glLineWidth\0" + "\0" + /* _mesa_function_pool[26159]: MapBufferARB (will be remapped) */ + "ii\0" + "glMapBuffer\0" + "glMapBufferARB\0" + "\0" + /* _mesa_function_pool[26190]: MultiDrawElementsBaseVertex (will be remapped) */ + "ipipip\0" + "glMultiDrawElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[26228]: TexParameterIuivEXT (will be remapped) */ + "iip\0" + "glTexParameterIuivEXT\0" + "glTexParameterIuiv\0" + "\0" + /* _mesa_function_pool[26274]: Binormal3svEXT (dynamic) */ + "p\0" + "glBinormal3svEXT\0" + "\0" + /* _mesa_function_pool[26294]: ApplyTextureEXT (dynamic) */ + "i\0" + "glApplyTextureEXT\0" + "\0" + /* _mesa_function_pool[26315]: GetBufferParameteri64v (will be remapped) */ + "iip\0" + "glGetBufferParameteri64v\0" + "\0" + /* _mesa_function_pool[26345]: TexGendv (offset 189) */ + "iip\0" + "glTexGendv\0" + "\0" + /* _mesa_function_pool[26361]: VertexAttribI3iEXT (will be remapped) */ + "iiii\0" + "glVertexAttribI3iEXT\0" + "glVertexAttribI3i\0" + "\0" + /* _mesa_function_pool[26406]: EnableIndexedEXT (will be remapped) */ + "ii\0" + "glEnableIndexedEXT\0" + "glEnablei\0" + "\0" + /* _mesa_function_pool[26439]: TextureMaterialEXT (dynamic) */ + "ii\0" + "glTextureMaterialEXT\0" + "\0" + /* _mesa_function_pool[26464]: TextureLightEXT (dynamic) */ + "i\0" + "glTextureLightEXT\0" + "\0" + /* _mesa_function_pool[26485]: ResetMinmax (offset 370) */ + "i\0" + "glResetMinmax\0" + "glResetMinmaxEXT\0" + "\0" + /* _mesa_function_pool[26519]: SpriteParameterfSGIX (dynamic) */ + "if\0" + "glSpriteParameterfSGIX\0" + "\0" + /* _mesa_function_pool[26546]: EnableClientState (offset 313) */ + "i\0" + "glEnableClientState\0" + "\0" + /* _mesa_function_pool[26569]: VertexAttrib4sNV (will be remapped) */ + "iiiii\0" + "glVertexAttrib4sNV\0" + "\0" + /* _mesa_function_pool[26595]: GetConvolutionParameterfv (offset 357) */ + "iip\0" + "glGetConvolutionParameterfv\0" + "glGetConvolutionParameterfvEXT\0" + "\0" + /* _mesa_function_pool[26659]: VertexAttribs4dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4dvNV\0" + "\0" + /* _mesa_function_pool[26685]: VertexAttrib4dARB (will be remapped) */ + "idddd\0" + "glVertexAttrib4d\0" + "glVertexAttrib4dARB\0" + "\0" + /* _mesa_function_pool[26729]: GetTexBumpParameterfvATI (will be remapped) */ + "ip\0" + "glGetTexBumpParameterfvATI\0" + "\0" + /* _mesa_function_pool[26760]: ProgramNamedParameter4dNV (will be remapped) */ + "iipdddd\0" + "glProgramNamedParameter4dNV\0" + "\0" + /* _mesa_function_pool[26797]: GetMaterialfv (offset 269) */ + "iip\0" + "glGetMaterialfv\0" + "\0" + /* _mesa_function_pool[26818]: VertexWeightfEXT (dynamic) */ + "f\0" + "glVertexWeightfEXT\0" + "\0" + /* _mesa_function_pool[26840]: Binormal3fEXT (dynamic) */ + "fff\0" + "glBinormal3fEXT\0" + "\0" + /* _mesa_function_pool[26861]: CallList (offset 2) */ + "i\0" + "glCallList\0" + "\0" + /* _mesa_function_pool[26875]: Materialfv (offset 170) */ + "iip\0" + "glMaterialfv\0" + "\0" + /* _mesa_function_pool[26893]: TexCoord3fv (offset 113) */ + "p\0" + "glTexCoord3fv\0" + "\0" + /* _mesa_function_pool[26910]: FogCoordfvEXT (will be remapped) */ + "p\0" + "glFogCoordfv\0" + "glFogCoordfvEXT\0" + "\0" + /* _mesa_function_pool[26942]: MultiTexCoord1ivARB (offset 381) */ + "ip\0" + "glMultiTexCoord1iv\0" + "glMultiTexCoord1ivARB\0" + "\0" + /* _mesa_function_pool[26987]: SecondaryColor3ubEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3ub\0" + "glSecondaryColor3ubEXT\0" + "\0" + /* _mesa_function_pool[27035]: MultiTexCoord2ivARB (offset 389) */ + "ip\0" + "glMultiTexCoord2iv\0" + "glMultiTexCoord2ivARB\0" + "\0" + /* _mesa_function_pool[27080]: FogFuncSGIS (dynamic) */ + "ip\0" + "glFogFuncSGIS\0" + "\0" + /* _mesa_function_pool[27098]: CopyTexSubImage2D (offset 326) */ + "iiiiiiii\0" + "glCopyTexSubImage2D\0" + "glCopyTexSubImage2DEXT\0" + "\0" + /* _mesa_function_pool[27151]: GetObjectParameterivARB (will be remapped) */ + "iip\0" + "glGetObjectParameterivARB\0" + "\0" + /* _mesa_function_pool[27182]: Color3iv (offset 16) */ + "p\0" + "glColor3iv\0" + "\0" + /* _mesa_function_pool[27196]: TexCoord4fVertex4fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord4fVertex4fSUN\0" + "\0" + /* _mesa_function_pool[27230]: DrawElements (offset 311) */ + "iiip\0" + "glDrawElements\0" + "\0" + /* _mesa_function_pool[27251]: BindVertexArrayAPPLE (will be remapped) */ + "i\0" + "glBindVertexArrayAPPLE\0" + "\0" + /* _mesa_function_pool[27277]: GetProgramLocalParameterdvARB (will be remapped) */ + "iip\0" + "glGetProgramLocalParameterdvARB\0" + "\0" + /* _mesa_function_pool[27314]: GetHistogramParameteriv (offset 363) */ + "iip\0" + "glGetHistogramParameteriv\0" + "glGetHistogramParameterivEXT\0" + "\0" + /* _mesa_function_pool[27374]: MultiTexCoord1iARB (offset 380) */ + "ii\0" + "glMultiTexCoord1i\0" + "glMultiTexCoord1iARB\0" + "\0" + /* _mesa_function_pool[27417]: GetConvolutionFilter (offset 356) */ + "iiip\0" + "glGetConvolutionFilter\0" + "glGetConvolutionFilterEXT\0" + "\0" + /* _mesa_function_pool[27472]: GetProgramivARB (will be remapped) */ + "iip\0" + "glGetProgramivARB\0" + "\0" + /* _mesa_function_pool[27495]: BlendFuncSeparateEXT (will be remapped) */ + "iiii\0" + "glBlendFuncSeparate\0" + "glBlendFuncSeparateEXT\0" + "glBlendFuncSeparateINGR\0" + "\0" + /* _mesa_function_pool[27568]: MapBufferRange (will be remapped) */ + "iiii\0" + "glMapBufferRange\0" + "\0" + /* _mesa_function_pool[27591]: ProgramParameters4dvNV (will be remapped) */ + "iiip\0" + "glProgramParameters4dvNV\0" + "\0" + /* _mesa_function_pool[27622]: TexCoord2fColor3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[27659]: EvalPoint2 (offset 239) */ + "ii\0" + "glEvalPoint2\0" + "\0" + /* _mesa_function_pool[27676]: Uniform1uivEXT (will be remapped) */ + "iip\0" + "glUniform1uivEXT\0" + "glUniform1uiv\0" + "\0" + /* _mesa_function_pool[27712]: EvalPoint1 (offset 237) */ + "i\0" + "glEvalPoint1\0" + "\0" + /* _mesa_function_pool[27728]: Binormal3dvEXT (dynamic) */ + "p\0" + "glBinormal3dvEXT\0" + "\0" + /* _mesa_function_pool[27748]: PopMatrix (offset 297) */ + "\0" + "glPopMatrix\0" + "\0" + /* _mesa_function_pool[27762]: FinishFenceNV (will be remapped) */ + "i\0" + "glFinishFenceNV\0" + "\0" + /* _mesa_function_pool[27781]: GetFogFuncSGIS (dynamic) */ + "p\0" + "glGetFogFuncSGIS\0" + "\0" + /* _mesa_function_pool[27801]: GetUniformLocationARB (will be remapped) */ + "ip\0" + "glGetUniformLocation\0" + "glGetUniformLocationARB\0" + "\0" + /* _mesa_function_pool[27850]: SecondaryColor3fEXT (will be remapped) */ + "fff\0" + "glSecondaryColor3f\0" + "glSecondaryColor3fEXT\0" + "\0" + /* _mesa_function_pool[27896]: GetTexGeniv (offset 280) */ + "iip\0" + "glGetTexGeniv\0" + "\0" + /* _mesa_function_pool[27915]: CombinerInputNV (will be remapped) */ + "iiiiii\0" + "glCombinerInputNV\0" + "\0" + /* _mesa_function_pool[27941]: VertexAttrib3sARB (will be remapped) */ + "iiii\0" + "glVertexAttrib3s\0" + "glVertexAttrib3sARB\0" + "\0" + /* _mesa_function_pool[27984]: IsTransformFeedback (will be remapped) */ + "i\0" + "glIsTransformFeedback\0" + "\0" + /* _mesa_function_pool[28009]: ReplacementCodeuiNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[28054]: Map2d (offset 222) */ + "iddiiddiip\0" + "glMap2d\0" + "\0" + /* _mesa_function_pool[28074]: Map2f (offset 223) */ + "iffiiffiip\0" + "glMap2f\0" + "\0" + /* _mesa_function_pool[28094]: ProgramStringARB (will be remapped) */ + "iiip\0" + "glProgramStringARB\0" + "\0" + /* _mesa_function_pool[28119]: Vertex4s (offset 148) */ + "iiii\0" + "glVertex4s\0" + "\0" + /* _mesa_function_pool[28136]: TexCoord4fVertex4fvSUN (dynamic) */ + "pp\0" + "glTexCoord4fVertex4fvSUN\0" + "\0" + /* _mesa_function_pool[28165]: FragmentLightModelivSGIX (dynamic) */ + "ip\0" + "glFragmentLightModelivSGIX\0" + "\0" + /* _mesa_function_pool[28196]: VertexAttrib1fNV (will be remapped) */ + "if\0" + "glVertexAttrib1fNV\0" + "\0" + /* _mesa_function_pool[28219]: Vertex4f (offset 144) */ + "ffff\0" + "glVertex4f\0" + "\0" + /* _mesa_function_pool[28236]: EvalCoord1d (offset 228) */ + "d\0" + "glEvalCoord1d\0" + "\0" + /* _mesa_function_pool[28253]: Vertex4d (offset 142) */ + "dddd\0" + "glVertex4d\0" + "\0" + /* _mesa_function_pool[28270]: RasterPos4dv (offset 79) */ + "p\0" + "glRasterPos4dv\0" + "\0" + /* _mesa_function_pool[28288]: UseShaderProgramEXT (will be remapped) */ + "ii\0" + "glUseShaderProgramEXT\0" + "\0" + /* _mesa_function_pool[28314]: FragmentLightfSGIX (dynamic) */ + "iif\0" + "glFragmentLightfSGIX\0" + "\0" + /* _mesa_function_pool[28340]: GetCompressedTexImageARB (will be remapped) */ + "iip\0" + "glGetCompressedTexImage\0" + "glGetCompressedTexImageARB\0" + "\0" + /* _mesa_function_pool[28396]: GetTexGenfv (offset 279) */ + "iip\0" + "glGetTexGenfv\0" + "\0" + /* _mesa_function_pool[28415]: Vertex4i (offset 146) */ + "iiii\0" + "glVertex4i\0" + "\0" + /* _mesa_function_pool[28432]: VertexWeightPointerEXT (dynamic) */ + "iiip\0" + "glVertexWeightPointerEXT\0" + "\0" + /* _mesa_function_pool[28463]: GetHistogram (offset 361) */ + "iiiip\0" + "glGetHistogram\0" + "glGetHistogramEXT\0" + "\0" + /* _mesa_function_pool[28503]: ActiveStencilFaceEXT (will be remapped) */ + "i\0" + "glActiveStencilFaceEXT\0" + "\0" + /* _mesa_function_pool[28529]: StencilFuncSeparateATI (will be remapped) */ + "iiii\0" + "glStencilFuncSeparateATI\0" + "\0" + /* _mesa_function_pool[28560]: Materialf (offset 169) */ + "iif\0" + "glMaterialf\0" + "\0" + /* _mesa_function_pool[28577]: GetShaderSourceARB (will be remapped) */ + "iipp\0" + "glGetShaderSource\0" + "glGetShaderSourceARB\0" + "\0" + /* _mesa_function_pool[28622]: IglooInterfaceSGIX (dynamic) */ + "ip\0" + "glIglooInterfaceSGIX\0" + "\0" + /* _mesa_function_pool[28647]: Materiali (offset 171) */ + "iii\0" + "glMateriali\0" + "\0" + /* _mesa_function_pool[28664]: VertexAttrib4dNV (will be remapped) */ + "idddd\0" + "glVertexAttrib4dNV\0" + "\0" + /* _mesa_function_pool[28690]: MultiModeDrawElementsIBM (will be remapped) */ + "ppipii\0" + "glMultiModeDrawElementsIBM\0" + "\0" + /* _mesa_function_pool[28725]: Indexsv (offset 51) */ + "p\0" + "glIndexsv\0" + "\0" + /* _mesa_function_pool[28738]: MultiTexCoord4svARB (offset 407) */ + "ip\0" + "glMultiTexCoord4sv\0" + "glMultiTexCoord4svARB\0" + "\0" + /* _mesa_function_pool[28783]: LightModelfv (offset 164) */ + "ip\0" + "glLightModelfv\0" + "\0" + /* _mesa_function_pool[28802]: TexCoord2dv (offset 103) */ + "p\0" + "glTexCoord2dv\0" + "\0" + /* _mesa_function_pool[28819]: GenQueriesARB (will be remapped) */ + "ip\0" + "glGenQueries\0" + "glGenQueriesARB\0" + "\0" + /* _mesa_function_pool[28852]: EvalCoord1dv (offset 229) */ + "p\0" + "glEvalCoord1dv\0" + "\0" + /* _mesa_function_pool[28870]: ReplacementCodeuiVertex3fSUN (dynamic) */ + "ifff\0" + "glReplacementCodeuiVertex3fSUN\0" + "\0" + /* _mesa_function_pool[28907]: Translated (offset 303) */ + "ddd\0" + "glTranslated\0" + "\0" + /* _mesa_function_pool[28925]: Translatef (offset 304) */ + "fff\0" + "glTranslatef\0" + "\0" + /* _mesa_function_pool[28943]: Uniform3uiEXT (will be remapped) */ + "iiii\0" + "glUniform3uiEXT\0" + "glUniform3ui\0" + "\0" + /* _mesa_function_pool[28978]: StencilMask (offset 209) */ + "i\0" + "glStencilMask\0" + "\0" + /* _mesa_function_pool[28995]: Tangent3iEXT (dynamic) */ + "iii\0" + "glTangent3iEXT\0" + "\0" + /* _mesa_function_pool[29015]: GetLightiv (offset 265) */ + "iip\0" + "glGetLightiv\0" + "\0" + /* _mesa_function_pool[29033]: DrawMeshArraysSUN (dynamic) */ + "iiii\0" + "glDrawMeshArraysSUN\0" + "\0" + /* _mesa_function_pool[29059]: IsList (offset 287) */ + "i\0" + "glIsList\0" + "\0" + /* _mesa_function_pool[29071]: IsSync (will be remapped) */ + "i\0" + "glIsSync\0" + "\0" + /* _mesa_function_pool[29083]: RenderMode (offset 196) */ + "i\0" + "glRenderMode\0" + "\0" + /* _mesa_function_pool[29099]: GetMapControlPointsNV (dynamic) */ + "iiiiiip\0" + "glGetMapControlPointsNV\0" + "\0" + /* _mesa_function_pool[29132]: DrawBuffersARB (will be remapped) */ + "ip\0" + "glDrawBuffers\0" + "glDrawBuffersARB\0" + "glDrawBuffersATI\0" + "\0" + /* _mesa_function_pool[29184]: ClearBufferiv (will be remapped) */ + "iip\0" + "glClearBufferiv\0" + "\0" + /* _mesa_function_pool[29205]: ProgramLocalParameter4fARB (will be remapped) */ + "iiffff\0" + "glProgramLocalParameter4fARB\0" + "\0" + /* _mesa_function_pool[29242]: SpriteParameterivSGIX (dynamic) */ + "ip\0" + "glSpriteParameterivSGIX\0" + "\0" + /* _mesa_function_pool[29270]: ProvokingVertexEXT (will be remapped) */ + "i\0" + "glProvokingVertexEXT\0" + "glProvokingVertex\0" + "\0" + /* _mesa_function_pool[29312]: MultiTexCoord1fARB (offset 378) */ + "if\0" + "glMultiTexCoord1f\0" + "glMultiTexCoord1fARB\0" + "\0" + /* _mesa_function_pool[29355]: LoadName (offset 198) */ + "i\0" + "glLoadName\0" + "\0" + /* _mesa_function_pool[29369]: VertexAttribs4ubvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4ubvNV\0" + "\0" + /* _mesa_function_pool[29396]: WeightsvARB (dynamic) */ + "ip\0" + "glWeightsvARB\0" + "\0" + /* _mesa_function_pool[29414]: Uniform1fvARB (will be remapped) */ + "iip\0" + "glUniform1fv\0" + "glUniform1fvARB\0" + "\0" + /* _mesa_function_pool[29448]: CopyTexSubImage1D (offset 325) */ + "iiiiii\0" + "glCopyTexSubImage1D\0" + "glCopyTexSubImage1DEXT\0" + "\0" + /* _mesa_function_pool[29499]: CullFace (offset 152) */ + "i\0" + "glCullFace\0" + "\0" + /* _mesa_function_pool[29513]: BindTexture (offset 307) */ + "ii\0" + "glBindTexture\0" + "glBindTextureEXT\0" + "\0" + /* _mesa_function_pool[29548]: BeginFragmentShaderATI (will be remapped) */ + "\0" + "glBeginFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[29575]: MultiTexCoord4fARB (offset 402) */ + "iffff\0" + "glMultiTexCoord4f\0" + "glMultiTexCoord4fARB\0" + "\0" + /* _mesa_function_pool[29621]: VertexAttribs3svNV (will be remapped) */ + "iip\0" + "glVertexAttribs3svNV\0" + "\0" + /* _mesa_function_pool[29647]: StencilFunc (offset 243) */ + "iii\0" + "glStencilFunc\0" + "\0" + /* _mesa_function_pool[29666]: CopyPixels (offset 255) */ + "iiiii\0" + "glCopyPixels\0" + "\0" + /* _mesa_function_pool[29686]: Rectsv (offset 93) */ + "pp\0" + "glRectsv\0" + "\0" + /* _mesa_function_pool[29699]: ReplacementCodeuivSUN (dynamic) */ + "p\0" + "glReplacementCodeuivSUN\0" + "\0" + /* _mesa_function_pool[29726]: EnableVertexAttribArrayARB (will be remapped) */ + "i\0" + "glEnableVertexAttribArray\0" + "glEnableVertexAttribArrayARB\0" + "\0" + /* _mesa_function_pool[29784]: NormalPointervINTEL (dynamic) */ + "ip\0" + "glNormalPointervINTEL\0" + "\0" + /* _mesa_function_pool[29810]: CopyConvolutionFilter2D (offset 355) */ + "iiiiii\0" + "glCopyConvolutionFilter2D\0" + "glCopyConvolutionFilter2DEXT\0" + "\0" + /* _mesa_function_pool[29873]: WindowPos3ivMESA (will be remapped) */ + "p\0" + "glWindowPos3iv\0" + "glWindowPos3ivARB\0" + "glWindowPos3ivMESA\0" + "\0" + /* _mesa_function_pool[29928]: CopyBufferSubData (will be remapped) */ + "iiiii\0" + "glCopyBufferSubData\0" + "\0" + /* _mesa_function_pool[29955]: NormalPointer (offset 318) */ + "iip\0" + "glNormalPointer\0" + "\0" + /* _mesa_function_pool[29976]: TexParameterfv (offset 179) */ + "iip\0" + "glTexParameterfv\0" + "\0" + /* _mesa_function_pool[29998]: IsBufferARB (will be remapped) */ + "i\0" + "glIsBuffer\0" + "glIsBufferARB\0" + "\0" + /* _mesa_function_pool[30026]: WindowPos4iMESA (will be remapped) */ + "iiii\0" + "glWindowPos4iMESA\0" + "\0" + /* _mesa_function_pool[30050]: VertexAttrib4uivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4uiv\0" + "glVertexAttrib4uivARB\0" + "\0" + /* _mesa_function_pool[30095]: Tangent3bvEXT (dynamic) */ + "p\0" + "glTangent3bvEXT\0" + "\0" + /* _mesa_function_pool[30114]: VertexAttribI3uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI3uivEXT\0" + "glVertexAttribI3uiv\0" + "\0" + /* _mesa_function_pool[30161]: UniformMatrix3x4fv (will be remapped) */ + "iiip\0" + "glUniformMatrix3x4fv\0" + "\0" + /* _mesa_function_pool[30188]: ClipPlane (offset 150) */ + "ip\0" + "glClipPlane\0" + "\0" + /* _mesa_function_pool[30204]: Recti (offset 90) */ + "iiii\0" + "glRecti\0" + "\0" + /* _mesa_function_pool[30218]: VertexAttribI3ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI3ivEXT\0" + "glVertexAttribI3iv\0" + "\0" + /* _mesa_function_pool[30263]: DrawRangeElementsBaseVertex (will be remapped) */ + "iiiiipi\0" + "glDrawRangeElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[30302]: TexCoordPointervINTEL (dynamic) */ + "iip\0" + "glTexCoordPointervINTEL\0" + "\0" + /* _mesa_function_pool[30331]: DeleteBuffersARB (will be remapped) */ + "ip\0" + "glDeleteBuffers\0" + "glDeleteBuffersARB\0" + "\0" + /* _mesa_function_pool[30370]: PixelTransformParameterfvEXT (dynamic) */ + "iip\0" + "glPixelTransformParameterfvEXT\0" + "\0" + /* _mesa_function_pool[30406]: PrimitiveRestartNV (will be remapped) */ + "\0" + "glPrimitiveRestartNV\0" + "\0" + /* _mesa_function_pool[30429]: WindowPos4fvMESA (will be remapped) */ + "p\0" + "glWindowPos4fvMESA\0" + "\0" + /* _mesa_function_pool[30451]: GetPixelMapuiv (offset 272) */ + "ip\0" + "glGetPixelMapuiv\0" + "\0" + /* _mesa_function_pool[30472]: Rectf (offset 88) */ + "ffff\0" + "glRectf\0" + "\0" + /* _mesa_function_pool[30486]: VertexAttrib1sNV (will be remapped) */ + "ii\0" + "glVertexAttrib1sNV\0" + "\0" + /* _mesa_function_pool[30509]: Indexfv (offset 47) */ + "p\0" + "glIndexfv\0" + "\0" + /* _mesa_function_pool[30522]: SecondaryColor3svEXT (will be remapped) */ + "p\0" + "glSecondaryColor3sv\0" + "glSecondaryColor3svEXT\0" + "\0" + /* _mesa_function_pool[30568]: LoadTransposeMatrixfARB (will be remapped) */ + "p\0" + "glLoadTransposeMatrixf\0" + "glLoadTransposeMatrixfARB\0" + "\0" + /* _mesa_function_pool[30620]: GetPointerv (offset 329) */ + "ip\0" + "glGetPointerv\0" + "glGetPointervEXT\0" + "\0" + /* _mesa_function_pool[30655]: Tangent3bEXT (dynamic) */ + "iii\0" + "glTangent3bEXT\0" + "\0" + /* _mesa_function_pool[30675]: CombinerParameterfNV (will be remapped) */ + "if\0" + "glCombinerParameterfNV\0" + "\0" + /* _mesa_function_pool[30702]: IndexMask (offset 212) */ + "i\0" + "glIndexMask\0" + "\0" + /* _mesa_function_pool[30717]: BindProgramNV (will be remapped) */ + "ii\0" + "glBindProgramARB\0" + "glBindProgramNV\0" + "\0" + /* _mesa_function_pool[30754]: VertexAttrib4svARB (will be remapped) */ + "ip\0" + "glVertexAttrib4sv\0" + "glVertexAttrib4svARB\0" + "\0" + /* _mesa_function_pool[30797]: GetFloatv (offset 262) */ + "ip\0" + "glGetFloatv\0" + "\0" + /* _mesa_function_pool[30813]: CreateDebugObjectMESA (dynamic) */ + "\0" + "glCreateDebugObjectMESA\0" + "\0" + /* _mesa_function_pool[30839]: GetShaderiv (will be remapped) */ + "iip\0" + "glGetShaderiv\0" + "\0" + /* _mesa_function_pool[30858]: ClientWaitSync (will be remapped) */ + "iii\0" + "glClientWaitSync\0" + "\0" + /* _mesa_function_pool[30880]: TexCoord4s (offset 124) */ + "iiii\0" + "glTexCoord4s\0" + "\0" + /* _mesa_function_pool[30899]: TexCoord3sv (offset 117) */ + "p\0" + "glTexCoord3sv\0" + "\0" + /* _mesa_function_pool[30916]: BindFragmentShaderATI (will be remapped) */ + "i\0" + "glBindFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[30943]: PopAttrib (offset 218) */ + "\0" + "glPopAttrib\0" + "\0" + /* _mesa_function_pool[30957]: Fogfv (offset 154) */ + "ip\0" + "glFogfv\0" + "\0" + /* _mesa_function_pool[30969]: UnmapBufferARB (will be remapped) */ + "i\0" + "glUnmapBuffer\0" + "glUnmapBufferARB\0" + "\0" + /* _mesa_function_pool[31003]: InitNames (offset 197) */ + "\0" + "glInitNames\0" + "\0" + /* _mesa_function_pool[31017]: Normal3sv (offset 61) */ + "p\0" + "glNormal3sv\0" + "\0" + /* _mesa_function_pool[31032]: Minmax (offset 368) */ + "iii\0" + "glMinmax\0" + "glMinmaxEXT\0" + "\0" + /* _mesa_function_pool[31058]: TexCoord4d (offset 118) */ + "dddd\0" + "glTexCoord4d\0" + "\0" + /* _mesa_function_pool[31077]: DeformationMap3dSGIX (dynamic) */ + "iddiiddiiddiip\0" + "glDeformationMap3dSGIX\0" + "\0" + /* _mesa_function_pool[31116]: TexCoord4f (offset 120) */ + "ffff\0" + "glTexCoord4f\0" + "\0" + /* _mesa_function_pool[31135]: FogCoorddvEXT (will be remapped) */ + "p\0" + "glFogCoorddv\0" + "glFogCoorddvEXT\0" + "\0" + /* _mesa_function_pool[31167]: FinishTextureSUNX (dynamic) */ + "\0" + "glFinishTextureSUNX\0" + "\0" + /* _mesa_function_pool[31189]: GetFragmentLightfvSGIX (dynamic) */ + "iip\0" + "glGetFragmentLightfvSGIX\0" + "\0" + /* _mesa_function_pool[31219]: Binormal3fvEXT (dynamic) */ + "p\0" + "glBinormal3fvEXT\0" + "\0" + /* _mesa_function_pool[31239]: GetBooleanv (offset 258) */ + "ip\0" + "glGetBooleanv\0" + "\0" + /* _mesa_function_pool[31257]: ColorFragmentOp3ATI (will be remapped) */ + "iiiiiiiiiiiii\0" + "glColorFragmentOp3ATI\0" + "\0" + /* _mesa_function_pool[31294]: Hint (offset 158) */ + "ii\0" + "glHint\0" + "\0" + /* _mesa_function_pool[31305]: Color4dv (offset 28) */ + "p\0" + "glColor4dv\0" + "\0" + /* _mesa_function_pool[31319]: VertexAttrib2svARB (will be remapped) */ + "ip\0" + "glVertexAttrib2sv\0" + "glVertexAttrib2svARB\0" + "\0" + /* _mesa_function_pool[31362]: AreProgramsResidentNV (will be remapped) */ + "ipp\0" + "glAreProgramsResidentNV\0" + "\0" + /* _mesa_function_pool[31391]: WindowPos3svMESA (will be remapped) */ + "p\0" + "glWindowPos3sv\0" + "glWindowPos3svARB\0" + "glWindowPos3svMESA\0" + "\0" + /* _mesa_function_pool[31446]: CopyColorSubTable (offset 347) */ + "iiiii\0" + "glCopyColorSubTable\0" + "glCopyColorSubTableEXT\0" + "\0" + /* _mesa_function_pool[31496]: WeightdvARB (dynamic) */ + "ip\0" + "glWeightdvARB\0" + "\0" + /* _mesa_function_pool[31514]: DeleteRenderbuffersEXT (will be remapped) */ + "ip\0" + "glDeleteRenderbuffers\0" + "glDeleteRenderbuffersEXT\0" + "\0" + /* _mesa_function_pool[31565]: VertexAttrib4NubvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nubv\0" + "glVertexAttrib4NubvARB\0" + "\0" + /* _mesa_function_pool[31612]: VertexAttrib3dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib3dvNV\0" + "\0" + /* _mesa_function_pool[31636]: GetObjectParameterfvARB (will be remapped) */ + "iip\0" + "glGetObjectParameterfvARB\0" + "\0" + /* _mesa_function_pool[31667]: Vertex4iv (offset 147) */ + "p\0" + "glVertex4iv\0" + "\0" + /* _mesa_function_pool[31682]: GetProgramEnvParameterdvARB (will be remapped) */ + "iip\0" + "glGetProgramEnvParameterdvARB\0" + "\0" + /* _mesa_function_pool[31717]: TexCoord4dv (offset 119) */ + "p\0" + "glTexCoord4dv\0" + "\0" + /* _mesa_function_pool[31734]: LockArraysEXT (will be remapped) */ + "ii\0" + "glLockArraysEXT\0" + "\0" + /* _mesa_function_pool[31754]: Begin (offset 7) */ + "i\0" + "glBegin\0" + "\0" + /* _mesa_function_pool[31765]: LightModeli (offset 165) */ + "ii\0" + "glLightModeli\0" + "\0" + /* _mesa_function_pool[31783]: VertexAttribI4ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4ivEXT\0" + "glVertexAttribI4iv\0" + "\0" + /* _mesa_function_pool[31828]: Rectfv (offset 89) */ + "pp\0" + "glRectfv\0" + "\0" + /* _mesa_function_pool[31841]: LightModelf (offset 163) */ + "if\0" + "glLightModelf\0" + "\0" + /* _mesa_function_pool[31859]: GetTexParameterfv (offset 282) */ + "iip\0" + "glGetTexParameterfv\0" + "\0" + /* _mesa_function_pool[31884]: GetLightfv (offset 264) */ + "iip\0" + "glGetLightfv\0" + "\0" + /* _mesa_function_pool[31902]: PixelTransformParameterivEXT (dynamic) */ + "iip\0" + "glPixelTransformParameterivEXT\0" + "\0" + /* _mesa_function_pool[31938]: BinormalPointerEXT (dynamic) */ + "iip\0" + "glBinormalPointerEXT\0" + "\0" + /* _mesa_function_pool[31964]: VertexAttrib1dNV (will be remapped) */ + "id\0" + "glVertexAttrib1dNV\0" + "\0" + /* _mesa_function_pool[31987]: GetCombinerInputParameterivNV (will be remapped) */ + "iiiip\0" + "glGetCombinerInputParameterivNV\0" + "\0" + /* _mesa_function_pool[32026]: Disable (offset 214) */ + "i\0" + "glDisable\0" + "\0" + /* _mesa_function_pool[32039]: MultiTexCoord2fvARB (offset 387) */ + "ip\0" + "glMultiTexCoord2fv\0" + "glMultiTexCoord2fvARB\0" + "\0" + /* _mesa_function_pool[32084]: GetRenderbufferParameterivEXT (will be remapped) */ + "iip\0" + "glGetRenderbufferParameteriv\0" + "glGetRenderbufferParameterivEXT\0" + "\0" + /* _mesa_function_pool[32150]: CombinerParameterivNV (will be remapped) */ + "ip\0" + "glCombinerParameterivNV\0" + "\0" + /* _mesa_function_pool[32178]: GenFragmentShadersATI (will be remapped) */ + "i\0" + "glGenFragmentShadersATI\0" + "\0" + /* _mesa_function_pool[32205]: DrawArrays (offset 310) */ + "iii\0" + "glDrawArrays\0" + "glDrawArraysEXT\0" + "\0" + /* _mesa_function_pool[32239]: WeightuivARB (dynamic) */ + "ip\0" + "glWeightuivARB\0" + "\0" + /* _mesa_function_pool[32258]: VertexAttrib2sARB (will be remapped) */ + "iii\0" + "glVertexAttrib2s\0" + "glVertexAttrib2sARB\0" + "\0" + /* _mesa_function_pool[32300]: ColorMask (offset 210) */ + "iiii\0" + "glColorMask\0" + "\0" + /* _mesa_function_pool[32318]: GenAsyncMarkersSGIX (dynamic) */ + "i\0" + "glGenAsyncMarkersSGIX\0" + "\0" + /* _mesa_function_pool[32343]: Tangent3svEXT (dynamic) */ + "p\0" + "glTangent3svEXT\0" + "\0" + /* _mesa_function_pool[32362]: GetListParameterivSGIX (dynamic) */ + "iip\0" + "glGetListParameterivSGIX\0" + "\0" + /* _mesa_function_pool[32392]: BindBufferARB (will be remapped) */ + "ii\0" + "glBindBuffer\0" + "glBindBufferARB\0" + "\0" + /* _mesa_function_pool[32425]: GetInfoLogARB (will be remapped) */ + "iipp\0" + "glGetInfoLogARB\0" + "\0" + /* _mesa_function_pool[32447]: RasterPos4iv (offset 83) */ + "p\0" + "glRasterPos4iv\0" + "\0" + /* _mesa_function_pool[32465]: Enable (offset 215) */ + "i\0" + "glEnable\0" + "\0" + /* _mesa_function_pool[32477]: LineStipple (offset 167) */ + "ii\0" + "glLineStipple\0" + "\0" + /* _mesa_function_pool[32495]: VertexAttribs4svNV (will be remapped) */ + "iip\0" + "glVertexAttribs4svNV\0" + "\0" + /* _mesa_function_pool[32521]: EdgeFlagPointerListIBM (dynamic) */ + "ipi\0" + "glEdgeFlagPointerListIBM\0" + "\0" + /* _mesa_function_pool[32551]: UniformMatrix3x2fv (will be remapped) */ + "iiip\0" + "glUniformMatrix3x2fv\0" + "\0" + /* _mesa_function_pool[32578]: GetMinmaxParameterfv (offset 365) */ + "iip\0" + "glGetMinmaxParameterfv\0" + "glGetMinmaxParameterfvEXT\0" + "\0" + /* _mesa_function_pool[32632]: VertexAttrib1fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib1fv\0" + "glVertexAttrib1fvARB\0" + "\0" + /* _mesa_function_pool[32675]: GenBuffersARB (will be remapped) */ + "ip\0" + "glGenBuffers\0" + "glGenBuffersARB\0" + "\0" + /* _mesa_function_pool[32708]: VertexAttribs1svNV (will be remapped) */ + "iip\0" + "glVertexAttribs1svNV\0" + "\0" + /* _mesa_function_pool[32734]: Vertex3fv (offset 137) */ + "p\0" + "glVertex3fv\0" + "\0" + /* _mesa_function_pool[32749]: GetTexBumpParameterivATI (will be remapped) */ + "ip\0" + "glGetTexBumpParameterivATI\0" + "\0" + /* _mesa_function_pool[32780]: Binormal3bEXT (dynamic) */ + "iii\0" + "glBinormal3bEXT\0" + "\0" + /* _mesa_function_pool[32801]: FragmentMaterialivSGIX (dynamic) */ + "iip\0" + "glFragmentMaterialivSGIX\0" + "\0" + /* _mesa_function_pool[32831]: IsRenderbufferEXT (will be remapped) */ + "i\0" + "glIsRenderbuffer\0" + "glIsRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[32871]: GenProgramsNV (will be remapped) */ + "ip\0" + "glGenProgramsARB\0" + "glGenProgramsNV\0" + "\0" + /* _mesa_function_pool[32908]: VertexAttrib4dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4dvNV\0" + "\0" + /* _mesa_function_pool[32932]: EndFragmentShaderATI (will be remapped) */ + "\0" + "glEndFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[32957]: Binormal3iEXT (dynamic) */ + "iii\0" + "glBinormal3iEXT\0" + "\0" + /* _mesa_function_pool[32978]: WindowPos2fMESA (will be remapped) */ + "ff\0" + "glWindowPos2f\0" + "glWindowPos2fARB\0" + "glWindowPos2fMESA\0" + "\0" + ; + +/* these functions need to be remapped */ +static const struct gl_function_pool_remap MESA_remap_table_functions[] = { + { 1577, AttachShader_remap_index }, + { 9902, CreateProgram_remap_index }, + { 22864, CreateShader_remap_index }, + { 25322, DeleteProgram_remap_index }, + { 18525, DeleteShader_remap_index }, + { 23336, DetachShader_remap_index }, + { 17928, GetAttachedShaders_remap_index }, + { 4869, GetProgramInfoLog_remap_index }, + { 405, GetProgramiv_remap_index }, + { 6542, GetShaderInfoLog_remap_index }, + { 30839, GetShaderiv_remap_index }, + { 13311, IsProgram_remap_index }, + { 12263, IsShader_remap_index }, + { 10006, StencilFuncSeparate_remap_index }, + { 3921, StencilMaskSeparate_remap_index }, + { 7624, StencilOpSeparate_remap_index }, + { 22152, UniformMatrix2x3fv_remap_index }, + { 2847, UniformMatrix2x4fv_remap_index }, + { 32551, UniformMatrix3x2fv_remap_index }, + { 30161, UniformMatrix3x4fv_remap_index }, + { 16226, UniformMatrix4x2fv_remap_index }, + { 3263, UniformMatrix4x3fv_remap_index }, + { 5030, ClampColor_remap_index }, + { 17982, ClearBufferfi_remap_index }, + { 17448, ClearBufferfv_remap_index }, + { 29184, ClearBufferiv_remap_index }, + { 13516, ClearBufferuiv_remap_index }, + { 19808, GetStringi_remap_index }, + { 2788, TexBuffer_remap_index }, + { 938, FramebufferTexture_remap_index }, + { 26315, GetBufferParameteri64v_remap_index }, + { 10106, GetInteger64i_v_remap_index }, + { 23178, VertexAttribDivisor_remap_index }, + { 9920, LoadTransposeMatrixdARB_remap_index }, + { 30568, LoadTransposeMatrixfARB_remap_index }, + { 5608, MultTransposeMatrixdARB_remap_index }, + { 23523, MultTransposeMatrixfARB_remap_index }, + { 216, SampleCoverageARB_remap_index }, + { 5834, CompressedTexImage1DARB_remap_index }, + { 24051, CompressedTexImage2DARB_remap_index }, + { 3984, CompressedTexImage3DARB_remap_index }, + { 18242, CompressedTexSubImage1DARB_remap_index }, + { 2050, CompressedTexSubImage2DARB_remap_index }, + { 20230, CompressedTexSubImage3DARB_remap_index }, + { 28340, GetCompressedTexImageARB_remap_index }, + { 3829, DisableVertexAttribArrayARB_remap_index }, + { 29726, EnableVertexAttribArrayARB_remap_index }, + { 31682, GetProgramEnvParameterdvARB_remap_index }, + { 23403, GetProgramEnvParameterfvARB_remap_index }, + { 27277, GetProgramLocalParameterdvARB_remap_index }, + { 8066, GetProgramLocalParameterfvARB_remap_index }, + { 18376, GetProgramStringARB_remap_index }, + { 27472, GetProgramivARB_remap_index }, + { 20425, GetVertexAttribdvARB_remap_index }, + { 16034, GetVertexAttribfvARB_remap_index }, + { 9765, GetVertexAttribivARB_remap_index }, + { 19289, ProgramEnvParameter4dARB_remap_index }, + { 25072, ProgramEnvParameter4dvARB_remap_index }, + { 16770, ProgramEnvParameter4fARB_remap_index }, + { 8965, ProgramEnvParameter4fvARB_remap_index }, + { 3947, ProgramLocalParameter4dARB_remap_index }, + { 13021, ProgramLocalParameter4dvARB_remap_index }, + { 29205, ProgramLocalParameter4fARB_remap_index }, + { 25675, ProgramLocalParameter4fvARB_remap_index }, + { 28094, ProgramStringARB_remap_index }, + { 19539, VertexAttrib1dARB_remap_index }, + { 15688, VertexAttrib1dvARB_remap_index }, + { 4122, VertexAttrib1fARB_remap_index }, + { 32632, VertexAttrib1fvARB_remap_index }, + { 7150, VertexAttrib1sARB_remap_index }, + { 2224, VertexAttrib1svARB_remap_index }, + { 15119, VertexAttrib2dARB_remap_index }, + { 17469, VertexAttrib2dvARB_remap_index }, + { 1596, VertexAttrib2fARB_remap_index }, + { 17582, VertexAttrib2fvARB_remap_index }, + { 32258, VertexAttrib2sARB_remap_index }, + { 31319, VertexAttrib2svARB_remap_index }, + { 11268, VertexAttrib3dARB_remap_index }, + { 8632, VertexAttrib3dvARB_remap_index }, + { 1683, VertexAttrib3fARB_remap_index }, + { 22415, VertexAttrib3fvARB_remap_index }, + { 27941, VertexAttrib3sARB_remap_index }, + { 20167, VertexAttrib3svARB_remap_index }, + { 4895, VertexAttrib4NbvARB_remap_index }, + { 17805, VertexAttrib4NivARB_remap_index }, + { 22370, VertexAttrib4NsvARB_remap_index }, + { 23355, VertexAttrib4NubARB_remap_index }, + { 31565, VertexAttrib4NubvARB_remap_index }, + { 18950, VertexAttrib4NuivARB_remap_index }, + { 3136, VertexAttrib4NusvARB_remap_index }, + { 10846, VertexAttrib4bvARB_remap_index }, + { 26685, VertexAttrib4dARB_remap_index }, + { 21189, VertexAttrib4dvARB_remap_index }, + { 11422, VertexAttrib4fARB_remap_index }, + { 11826, VertexAttrib4fvARB_remap_index }, + { 10222, VertexAttrib4ivARB_remap_index }, + { 17262, VertexAttrib4sARB_remap_index }, + { 30754, VertexAttrib4svARB_remap_index }, + { 16575, VertexAttrib4ubvARB_remap_index }, + { 30050, VertexAttrib4uivARB_remap_index }, + { 19978, VertexAttrib4usvARB_remap_index }, + { 21967, VertexAttribPointerARB_remap_index }, + { 32392, BindBufferARB_remap_index }, + { 6857, BufferDataARB_remap_index }, + { 1498, BufferSubDataARB_remap_index }, + { 30331, DeleteBuffersARB_remap_index }, + { 32675, GenBuffersARB_remap_index }, + { 17625, GetBufferParameterivARB_remap_index }, + { 16722, GetBufferPointervARB_remap_index }, + { 1451, GetBufferSubDataARB_remap_index }, + { 29998, IsBufferARB_remap_index }, + { 26159, MapBufferARB_remap_index }, + { 30969, UnmapBufferARB_remap_index }, + { 312, BeginQueryARB_remap_index }, + { 19634, DeleteQueriesARB_remap_index }, + { 12153, EndQueryARB_remap_index }, + { 28819, GenQueriesARB_remap_index }, + { 1942, GetQueryObjectivARB_remap_index }, + { 17306, GetQueryObjectuivARB_remap_index }, + { 1740, GetQueryivARB_remap_index }, + { 19885, IsQueryARB_remap_index }, + { 8242, AttachObjectARB_remap_index }, + { 18487, CompileShaderARB_remap_index }, + { 3205, CreateProgramObjectARB_remap_index }, + { 6802, CreateShaderObjectARB_remap_index }, + { 14454, DeleteObjectARB_remap_index }, + { 23842, DetachObjectARB_remap_index }, + { 11898, GetActiveUniformARB_remap_index }, + { 9440, GetAttachedObjectsARB_remap_index }, + { 9747, GetHandleARB_remap_index }, + { 32425, GetInfoLogARB_remap_index }, + { 31636, GetObjectParameterfvARB_remap_index }, + { 27151, GetObjectParameterivARB_remap_index }, + { 28577, GetShaderSourceARB_remap_index }, + { 27801, GetUniformLocationARB_remap_index }, + { 23625, GetUniformfvARB_remap_index }, + { 12596, GetUniformivARB_remap_index }, + { 20023, LinkProgramARB_remap_index }, + { 20081, ShaderSourceARB_remap_index }, + { 7524, Uniform1fARB_remap_index }, + { 29414, Uniform1fvARB_remap_index }, + { 21936, Uniform1iARB_remap_index }, + { 20878, Uniform1ivARB_remap_index }, + { 2173, Uniform2fARB_remap_index }, + { 14290, Uniform2fvARB_remap_index }, + { 26046, Uniform2iARB_remap_index }, + { 2293, Uniform2ivARB_remap_index }, + { 18597, Uniform3fARB_remap_index }, + { 9470, Uniform3fvARB_remap_index }, + { 6396, Uniform3iARB_remap_index }, + { 16828, Uniform3ivARB_remap_index }, + { 19095, Uniform4fARB_remap_index }, + { 23489, Uniform4fvARB_remap_index }, + { 24751, Uniform4iARB_remap_index }, + { 20391, Uniform4ivARB_remap_index }, + { 8294, UniformMatrix2fvARB_remap_index }, + { 17, UniformMatrix3fvARB_remap_index }, + { 2690, UniformMatrix4fvARB_remap_index }, + { 25184, UseProgramObjectARB_remap_index }, + { 14807, ValidateProgramARB_remap_index }, + { 21232, BindAttribLocationARB_remap_index }, + { 4940, GetActiveAttribARB_remap_index }, + { 16509, GetAttribLocationARB_remap_index }, + { 29132, DrawBuffersARB_remap_index }, + { 17850, DrawArraysInstancedARB_remap_index }, + { 6457, DrawElementsInstancedARB_remap_index }, + { 13126, RenderbufferStorageMultisample_remap_index }, + { 13597, FramebufferTextureARB_remap_index }, + { 25577, FramebufferTextureFaceARB_remap_index }, + { 23991, ProgramParameteriARB_remap_index }, + { 19143, FlushMappedBufferRange_remap_index }, + { 27568, MapBufferRange_remap_index }, + { 16337, BindVertexArray_remap_index }, + { 14630, GenVertexArrays_remap_index }, + { 29928, CopyBufferSubData_remap_index }, + { 30858, ClientWaitSync_remap_index }, + { 2609, DeleteSync_remap_index }, + { 7191, FenceSync_remap_index }, + { 15178, GetInteger64v_remap_index }, + { 22477, GetSynciv_remap_index }, + { 29071, IsSync_remap_index }, + { 9388, WaitSync_remap_index }, + { 3797, DrawElementsBaseVertex_remap_index }, + { 30263, DrawRangeElementsBaseVertex_remap_index }, + { 26190, MultiDrawElementsBaseVertex_remap_index }, + { 5091, BindTransformFeedback_remap_index }, + { 3232, DeleteTransformFeedbacks_remap_index }, + { 6429, DrawTransformFeedback_remap_index }, + { 9607, GenTransformFeedbacks_remap_index }, + { 27984, IsTransformFeedback_remap_index }, + { 25770, PauseTransformFeedback_remap_index }, + { 5528, ResumeTransformFeedback_remap_index }, + { 5396, PolygonOffsetEXT_remap_index }, + { 23099, GetPixelTexGenParameterfvSGIS_remap_index }, + { 4417, GetPixelTexGenParameterivSGIS_remap_index }, + { 22832, PixelTexGenParameterfSGIS_remap_index }, + { 624, PixelTexGenParameterfvSGIS_remap_index }, + { 12634, PixelTexGenParameteriSGIS_remap_index }, + { 13771, PixelTexGenParameterivSGIS_remap_index }, + { 16425, SampleMaskSGIS_remap_index }, + { 19825, SamplePatternSGIS_remap_index }, + { 26119, ColorPointerEXT_remap_index }, + { 17512, EdgeFlagPointerEXT_remap_index }, + { 6050, IndexPointerEXT_remap_index }, + { 6130, NormalPointerEXT_remap_index }, + { 15772, TexCoordPointerEXT_remap_index }, + { 6980, VertexPointerEXT_remap_index }, + { 3599, PointParameterfEXT_remap_index }, + { 7831, PointParameterfvEXT_remap_index }, + { 31734, LockArraysEXT_remap_index }, + { 14871, UnlockArraysEXT_remap_index }, + { 1267, SecondaryColor3bEXT_remap_index }, + { 7990, SecondaryColor3bvEXT_remap_index }, + { 10399, SecondaryColor3dEXT_remap_index }, + { 25380, SecondaryColor3dvEXT_remap_index }, + { 27850, SecondaryColor3fEXT_remap_index }, + { 18178, SecondaryColor3fvEXT_remap_index }, + { 470, SecondaryColor3iEXT_remap_index }, + { 16082, SecondaryColor3ivEXT_remap_index }, + { 10034, SecondaryColor3sEXT_remap_index }, + { 30522, SecondaryColor3svEXT_remap_index }, + { 26987, SecondaryColor3ubEXT_remap_index }, + { 21123, SecondaryColor3ubvEXT_remap_index }, + { 12876, SecondaryColor3uiEXT_remap_index }, + { 22719, SecondaryColor3uivEXT_remap_index }, + { 25627, SecondaryColor3usEXT_remap_index }, + { 12949, SecondaryColor3usvEXT_remap_index }, + { 11769, SecondaryColorPointerEXT_remap_index }, + { 25441, MultiDrawArraysEXT_remap_index }, + { 20813, MultiDrawElementsEXT_remap_index }, + { 21008, FogCoordPointerEXT_remap_index }, + { 4566, FogCoorddEXT_remap_index }, + { 31135, FogCoorddvEXT_remap_index }, + { 4683, FogCoordfEXT_remap_index }, + { 26910, FogCoordfvEXT_remap_index }, + { 19047, PixelTexGenSGIX_remap_index }, + { 27495, BlendFuncSeparateEXT_remap_index }, + { 6892, FlushVertexArrayRangeNV_remap_index }, + { 5345, VertexArrayRangeNV_remap_index }, + { 27915, CombinerInputNV_remap_index }, + { 2116, CombinerOutputNV_remap_index }, + { 30675, CombinerParameterfNV_remap_index }, + { 5219, CombinerParameterfvNV_remap_index }, + { 22201, CombinerParameteriNV_remap_index }, + { 32150, CombinerParameterivNV_remap_index }, + { 7268, FinalCombinerInputNV_remap_index }, + { 9813, GetCombinerInputParameterfvNV_remap_index }, + { 31987, GetCombinerInputParameterivNV_remap_index }, + { 13872, GetCombinerOutputParameterfvNV_remap_index }, + { 13700, GetCombinerOutputParameterivNV_remap_index }, + { 6637, GetFinalCombinerInputParameterfvNV_remap_index }, + { 24623, GetFinalCombinerInputParameterivNV_remap_index }, + { 12574, ResizeBuffersMESA_remap_index }, + { 11095, WindowPos2dMESA_remap_index }, + { 1060, WindowPos2dvMESA_remap_index }, + { 32978, WindowPos2fMESA_remap_index }, + { 7935, WindowPos2fvMESA_remap_index }, + { 18125, WindowPos2iMESA_remap_index }, + { 20298, WindowPos2ivMESA_remap_index }, + { 20912, WindowPos2sMESA_remap_index }, + { 5748, WindowPos2svMESA_remap_index }, + { 7760, WindowPos3dMESA_remap_index }, + { 14018, WindowPos3dvMESA_remap_index }, + { 516, WindowPos3fMESA_remap_index }, + { 14932, WindowPos3fvMESA_remap_index }, + { 23884, WindowPos3iMESA_remap_index }, + { 29873, WindowPos3ivMESA_remap_index }, + { 18742, WindowPos3sMESA_remap_index }, + { 31391, WindowPos3svMESA_remap_index }, + { 11046, WindowPos4dMESA_remap_index }, + { 16966, WindowPos4dvMESA_remap_index }, + { 13977, WindowPos4fMESA_remap_index }, + { 30429, WindowPos4fvMESA_remap_index }, + { 30026, WindowPos4iMESA_remap_index }, + { 12377, WindowPos4ivMESA_remap_index }, + { 18926, WindowPos4sMESA_remap_index }, + { 3183, WindowPos4svMESA_remap_index }, + { 13739, MultiModeDrawArraysIBM_remap_index }, + { 28690, MultiModeDrawElementsIBM_remap_index }, + { 12181, DeleteFencesNV_remap_index }, + { 27762, FinishFenceNV_remap_index }, + { 3721, GenFencesNV_remap_index }, + { 16946, GetFenceivNV_remap_index }, + { 8227, IsFenceNV_remap_index }, + { 13627, SetFenceNV_remap_index }, + { 4178, TestFenceNV_remap_index }, + { 31362, AreProgramsResidentNV_remap_index }, + { 30717, BindProgramNV_remap_index }, + { 25710, DeleteProgramsNV_remap_index }, + { 21341, ExecuteProgramNV_remap_index }, + { 32871, GenProgramsNV_remap_index }, + { 23204, GetProgramParameterdvNV_remap_index }, + { 10461, GetProgramParameterfvNV_remap_index }, + { 26093, GetProgramStringNV_remap_index }, + { 24261, GetProgramivNV_remap_index }, + { 23438, GetTrackMatrixivNV_remap_index }, + { 25887, GetVertexAttribPointervNV_remap_index }, + { 24556, GetVertexAttribdvNV_remap_index }, + { 9283, GetVertexAttribfvNV_remap_index }, + { 18349, GetVertexAttribivNV_remap_index }, + { 19173, IsProgramNV_remap_index }, + { 9366, LoadProgramNV_remap_index }, + { 27591, ProgramParameters4dvNV_remap_index }, + { 24191, ProgramParameters4fvNV_remap_index }, + { 20602, RequestResidentProgramsNV_remap_index }, + { 22179, TrackMatrixNV_remap_index }, + { 31964, VertexAttrib1dNV_remap_index }, + { 13538, VertexAttrib1dvNV_remap_index }, + { 28196, VertexAttrib1fNV_remap_index }, + { 2415, VertexAttrib1fvNV_remap_index }, + { 30486, VertexAttrib1sNV_remap_index }, + { 15005, VertexAttrib1svNV_remap_index }, + { 4845, VertexAttrib2dNV_remap_index }, + { 13431, VertexAttrib2dvNV_remap_index }, + { 20057, VertexAttrib2fNV_remap_index }, + { 12997, VertexAttrib2fvNV_remap_index }, + { 5960, VertexAttrib2sNV_remap_index }, + { 18796, VertexAttrib2svNV_remap_index }, + { 11243, VertexAttrib3dNV_remap_index }, + { 31612, VertexAttrib3dvNV_remap_index }, + { 10273, VertexAttrib3fNV_remap_index }, + { 24583, VertexAttrib3fvNV_remap_index }, + { 22022, VertexAttrib3sNV_remap_index }, + { 23465, VertexAttrib3svNV_remap_index }, + { 28664, VertexAttrib4dNV_remap_index }, + { 32908, VertexAttrib4dvNV_remap_index }, + { 4467, VertexAttrib4fNV_remap_index }, + { 9416, VertexAttrib4fvNV_remap_index }, + { 26569, VertexAttrib4sNV_remap_index }, + { 1409, VertexAttrib4svNV_remap_index }, + { 5003, VertexAttrib4ubNV_remap_index }, + { 778, VertexAttrib4ubvNV_remap_index }, + { 21521, VertexAttribPointerNV_remap_index }, + { 2267, VertexAttribs1dvNV_remap_index }, + { 25975, VertexAttribs1fvNV_remap_index }, + { 32708, VertexAttribs1svNV_remap_index }, + { 10298, VertexAttribs2dvNV_remap_index }, + { 25145, VertexAttribs2fvNV_remap_index }, + { 17538, VertexAttribs2svNV_remap_index }, + { 5247, VertexAttribs3dvNV_remap_index }, + { 2147, VertexAttribs3fvNV_remap_index }, + { 29621, VertexAttribs3svNV_remap_index }, + { 26659, VertexAttribs4dvNV_remap_index }, + { 5319, VertexAttribs4fvNV_remap_index }, + { 32495, VertexAttribs4svNV_remap_index }, + { 29369, VertexAttribs4ubvNV_remap_index }, + { 26729, GetTexBumpParameterfvATI_remap_index }, + { 32749, GetTexBumpParameterivATI_remap_index }, + { 18459, TexBumpParameterfvATI_remap_index }, + { 20473, TexBumpParameterivATI_remap_index }, + { 15551, AlphaFragmentOp1ATI_remap_index }, + { 10889, AlphaFragmentOp2ATI_remap_index }, + { 24499, AlphaFragmentOp3ATI_remap_index }, + { 29548, BeginFragmentShaderATI_remap_index }, + { 30916, BindFragmentShaderATI_remap_index }, + { 23594, ColorFragmentOp1ATI_remap_index }, + { 4345, ColorFragmentOp2ATI_remap_index }, + { 31257, ColorFragmentOp3ATI_remap_index }, + { 5485, DeleteFragmentShaderATI_remap_index }, + { 32932, EndFragmentShaderATI_remap_index }, + { 32178, GenFragmentShadersATI_remap_index }, + { 25299, PassTexCoordATI_remap_index }, + { 6960, SampleMapATI_remap_index }, + { 6733, SetFragmentShaderConstantATI_remap_index }, + { 363, PointParameteriNV_remap_index }, + { 14179, PointParameterivNV_remap_index }, + { 28503, ActiveStencilFaceEXT_remap_index }, + { 27251, BindVertexArrayAPPLE_remap_index }, + { 2737, DeleteVertexArraysAPPLE_remap_index }, + { 17955, GenVertexArraysAPPLE_remap_index }, + { 23269, IsVertexArrayAPPLE_remap_index }, + { 819, GetProgramNamedParameterdvNV_remap_index }, + { 3562, GetProgramNamedParameterfvNV_remap_index }, + { 26760, ProgramNamedParameter4dNV_remap_index }, + { 14505, ProgramNamedParameter4dvNV_remap_index }, + { 8899, ProgramNamedParameter4fNV_remap_index }, + { 11734, ProgramNamedParameter4fvNV_remap_index }, + { 16877, PrimitiveRestartIndexNV_remap_index }, + { 30406, PrimitiveRestartNV_remap_index }, + { 24170, DepthBoundsEXT_remap_index }, + { 1159, BlendEquationSeparateEXT_remap_index }, + { 14706, BindFramebufferEXT_remap_index }, + { 25486, BindRenderbufferEXT_remap_index }, + { 9663, CheckFramebufferStatusEXT_remap_index }, + { 22520, DeleteFramebuffersEXT_remap_index }, + { 31514, DeleteRenderbuffersEXT_remap_index }, + { 13455, FramebufferRenderbufferEXT_remap_index }, + { 13644, FramebufferTexture1DEXT_remap_index }, + { 11528, FramebufferTexture2DEXT_remap_index }, + { 11148, FramebufferTexture3DEXT_remap_index }, + { 23135, GenFramebuffersEXT_remap_index }, + { 17403, GenRenderbuffersEXT_remap_index }, + { 6679, GenerateMipmapEXT_remap_index }, + { 21597, GetFramebufferAttachmentParameterivEXT_remap_index }, + { 32084, GetRenderbufferParameterivEXT_remap_index }, + { 20353, IsFramebufferEXT_remap_index }, + { 32831, IsRenderbufferEXT_remap_index }, + { 8174, RenderbufferStorageEXT_remap_index }, + { 695, BlitFramebufferEXT_remap_index }, + { 14324, BufferParameteriAPPLE_remap_index }, + { 19205, FlushMappedBufferRangeAPPLE_remap_index }, + { 1815, BindFragDataLocationEXT_remap_index }, + { 24283, GetFragDataLocationEXT_remap_index }, + { 10576, GetUniformuivEXT_remap_index }, + { 2933, GetVertexAttribIivEXT_remap_index }, + { 4195, GetVertexAttribIuivEXT_remap_index }, + { 12014, Uniform1uiEXT_remap_index }, + { 27676, Uniform1uivEXT_remap_index }, + { 22118, Uniform2uiEXT_remap_index }, + { 4309, Uniform2uivEXT_remap_index }, + { 28943, Uniform3uiEXT_remap_index }, + { 14652, Uniform3uivEXT_remap_index }, + { 3486, Uniform4uiEXT_remap_index }, + { 8675, Uniform4uivEXT_remap_index }, + { 18306, VertexAttribI1iEXT_remap_index }, + { 965, VertexAttribI1ivEXT_remap_index }, + { 2516, VertexAttribI1uiEXT_remap_index }, + { 12725, VertexAttribI1uivEXT_remap_index }, + { 81, VertexAttribI2iEXT_remap_index }, + { 23706, VertexAttribI2ivEXT_remap_index }, + { 5273, VertexAttribI2uiEXT_remap_index }, + { 4728, VertexAttribI2uivEXT_remap_index }, + { 26361, VertexAttribI3iEXT_remap_index }, + { 30218, VertexAttribI3ivEXT_remap_index }, + { 3340, VertexAttribI3uiEXT_remap_index }, + { 30114, VertexAttribI3uivEXT_remap_index }, + { 21848, VertexAttribI4bvEXT_remap_index }, + { 14584, VertexAttribI4iEXT_remap_index }, + { 31783, VertexAttribI4ivEXT_remap_index }, + { 13358, VertexAttribI4svEXT_remap_index }, + { 16462, VertexAttribI4ubvEXT_remap_index }, + { 16145, VertexAttribI4uiEXT_remap_index }, + { 5419, VertexAttribI4uivEXT_remap_index }, + { 11311, VertexAttribI4usvEXT_remap_index }, + { 18403, VertexAttribIPointerEXT_remap_index }, + { 3027, FramebufferTextureLayerEXT_remap_index }, + { 5660, ColorMaskIndexedEXT_remap_index }, + { 18820, DisableIndexedEXT_remap_index }, + { 26406, EnableIndexedEXT_remap_index }, + { 21552, GetBooleanIndexedvEXT_remap_index }, + { 10922, GetIntegerIndexedvEXT_remap_index }, + { 22596, IsEnabledIndexedEXT_remap_index }, + { 22496, ClearColorIiEXT_remap_index }, + { 3436, ClearColorIuiEXT_remap_index }, + { 9852, GetTexParameterIivEXT_remap_index }, + { 5908, GetTexParameterIuivEXT_remap_index }, + { 2983, TexParameterIivEXT_remap_index }, + { 26228, TexParameterIuivEXT_remap_index }, + { 4596, BeginConditionalRenderNV_remap_index }, + { 25249, EndConditionalRenderNV_remap_index }, + { 9310, BeginTransformFeedbackEXT_remap_index }, + { 18855, BindBufferBaseEXT_remap_index }, + { 18714, BindBufferOffsetEXT_remap_index }, + { 12202, BindBufferRangeEXT_remap_index }, + { 14239, EndTransformFeedbackEXT_remap_index }, + { 10774, GetTransformFeedbackVaryingEXT_remap_index }, + { 20658, TransformFeedbackVaryingsEXT_remap_index }, + { 29270, ProvokingVertexEXT_remap_index }, + { 10722, GetTexParameterPointervAPPLE_remap_index }, + { 5047, TextureRangeAPPLE_remap_index }, + { 11600, GetObjectParameterivAPPLE_remap_index }, + { 19780, ObjectPurgeableAPPLE_remap_index }, + { 5702, ObjectUnpurgeableAPPLE_remap_index }, + { 17225, ActiveProgramEXT_remap_index }, + { 17196, CreateShaderProgramEXT_remap_index }, + { 28288, UseShaderProgramEXT_remap_index }, + { 28529, StencilFuncSeparateATI_remap_index }, + { 18044, ProgramEnvParameters4fvEXT_remap_index }, + { 17090, ProgramLocalParameters4fvEXT_remap_index }, + { 14107, GetQueryObjecti64vEXT_remap_index }, + { 10324, GetQueryObjectui64vEXT_remap_index }, + { 23663, EGLImageTargetRenderbufferStorageOES_remap_index }, + { 12120, EGLImageTargetTexture2DOES_remap_index }, + { -1, -1 } +}; + +/* these functions are in the ABI, but have alternative names */ +static const struct gl_function_remap MESA_alt_functions[] = { + /* from GL_EXT_blend_color */ + { 2655, _gloffset_BlendColor }, + /* from GL_EXT_blend_minmax */ + { 11205, _gloffset_BlendEquation }, + /* from GL_EXT_color_subtable */ + { 16988, _gloffset_ColorSubTable }, + { 31446, _gloffset_CopyColorSubTable }, + /* from GL_EXT_convolution */ + { 257, _gloffset_ConvolutionFilter1D }, + { 2454, _gloffset_CopyConvolutionFilter1D }, + { 4058, _gloffset_GetConvolutionParameteriv }, + { 8523, _gloffset_ConvolutionFilter2D }, + { 8725, _gloffset_ConvolutionParameteriv }, + { 9185, _gloffset_ConvolutionParameterfv }, + { 20501, _gloffset_GetSeparableFilter }, + { 23938, _gloffset_SeparableFilter2D }, + { 24801, _gloffset_ConvolutionParameteri }, + { 24924, _gloffset_ConvolutionParameterf }, + { 26595, _gloffset_GetConvolutionParameterfv }, + { 27417, _gloffset_GetConvolutionFilter }, + { 29810, _gloffset_CopyConvolutionFilter2D }, + /* from GL_EXT_copy_texture */ + { 15065, _gloffset_CopyTexSubImage3D }, + { 16675, _gloffset_CopyTexImage2D }, + { 24409, _gloffset_CopyTexImage1D }, + { 27098, _gloffset_CopyTexSubImage2D }, + { 29448, _gloffset_CopyTexSubImage1D }, + /* from GL_EXT_draw_range_elements */ + { 9522, _gloffset_DrawRangeElements }, + /* from GL_EXT_histogram */ + { 856, _gloffset_Histogram }, + { 3522, _gloffset_ResetHistogram }, + { 9972, _gloffset_GetMinmax }, + { 15399, _gloffset_GetHistogramParameterfv }, + { 24334, _gloffset_GetMinmaxParameteriv }, + { 26485, _gloffset_ResetMinmax }, + { 27314, _gloffset_GetHistogramParameteriv }, + { 28463, _gloffset_GetHistogram }, + { 31032, _gloffset_Minmax }, + { 32578, _gloffset_GetMinmaxParameterfv }, + /* from GL_EXT_paletted_texture */ + { 8385, _gloffset_ColorTable }, + { 15245, _gloffset_GetColorTable }, + { 22882, _gloffset_GetColorTableParameterfv }, + { 24980, _gloffset_GetColorTableParameteriv }, + /* from GL_EXT_subtexture */ + { 7106, _gloffset_TexSubImage1D }, + { 10649, _gloffset_TexSubImage2D }, + /* from GL_EXT_texture3D */ + { 1774, _gloffset_TexImage3D }, + { 22651, _gloffset_TexSubImage3D }, + /* from GL_EXT_texture_object */ + { 3290, _gloffset_PrioritizeTextures }, + { 7555, _gloffset_AreTexturesResident }, + { 13562, _gloffset_GenTextures }, + { 15731, _gloffset_DeleteTextures }, + { 19486, _gloffset_IsTexture }, + { 29513, _gloffset_BindTexture }, + /* from GL_EXT_vertex_array */ + { 24110, _gloffset_ArrayElement }, + { 30620, _gloffset_GetPointerv }, + { 32205, _gloffset_DrawArrays }, + /* from GL_SGI_color_table */ + { 7673, _gloffset_ColorTableParameteriv }, + { 8385, _gloffset_ColorTable }, + { 15245, _gloffset_GetColorTable }, + { 15355, _gloffset_CopyColorTable }, + { 19347, _gloffset_ColorTableParameterfv }, + { 22882, _gloffset_GetColorTableParameterfv }, + { 24980, _gloffset_GetColorTableParameteriv }, + /* from GL_VERSION_1_3 */ + { 425, _gloffset_MultiTexCoord3sARB }, + { 657, _gloffset_ActiveTextureARB }, + { 4247, _gloffset_MultiTexCoord1fvARB }, + { 6155, _gloffset_MultiTexCoord3dARB }, + { 6200, _gloffset_MultiTexCoord2iARB }, + { 6324, _gloffset_MultiTexCoord2svARB }, + { 8341, _gloffset_MultiTexCoord2fARB }, + { 10354, _gloffset_MultiTexCoord3fvARB }, + { 10967, _gloffset_MultiTexCoord4sARB }, + { 11648, _gloffset_MultiTexCoord2dvARB }, + { 12063, _gloffset_MultiTexCoord1svARB }, + { 12435, _gloffset_MultiTexCoord3svARB }, + { 12496, _gloffset_MultiTexCoord4iARB }, + { 13266, _gloffset_MultiTexCoord3iARB }, + { 14136, _gloffset_MultiTexCoord1dARB }, + { 14353, _gloffset_MultiTexCoord3dvARB }, + { 15599, _gloffset_MultiTexCoord3ivARB }, + { 15644, _gloffset_MultiTexCoord2sARB }, + { 17045, _gloffset_MultiTexCoord4ivARB }, + { 18997, _gloffset_ClientActiveTextureARB }, + { 21297, _gloffset_MultiTexCoord2dARB }, + { 21717, _gloffset_MultiTexCoord4dvARB }, + { 22073, _gloffset_MultiTexCoord4fvARB }, + { 23023, _gloffset_MultiTexCoord3fARB }, + { 25531, _gloffset_MultiTexCoord4dARB }, + { 25797, _gloffset_MultiTexCoord1sARB }, + { 26001, _gloffset_MultiTexCoord1dvARB }, + { 26942, _gloffset_MultiTexCoord1ivARB }, + { 27035, _gloffset_MultiTexCoord2ivARB }, + { 27374, _gloffset_MultiTexCoord1iARB }, + { 28738, _gloffset_MultiTexCoord4svARB }, + { 29312, _gloffset_MultiTexCoord1fARB }, + { 29575, _gloffset_MultiTexCoord4fARB }, + { 32039, _gloffset_MultiTexCoord2fvARB }, + { -1, -1 } +}; + +#endif /* need_MESA_remap_table */ + +#if defined(need_GL_3DFX_tbuffer) +static const struct gl_function_remap GL_3DFX_tbuffer_functions[] = { + { 9243, -1 }, /* TbufferMask3DFX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_flush_buffer_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_flush_buffer_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_object_purgeable) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_object_purgeable_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_texture_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_texture_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_vertex_array_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_vertex_array_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_copy_buffer) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_copy_buffer_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_elements_base_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_elements_base_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_instanced) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_instanced_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_framebuffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_framebuffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_geometry_shader4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_geometry_shader4_functions[] = { + { 12399, -1 }, /* FramebufferTextureLayer */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_map_buffer_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_map_buffer_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_matrix_palette) +static const struct gl_function_remap GL_ARB_matrix_palette_functions[] = { + { 3773, -1 }, /* MatrixIndexusvARB */ + { 13087, -1 }, /* MatrixIndexuivARB */ + { 14475, -1 }, /* MatrixIndexPointerARB */ + { 19735, -1 }, /* CurrentPaletteMatrixARB */ + { 22767, -1 }, /* MatrixIndexubvARB */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_occlusion_query) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_occlusion_query_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_provoking_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_provoking_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_shader_objects) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_shader_objects_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_sync) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_sync_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_texture_compression) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_texture_compression_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_transform_feedback2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_transform_feedback2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_transpose_matrix) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_transpose_matrix_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_array_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_array_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_blend) +static const struct gl_function_remap GL_ARB_vertex_blend_functions[] = { + { 2396, -1 }, /* WeightubvARB */ + { 6567, -1 }, /* WeightivARB */ + { 11070, -1 }, /* WeightPointerARB */ + { 13854, -1 }, /* WeightfvARB */ + { 17564, -1 }, /* WeightbvARB */ + { 20965, -1 }, /* WeightusvARB */ + { 23864, -1 }, /* VertexBlendARB */ + { 29396, -1 }, /* WeightsvARB */ + { 31496, -1 }, /* WeightdvARB */ + { 32239, -1 }, /* WeightuivARB */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_buffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_buffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_shader) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_shader_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_window_pos) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_window_pos_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_blend_equation_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_blend_equation_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_draw_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_draw_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_envmap_bumpmap) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_envmap_bumpmap_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_fragment_shader) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_fragment_shader_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_separate_stencil) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_separate_stencil_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_color) +static const struct gl_function_remap GL_EXT_blend_color_functions[] = { + { 2655, _gloffset_BlendColor }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_equation_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_blend_equation_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_func_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_blend_func_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_minmax) +static const struct gl_function_remap GL_EXT_blend_minmax_functions[] = { + { 11205, _gloffset_BlendEquation }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_color_subtable) +static const struct gl_function_remap GL_EXT_color_subtable_functions[] = { + { 16988, _gloffset_ColorSubTable }, + { 31446, _gloffset_CopyColorSubTable }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_compiled_vertex_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_compiled_vertex_array_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_convolution) +static const struct gl_function_remap GL_EXT_convolution_functions[] = { + { 257, _gloffset_ConvolutionFilter1D }, + { 2454, _gloffset_CopyConvolutionFilter1D }, + { 4058, _gloffset_GetConvolutionParameteriv }, + { 8523, _gloffset_ConvolutionFilter2D }, + { 8725, _gloffset_ConvolutionParameteriv }, + { 9185, _gloffset_ConvolutionParameterfv }, + { 20501, _gloffset_GetSeparableFilter }, + { 23938, _gloffset_SeparableFilter2D }, + { 24801, _gloffset_ConvolutionParameteri }, + { 24924, _gloffset_ConvolutionParameterf }, + { 26595, _gloffset_GetConvolutionParameterfv }, + { 27417, _gloffset_GetConvolutionFilter }, + { 29810, _gloffset_CopyConvolutionFilter2D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_coordinate_frame) +static const struct gl_function_remap GL_EXT_coordinate_frame_functions[] = { + { 10493, -1 }, /* TangentPointerEXT */ + { 12554, -1 }, /* Binormal3ivEXT */ + { 13219, -1 }, /* Tangent3sEXT */ + { 14540, -1 }, /* Tangent3fvEXT */ + { 18695, -1 }, /* Tangent3dvEXT */ + { 19433, -1 }, /* Binormal3bvEXT */ + { 20554, -1 }, /* Binormal3dEXT */ + { 22699, -1 }, /* Tangent3fEXT */ + { 24873, -1 }, /* Binormal3sEXT */ + { 25341, -1 }, /* Tangent3ivEXT */ + { 25360, -1 }, /* Tangent3dEXT */ + { 26274, -1 }, /* Binormal3svEXT */ + { 26840, -1 }, /* Binormal3fEXT */ + { 27728, -1 }, /* Binormal3dvEXT */ + { 28995, -1 }, /* Tangent3iEXT */ + { 30095, -1 }, /* Tangent3bvEXT */ + { 30655, -1 }, /* Tangent3bEXT */ + { 31219, -1 }, /* Binormal3fvEXT */ + { 31938, -1 }, /* BinormalPointerEXT */ + { 32343, -1 }, /* Tangent3svEXT */ + { 32780, -1 }, /* Binormal3bEXT */ + { 32957, -1 }, /* Binormal3iEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_copy_texture) +static const struct gl_function_remap GL_EXT_copy_texture_functions[] = { + { 15065, _gloffset_CopyTexSubImage3D }, + { 16675, _gloffset_CopyTexImage2D }, + { 24409, _gloffset_CopyTexImage1D }, + { 27098, _gloffset_CopyTexSubImage2D }, + { 29448, _gloffset_CopyTexSubImage1D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_cull_vertex) +static const struct gl_function_remap GL_EXT_cull_vertex_functions[] = { + { 8874, -1 }, /* CullParameterdvEXT */ + { 11693, -1 }, /* CullParameterfvEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_depth_bounds_test) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_depth_bounds_test_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_buffers2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_draw_buffers2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_instanced) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_draw_instanced_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_range_elements) +static const struct gl_function_remap GL_EXT_draw_range_elements_functions[] = { + { 9522, _gloffset_DrawRangeElements }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_fog_coord) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_fog_coord_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_blit) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_blit_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_gpu_program_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_gpu_program_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_gpu_shader4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_gpu_shader4_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_histogram) +static const struct gl_function_remap GL_EXT_histogram_functions[] = { + { 856, _gloffset_Histogram }, + { 3522, _gloffset_ResetHistogram }, + { 9972, _gloffset_GetMinmax }, + { 15399, _gloffset_GetHistogramParameterfv }, + { 24334, _gloffset_GetMinmaxParameteriv }, + { 26485, _gloffset_ResetMinmax }, + { 27314, _gloffset_GetHistogramParameteriv }, + { 28463, _gloffset_GetHistogram }, + { 31032, _gloffset_Minmax }, + { 32578, _gloffset_GetMinmaxParameterfv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_index_func) +static const struct gl_function_remap GL_EXT_index_func_functions[] = { + { 11479, -1 }, /* IndexFuncEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_index_material) +static const struct gl_function_remap GL_EXT_index_material_functions[] = { + { 21052, -1 }, /* IndexMaterialEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_light_texture) +static const struct gl_function_remap GL_EXT_light_texture_functions[] = { + { 26294, -1 }, /* ApplyTextureEXT */ + { 26439, -1 }, /* TextureMaterialEXT */ + { 26464, -1 }, /* TextureLightEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_multi_draw_arrays) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_multi_draw_arrays_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_paletted_texture) +static const struct gl_function_remap GL_EXT_paletted_texture_functions[] = { + { 8385, _gloffset_ColorTable }, + { 15245, _gloffset_GetColorTable }, + { 22882, _gloffset_GetColorTableParameterfv }, + { 24980, _gloffset_GetColorTableParameteriv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_pixel_transform) +static const struct gl_function_remap GL_EXT_pixel_transform_functions[] = { + { 21682, -1 }, /* PixelTransformParameterfEXT */ + { 21762, -1 }, /* PixelTransformParameteriEXT */ + { 30370, -1 }, /* PixelTransformParameterfvEXT */ + { 31902, -1 }, /* PixelTransformParameterivEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_polygon_offset) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_polygon_offset_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_provoking_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_provoking_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_secondary_color) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_secondary_color_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_separate_shader_objects) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_separate_shader_objects_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_stencil_two_side) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_stencil_two_side_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_subtexture) +static const struct gl_function_remap GL_EXT_subtexture_functions[] = { + { 7106, _gloffset_TexSubImage1D }, + { 10649, _gloffset_TexSubImage2D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture3D) +static const struct gl_function_remap GL_EXT_texture3D_functions[] = { + { 1774, _gloffset_TexImage3D }, + { 22651, _gloffset_TexSubImage3D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_texture_array_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_integer) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_texture_integer_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_object) +static const struct gl_function_remap GL_EXT_texture_object_functions[] = { + { 3290, _gloffset_PrioritizeTextures }, + { 7555, _gloffset_AreTexturesResident }, + { 13562, _gloffset_GenTextures }, + { 15731, _gloffset_DeleteTextures }, + { 19486, _gloffset_IsTexture }, + { 29513, _gloffset_BindTexture }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_perturb_normal) +static const struct gl_function_remap GL_EXT_texture_perturb_normal_functions[] = { + { 13804, -1 }, /* TextureNormalEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_timer_query) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_timer_query_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_transform_feedback) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_transform_feedback_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_vertex_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_vertex_array_functions[] = { + { 24110, _gloffset_ArrayElement }, + { 30620, _gloffset_GetPointerv }, + { 32205, _gloffset_DrawArrays }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_vertex_weighting) +static const struct gl_function_remap GL_EXT_vertex_weighting_functions[] = { + { 19516, -1 }, /* VertexWeightfvEXT */ + { 26818, -1 }, /* VertexWeightfEXT */ + { 28432, -1 }, /* VertexWeightPointerEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_HP_image_transform) +static const struct gl_function_remap GL_HP_image_transform_functions[] = { + { 2327, -1 }, /* GetImageTransformParameterfvHP */ + { 3739, -1 }, /* ImageTransformParameterfHP */ + { 10187, -1 }, /* ImageTransformParameterfvHP */ + { 11948, -1 }, /* ImageTransformParameteriHP */ + { 12289, -1 }, /* GetImageTransformParameterivHP */ + { 19580, -1 }, /* ImageTransformParameterivHP */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_IBM_multimode_draw_arrays) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_IBM_multimode_draw_arrays_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_IBM_vertex_array_lists) +static const struct gl_function_remap GL_IBM_vertex_array_lists_functions[] = { + { 4379, -1 }, /* SecondaryColorPointerListIBM */ + { 6021, -1 }, /* NormalPointerListIBM */ + { 7729, -1 }, /* FogCoordPointerListIBM */ + { 8036, -1 }, /* VertexPointerListIBM */ + { 11869, -1 }, /* ColorPointerListIBM */ + { 13326, -1 }, /* TexCoordPointerListIBM */ + { 13826, -1 }, /* IndexPointerListIBM */ + { 32521, -1 }, /* EdgeFlagPointerListIBM */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_INGR_blend_func_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_INGR_blend_func_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_INTEL_parallel_arrays) +static const struct gl_function_remap GL_INTEL_parallel_arrays_functions[] = { + { 12666, -1 }, /* VertexPointervINTEL */ + { 15492, -1 }, /* ColorPointervINTEL */ + { 29784, -1 }, /* NormalPointervINTEL */ + { 30302, -1 }, /* TexCoordPointervINTEL */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_resize_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_MESA_resize_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_shader_debug) +static const struct gl_function_remap GL_MESA_shader_debug_functions[] = { + { 1638, -1 }, /* GetDebugLogLengthMESA */ + { 3461, -1 }, /* ClearDebugLogMESA */ + { 4540, -1 }, /* GetDebugLogMESA */ + { 30813, -1 }, /* CreateDebugObjectMESA */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_window_pos) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_MESA_window_pos_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_condtitional_render) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_condtitional_render_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_evaluators) +static const struct gl_function_remap GL_NV_evaluators_functions[] = { + { 6768, -1 }, /* GetMapAttribParameterivNV */ + { 8491, -1 }, /* MapControlPointsNV */ + { 8590, -1 }, /* MapParameterfvNV */ + { 10632, -1 }, /* EvalMapsNV */ + { 17162, -1 }, /* GetMapAttribParameterfvNV */ + { 17379, -1 }, /* MapParameterivNV */ + { 24724, -1 }, /* GetMapParameterivNV */ + { 25222, -1 }, /* GetMapParameterfvNV */ + { 29099, -1 }, /* GetMapControlPointsNV */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_fence) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_fence_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_fragment_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_fragment_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_point_sprite) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_point_sprite_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_primitive_restart) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_primitive_restart_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_register_combiners) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_register_combiners_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_register_combiners2) +static const struct gl_function_remap GL_NV_register_combiners2_functions[] = { + { 15884, -1 }, /* CombinerStageParameterfvNV */ + { 16280, -1 }, /* GetCombinerStageParameterfvNV */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_vertex_array_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_vertex_array_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_vertex_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_vertex_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_OES_EGL_image) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_OES_EGL_image_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_PGI_misc_hints) +static const struct gl_function_remap GL_PGI_misc_hints_functions[] = { + { 8711, -1 }, /* HintPGI */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_detail_texture) +static const struct gl_function_remap GL_SGIS_detail_texture_functions[] = { + { 16253, -1 }, /* GetDetailTexFuncSGIS */ + { 16620, -1 }, /* DetailTexFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_fog_function) +static const struct gl_function_remap GL_SGIS_fog_function_functions[] = { + { 27080, -1 }, /* FogFuncSGIS */ + { 27781, -1 }, /* GetFogFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_pixel_texture) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_pixel_texture_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_sharpen_texture) +static const struct gl_function_remap GL_SGIS_sharpen_texture_functions[] = { + { 6829, -1 }, /* GetSharpenTexFuncSGIS */ + { 22047, -1 }, /* SharpenTexFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture4D) +static const struct gl_function_remap GL_SGIS_texture4D_functions[] = { + { 1010, -1 }, /* TexImage4DSGIS */ + { 15800, -1 }, /* TexSubImage4DSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture_color_mask) +static const struct gl_function_remap GL_SGIS_texture_color_mask_functions[] = { + { 15198, -1 }, /* TextureColorMaskSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture_filter4) +static const struct gl_function_remap GL_SGIS_texture_filter4_functions[] = { + { 7006, -1 }, /* GetTexFilterFuncSGIS */ + { 16399, -1 }, /* TexFilterFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_async) +static const struct gl_function_remap GL_SGIX_async_functions[] = { + { 3387, -1 }, /* AsyncMarkerSGIX */ + { 4519, -1 }, /* FinishAsyncSGIX */ + { 5466, -1 }, /* PollAsyncSGIX */ + { 22228, -1 }, /* DeleteAsyncMarkersSGIX */ + { 22283, -1 }, /* IsAsyncMarkerSGIX */ + { 32318, -1 }, /* GenAsyncMarkersSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_flush_raster) +static const struct gl_function_remap GL_SGIX_flush_raster_functions[] = { + { 7383, -1 }, /* FlushRasterSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_fragment_lighting) +static const struct gl_function_remap GL_SGIX_fragment_lighting_functions[] = { + { 2625, -1 }, /* FragmentMaterialfvSGIX */ + { 5370, -1 }, /* FragmentLightiSGIX */ + { 8103, -1 }, /* FragmentMaterialfSGIX */ + { 8264, -1 }, /* GetFragmentLightivSGIX */ + { 9137, -1 }, /* FragmentLightModeliSGIX */ + { 10695, -1 }, /* FragmentLightivSGIX */ + { 11013, -1 }, /* GetFragmentMaterialivSGIX */ + { 16193, -1 }, /* GetFragmentMaterialfvSGIX */ + { 19403, -1 }, /* FragmentLightModelfSGIX */ + { 19703, -1 }, /* FragmentColorMaterialSGIX */ + { 20120, -1 }, /* FragmentMaterialiSGIX */ + { 21380, -1 }, /* LightEnviSGIX */ + { 22974, -1 }, /* FragmentLightModelfvSGIX */ + { 23309, -1 }, /* FragmentLightfvSGIX */ + { 28165, -1 }, /* FragmentLightModelivSGIX */ + { 28314, -1 }, /* FragmentLightfSGIX */ + { 31189, -1 }, /* GetFragmentLightfvSGIX */ + { 32801, -1 }, /* FragmentMaterialivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_framezoom) +static const struct gl_function_remap GL_SGIX_framezoom_functions[] = { + { 22306, -1 }, /* FrameZoomSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_igloo_interface) +static const struct gl_function_remap GL_SGIX_igloo_interface_functions[] = { + { 28622, -1 }, /* IglooInterfaceSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_instruments) +static const struct gl_function_remap GL_SGIX_instruments_functions[] = { + { 2805, -1 }, /* ReadInstrumentsSGIX */ + { 6585, -1 }, /* PollInstrumentsSGIX */ + { 10553, -1 }, /* GetInstrumentsSGIX */ + { 12924, -1 }, /* StartInstrumentsSGIX */ + { 15918, -1 }, /* StopInstrumentsSGIX */ + { 17777, -1 }, /* InstrumentsBufferSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_list_priority) +static const struct gl_function_remap GL_SGIX_list_priority_functions[] = { + { 1241, -1 }, /* ListParameterfSGIX */ + { 3089, -1 }, /* GetListParameterfvSGIX */ + { 17692, -1 }, /* ListParameteriSGIX */ + { 18645, -1 }, /* ListParameterfvSGIX */ + { 20786, -1 }, /* ListParameterivSGIX */ + { 32362, -1 }, /* GetListParameterivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_pixel_texture) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIX_pixel_texture_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_polynomial_ffd) +static const struct gl_function_remap GL_SGIX_polynomial_ffd_functions[] = { + { 3685, -1 }, /* LoadIdentityDeformationMapSGIX */ + { 16018, -1 }, /* DeformSGIX */ + { 24222, -1 }, /* DeformationMap3fSGIX */ + { 31077, -1 }, /* DeformationMap3dSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_reference_plane) +static const struct gl_function_remap GL_SGIX_reference_plane_functions[] = { + { 14749, -1 }, /* ReferencePlaneSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_sprite) +static const struct gl_function_remap GL_SGIX_sprite_functions[] = { + { 9635, -1 }, /* SpriteParameterfvSGIX */ + { 20575, -1 }, /* SpriteParameteriSGIX */ + { 26519, -1 }, /* SpriteParameterfSGIX */ + { 29242, -1 }, /* SpriteParameterivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_tag_sample_buffer) +static const struct gl_function_remap GL_SGIX_tag_sample_buffer_functions[] = { + { 20634, -1 }, /* TagSampleBufferSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGI_color_table) +static const struct gl_function_remap GL_SGI_color_table_functions[] = { + { 7673, _gloffset_ColorTableParameteriv }, + { 8385, _gloffset_ColorTable }, + { 15245, _gloffset_GetColorTable }, + { 15355, _gloffset_CopyColorTable }, + { 19347, _gloffset_ColorTableParameterfv }, + { 22882, _gloffset_GetColorTableParameterfv }, + { 24980, _gloffset_GetColorTableParameteriv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUNX_constant_data) +static const struct gl_function_remap GL_SUNX_constant_data_functions[] = { + { 31167, -1 }, /* FinishTextureSUNX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_global_alpha) +static const struct gl_function_remap GL_SUN_global_alpha_functions[] = { + { 3408, -1 }, /* GlobalAlphaFactorubSUN */ + { 4818, -1 }, /* GlobalAlphaFactoriSUN */ + { 6610, -1 }, /* GlobalAlphaFactordSUN */ + { 9719, -1 }, /* GlobalAlphaFactoruiSUN */ + { 10144, -1 }, /* GlobalAlphaFactorbSUN */ + { 13239, -1 }, /* GlobalAlphaFactorfSUN */ + { 13403, -1 }, /* GlobalAlphaFactorusSUN */ + { 22569, -1 }, /* GlobalAlphaFactorsSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_mesh_array) +static const struct gl_function_remap GL_SUN_mesh_array_functions[] = { + { 29033, -1 }, /* DrawMeshArraysSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_triangle_list) +static const struct gl_function_remap GL_SUN_triangle_list_functions[] = { + { 4493, -1 }, /* ReplacementCodeubSUN */ + { 6369, -1 }, /* ReplacementCodeubvSUN */ + { 19068, -1 }, /* ReplacementCodeusvSUN */ + { 19256, -1 }, /* ReplacementCodePointerSUN */ + { 21444, -1 }, /* ReplacementCodeuiSUN */ + { 22257, -1 }, /* ReplacementCodeusSUN */ + { 29699, -1 }, /* ReplacementCodeuivSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_vertex) +static const struct gl_function_remap GL_SUN_vertex_functions[] = { + { 1115, -1 }, /* ReplacementCodeuiColor3fVertex3fvSUN */ + { 1313, -1 }, /* TexCoord4fColor4fNormal3fVertex4fvSUN */ + { 1539, -1 }, /* TexCoord2fColor4ubVertex3fvSUN */ + { 1869, -1 }, /* ReplacementCodeuiVertex3fvSUN */ + { 2003, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fvSUN */ + { 2561, -1 }, /* ReplacementCodeuiNormal3fVertex3fSUN */ + { 2874, -1 }, /* Color4ubVertex3fvSUN */ + { 4652, -1 }, /* Color4ubVertex3fSUN */ + { 4775, -1 }, /* TexCoord2fVertex3fSUN */ + { 5119, -1 }, /* TexCoord2fColor4fNormal3fVertex3fSUN */ + { 5570, -1 }, /* TexCoord2fNormal3fVertex3fvSUN */ + { 6264, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN */ + { 7061, -1 }, /* ReplacementCodeuiColor4ubVertex3fvSUN */ + { 7420, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fSUN */ + { 8132, -1 }, /* TexCoord2fNormal3fVertex3fSUN */ + { 8936, -1 }, /* Color3fVertex3fSUN */ + { 10080, -1 }, /* Color3fVertex3fvSUN */ + { 10518, -1 }, /* Color4fNormal3fVertex3fvSUN */ + { 11358, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN */ + { 12787, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fvSUN */ + { 14398, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN */ + { 14891, -1 }, /* TexCoord2fColor3fVertex3fSUN */ + { 15943, -1 }, /* TexCoord4fColor4fNormal3fVertex4fSUN */ + { 16358, -1 }, /* Color4ubVertex2fvSUN */ + { 16645, -1 }, /* Normal3fVertex3fSUN */ + { 17718, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fSUN */ + { 18079, -1 }, /* TexCoord2fColor4fNormal3fVertex3fvSUN */ + { 18897, -1 }, /* TexCoord2fVertex3fvSUN */ + { 19673, -1 }, /* Color4ubVertex2fSUN */ + { 19911, -1 }, /* ReplacementCodeuiColor4ubVertex3fSUN */ + { 21893, -1 }, /* TexCoord2fColor4ubVertex3fSUN */ + { 22325, -1 }, /* Normal3fVertex3fvSUN */ + { 22791, -1 }, /* Color4fNormal3fVertex3fSUN */ + { 23771, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN */ + { 25840, -1 }, /* ReplacementCodeuiColor3fVertex3fSUN */ + { 27196, -1 }, /* TexCoord4fVertex4fSUN */ + { 27622, -1 }, /* TexCoord2fColor3fVertex3fvSUN */ + { 28009, -1 }, /* ReplacementCodeuiNormal3fVertex3fvSUN */ + { 28136, -1 }, /* TexCoord4fVertex4fvSUN */ + { 28870, -1 }, /* ReplacementCodeuiVertex3fSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_3) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_3_functions[] = { + { 425, _gloffset_MultiTexCoord3sARB }, + { 657, _gloffset_ActiveTextureARB }, + { 4247, _gloffset_MultiTexCoord1fvARB }, + { 6155, _gloffset_MultiTexCoord3dARB }, + { 6200, _gloffset_MultiTexCoord2iARB }, + { 6324, _gloffset_MultiTexCoord2svARB }, + { 8341, _gloffset_MultiTexCoord2fARB }, + { 10354, _gloffset_MultiTexCoord3fvARB }, + { 10967, _gloffset_MultiTexCoord4sARB }, + { 11648, _gloffset_MultiTexCoord2dvARB }, + { 12063, _gloffset_MultiTexCoord1svARB }, + { 12435, _gloffset_MultiTexCoord3svARB }, + { 12496, _gloffset_MultiTexCoord4iARB }, + { 13266, _gloffset_MultiTexCoord3iARB }, + { 14136, _gloffset_MultiTexCoord1dARB }, + { 14353, _gloffset_MultiTexCoord3dvARB }, + { 15599, _gloffset_MultiTexCoord3ivARB }, + { 15644, _gloffset_MultiTexCoord2sARB }, + { 17045, _gloffset_MultiTexCoord4ivARB }, + { 18997, _gloffset_ClientActiveTextureARB }, + { 21297, _gloffset_MultiTexCoord2dARB }, + { 21717, _gloffset_MultiTexCoord4dvARB }, + { 22073, _gloffset_MultiTexCoord4fvARB }, + { 23023, _gloffset_MultiTexCoord3fARB }, + { 25531, _gloffset_MultiTexCoord4dARB }, + { 25797, _gloffset_MultiTexCoord1sARB }, + { 26001, _gloffset_MultiTexCoord1dvARB }, + { 26942, _gloffset_MultiTexCoord1ivARB }, + { 27035, _gloffset_MultiTexCoord2ivARB }, + { 27374, _gloffset_MultiTexCoord1iARB }, + { 28738, _gloffset_MultiTexCoord4svARB }, + { 29312, _gloffset_MultiTexCoord1fARB }, + { 29575, _gloffset_MultiTexCoord4fARB }, + { 32039, _gloffset_MultiTexCoord2fvARB }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_4_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_5) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_5_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_2_0) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_2_0_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_2_1) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_2_1_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_0) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_0_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_1) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_1_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_3) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_3_functions[] = { + { -1, -1 } +}; +#endif + diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index adc1199d8..ddc2fe30d 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -1,2008 +1,2007 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Functions for allocating/managing renderbuffers. - * Also, routines for reading/writing software-based renderbuffer data as - * ubytes, ushorts, uints, etc. - * - * The 'alpha8' renderbuffer is interesting. It's used to add a software-based - * alpha channel to RGB renderbuffers. This is done by wrapping the RGB - * renderbuffer with the alpha renderbuffer. We can do this because of the - * OO-nature of renderbuffers. - * - * Down the road we'll use this for run-time support of 8, 16 and 32-bit - * color channels. For example, Mesa may use 32-bit/float color channels - * internally (swrast) and use wrapper renderbuffers to convert 32-bit - * values down to 16 or 8-bit values for whatever kind of framebuffer we have. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "fbobject.h" -#include "formats.h" -#include "mtypes.h" -#include "fbobject.h" -#include "renderbuffer.h" - - -/* - * Routines for get/put values in common buffer formats follow. - * Someday add support for arbitrary row stride to make them more - * flexible. - */ - -/********************************************************************** - * Functions for buffers of 1 X GLubyte values. - * Typically stencil. - */ - -static void * -get_pointer_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - /* Can't assert rb->Format since these funcs may be used for serveral - * different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc). - */ - return (GLubyte *) rb->Data + y * rb->Width + x; -} - - -static void -get_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - memcpy(values, src, count * sizeof(GLubyte)); -} - - -static void -get_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, values, count * sizeof(GLubyte)); - } -} - - -static void -put_mono_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLubyte val = *((const GLubyte *) value); - GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLubyte val = *((const GLubyte *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLushort values. - * Typically depth/Z. - */ - -static void * -get_pointer_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Width > 0); - return (GLushort *) rb->Data + y * rb->Width + x; -} - - -static void -get_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const void *src = rb->GetPointer(ctx, rb, x, y); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - memcpy(values, src, count * sizeof(GLushort)); -} - - -static void -get_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLushort)); - } -} - - -static void -put_mono_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLushort val = *((const GLushort *) value); - GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLushort val = *((const GLushort *) value); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; - *dst = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLuint values. - * Typically depth/Z or color index. - */ - -static void * -get_pointer_uint(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - return (GLuint *) rb->Data + y * rb->Width + x; -} - - -static void -get_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const void *src = rb->GetPointer(ctx, rb, x, y); - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - memcpy(values, src, count * sizeof(GLuint)); -} - - -static void -get_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLuint)); - } -} - - -static void -put_mono_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLuint val = *((const GLuint *) value); - GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *value, - const GLubyte *mask) -{ - const GLuint val = *((const GLuint *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 3 X GLubyte (or GLbyte) values. - * Typically color buffers. - * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming - * alpha values and return 255 for outgoing alpha values. - */ - -static void * -get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - ASSERT(rb->Format == MESA_FORMAT_RGB888); - /* No direct access since this buffer is RGB but caller will be - * treating it as if it were RGBA. - */ - return NULL; -} - - -static void -get_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x); - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -get_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src - = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); - dst[i * 4 + 0] = src[0]; - dst[i * 4 + 1] = src[1]; - dst[i * 4 + 2] = src[2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -put_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = src[i * 4 + 0]; - dst[i * 3 + 1] = src[i * 4 + 1]; - dst[i * 3 + 2] = src[i * 4 + 2]; - } - } -} - - -static void -put_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = src[i * 3 + 0]; - dst[i * 3 + 1] = src[i * 3 + 1]; - dst[i * 3 + 2] = src[i * 3 + 2]; - } - } -} - - -static void -put_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - /* note: incoming value is RGB+A! */ - const GLubyte val0 = ((const GLubyte *) value)[0]; - const GLubyte val1 = ((const GLubyte *) value)[1]; - const GLubyte val2 = ((const GLubyte *) value)[2]; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (!mask && val0 == val1 && val1 == val2) { - /* optimized case */ - memset(dst, val0, 3 * count); - } - else { - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = val0; - dst[i * 3 + 1] = val1; - dst[i * 3 + 2] = val2; - } - } - } -} - - -static void -put_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - } - } -} - - -static void -put_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - /* note: incoming value is RGB+A! */ - const GLubyte val0 = ((const GLubyte *) value)[0]; - const GLubyte val1 = ((const GLubyte *) value)[1]; - const GLubyte val2 = ((const GLubyte *) value)[2]; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); - dst[0] = val0; - dst[1] = val1; - dst[2] = val2; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLubyte (or GLbyte) values. - * Typically color buffers. - */ - -static void * -get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - return (GLubyte *) rb->Data + 4 * (y * rb->Width + x); -} - - -static void -get_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - memcpy(values, src, 4 * count * sizeof(GLubyte)); -} - - -static void -get_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - /* treat 4*GLubyte as 1*GLuint */ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLubyte)); - } -} - - -static void -put_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* Store RGB values in RGBA buffer */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 0xff; - } - } -} - - -static void -put_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint val = *((const GLuint *) value); - GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - if (!mask && val == 0) { - /* common case */ - memset(dst, 0, count * 4 * sizeof(GLubyte)); - } - else { - /* general case */ - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } - } -} - - -static void -put_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint val = *((const GLuint *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLushort (or GLshort) values. - * Typically accum buffer. - */ - -static void * -get_pointer_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - return (GLushort *) rb->Data + 4 * (y * rb->Width + x); -} - - -static void -get_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - memcpy(values, src, 4 * count * sizeof(GLshort)); -} - - -static void -get_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src - = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i * 4 + 0] = src[i * 4 + 0]; - dst[i * 4 + 1] = src[i * 4 + 1]; - dst[i * 4 + 2] = src[i * 4 + 2]; - dst[i * 4 + 3] = src[i * 4 + 3]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLushort)); - } -} - - -static void -put_row_rgb_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* Put RGB values in RGBA buffer */ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 0xffff; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLushort)); - } -} - - -static void -put_mono_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLushort val0 = ((const GLushort *) value)[0]; - const GLushort val1 = ((const GLushort *) value)[1]; - const GLushort val2 = ((const GLushort *) value)[2]; - const GLushort val3 = ((const GLushort *) value)[3]; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) { - /* common case for clearing accum buffer */ - memset(dst, 0, count * 4 * sizeof(GLushort)); - } - else { - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 4 + 0] = val0; - dst[i * 4 + 1] = val1; - dst[i * 4 + 2] = val2; - dst[i * 4 + 3] = val3; - } - } - } -} - - -static void -put_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - dst[3] = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLushort val0 = ((const GLushort *) value)[0]; - const GLushort val1 = ((const GLushort *) value)[1]; - const GLushort val2 = ((const GLushort *) value)[2]; - const GLushort val3 = ((const GLushort *) value)[3]; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); - dst[0] = val0; - dst[1] = val1; - dst[2] = val2; - dst[3] = val3; - } - } -} - - - -/** - * This is a software fallback for the gl_renderbuffer->AllocStorage - * function. - * Device drivers will typically override this function for the buffers - * which it manages (typically color buffers, Z and stencil). - * Other buffers (like software accumulation and aux buffers) which the driver - * doesn't manage can be handled with this function. - * - * This one multi-purpose function can allocate stencil, depth, accum, color - * or color-index buffers! - * - * This function also plugs in the appropriate GetPointer, Get/PutRow and - * Get/PutValues functions. - */ -GLboolean -_mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - GLuint pixelSize; - - switch (internalFormat) { - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - rb->Format = MESA_FORMAT_RGB888; - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte3; - rb->GetRow = get_row_ubyte3; - rb->GetValues = get_values_ubyte3; - rb->PutRow = put_row_ubyte3; - rb->PutRowRGB = put_row_rgb_ubyte3; - rb->PutMonoRow = put_mono_row_ubyte3; - rb->PutValues = put_values_ubyte3; - rb->PutMonoValues = put_mono_values_ubyte3; - pixelSize = 3 * sizeof(GLubyte); - break; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: -#if 1 - case GL_RGB10_A2: - case GL_RGBA12: -#endif - rb->Format = MESA_FORMAT_RGBA8888; - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte4; - rb->GetRow = get_row_ubyte4; - rb->GetValues = get_values_ubyte4; - rb->PutRow = put_row_ubyte4; - rb->PutRowRGB = put_row_rgb_ubyte4; - rb->PutMonoRow = put_mono_row_ubyte4; - rb->PutValues = put_values_ubyte4; - rb->PutMonoValues = put_mono_values_ubyte4; - pixelSize = 4 * sizeof(GLubyte); - break; - case GL_RGBA16: - case GL_RGBA16_SNORM: - /* for accum buffer */ - rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - rb->DataType = GL_SHORT; - rb->GetPointer = get_pointer_ushort4; - rb->GetRow = get_row_ushort4; - rb->GetValues = get_values_ushort4; - rb->PutRow = put_row_ushort4; - rb->PutRowRGB = put_row_rgb_ushort4; - rb->PutMonoRow = put_mono_row_ushort4; - rb->PutValues = put_values_ushort4; - rb->PutMonoValues = put_mono_values_ushort4; - pixelSize = 4 * sizeof(GLushort); - break; -#if 0 - case GL_ALPHA8: - rb->Format = MESA_FORMAT_A8; - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_alpha8; - rb->GetRow = get_row_alpha8; - rb->GetValues = get_values_alpha8; - rb->PutRow = put_row_alpha8; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_alpha8; - rb->PutValues = put_values_alpha8; - rb->PutMonoValues = put_mono_values_alpha8; - pixelSize = sizeof(GLubyte); - break; -#endif - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - rb->Format = MESA_FORMAT_S8; - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte; - rb->GetRow = get_row_ubyte; - rb->GetValues = get_values_ubyte; - rb->PutRow = put_row_ubyte; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_ubyte; - rb->PutValues = put_values_ubyte; - rb->PutMonoValues = put_mono_values_ubyte; - pixelSize = sizeof(GLubyte); - break; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - rb->Format = MESA_FORMAT_Z16; - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetPointer = get_pointer_ushort; - rb->GetRow = get_row_ushort; - rb->GetValues = get_values_ushort; - rb->PutRow = put_row_ushort; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_ushort; - rb->PutValues = put_values_ushort; - rb->PutMonoValues = put_mono_values_ushort; - pixelSize = sizeof(GLushort); - break; - case GL_DEPTH_COMPONENT24: - rb->DataType = GL_UNSIGNED_INT; - rb->GetPointer = get_pointer_uint; - rb->GetRow = get_row_uint; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_uint; - rb->PutValues = put_values_uint; - rb->PutMonoValues = put_mono_values_uint; - rb->Format = MESA_FORMAT_X8_Z24; - pixelSize = sizeof(GLuint); - break; - case GL_DEPTH_COMPONENT32: - rb->DataType = GL_UNSIGNED_INT; - rb->GetPointer = get_pointer_uint; - rb->GetRow = get_row_uint; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_uint; - rb->PutValues = put_values_uint; - rb->PutMonoValues = put_mono_values_uint; - rb->Format = MESA_FORMAT_Z32; - pixelSize = sizeof(GLuint); - break; - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - rb->Format = MESA_FORMAT_Z24_S8; - rb->DataType = GL_UNSIGNED_INT_24_8_EXT; - rb->GetPointer = get_pointer_uint; - rb->GetRow = get_row_uint; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_uint; - rb->PutValues = put_values_uint; - rb->PutMonoValues = put_mono_values_uint; - pixelSize = sizeof(GLuint); - break; - default: - _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage"); - return GL_FALSE; - } - - ASSERT(rb->DataType); - ASSERT(rb->GetPointer); - ASSERT(rb->GetRow); - ASSERT(rb->GetValues); - ASSERT(rb->PutRow); - ASSERT(rb->PutMonoRow); - ASSERT(rb->PutValues); - ASSERT(rb->PutMonoValues); - - /* free old buffer storage */ - if (rb->Data) { - free(rb->Data); - rb->Data = NULL; - } - - if (width > 0 && height > 0) { - /* allocate new buffer storage */ - rb->Data = malloc(width * height * pixelSize); - - if (rb->Data == NULL) { - rb->Width = 0; - rb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "software renderbuffer allocation (%d x %d x %d)", - width, height, pixelSize); - return GL_FALSE; - } - } - - rb->Width = width; - rb->Height = height; - rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); - ASSERT(rb->_BaseFormat); - - return GL_TRUE; -} - - - -/**********************************************************************/ -/**********************************************************************/ -/**********************************************************************/ - - -/** - * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha - * buffer wrapper around an existing RGB renderbuffer (hw or sw). - * - * When PutRow is called (for example), we store the alpha values in - * this buffer, then pass on the PutRow call to the wrapped RGB - * buffer. - */ - - -static GLboolean -alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, - GLenum internalFormat, GLuint width, GLuint height) -{ - ASSERT(arb != arb->Wrapped); - ASSERT(arb->Format == MESA_FORMAT_A8); - - /* first, pass the call to the wrapped RGB buffer */ - if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat, - width, height)) { - return GL_FALSE; - } - - /* next, resize my alpha buffer */ - if (arb->Data) { - free(arb->Data); - } - - arb->Data = malloc(width * height * sizeof(GLubyte)); - if (arb->Data == NULL) { - arb->Width = 0; - arb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation"); - return GL_FALSE; - } - - arb->Width = width; - arb->Height = height; - - return GL_TRUE; -} - - -/** - * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer. - */ -static void -delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) -{ - if (arb->Data) { - free(arb->Data); - } - ASSERT(arb->Wrapped); - ASSERT(arb != arb->Wrapped); - arb->Wrapped->Delete(arb->Wrapped); - arb->Wrapped = NULL; - free(arb); -} - - -static void * -get_pointer_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, - GLint x, GLint y) -{ - return NULL; /* don't allow direct access! */ -} - - -static void -get_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, void *values) -{ - /* NOTE: 'values' is RGBA format! */ - const GLubyte *src = (const GLubyte *) arb->Data + y * arb->Width + x; - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values); - /* second, fill in alpha values from this buffer! */ - for (i = 0; i < count; i++) { - dst[i * 4 + 3] = src[i]; - } -} - - -static void -get_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values); - /* second, fill in alpha values from this buffer! */ - for (i = 0; i < count; i++) { - const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; - dst[i * 4 + 3] = *src; - } -} - - -static void -put_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = src[i * 4 + 3]; - } - } -} - - -static void -put_row_rgb_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLubyte val = ((const GLubyte *) value)[3]; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask); - /* second, store alpha in our buffer */ - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - memset(dst, val, count); - } -} - - -static void -put_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; - *dst = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLubyte val = ((const GLubyte *) value)[3]; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; - *dst = val; - } - } -} - - -static void -copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) -{ - ASSERT(dst->Format == MESA_FORMAT_A8); - ASSERT(src->Format == MESA_FORMAT_A8); - ASSERT(dst->Width == src->Width); - ASSERT(dst->Height == src->Height); - - memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte)); -} - - -/**********************************************************************/ -/**********************************************************************/ -/**********************************************************************/ - - -/** - * Default GetPointer routine. Always return NULL to indicate that - * direct buffer access is not supported. - */ -static void * -nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - return NULL; -} - - -/** - * Initialize the fields of a gl_renderbuffer to default values. - */ -void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) -{ - _glthread_INIT_MUTEX(rb->Mutex); - - rb->Magic = RB_MAGIC; - rb->ClassID = 0; - rb->Name = name; - rb->RefCount = 0; - rb->Delete = _mesa_delete_renderbuffer; - - /* The rest of these should be set later by the caller of this function or - * the AllocStorage method: - */ - rb->AllocStorage = NULL; - - rb->Width = 0; - rb->Height = 0; - rb->InternalFormat = GL_NONE; - rb->Format = MESA_FORMAT_NONE; - - rb->DataType = GL_NONE; - rb->Data = NULL; - - /* Point back to ourself so that we don't have to check for Wrapped==NULL - * all over the drivers. - */ - rb->Wrapped = rb; - - rb->GetPointer = nop_get_pointer; - rb->GetRow = NULL; - rb->GetValues = NULL; - rb->PutRow = NULL; - rb->PutRowRGB = NULL; - rb->PutMonoRow = NULL; - rb->PutValues = NULL; - rb->PutMonoValues = NULL; -} - - -/** - * Allocate a new gl_renderbuffer object. This can be used for user-created - * renderbuffers or window-system renderbuffers. - */ -struct gl_renderbuffer * -_mesa_new_renderbuffer(GLcontext *ctx, GLuint name) -{ - struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); - if (rb) { - _mesa_init_renderbuffer(rb, name); - } - return rb; -} - - -/** - * Delete a gl_framebuffer. - * This is the default function for renderbuffer->Delete(). - */ -void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) -{ - if (rb->Data) { - free(rb->Data); - } - free(rb); -} - - -/** - * Allocate a software-based renderbuffer. This is called via the - * ctx->Driver.NewRenderbuffer() function when the user creates a new - * renderbuffer. - * This would not be used for hardware-based renderbuffers. - */ -struct gl_renderbuffer * -_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name) -{ - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); - if (rb) { - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - /* Normally, one would setup the PutRow, GetRow, etc functions here. - * But we're doing that in the _mesa_soft_renderbuffer_storage() function - * instead. - */ - } - return rb; -} - - -/** - * Add software-based color renderbuffers to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint rgbBits, GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight) -{ - GLuint b; - - if (rgbBits > 16 || alphaBits > 16) { - _mesa_problem(ctx, - "Unsupported bit depth in _mesa_add_color_renderbuffers"); - return GL_FALSE; - } - - assert(MAX_COLOR_ATTACHMENTS >= 4); - - for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { - struct gl_renderbuffer *rb; - - if (b == BUFFER_FRONT_LEFT && !frontLeft) - continue; - else if (b == BUFFER_BACK_LEFT && !backLeft) - continue; - else if (b == BUFFER_FRONT_RIGHT && !frontRight) - continue; - else if (b == BUFFER_BACK_RIGHT && !backRight) - continue; - - assert(fb->Attachment[b].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); - return GL_FALSE; - } - - if (rgbBits <= 8) { - if (alphaBits) - rb->Format = MESA_FORMAT_RGBA8888; - else - rb->Format = MESA_FORMAT_RGB888; - } - else { - assert(rgbBits <= 16); - rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/ - } - rb->InternalFormat = GL_RGBA; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, b, rb); - } - - return GL_TRUE; -} - - -/** - * Add software-based alpha renderbuffers to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight) -{ - GLuint b; - - /* for window system framebuffers only! */ - assert(fb->Name == 0); - - if (alphaBits > 8) { - _mesa_problem(ctx, - "Unsupported bit depth in _mesa_add_alpha_renderbuffers"); - return GL_FALSE; - } - - assert(MAX_COLOR_ATTACHMENTS >= 4); - - /* Wrap each of the RGB color buffers with an alpha renderbuffer. - */ - for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { - struct gl_renderbuffer *arb; - - if (b == BUFFER_FRONT_LEFT && !frontLeft) - continue; - else if (b == BUFFER_BACK_LEFT && !backLeft) - continue; - else if (b == BUFFER_FRONT_RIGHT && !frontRight) - continue; - else if (b == BUFFER_BACK_RIGHT && !backRight) - continue; - - /* the RGB buffer to wrap must already exist!! */ - assert(fb->Attachment[b].Renderbuffer); - - /* only GLubyte supported for now */ - assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE); - - /* allocate alpha renderbuffer */ - arb = _mesa_new_renderbuffer(ctx, 0); - if (!arb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer"); - return GL_FALSE; - } - - /* wrap the alpha renderbuffer around the RGB renderbuffer */ - arb->Wrapped = fb->Attachment[b].Renderbuffer; - - /* Set up my alphabuffer fields and plug in my functions. - * The functions will put/get the alpha values from/to RGBA arrays - * and then call the wrapped buffer's functions to handle the RGB - * values. - */ - arb->InternalFormat = arb->Wrapped->InternalFormat; - arb->Format = MESA_FORMAT_A8; - arb->DataType = arb->Wrapped->DataType; - arb->AllocStorage = alloc_storage_alpha8; - arb->Delete = delete_renderbuffer_alpha8; - arb->GetPointer = get_pointer_alpha8; - arb->GetRow = get_row_alpha8; - arb->GetValues = get_values_alpha8; - arb->PutRow = put_row_alpha8; - arb->PutRowRGB = put_row_rgb_alpha8; - arb->PutMonoRow = put_mono_row_alpha8; - arb->PutValues = put_values_alpha8; - arb->PutMonoValues = put_mono_values_alpha8; - - /* clear the pointer to avoid assertion/sanity check failure later */ - fb->Attachment[b].Renderbuffer = NULL; - - /* plug the alpha renderbuffer into the colorbuffer attachment */ - _mesa_add_renderbuffer(fb, b, arb); - } - - return GL_TRUE; -} - - -/** - * For framebuffers that use a software alpha channel wrapper - * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, - * copy the back buffer alpha channel into the front buffer alpha channel. - */ -void -_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb) -{ - if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && - fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) - copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, - fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); - - - if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && - fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) - copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, - fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); -} - - -/** - * Add a software-based depth renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint depthBits) -{ - struct gl_renderbuffer *rb; - - if (depthBits > 32) { - _mesa_problem(ctx, - "Unsupported depthBits in _mesa_add_depth_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); - return GL_FALSE; - } - - if (depthBits <= 16) { - rb->Format = MESA_FORMAT_Z16; - rb->InternalFormat = GL_DEPTH_COMPONENT16; - } - else if (depthBits <= 24) { - rb->Format = MESA_FORMAT_X8_Z24; - rb->InternalFormat = GL_DEPTH_COMPONENT24; - } - else { - rb->Format = MESA_FORMAT_Z32; - rb->InternalFormat = GL_DEPTH_COMPONENT32; - } - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based stencil renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint stencilBits) -{ - struct gl_renderbuffer *rb; - - if (stencilBits > 16) { - _mesa_problem(ctx, - "Unsupported stencilBits in _mesa_add_stencil_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); - return GL_FALSE; - } - - assert(stencilBits <= 8); - rb->Format = MESA_FORMAT_S8; - rb->InternalFormat = GL_STENCIL_INDEX8; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based accumulation renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint redBits, GLuint greenBits, - GLuint blueBits, GLuint alphaBits) -{ - struct gl_renderbuffer *rb; - - if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { - _mesa_problem(ctx, - "Unsupported accumBits in _mesa_add_accum_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); - return GL_FALSE; - } - - rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - rb->InternalFormat = GL_RGBA16_SNORM; - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); - - return GL_TRUE; -} - - - -/** - * Add a software-based accumulation renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - * - * NOTE: color-index aux buffers not supported. - */ -GLboolean -_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint colorBits, GLuint numBuffers) -{ - GLuint i; - - if (colorBits > 16) { - _mesa_problem(ctx, - "Unsupported accumBits in _mesa_add_aux_renderbuffers"); - return GL_FALSE; - } - - assert(numBuffers <= MAX_AUX_BUFFERS); - - for (i = 0; i < numBuffers; i++) { - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); - - assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); - - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); - return GL_FALSE; - } - - assert (colorBits <= 8); - rb->Format = MESA_FORMAT_RGBA8888; - rb->InternalFormat = GL_RGBA; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); - } - return GL_TRUE; -} - - -/** - * Create/attach software-based renderbuffers to the given framebuffer. - * This is a helper routine for device drivers. Drivers can just as well - * call the individual _mesa_add_*_renderbuffer() routines directly. - */ -void -_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux) -{ - GLboolean frontLeft = GL_TRUE; - GLboolean backLeft = fb->Visual.doubleBufferMode; - GLboolean frontRight = fb->Visual.stereoMode; - GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode; - - if (color) { - assert(fb->Visual.redBits == fb->Visual.greenBits); - assert(fb->Visual.redBits == fb->Visual.blueBits); - _mesa_add_color_renderbuffers(NULL, fb, - fb->Visual.redBits, - fb->Visual.alphaBits, - frontLeft, backLeft, - frontRight, backRight); - } - - if (depth) { - assert(fb->Visual.depthBits > 0); - _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); - } - - if (stencil) { - assert(fb->Visual.stencilBits > 0); - _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); - } - - if (accum) { - assert(fb->Visual.accumRedBits > 0); - assert(fb->Visual.accumGreenBits > 0); - assert(fb->Visual.accumBlueBits > 0); - _mesa_add_accum_renderbuffer(NULL, fb, - fb->Visual.accumRedBits, - fb->Visual.accumGreenBits, - fb->Visual.accumBlueBits, - fb->Visual.accumAlphaBits); - } - - if (aux) { - assert(fb->Visual.numAuxBuffers > 0); - _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, - fb->Visual.numAuxBuffers); - } - - if (alpha) { - assert(fb->Visual.alphaBits > 0); - _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits, - frontLeft, backLeft, - frontRight, backRight); - } - -#if 0 - if (multisample) { - /* maybe someday */ - } -#endif -} - - -/** - * Attach a renderbuffer to a framebuffer. - */ -void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - GLuint bufferName, struct gl_renderbuffer *rb) -{ - assert(fb); - assert(rb); - assert(bufferName < BUFFER_COUNT); - - /* There should be no previous renderbuffer on this attachment point, - * with the exception of depth/stencil since the same renderbuffer may - * be used for both. - */ - assert(bufferName == BUFFER_DEPTH || - bufferName == BUFFER_STENCIL || - fb->Attachment[bufferName].Renderbuffer == NULL); - - /* winsys vs. user-created buffer cross check */ - if (fb->Name) { - assert(rb->Name); - } - else { - assert(!rb->Name); - } - - fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; - fb->Attachment[bufferName].Complete = GL_TRUE; - _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); -} - - -/** - * Remove the named renderbuffer from the given framebuffer. - */ -void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName) -{ - struct gl_renderbuffer *rb; - - assert(bufferName < BUFFER_COUNT); - - rb = fb->Attachment[bufferName].Renderbuffer; - if (!rb) - return; - - _mesa_reference_renderbuffer(&rb, NULL); - - fb->Attachment[bufferName].Renderbuffer = NULL; -} - - -/** - * Set *ptr to point to rb. If *ptr points to another renderbuffer, - * dereference that buffer first. The new renderbuffer's refcount will - * be incremented. The old renderbuffer's refcount will be decremented. - */ -void -_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb) -{ - assert(ptr); - if (*ptr == rb) { - /* no change */ - return; - } - - if (*ptr) { - /* Unreference the old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_renderbuffer *oldRb = *ptr; - - assert(oldRb->Magic == RB_MAGIC); - _glthread_LOCK_MUTEX(oldRb->Mutex); - assert(oldRb->Magic == RB_MAGIC); - ASSERT(oldRb->RefCount > 0); - oldRb->RefCount--; - /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ - deleteFlag = (oldRb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldRb->Mutex); - - if (deleteFlag) { - oldRb->Magic = 0; /* now invalid memory! */ - oldRb->Delete(oldRb); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (rb) { - assert(rb->Magic == RB_MAGIC); - /* reference new renderbuffer */ - _glthread_LOCK_MUTEX(rb->Mutex); - rb->RefCount++; - /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ - _glthread_UNLOCK_MUTEX(rb->Mutex); - *ptr = rb; - } -} - - -/** - * Create a new combined depth/stencil renderbuffer for implementing - * the GL_EXT_packed_depth_stencil extension. - * \return new depth/stencil renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name) -{ - struct gl_renderbuffer *dsrb; - - dsrb = _mesa_new_renderbuffer(ctx, name); - if (!dsrb) - return NULL; - - /* init fields not covered by _mesa_new_renderbuffer() */ - dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT; - dsrb->Format = MESA_FORMAT_Z24_S8; - dsrb->AllocStorage = _mesa_soft_renderbuffer_storage; - - return dsrb; -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * Functions for allocating/managing renderbuffers. + * Also, routines for reading/writing software-based renderbuffer data as + * ubytes, ushorts, uints, etc. + * + * The 'alpha8' renderbuffer is interesting. It's used to add a software-based + * alpha channel to RGB renderbuffers. This is done by wrapping the RGB + * renderbuffer with the alpha renderbuffer. We can do this because of the + * OO-nature of renderbuffers. + * + * Down the road we'll use this for run-time support of 8, 16 and 32-bit + * color channels. For example, Mesa may use 32-bit/float color channels + * internally (swrast) and use wrapper renderbuffers to convert 32-bit + * values down to 16 or 8-bit values for whatever kind of framebuffer we have. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "fbobject.h" +#include "formats.h" +#include "mtypes.h" +#include "renderbuffer.h" + + +/* + * Routines for get/put values in common buffer formats follow. + * Someday add support for arbitrary row stride to make them more + * flexible. + */ + +/********************************************************************** + * Functions for buffers of 1 X GLubyte values. + * Typically stencil. + */ + +static void * +get_pointer_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + /* Can't assert rb->Format since these funcs may be used for serveral + * different formats (GL_ALPHA8, GL_STENCIL_INDEX8, etc). + */ + return (GLubyte *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + memcpy(values, src, count * sizeof(GLubyte)); +} + + +static void +get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, values, count * sizeof(GLubyte)); + } +} + + +static void +put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLushort values. + * Typically depth/Z. + */ + +static void * +get_pointer_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + ASSERT(rb->Width > 0); + return (GLushort *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const void *src = rb->GetPointer(ctx, rb, x, y); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + memcpy(values, src, count * sizeof(GLushort)); +} + + +static void +get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLuint values. + * Typically depth/Z or color index. + */ + +static void * +get_pointer_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + return (GLuint *) rb->Data + y * rb->Width + x; +} + + +static void +get_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const void *src = rb->GetPointer(ctx, rb, x, y); + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + memcpy(values, src, count * sizeof(GLuint)); +} + + +static void +get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLuint)); + } +} + + +static void +put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *value, + const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 3 X GLubyte (or GLbyte) values. + * Typically color buffers. + * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming + * alpha values and return 255 for outgoing alpha values. + */ + +static void * +get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + ASSERT(rb->Format == MESA_FORMAT_RGB888); + /* No direct access since this buffer is RGB but caller will be + * treating it as if it were RGBA. + */ + return NULL; +} + + +static void +get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src + = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[i * 4 + 0] = src[0]; + dst[i * 4 + 1] = src[1]; + dst[i * 4 + 2] = src[2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 4 + 0]; + dst[i * 3 + 1] = src[i * 4 + 1]; + dst[i * 3 + 2] = src[i * 4 + 2]; + } + } +} + + +static void +put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 3 + 0]; + dst[i * 3 + 1] = src[i * 3 + 1]; + dst[i * 3 + 2] = src[i * 3 + 2]; + } + } +} + + +static void +put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x); + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (!mask && val0 == val1 && val1 == val2) { + /* optimized case */ + memset(dst, val0, 3 * count); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = val0; + dst[i * 3 + 1] = val1; + dst[i * 3 + 2] = val2; + } + } + } +} + + +static void +put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + } + } +} + + +static void +put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLubyte (or GLbyte) values. + * Typically color buffers. + */ + +static void * +get_pointer_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + return (GLubyte *) rb->Data + 4 * (y * rb->Width + x); +} + + +static void +get_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = (const GLubyte *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + memcpy(values, src, 4 * count * sizeof(GLubyte)); +} + + +static void +get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + /* treat 4*GLubyte as 1*GLuint */ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLubyte)); + } +} + + +static void +put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Store RGB values in RGBA buffer */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xff; + } + } +} + + +static void +put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (!mask && val == 0) { + /* common case */ + memset(dst, 0, count * 4 * sizeof(GLubyte)); + } + else { + /* general case */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } + } +} + + +static void +put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]); + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLushort (or GLshort) values. + * Typically accum buffer. + */ + +static void * +get_pointer_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + return (GLushort *) rb->Data + 4 * (y * rb->Width + x); +} + + +static void +get_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + memcpy(values, src, 4 * count * sizeof(GLshort)); +} + + +static void +get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src + = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 4 + 0]; + dst[i * 4 + 1] = src[i * 4 + 1]; + dst[i * 4 + 2] = src[i * 4 + 2]; + dst[i * 4 + 3] = src[i * 4 + 3]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Put RGB values in RGBA buffer */ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xffff; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) { + /* common case for clearing accum buffer */ + memset(dst, 0, count * 4 * sizeof(GLushort)); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = val0; + dst[i * 4 + 1] = val1; + dst[i * 4 + 2] = val2; + dst[i * 4 + 3] = val3; + } + } + } +} + + +static void +put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + dst[3] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + dst[3] = val3; + } + } +} + + + +/** + * This is a software fallback for the gl_renderbuffer->AllocStorage + * function. + * Device drivers will typically override this function for the buffers + * which it manages (typically color buffers, Z and stencil). + * Other buffers (like software accumulation and aux buffers) which the driver + * doesn't manage can be handled with this function. + * + * This one multi-purpose function can allocate stencil, depth, accum, color + * or color-index buffers! + * + * This function also plugs in the appropriate GetPointer, Get/PutRow and + * Get/PutValues functions. + */ +GLboolean +_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + GLuint pixelSize; + + switch (internalFormat) { + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + rb->Format = MESA_FORMAT_RGB888; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte3; + rb->GetRow = get_row_ubyte3; + rb->GetValues = get_values_ubyte3; + rb->PutRow = put_row_ubyte3; + rb->PutRowRGB = put_row_rgb_ubyte3; + rb->PutMonoRow = put_mono_row_ubyte3; + rb->PutValues = put_values_ubyte3; + rb->PutMonoValues = put_mono_values_ubyte3; + pixelSize = 3 * sizeof(GLubyte); + break; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: +#if 1 + case GL_RGB10_A2: + case GL_RGBA12: +#endif + rb->Format = MESA_FORMAT_RGBA8888; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte4; + rb->GetRow = get_row_ubyte4; + rb->GetValues = get_values_ubyte4; + rb->PutRow = put_row_ubyte4; + rb->PutRowRGB = put_row_rgb_ubyte4; + rb->PutMonoRow = put_mono_row_ubyte4; + rb->PutValues = put_values_ubyte4; + rb->PutMonoValues = put_mono_values_ubyte4; + pixelSize = 4 * sizeof(GLubyte); + break; + case GL_RGBA16: + case GL_RGBA16_SNORM: + /* for accum buffer */ + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + rb->DataType = GL_SHORT; + rb->GetPointer = get_pointer_ushort4; + rb->GetRow = get_row_ushort4; + rb->GetValues = get_values_ushort4; + rb->PutRow = put_row_ushort4; + rb->PutRowRGB = put_row_rgb_ushort4; + rb->PutMonoRow = put_mono_row_ushort4; + rb->PutValues = put_values_ushort4; + rb->PutMonoValues = put_mono_values_ushort4; + pixelSize = 4 * sizeof(GLushort); + break; +#if 0 + case GL_ALPHA8: + rb->Format = MESA_FORMAT_A8; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_alpha8; + rb->GetRow = get_row_alpha8; + rb->GetValues = get_values_alpha8; + rb->PutRow = put_row_alpha8; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_alpha8; + rb->PutValues = put_values_alpha8; + rb->PutMonoValues = put_mono_values_alpha8; + pixelSize = sizeof(GLubyte); + break; +#endif + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + rb->Format = MESA_FORMAT_S8; + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte; + rb->GetRow = get_row_ubyte; + rb->GetValues = get_values_ubyte; + rb->PutRow = put_row_ubyte; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ubyte; + rb->PutValues = put_values_ubyte; + rb->PutMonoValues = put_mono_values_ubyte; + pixelSize = sizeof(GLubyte); + break; + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + rb->Format = MESA_FORMAT_Z16; + rb->DataType = GL_UNSIGNED_SHORT; + rb->GetPointer = get_pointer_ushort; + rb->GetRow = get_row_ushort; + rb->GetValues = get_values_ushort; + rb->PutRow = put_row_ushort; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ushort; + rb->PutValues = put_values_ushort; + rb->PutMonoValues = put_mono_values_ushort; + pixelSize = sizeof(GLushort); + break; + case GL_DEPTH_COMPONENT24: + rb->DataType = GL_UNSIGNED_INT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + rb->Format = MESA_FORMAT_X8_Z24; + pixelSize = sizeof(GLuint); + break; + case GL_DEPTH_COMPONENT32: + rb->DataType = GL_UNSIGNED_INT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + rb->Format = MESA_FORMAT_Z32; + pixelSize = sizeof(GLuint); + break; + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + rb->Format = MESA_FORMAT_Z24_S8; + rb->DataType = GL_UNSIGNED_INT_24_8_EXT; + rb->GetPointer = get_pointer_uint; + rb->GetRow = get_row_uint; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + pixelSize = sizeof(GLuint); + break; + default: + _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage"); + return GL_FALSE; + } + + ASSERT(rb->DataType); + ASSERT(rb->GetPointer); + ASSERT(rb->GetRow); + ASSERT(rb->GetValues); + ASSERT(rb->PutRow); + ASSERT(rb->PutMonoRow); + ASSERT(rb->PutValues); + ASSERT(rb->PutMonoValues); + + /* free old buffer storage */ + if (rb->Data) { + free(rb->Data); + rb->Data = NULL; + } + + if (width > 0 && height > 0) { + /* allocate new buffer storage */ + rb->Data = malloc(width * height * pixelSize); + + if (rb->Data == NULL) { + rb->Width = 0; + rb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "software renderbuffer allocation (%d x %d x %d)", + width, height, pixelSize); + return GL_FALSE; + } + } + + rb->Width = width; + rb->Height = height; + rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); + ASSERT(rb->_BaseFormat); + + return GL_TRUE; +} + + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha + * buffer wrapper around an existing RGB renderbuffer (hw or sw). + * + * When PutRow is called (for example), we store the alpha values in + * this buffer, then pass on the PutRow call to the wrapped RGB + * buffer. + */ + + +static GLboolean +alloc_storage_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLenum internalFormat, GLuint width, GLuint height) +{ + ASSERT(arb != arb->Wrapped); + ASSERT(arb->Format == MESA_FORMAT_A8); + + /* first, pass the call to the wrapped RGB buffer */ + if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat, + width, height)) { + return GL_FALSE; + } + + /* next, resize my alpha buffer */ + if (arb->Data) { + free(arb->Data); + } + + arb->Data = malloc(width * height * sizeof(GLubyte)); + if (arb->Data == NULL) { + arb->Width = 0; + arb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation"); + return GL_FALSE; + } + + arb->Width = width; + arb->Height = height; + + return GL_TRUE; +} + + +/** + * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer. + */ +static void +delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) +{ + if (arb->Data) { + free(arb->Data); + } + ASSERT(arb->Wrapped); + ASSERT(arb != arb->Wrapped); + arb->Wrapped->Delete(arb->Wrapped); + arb->Wrapped = NULL; + free(arb); +} + + +static void * +get_pointer_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLint x, GLint y) +{ + return NULL; /* don't allow direct access! */ +} + + +static void +get_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, void *values) +{ + /* NOTE: 'values' is RGBA format! */ + const GLubyte *src = (const GLubyte *) arb->Data + y * arb->Width + x; + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + dst[i * 4 + 3] = src[i]; + } +} + + +static void +get_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + dst[i * 4 + 3] = *src; + } +} + + +static void +put_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_row_rgb_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + memset(dst, val, count); + } +} + + +static void +put_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + *dst = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i]; + *dst = val; + } + } +} + + +static void +copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) +{ + ASSERT(dst->Format == MESA_FORMAT_A8); + ASSERT(src->Format == MESA_FORMAT_A8); + ASSERT(dst->Width == src->Width); + ASSERT(dst->Height == src->Height); + + memcpy(dst->Data, src->Data, dst->Width * dst->Height * sizeof(GLubyte)); +} + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Default GetPointer routine. Always return NULL to indicate that + * direct buffer access is not supported. + */ +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + return NULL; +} + + +/** + * Initialize the fields of a gl_renderbuffer to default values. + */ +void +_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) +{ + _glthread_INIT_MUTEX(rb->Mutex); + + rb->Magic = RB_MAGIC; + rb->ClassID = 0; + rb->Name = name; + rb->RefCount = 0; + rb->Delete = _mesa_delete_renderbuffer; + + /* The rest of these should be set later by the caller of this function or + * the AllocStorage method: + */ + rb->AllocStorage = NULL; + + rb->Width = 0; + rb->Height = 0; + rb->InternalFormat = GL_NONE; + rb->Format = MESA_FORMAT_NONE; + + rb->DataType = GL_NONE; + rb->Data = NULL; + + /* Point back to ourself so that we don't have to check for Wrapped==NULL + * all over the drivers. + */ + rb->Wrapped = rb; + + rb->GetPointer = nop_get_pointer; + rb->GetRow = NULL; + rb->GetValues = NULL; + rb->PutRow = NULL; + rb->PutRowRGB = NULL; + rb->PutMonoRow = NULL; + rb->PutValues = NULL; + rb->PutMonoValues = NULL; +} + + +/** + * Allocate a new gl_renderbuffer object. This can be used for user-created + * renderbuffers or window-system renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); + if (rb) { + _mesa_init_renderbuffer(rb, name); + } + return rb; +} + + +/** + * Delete a gl_framebuffer. + * This is the default function for renderbuffer->Delete(). + */ +void +_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) +{ + if (rb->Data) { + free(rb->Data); + } + free(rb); +} + + +/** + * Allocate a software-based renderbuffer. This is called via the + * ctx->Driver.NewRenderbuffer() function when the user creates a new + * renderbuffer. + * This would not be used for hardware-based renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); + if (rb) { + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + /* Normally, one would setup the PutRow, GetRow, etc functions here. + * But we're doing that in the _mesa_soft_renderbuffer_storage() function + * instead. + */ + } + return rb; +} + + +/** + * Add software-based color renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint rgbBits, GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + GLuint b; + + if (rgbBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_color_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *rb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + assert(fb->Attachment[b].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); + return GL_FALSE; + } + + if (rgbBits <= 8) { + if (alphaBits) + rb->Format = MESA_FORMAT_RGBA8888; + else + rb->Format = MESA_FORMAT_RGB888; + } + else { + assert(rgbBits <= 16); + rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/ + } + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, b, rb); + } + + return GL_TRUE; +} + + +/** + * Add software-based alpha renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + GLuint b; + + /* for window system framebuffers only! */ + assert(fb->Name == 0); + + if (alphaBits > 8) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_alpha_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + /* Wrap each of the RGB color buffers with an alpha renderbuffer. + */ + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *arb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + /* the RGB buffer to wrap must already exist!! */ + assert(fb->Attachment[b].Renderbuffer); + + /* only GLubyte supported for now */ + assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE); + + /* allocate alpha renderbuffer */ + arb = _mesa_new_renderbuffer(ctx, 0); + if (!arb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer"); + return GL_FALSE; + } + + /* wrap the alpha renderbuffer around the RGB renderbuffer */ + arb->Wrapped = fb->Attachment[b].Renderbuffer; + + /* Set up my alphabuffer fields and plug in my functions. + * The functions will put/get the alpha values from/to RGBA arrays + * and then call the wrapped buffer's functions to handle the RGB + * values. + */ + arb->InternalFormat = arb->Wrapped->InternalFormat; + arb->Format = MESA_FORMAT_A8; + arb->DataType = arb->Wrapped->DataType; + arb->AllocStorage = alloc_storage_alpha8; + arb->Delete = delete_renderbuffer_alpha8; + arb->GetPointer = get_pointer_alpha8; + arb->GetRow = get_row_alpha8; + arb->GetValues = get_values_alpha8; + arb->PutRow = put_row_alpha8; + arb->PutRowRGB = put_row_rgb_alpha8; + arb->PutMonoRow = put_mono_row_alpha8; + arb->PutValues = put_values_alpha8; + arb->PutMonoValues = put_mono_values_alpha8; + + /* clear the pointer to avoid assertion/sanity check failure later */ + fb->Attachment[b].Renderbuffer = NULL; + + /* plug the alpha renderbuffer into the colorbuffer attachment */ + _mesa_add_renderbuffer(fb, b, arb); + } + + return GL_TRUE; +} + + +/** + * For framebuffers that use a software alpha channel wrapper + * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, + * copy the back buffer alpha channel into the front buffer alpha channel. + */ +void +_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + + + if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); +} + + +/** + * Add a software-based depth renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint depthBits) +{ + struct gl_renderbuffer *rb; + + if (depthBits > 32) { + _mesa_problem(ctx, + "Unsupported depthBits in _mesa_add_depth_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); + return GL_FALSE; + } + + if (depthBits <= 16) { + rb->Format = MESA_FORMAT_Z16; + rb->InternalFormat = GL_DEPTH_COMPONENT16; + } + else if (depthBits <= 24) { + rb->Format = MESA_FORMAT_X8_Z24; + rb->InternalFormat = GL_DEPTH_COMPONENT24; + } + else { + rb->Format = MESA_FORMAT_Z32; + rb->InternalFormat = GL_DEPTH_COMPONENT32; + } + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based stencil renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint stencilBits) +{ + struct gl_renderbuffer *rb; + + if (stencilBits > 16) { + _mesa_problem(ctx, + "Unsupported stencilBits in _mesa_add_stencil_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); + return GL_FALSE; + } + + assert(stencilBits <= 8); + rb->Format = MESA_FORMAT_S8; + rb->InternalFormat = GL_STENCIL_INDEX8; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based accumulation renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint redBits, GLuint greenBits, + GLuint blueBits, GLuint alphaBits) +{ + struct gl_renderbuffer *rb; + + if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_accum_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); + return GL_FALSE; + } + + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + rb->InternalFormat = GL_RGBA16_SNORM; + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); + + return GL_TRUE; +} + + + +/** + * Add a software-based aux renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + * + * NOTE: color-index aux buffers not supported. + */ +GLboolean +_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint colorBits, GLuint numBuffers) +{ + GLuint i; + + if (colorBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_aux_renderbuffers"); + return GL_FALSE; + } + + assert(numBuffers <= MAX_AUX_BUFFERS); + + for (i = 0; i < numBuffers; i++) { + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); + + assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); + + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer"); + return GL_FALSE; + } + + assert (colorBits <= 8); + rb->Format = MESA_FORMAT_RGBA8888; + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); + } + return GL_TRUE; +} + + +/** + * Create/attach software-based renderbuffers to the given framebuffer. + * This is a helper routine for device drivers. Drivers can just as well + * call the individual _mesa_add_*_renderbuffer() routines directly. + */ +void +_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, + GLboolean color, + GLboolean depth, + GLboolean stencil, + GLboolean accum, + GLboolean alpha, + GLboolean aux) +{ + GLboolean frontLeft = GL_TRUE; + GLboolean backLeft = fb->Visual.doubleBufferMode; + GLboolean frontRight = fb->Visual.stereoMode; + GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode; + + if (color) { + assert(fb->Visual.redBits == fb->Visual.greenBits); + assert(fb->Visual.redBits == fb->Visual.blueBits); + _mesa_add_color_renderbuffers(NULL, fb, + fb->Visual.redBits, + fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + + if (depth) { + assert(fb->Visual.depthBits > 0); + _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); + } + + if (stencil) { + assert(fb->Visual.stencilBits > 0); + _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + } + + if (accum) { + assert(fb->Visual.accumRedBits > 0); + assert(fb->Visual.accumGreenBits > 0); + assert(fb->Visual.accumBlueBits > 0); + _mesa_add_accum_renderbuffer(NULL, fb, + fb->Visual.accumRedBits, + fb->Visual.accumGreenBits, + fb->Visual.accumBlueBits, + fb->Visual.accumAlphaBits); + } + + if (aux) { + assert(fb->Visual.numAuxBuffers > 0); + _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, + fb->Visual.numAuxBuffers); + } + + if (alpha) { + assert(fb->Visual.alphaBits > 0); + _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + +#if 0 + if (multisample) { + /* maybe someday */ + } +#endif +} + + +/** + * Attach a renderbuffer to a framebuffer. + */ +void +_mesa_add_renderbuffer(struct gl_framebuffer *fb, + GLuint bufferName, struct gl_renderbuffer *rb) +{ + assert(fb); + assert(rb); + assert(bufferName < BUFFER_COUNT); + + /* There should be no previous renderbuffer on this attachment point, + * with the exception of depth/stencil since the same renderbuffer may + * be used for both. + */ + assert(bufferName == BUFFER_DEPTH || + bufferName == BUFFER_STENCIL || + fb->Attachment[bufferName].Renderbuffer == NULL); + + /* winsys vs. user-created buffer cross check */ + if (fb->Name) { + assert(rb->Name); + } + else { + assert(!rb->Name); + } + + fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; + fb->Attachment[bufferName].Complete = GL_TRUE; + _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); +} + + +/** + * Remove the named renderbuffer from the given framebuffer. + */ +void +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName) +{ + struct gl_renderbuffer *rb; + + assert(bufferName < BUFFER_COUNT); + + rb = fb->Attachment[bufferName].Renderbuffer; + if (!rb) + return; + + _mesa_reference_renderbuffer(&rb, NULL); + + fb->Attachment[bufferName].Renderbuffer = NULL; +} + + +/** + * Set *ptr to point to rb. If *ptr points to another renderbuffer, + * dereference that buffer first. The new renderbuffer's refcount will + * be incremented. The old renderbuffer's refcount will be decremented. + */ +void +_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb) +{ + assert(ptr); + if (*ptr == rb) { + /* no change */ + return; + } + + if (*ptr) { + /* Unreference the old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_renderbuffer *oldRb = *ptr; + + assert(oldRb->Magic == RB_MAGIC); + _glthread_LOCK_MUTEX(oldRb->Mutex); + assert(oldRb->Magic == RB_MAGIC); + ASSERT(oldRb->RefCount > 0); + oldRb->RefCount--; + /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ + deleteFlag = (oldRb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldRb->Mutex); + + if (deleteFlag) { + oldRb->Magic = 0; /* now invalid memory! */ + oldRb->Delete(oldRb); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (rb) { + assert(rb->Magic == RB_MAGIC); + /* reference new renderbuffer */ + _glthread_LOCK_MUTEX(rb->Mutex); + rb->RefCount++; + /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ + _glthread_UNLOCK_MUTEX(rb->Mutex); + *ptr = rb; + } +} + + +/** + * Create a new combined depth/stencil renderbuffer for implementing + * the GL_EXT_packed_depth_stencil extension. + * \return new depth/stencil renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *dsrb; + + dsrb = _mesa_new_renderbuffer(ctx, name); + if (!dsrb) + return NULL; + + /* init fields not covered by _mesa_new_renderbuffer() */ + dsrb->InternalFormat = GL_DEPTH24_STENCIL8_EXT; + dsrb->Format = MESA_FORMAT_Z24_S8; + dsrb->AllocStorage = _mesa_soft_renderbuffer_storage; + + return dsrb; +} diff --git a/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h index bc92b2698..c93eef4b8 100644 --- a/mesalib/src/mesa/main/renderbuffer.h +++ b/mesalib/src/mesa/main/renderbuffer.h @@ -1,111 +1,111 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef RENDERBUFFER_H -#define RENDERBUFFER_H - -#include "glheader.h" -#include "mtypes.h" - -struct gl_framebuffer; -struct gl_renderbuffer; - -extern void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); - -extern struct gl_renderbuffer * -_mesa_new_renderbuffer(GLcontext *ctx, GLuint name); - -extern void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); - - -extern struct gl_renderbuffer * -_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name); - - -extern GLboolean -_mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height); - -extern GLboolean -_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint rgbBits, GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight); - -extern GLboolean -_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight); - -extern void -_mesa_copy_soft_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb); - -extern GLboolean -_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint depthBits); - -extern GLboolean -_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint stencilBits); - - -extern GLboolean -_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint redBits, GLuint greenBits, - GLuint blueBits, GLuint alphaBits); - -extern GLboolean -_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb, - GLuint bits, GLuint numBuffers); - -extern void -_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux); - -extern void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - GLuint bufferName, struct gl_renderbuffer *rb); - -extern void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName); - -extern void -_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb); - -extern struct gl_renderbuffer * -_mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name); - - -#endif /* RENDERBUFFER_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef RENDERBUFFER_H +#define RENDERBUFFER_H + +#include "glheader.h" + +struct gl_context; +struct gl_framebuffer; +struct gl_renderbuffer; + +extern void +_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); + +extern struct gl_renderbuffer * +_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name); + +extern void +_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); + + +extern struct gl_renderbuffer * +_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name); + + +extern GLboolean +_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height); + +extern GLboolean +_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint rgbBits, GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight); + +extern GLboolean +_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight); + +extern void +_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb); + +extern GLboolean +_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint depthBits); + +extern GLboolean +_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint stencilBits); + + +extern GLboolean +_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint redBits, GLuint greenBits, + GLuint blueBits, GLuint alphaBits); + +extern GLboolean +_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint bits, GLuint numBuffers); + +extern void +_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, + GLboolean color, + GLboolean depth, + GLboolean stencil, + GLboolean accum, + GLboolean alpha, + GLboolean aux); + +extern void +_mesa_add_renderbuffer(struct gl_framebuffer *fb, + GLuint bufferName, struct gl_renderbuffer *rb); + +extern void +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName); + +extern void +_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb); + +extern struct gl_renderbuffer * +_mesa_new_depthstencil_renderbuffer(struct gl_context *ctx, GLuint name); + + +#endif /* RENDERBUFFER_H */ diff --git a/mesalib/src/mesa/main/scissor.c b/mesalib/src/mesa/main/scissor.c index 523f3c3ab..716b16b80 100644 --- a/mesalib/src/mesa/main/scissor.c +++ b/mesalib/src/mesa/main/scissor.c @@ -1,99 +1,99 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/scissor.h" - - -/** - * Called via glScissor - */ -void GLAPIENTRY -_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" ); - return; - } - - _mesa_set_scissor(ctx, x, y, width, height); -} - - -/** - * Define the scissor box. - * - * \param x, y coordinates of the scissor box lower-left corner. - * \param width width of the scissor box. - * \param height height of the scissor box. - * - * \sa glScissor(). - * - * Verifies the parameters and updates __GLcontextRec::Scissor. On a - * change flushes the vertices and notifies the driver via - * the dd_function_table::Scissor callback. - */ -void -_mesa_set_scissor(GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - if (x == ctx->Scissor.X && - y == ctx->Scissor.Y && - width == ctx->Scissor.Width && - height == ctx->Scissor.Height) - return; - - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.X = x; - ctx->Scissor.Y = y; - ctx->Scissor.Width = width; - ctx->Scissor.Height = height; - - if (ctx->Driver.Scissor) - ctx->Driver.Scissor( ctx, x, y, width, height ); -} - - -/** - * Initialize the context's scissor state. - * \param ctx the GL context. - */ -void -_mesa_init_scissor(GLcontext *ctx) -{ - /* Scissor group */ - ctx->Scissor.Enabled = GL_FALSE; - ctx->Scissor.X = 0; - ctx->Scissor.Y = 0; - ctx->Scissor.Width = 0; - ctx->Scissor.Height = 0; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/scissor.h" + + +/** + * Called via glScissor + */ +void GLAPIENTRY +_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" ); + return; + } + + _mesa_set_scissor(ctx, x, y, width, height); +} + + +/** + * Define the scissor box. + * + * \param x, y coordinates of the scissor box lower-left corner. + * \param width width of the scissor box. + * \param height height of the scissor box. + * + * \sa glScissor(). + * + * Verifies the parameters and updates __struct gl_contextRec::Scissor. On a + * change flushes the vertices and notifies the driver via + * the dd_function_table::Scissor callback. + */ +void +_mesa_set_scissor(struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + if (x == ctx->Scissor.X && + y == ctx->Scissor.Y && + width == ctx->Scissor.Width && + height == ctx->Scissor.Height) + return; + + FLUSH_VERTICES(ctx, _NEW_SCISSOR); + ctx->Scissor.X = x; + ctx->Scissor.Y = y; + ctx->Scissor.Width = width; + ctx->Scissor.Height = height; + + if (ctx->Driver.Scissor) + ctx->Driver.Scissor( ctx, x, y, width, height ); +} + + +/** + * Initialize the context's scissor state. + * \param ctx the GL context. + */ +void +_mesa_init_scissor(struct gl_context *ctx) +{ + /* Scissor group */ + ctx->Scissor.Enabled = GL_FALSE; + ctx->Scissor.X = 0; + ctx->Scissor.Y = 0; + ctx->Scissor.Width = 0; + ctx->Scissor.Height = 0; +} diff --git a/mesalib/src/mesa/main/scissor.h b/mesalib/src/mesa/main/scissor.h index b852a2122..8735ec0cd 100644 --- a/mesalib/src/mesa/main/scissor.h +++ b/mesalib/src/mesa/main/scissor.h @@ -1,46 +1,47 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SCISSOR_H -#define SCISSOR_H - - -#include "main/mtypes.h" - - -extern void GLAPIENTRY -_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ); - - -extern void -_mesa_set_scissor(GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height); - - -extern void -_mesa_init_scissor(GLcontext *ctx); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef SCISSOR_H +#define SCISSOR_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ); + + +extern void +_mesa_set_scissor(struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height); + + +extern void +_mesa_init_scissor(struct gl_context *ctx); + + +#endif diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index c25d2a197..d84273263 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -1,1642 +1,1886 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file shaderapi.c - * \author Brian Paul - * - * Implementation of GLSL-related API functions. - * The glUniform* functions are in uniforms.c - * - * - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/enums.h" -#include "main/hash.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_uniform.h" -#include "talloc.h" - - -/** Define this to enable shader substitution (see below) */ -#define SHADER_SUBST 0 - - -/** - * Return mask of GLSL_x flags by examining the MESA_GLSL env var. - */ -static GLbitfield -get_shader_flags(void) -{ - GLbitfield flags = 0x0; - const char *env = _mesa_getenv("MESA_GLSL"); - - if (env) { - if (strstr(env, "dump")) - flags |= GLSL_DUMP; - if (strstr(env, "log")) - flags |= GLSL_LOG; - if (strstr(env, "nopvert")) - flags |= GLSL_NOP_VERT; - if (strstr(env, "nopfrag")) - flags |= GLSL_NOP_FRAG; - if (strstr(env, "nopt")) - flags |= GLSL_NO_OPT; - else if (strstr(env, "opt")) - flags |= GLSL_OPT; - if (strstr(env, "uniform")) - flags |= GLSL_UNIFORMS; - if (strstr(env, "useprog")) - flags |= GLSL_USE_PROG; - } - - return flags; -} - - -/** - * Initialize context's shader state. - */ -void -_mesa_init_shader_state(GLcontext *ctx) -{ - /* Device drivers may override these to control what kind of instructions - * are generated by the GLSL compiler. - */ - struct gl_shader_compiler_options options; - GLuint i; - - memset(&options, 0, sizeof(options)); - options.MaxUnrollIterations = 32; - - /* Default pragma settings */ - options.DefaultPragmas.Optimize = GL_TRUE; - - for(i = 0; i < MESA_SHADER_TYPES; ++i) - memcpy(&ctx->ShaderCompilerOptions[i], &options, sizeof(options)); - - ctx->Shader.Flags = get_shader_flags(); -} - - -/** - * Free the per-context shader-related state. - */ -void -_mesa_free_shader_state(GLcontext *ctx) -{ - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, NULL); -} - - -/** - * Return the size of the given GLSL datatype, in floats (components). - */ -GLint -_mesa_sizeof_glsl_type(GLenum type) -{ - switch (type) { - case GL_FLOAT: - case GL_INT: - case GL_BOOL: - case GL_SAMPLER_1D: - case GL_SAMPLER_2D: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_2D_RECT_ARB: - case GL_SAMPLER_2D_RECT_SHADOW_ARB: - case GL_SAMPLER_1D_ARRAY_EXT: - case GL_SAMPLER_2D_ARRAY_EXT: - case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_CUBE_SHADOW_EXT: - return 1; - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_UNSIGNED_INT_VEC2: - case GL_BOOL_VEC2: - return 2; - case GL_FLOAT_VEC3: - case GL_INT_VEC3: - case GL_UNSIGNED_INT_VEC3: - case GL_BOOL_VEC3: - return 3; - case GL_FLOAT_VEC4: - case GL_INT_VEC4: - case GL_UNSIGNED_INT_VEC4: - case GL_BOOL_VEC4: - return 4; - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - return 8; /* two float[4] vectors */ - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3x4: - return 12; /* three float[4] vectors */ - case GL_FLOAT_MAT4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - return 16; /* four float[4] vectors */ - default: - _mesa_problem(NULL, "Invalid type in _mesa_sizeof_glsl_type()"); - return 1; - } -} - - -/** - * Copy string from to , up to maxLength characters, returning - * length of in . - * \param src the strings source - * \param maxLength max chars to copy - * \param length returns number of chars copied - * \param dst the string destination - */ -void -_mesa_copy_string(GLchar *dst, GLsizei maxLength, - GLsizei *length, const GLchar *src) -{ - GLsizei len; - for (len = 0; len < maxLength - 1 && src && src[len]; len++) - dst[len] = src[len]; - if (maxLength > 0) - dst[len] = 0; - if (length) - *length = len; -} - - - -/** - * Find the length of the longest transform feedback varying name - * which was specified with glTransformFeedbackVaryings(). - */ -static GLint -longest_feedback_varying_name(const struct gl_shader_program *shProg) -{ - GLuint i; - GLint max = 0; - for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { - GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); - if (len > max) - max = len; - } - return max; -} - - - -static GLboolean -is_program(GLcontext *ctx, GLuint name) -{ - struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name); - return shProg ? GL_TRUE : GL_FALSE; -} - - -static GLboolean -is_shader(GLcontext *ctx, GLuint name) -{ - struct gl_shader *shader = _mesa_lookup_shader(ctx, name); - return shader ? GL_TRUE : GL_FALSE; -} - - -/** - * Attach shader to a shader program. - */ -static void -attach_shader(GLcontext *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - struct gl_shader *sh; - GLuint i, n; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); - if (!shProg) - return; - - sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader"); - if (!sh) { - return; - } - - n = shProg->NumShaders; - for (i = 0; i < n; i++) { - if (shProg->Shaders[i] == sh) { - /* The shader is already attched to this program. The - * GL_ARB_shader_objects spec says: - * - * "The error INVALID_OPERATION is generated by AttachObjectARB - * if is already attached to ." - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); - return; - } - } - - /* grow list */ - shProg->Shaders = (struct gl_shader **) - _mesa_realloc(shProg->Shaders, - n * sizeof(struct gl_shader *), - (n + 1) * sizeof(struct gl_shader *)); - if (!shProg->Shaders) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader"); - return; - } - - /* append */ - shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ - _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); - shProg->NumShaders++; -} - - -static GLint -get_attrib_location(GLcontext *ctx, GLuint program, const GLchar *name) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); - - if (!shProg) { - return -1; - } - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetAttribLocation(program not linked)"); - return -1; - } - - if (!name) - return -1; - - if (shProg->VertexProgram) { - const struct gl_program_parameter_list *attribs = - shProg->VertexProgram->Base.Attributes; - if (attribs) { - GLint i = _mesa_lookup_parameter_index(attribs, -1, name); - if (i >= 0) { - return attribs->Parameters[i].StateIndexes[0]; - } - } - } - return -1; -} - - -static void -bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, - const GLchar *name) -{ - struct gl_shader_program *shProg; - const GLint size = -1; /* unknown size */ - GLint i, oldIndex; - GLenum datatype = GL_FLOAT_VEC4; - - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glBindAttribLocation"); - if (!shProg) { - return; - } - - if (!name) - return; - - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindAttribLocation(illegal name)"); - return; - } - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)"); - return; - } - - if (shProg->LinkStatus) { - /* get current index/location for the attribute */ - oldIndex = get_attrib_location(ctx, program, name); - } - else { - oldIndex = -1; - } - - /* this will replace the current value if it's already in the list */ - i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); - if (i < 0) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation"); - return; - } - - /* - * Note that this attribute binding won't go into effect until - * glLinkProgram is called again. - */ -} - - -static GLuint -create_shader(GLcontext *ctx, GLenum type) -{ - struct gl_shader *sh; - GLuint name; - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - - switch (type) { - case GL_FRAGMENT_SHADER: - case GL_VERTEX_SHADER: - case GL_GEOMETRY_SHADER_ARB: - sh = ctx->Driver.NewShader(ctx, name, type); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)"); - return 0; - } - - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh); - - return name; -} - - -static GLuint -create_shader_program(GLcontext *ctx) -{ - GLuint name; - struct gl_shader_program *shProg; - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - - shProg = ctx->Driver.NewShaderProgram(ctx, name); - - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg); - - assert(shProg->RefCount == 1); - - return name; -} - - -/** - * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's - * DeleteProgramARB. - */ -static void -delete_shader_program(GLcontext *ctx, GLuint name) -{ - /* - * NOTE: deleting shaders/programs works a bit differently than - * texture objects (and buffer objects, etc). Shader/program - * handles/IDs exist in the hash table until the object is really - * deleted (refcount==0). With texture objects, the handle/ID is - * removed from the hash table in glDeleteTextures() while the tex - * object itself might linger until its refcount goes to zero. - */ - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram"); - if (!shProg) - return; - - shProg->DeletePending = GL_TRUE; - - /* effectively, decr shProg's refcount */ - _mesa_reference_shader_program(ctx, &shProg, NULL); -} - - -static void -delete_shader(GLcontext *ctx, GLuint shader) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader"); - if (!sh) - return; - - sh->DeletePending = GL_TRUE; - - /* effectively, decr sh's refcount */ - _mesa_reference_shader(ctx, &sh, NULL); -} - - -static void -detach_shader(GLcontext *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - GLuint n; - GLuint i, j; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); - if (!shProg) - return; - - n = shProg->NumShaders; - - for (i = 0; i < n; i++) { - if (shProg->Shaders[i]->Name == shader) { - /* found it */ - struct gl_shader **newList; - - /* release */ - _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); - - /* alloc new, smaller array */ - newList = (struct gl_shader **) - malloc((n - 1) * sizeof(struct gl_shader *)); - if (!newList) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); - return; - } - for (j = 0; j < i; j++) { - newList[j] = shProg->Shaders[j]; - } - while (++i < n) - newList[j++] = shProg->Shaders[i]; - free(shProg->Shaders); - - shProg->Shaders = newList; - shProg->NumShaders = n - 1; - -#ifdef DEBUG - /* sanity check */ - { - for (j = 0; j < shProg->NumShaders; j++) { - assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || - shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); - assert(shProg->Shaders[j]->RefCount > 0); - } - } -#endif - - return; - } - } - - /* not found */ - { - GLenum err; - if (is_shader(ctx, shader)) - err = GL_INVALID_OPERATION; - else if (is_program(ctx, shader)) - err = GL_INVALID_OPERATION; - else - err = GL_INVALID_VALUE; - _mesa_error(ctx, err, "glDetachProgram(shader)"); - return; - } -} - - -static void -get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLchar *nameOut) -{ - const struct gl_program_parameter_list *attribs = NULL; - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); - if (!shProg) - return; - - if (shProg->VertexProgram) - attribs = shProg->VertexProgram->Base.Attributes; - - if (!attribs || index >= attribs->NumParameters) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); - return; - } - - _mesa_copy_string(nameOut, maxLength, length, - attribs->Parameters[index].Name); - - if (size) - *size = attribs->Parameters[index].Size - / _mesa_sizeof_glsl_type(attribs->Parameters[index].DataType); - - if (type) - *type = attribs->Parameters[index].DataType; -} - - -/** - * Return list of shaders attached to shader program. - */ -static void -get_attached_shaders(GLcontext *ctx, GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders"); - if (shProg) { - GLuint i; - for (i = 0; i < (GLuint) maxCount && i < shProg->NumShaders; i++) { - obj[i] = shProg->Shaders[i]->Name; - } - if (count) - *count = i; - } -} - - -/** - * glGetHandleARB() - return ID/name of currently bound shader program. - */ -static GLuint -get_handle(GLcontext *ctx, GLenum pname) -{ - if (pname == GL_PROGRAM_OBJECT_ARB) { - if (ctx->Shader.CurrentProgram) - return ctx->Shader.CurrentProgram->Name; - else - return 0; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); - return 0; - } -} - - -/** - * glGetProgramiv() - get shader program state. - * Note that this is for GLSL shader programs, not ARB vertex/fragment - * programs (see glGetProgramivARB). - */ -static void -get_programiv(GLcontext *ctx, GLuint program, GLenum pname, GLint *params) -{ - const struct gl_program_parameter_list *attribs; - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); - return; - } - - if (shProg->VertexProgram) - attribs = shProg->VertexProgram->Base.Attributes; - else - attribs = NULL; - - switch (pname) { - case GL_DELETE_STATUS: - *params = shProg->DeletePending; - break; - case GL_LINK_STATUS: - *params = shProg->LinkStatus; - break; - case GL_VALIDATE_STATUS: - *params = shProg->Validated; - break; - case GL_INFO_LOG_LENGTH: - *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; - break; - case GL_ATTACHED_SHADERS: - *params = shProg->NumShaders; - break; - case GL_ACTIVE_ATTRIBUTES: - *params = attribs ? attribs->NumParameters : 0; - break; - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; - break; - case GL_ACTIVE_UNIFORMS: - *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; - break; - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - *params = _mesa_longest_uniform_name(shProg->Uniforms); - if (*params > 0) - (*params)++; /* add one for terminating zero */ - break; - case GL_PROGRAM_BINARY_LENGTH_OES: - *params = 0; - break; -#if FEATURE_EXT_transform_feedback - case GL_TRANSFORM_FEEDBACK_VARYINGS: - *params = shProg->TransformFeedback.NumVarying; - break; - case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: - *params = longest_feedback_varying_name(shProg) + 1; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: - *params = shProg->TransformFeedback.BufferMode; - break; -#endif -#if FEATURE_ARB_geometry_shader4 - case GL_GEOMETRY_VERTICES_OUT_ARB: - *params = shProg->Geom.VerticesOut; - break; - case GL_GEOMETRY_INPUT_TYPE_ARB: - *params = shProg->Geom.InputType; - break; - case GL_GEOMETRY_OUTPUT_TYPE_ARB: - *params = shProg->Geom.OutputType; - break; -#endif - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); - return; - } -} - - -/** - * glGetShaderiv() - get GLSL shader state - */ -static void -get_shaderiv(GLcontext *ctx, GLuint name, GLenum pname, GLint *params) -{ - struct gl_shader *shader = - _mesa_lookup_shader_err(ctx, name, "glGetShaderiv"); - - if (!shader) { - return; - } - - switch (pname) { - case GL_SHADER_TYPE: - *params = shader->Type; - break; - case GL_DELETE_STATUS: - *params = shader->DeletePending; - break; - case GL_COMPILE_STATUS: - *params = shader->CompileStatus; - break; - case GL_INFO_LOG_LENGTH: - *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; - break; - case GL_SHADER_SOURCE_LENGTH: - *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); - return; - } -} - - -static void -get_program_info_log(GLcontext *ctx, GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); -} - - -static void -get_shader_info_log(GLcontext *ctx, GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); - if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); -} - - -/** - * Return shader source code. - */ -static void -get_shader_source(GLcontext *ctx, GLuint shader, GLsizei maxLength, - GLsizei *length, GLchar *sourceOut) -{ - struct gl_shader *sh; - sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource"); - if (!sh) { - return; - } - _mesa_copy_string(sourceOut, maxLength, length, sh->Source); -} - - -/** - * Set/replace shader source code. - */ -static void -shader_source(GLcontext *ctx, GLuint shader, const GLchar *source) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource"); - if (!sh) - return; - - /* free old shader source string and install new one */ - if (sh->Source) { - free((void *) sh->Source); - } - sh->Source = source; - sh->CompileStatus = GL_FALSE; -#ifdef DEBUG - sh->SourceChecksum = _mesa_str_checksum(sh->Source); -#endif -} - - -/** - * Compile a shader. - */ -static void -compile_shader(GLcontext *ctx, GLuint shaderObj) -{ - struct gl_shader *sh; - struct gl_shader_compiler_options *options; - - sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); - if (!sh) - return; - - options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; - - /* set default pragma state for shader */ - sh->Pragmas = options->DefaultPragmas; - - /* this call will set the sh->CompileStatus field to indicate if - * compilation was successful. - */ - _mesa_glsl_compile_shader(ctx, sh); -} - - -/** - * Link a program's shaders. - */ -static void -link_program(GLcontext *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); - if (!shProg) - return; - - if (obj->Active && shProg == ctx->Shader.CurrentProgram) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLinkProgram(transform feedback active"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - _mesa_glsl_link_shader(ctx, shProg); - - /* debug code */ - if (0) { - GLuint i; - - printf("Link %u shaders in program %u: %s\n", - shProg->NumShaders, shProg->Name, - shProg->LinkStatus ? "Success" : "Failed"); - - for (i = 0; i < shProg->NumShaders; i++) { - printf(" shader %u, type 0x%x\n", - shProg->Shaders[i]->Name, - shProg->Shaders[i]->Type); - } - } -} - - -/** - * Print basic shader info (for debug). - */ -static void -print_shader_info(const struct gl_shader_program *shProg) -{ - GLuint i; - - printf("Mesa: glUseProgram(%u)\n", shProg->Name); - for (i = 0; i < shProg->NumShaders; i++) { - const char *s; - switch (shProg->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - s = "vertex"; - break; - case GL_FRAGMENT_SHADER: - s = "fragment"; - break; - case GL_GEOMETRY_SHADER: - s = "geometry"; - break; - default: - s = ""; - } - printf(" %s shader %u, checksum %u\n", s, - shProg->Shaders[i]->Name, - shProg->Shaders[i]->SourceChecksum); - } - if (shProg->VertexProgram) - printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); - if (shProg->FragmentProgram) - printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); -} - - -/** - * Use the named shader program for subsequent rendering. - */ -void -_mesa_use_program(GLcontext *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(transform feedback active)"); - return; - } - - if (ctx->Shader.CurrentProgram && - ctx->Shader.CurrentProgram->Name == program) { - /* no-op */ - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); - if (!shProg) { - return; - } - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(program %u not linked)", program); - return; - } - - /* debug code */ - if (ctx->Shader.Flags & GLSL_USE_PROG) { - print_shader_info(shProg); - } - } - else { - shProg = NULL; - } - - if (ctx->Shader.CurrentProgram != shProg) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, shProg); - } - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); -} - - -/** - * Validate a program's samplers. - * Specifically, check that there aren't two samplers of different types - * pointing to the same texture unit. - * \return GL_TRUE if valid, GL_FALSE if invalid - */ -static GLboolean -validate_samplers(GLcontext *ctx, const struct gl_program *prog, char *errMsg) -{ - static const char *targetName[] = { - "TEXTURE_2D_ARRAY", - "TEXTURE_1D_ARRAY", - "TEXTURE_CUBE", - "TEXTURE_3D", - "TEXTURE_RECT", - "TEXTURE_2D", - "TEXTURE_1D", - }; - GLint targetUsed[MAX_TEXTURE_IMAGE_UNITS]; - GLbitfield samplersUsed = prog->SamplersUsed; - GLuint i; - - assert(Elements(targetName) == NUM_TEXTURE_TARGETS); - - if (samplersUsed == 0x0) - return GL_TRUE; - - for (i = 0; i < Elements(targetUsed); i++) - targetUsed[i] = -1; - - /* walk over bits which are set in 'samplers' */ - while (samplersUsed) { - GLuint unit; - gl_texture_index target; - GLint sampler = _mesa_ffs(samplersUsed) - 1; - assert(sampler >= 0); - assert(sampler < MAX_TEXTURE_IMAGE_UNITS); - unit = prog->SamplerUnits[sampler]; - target = prog->SamplerTargets[sampler]; - if (targetUsed[unit] != -1 && targetUsed[unit] != target) { - _mesa_snprintf(errMsg, 100, - "Texture unit %d is accessed both as %s and %s", - unit, targetName[targetUsed[unit]], targetName[target]); - return GL_FALSE; - } - targetUsed[unit] = target; - samplersUsed ^= (1 << sampler); - } - - return GL_TRUE; -} - - -/** - * Do validation of the given shader program. - * \param errMsg returns error message if validation fails. - * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg) - */ -static GLboolean -validate_shader_program(GLcontext *ctx, - const struct gl_shader_program *shProg, - char *errMsg) -{ - const struct gl_vertex_program *vp = shProg->VertexProgram; - const struct gl_fragment_program *fp = shProg->FragmentProgram; - - if (!shProg->LinkStatus) { - return GL_FALSE; - } - - /* From the GL spec, a program is invalid if any of these are true: - - any two active samplers in the current program object are of - different types, but refer to the same texture image unit, - - any active sampler in the current program object refers to a texture - image unit where fixed-function fragment processing accesses a - texture target that does not match the sampler type, or - - the sum of the number of active samplers in the program and the - number of texture image units enabled for fixed-function fragment - processing exceeds the combined limit on the total number of texture - image units allowed. - */ - - - /* - * Check: any two active samplers in the current program object are of - * different types, but refer to the same texture image unit, - */ - if (vp && !validate_samplers(ctx, &vp->Base, errMsg)) { - return GL_FALSE; - } - if (fp && !validate_samplers(ctx, &fp->Base, errMsg)) { - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Called via glValidateProgram() - */ -static void -validate_program(GLcontext *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - char errMsg[100]; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram"); - if (!shProg) { - return; - } - - shProg->Validated = validate_shader_program(ctx, shProg, errMsg); - if (!shProg->Validated) { - /* update info log */ - if (shProg->InfoLog) { - talloc_free(shProg->InfoLog); - } - shProg->InfoLog = talloc_strdup(shProg, errMsg); - } -} - - - -void GLAPIENTRY -_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_AttachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, - const GLcharARB *name) -{ - GET_CURRENT_CONTEXT(ctx); - bind_attrib_location(ctx, program, index, name); -} - - -void GLAPIENTRY -_mesa_CompileShaderARB(GLhandleARB shaderObj) -{ - GET_CURRENT_CONTEXT(ctx); - compile_shader(ctx, shaderObj); -} - - -GLuint GLAPIENTRY -_mesa_CreateShader(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader(ctx, type); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateShaderObjectARB(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader(ctx, type); -} - - -GLuint GLAPIENTRY -_mesa_CreateProgram(void) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader_program(ctx); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateProgramObjectARB(void) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader_program(ctx); -} - - -void GLAPIENTRY -_mesa_DeleteObjectARB(GLhandleARB obj) -{ - if (obj) { - GET_CURRENT_CONTEXT(ctx); - if (is_program(ctx, obj)) { - delete_shader_program(ctx, obj); - } - else if (is_shader(ctx, obj)) { - delete_shader(ctx, obj); - } - else { - /* error? */ - } - } -} - - -void GLAPIENTRY -_mesa_DeleteProgram(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - delete_shader_program(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DeleteShader(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - delete_shader(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_DetachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - get_active_attrib(ctx, program, index, maxLength, length, size, type, name); -} - - -void GLAPIENTRY -_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount, - GLsizei * count, GLhandleARB * obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, container, maxCount, count, obj); -} - - -void GLAPIENTRY -_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, program, maxCount, count, obj); -} - - -GLint GLAPIENTRY -_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - return get_attrib_location(ctx, program, name); -} - - -void GLAPIENTRY -_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, - GLcharARB * infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - if (is_program(ctx, object)) { - get_program_info_log(ctx, object, maxLength, length, infoLog); - } - else if (is_shader(ctx, object)) { - get_shader_info_log(ctx, object, maxLength, length, infoLog); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - /* Implement in terms of GetProgramiv, GetShaderiv */ - if (is_program(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_PROGRAM_OBJECT_ARB; - } - else { - get_programiv(ctx, object, pname, params); - } - } - else if (is_shader(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_SHADER_OBJECT_ARB; - } - else { - get_shaderiv(ctx, object, pname, params); - } - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname, - GLfloat *params) -{ - GLint iparams[1]; /* XXX is one element enough? */ - _mesa_GetObjectParameterivARB(object, pname, iparams); - params[0] = (GLfloat) iparams[0]; -} - - -void GLAPIENTRY -_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_programiv(ctx, program, pname, params); -} - - -void GLAPIENTRY -_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_shaderiv(ctx, shader, pname, params); -} - - -void GLAPIENTRY -_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_program_info_log(ctx, program, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_info_log(ctx, shader, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength, - GLsizei *length, GLcharARB *sourceOut) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_source(ctx, shader, maxLength, length, sourceOut); -} - - -GLhandleARB GLAPIENTRY -_mesa_GetHandleARB(GLenum pname) -{ - GET_CURRENT_CONTEXT(ctx); - return get_handle(ctx, pname); -} - - -GLboolean GLAPIENTRY -_mesa_IsProgram(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_program(ctx, name); -} - - -GLboolean GLAPIENTRY -_mesa_IsShader(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_shader(ctx, name); -} - - -void GLAPIENTRY -_mesa_LinkProgramARB(GLhandleARB programObj) -{ - GET_CURRENT_CONTEXT(ctx); - link_program(ctx, programObj); -} - - - -/** - * Read shader source code from a file. - * Useful for debugging to override an app's shader. - */ -static GLcharARB * -read_shader(const char *fname) -{ - const int max = 50*1000; - FILE *f = fopen(fname, "r"); - GLcharARB *buffer, *shader; - int len; - - if (!f) { - return NULL; - } - - buffer = (char *) malloc(max); - len = fread(buffer, 1, max, f); - buffer[len] = 0; - - fclose(f); - - shader = _mesa_strdup(buffer); - free(buffer); - - return shader; -} - - -/** - * Called via glShaderSource() and glShaderSourceARB() API functions. - * Basically, concatenate the source code strings into one long string - * and pass it to _mesa_shader_source(). - */ -void GLAPIENTRY -_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, - const GLcharARB ** string, const GLint * length) -{ - GET_CURRENT_CONTEXT(ctx); - GLint *offsets; - GLsizei i, totalLength; - GLcharARB *source; - GLuint checksum; - - if (!shaderObj || string == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); - return; - } - - /* - * This array holds offsets of where the appropriate string ends, thus the - * last element will be set to the total length of the source code. - */ - offsets = (GLint *) malloc(count * sizeof(GLint)); - if (offsets == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - if (string[i] == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_INVALID_OPERATION, "glShaderSourceARB(null string)"); - return; - } - if (length == NULL || length[i] < 0) - offsets[i] = strlen(string[i]); - else - offsets[i] = length[i]; - /* accumulate string lengths */ - if (i > 0) - offsets[i] += offsets[i - 1]; - } - - /* Total length of source string is sum off all strings plus two. - * One extra byte for terminating zero, another extra byte to silence - * valgrind warnings in the parser/grammer code. - */ - totalLength = offsets[count - 1] + 2; - source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); - if (source == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - GLint start = (i > 0) ? offsets[i - 1] : 0; - memcpy(source + start, string[i], - (offsets[i] - start) * sizeof(GLcharARB)); - } - source[totalLength - 1] = '\0'; - source[totalLength - 2] = '\0'; - - if (SHADER_SUBST) { - /* Compute the shader's source code checksum then try to open a file - * named newshader_. If it exists, use it in place of the - * original shader source code. For debugging. - */ - char filename[100]; - GLcharARB *newSource; - - checksum = _mesa_str_checksum(source); - - _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum); - - newSource = read_shader(filename); - if (newSource) { - fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", - shaderObj, checksum, filename); - free(source); - source = newSource; - } - } - - shader_source(ctx, shaderObj, source); - - if (SHADER_SUBST) { - struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); - if (sh) - sh->SourceChecksum = checksum; /* save original checksum */ - } - - free(offsets); -} - - -void GLAPIENTRY -_mesa_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - _mesa_use_program(ctx, program); -} - - -void GLAPIENTRY -_mesa_ValidateProgramARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - validate_program(ctx, program); -} - -#ifdef FEATURE_ES2 - -void GLAPIENTRY -_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, - GLint* range, GLint* precision) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); -} - - -void GLAPIENTRY -_mesa_ReleaseShaderCompiler(void) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); -} - - -void GLAPIENTRY -_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, - const void* binary, GLint length) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); -} - -#endif /* FEATURE_ES2 */ - - -#if FEATURE_ARB_geometry_shader4 - -void GLAPIENTRY -_mesa_ProgramParameteriARB(GLuint program, GLenum pname, - GLint value) -{ - struct gl_shader_program *shProg; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glProgramParameteri"); - if (!shProg) - return; - - switch (pname) { - case GL_GEOMETRY_VERTICES_OUT_ARB: - if (value < 1 || - value > ctx->Const.GeometryProgram.MaxGeometryOutputVertices) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d", - value); - return; - } - shProg->Geom.VerticesOut = value; - break; - case GL_GEOMETRY_INPUT_TYPE_ARB: - switch (value) { - case GL_POINTS: - case GL_LINES: - case GL_LINES_ADJACENCY_ARB: - case GL_TRIANGLES: - case GL_TRIANGLES_ADJACENCY_ARB: - shProg->Geom.InputType = value; - break; - default: - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(geometry input type = %s", - _mesa_lookup_enum_by_nr(value)); - return; - } - break; - case GL_GEOMETRY_OUTPUT_TYPE_ARB: - switch (value) { - case GL_POINTS: - case GL_LINE_STRIP: - case GL_TRIANGLE_STRIP: - shProg->Geom.OutputType = value; - break; - default: - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(geometry output type = %s", - _mesa_lookup_enum_by_nr(value)); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); - break; - } -} - -#endif - - -/** - * Plug in shader-related functions into API dispatch table. - */ -void -_mesa_init_shader_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - /* GL_ARB_vertex/fragment_shader */ - SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); - SET_GetHandleARB(exec, _mesa_GetHandleARB); - SET_DetachObjectARB(exec, _mesa_DetachObjectARB); - SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); - SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); - SET_CompileShaderARB(exec, _mesa_CompileShaderARB); - SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); - SET_AttachObjectARB(exec, _mesa_AttachObjectARB); - SET_LinkProgramARB(exec, _mesa_LinkProgramARB); - SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); - SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); - SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); - SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); - SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); - SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); - SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); - - /* OpenGL 2.0 */ - SET_AttachShader(exec, _mesa_AttachShader); - SET_CreateProgram(exec, _mesa_CreateProgram); - SET_CreateShader(exec, _mesa_CreateShader); - SET_DeleteProgram(exec, _mesa_DeleteProgram); - SET_DeleteShader(exec, _mesa_DeleteShader); - SET_DetachShader(exec, _mesa_DetachShader); - SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders); - SET_GetProgramiv(exec, _mesa_GetProgramiv); - SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog); - SET_GetShaderiv(exec, _mesa_GetShaderiv); - SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog); - SET_IsProgram(exec, _mesa_IsProgram); - SET_IsShader(exec, _mesa_IsShader); - -#if FEATURE_ARB_vertex_shader - SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB); - SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); - SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); -#endif - -#if FEATURE_ARB_geometry_shader4 - SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); -#endif -#endif /* FEATURE_GL */ -} - +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file shaderapi.c + * \author Brian Paul + * + * Implementation of GLSL-related API functions. + * The glUniform* functions are in uniforms.c + * + * + * XXX things to do: + * 1. Check that the right error code is generated for all _mesa_error() calls. + * 2. Insert FLUSH_VERTICES calls in various places + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/enums.h" +#include "main/hash.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "program/prog_uniform.h" +#include "talloc.h" +#include + +/** Define this to enable shader substitution (see below) */ +#define SHADER_SUBST 0 + + +/** + * Return mask of GLSL_x flags by examining the MESA_GLSL env var. + */ +static GLbitfield +get_shader_flags(void) +{ + GLbitfield flags = 0x0; + const char *env = _mesa_getenv("MESA_GLSL"); + + if (env) { + if (strstr(env, "dump")) + flags |= GLSL_DUMP; + if (strstr(env, "log")) + flags |= GLSL_LOG; + if (strstr(env, "nopvert")) + flags |= GLSL_NOP_VERT; + if (strstr(env, "nopfrag")) + flags |= GLSL_NOP_FRAG; + if (strstr(env, "nopt")) + flags |= GLSL_NO_OPT; + else if (strstr(env, "opt")) + flags |= GLSL_OPT; + if (strstr(env, "uniform")) + flags |= GLSL_UNIFORMS; + if (strstr(env, "useprog")) + flags |= GLSL_USE_PROG; + } + + return flags; +} + + +/** + * Initialize context's shader state. + */ +void +_mesa_init_shader_state(struct gl_context *ctx) +{ + /* Device drivers may override these to control what kind of instructions + * are generated by the GLSL compiler. + */ + struct gl_shader_compiler_options options; + gl_shader_type sh; + + memset(&options, 0, sizeof(options)); + options.MaxUnrollIterations = 32; + + /* Default pragma settings */ + options.DefaultPragmas.Optimize = GL_TRUE; + + for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) + memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); + + ctx->Shader.Flags = get_shader_flags(); +} + + +/** + * Free the per-context shader-related state. + */ +void +_mesa_free_shader_state(struct gl_context *ctx) +{ + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram, + NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram, + NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); +} + + +/** + * Return the size of the given GLSL datatype, in floats (components). + */ +GLint +_mesa_sizeof_glsl_type(GLenum type) +{ + switch (type) { + case GL_FLOAT: + case GL_INT: + case GL_BOOL: + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + case GL_SAMPLER_1D_ARRAY_EXT: + case GL_SAMPLER_2D_ARRAY_EXT: + case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_CUBE_SHADOW_EXT: + return 1; + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_UNSIGNED_INT_VEC2: + case GL_BOOL_VEC2: + return 2; + case GL_FLOAT_VEC3: + case GL_INT_VEC3: + case GL_UNSIGNED_INT_VEC3: + case GL_BOOL_VEC3: + return 3; + case GL_FLOAT_VEC4: + case GL_INT_VEC4: + case GL_UNSIGNED_INT_VEC4: + case GL_BOOL_VEC4: + return 4; + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + return 8; /* two float[4] vectors */ + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3x4: + return 12; /* three float[4] vectors */ + case GL_FLOAT_MAT4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: + return 16; /* four float[4] vectors */ + default: + _mesa_problem(NULL, "Invalid type in _mesa_sizeof_glsl_type()"); + return 1; + } +} + + +/** + * Copy string from to , up to maxLength characters, returning + * length of in . + * \param src the strings source + * \param maxLength max chars to copy + * \param length returns number of chars copied + * \param dst the string destination + */ +void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src) +{ + GLsizei len; + for (len = 0; len < maxLength - 1 && src && src[len]; len++) + dst[len] = src[len]; + if (maxLength > 0) + dst[len] = 0; + if (length) + *length = len; +} + + + +/** + * Confirm that the a shader type is valid and supported by the implementation + * + * \param ctx Current GL context + * \param type Shader target + * + */ +static bool +validate_shader_target(const struct gl_context *ctx, GLenum type) +{ + switch (type) { +#if FEATURE_ARB_fragment_shader + case GL_FRAGMENT_SHADER: + return ctx->Extensions.ARB_fragment_shader; +#endif +#if FEATURE_ARB_vertex_shader + case GL_VERTEX_SHADER: + return ctx->Extensions.ARB_vertex_shader; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_SHADER_ARB: + return ctx->Extensions.ARB_geometry_shader4; +#endif + default: + return false; + } +} + + +/** + * Find the length of the longest transform feedback varying name + * which was specified with glTransformFeedbackVaryings(). + */ +static GLint +longest_feedback_varying_name(const struct gl_shader_program *shProg) +{ + GLuint i; + GLint max = 0; + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); + if (len > max) + max = len; + } + return max; +} + + + +static GLboolean +is_program(struct gl_context *ctx, GLuint name) +{ + struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name); + return shProg ? GL_TRUE : GL_FALSE; +} + + +static GLboolean +is_shader(struct gl_context *ctx, GLuint name) +{ + struct gl_shader *shader = _mesa_lookup_shader(ctx, name); + return shader ? GL_TRUE : GL_FALSE; +} + + +/** + * Attach shader to a shader program. + */ +static void +attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) +{ + struct gl_shader_program *shProg; + struct gl_shader *sh; + GLuint i, n; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); + if (!shProg) + return; + + sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader"); + if (!sh) { + return; + } + + n = shProg->NumShaders; + for (i = 0; i < n; i++) { + if (shProg->Shaders[i] == sh) { + /* The shader is already attched to this program. The + * GL_ARB_shader_objects spec says: + * + * "The error INVALID_OPERATION is generated by AttachObjectARB + * if is already attached to ." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); + return; + } + } + + /* grow list */ + shProg->Shaders = (struct gl_shader **) + _mesa_realloc(shProg->Shaders, + n * sizeof(struct gl_shader *), + (n + 1) * sizeof(struct gl_shader *)); + if (!shProg->Shaders) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader"); + return; + } + + /* append */ + shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ + _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); + shProg->NumShaders++; +} + + +static GLint +get_attrib_location(struct gl_context *ctx, GLuint program, const GLchar *name) +{ + struct gl_shader_program *shProg + = _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); + + if (!shProg) { + return -1; + } + + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetAttribLocation(program not linked)"); + return -1; + } + + if (!name) + return -1; + + if (shProg->VertexProgram) { + const struct gl_program_parameter_list *attribs = + shProg->VertexProgram->Base.Attributes; + if (attribs) { + GLint i = _mesa_lookup_parameter_index(attribs, -1, name); + if (i >= 0) { + return attribs->Parameters[i].StateIndexes[0]; + } + } + } + return -1; +} + + +static void +bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index, + const GLchar *name) +{ + struct gl_shader_program *shProg; + const GLint size = -1; /* unknown size */ + GLint i, oldIndex; + GLenum datatype = GL_FLOAT_VEC4; + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glBindAttribLocation"); + if (!shProg) { + return; + } + + if (!name) + return; + + if (strncmp(name, "gl_", 3) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindAttribLocation(illegal name)"); + return; + } + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)"); + return; + } + + if (shProg->LinkStatus) { + /* get current index/location for the attribute */ + oldIndex = get_attrib_location(ctx, program, name); + } + else { + oldIndex = -1; + } + + /* this will replace the current value if it's already in the list */ + i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); + if (i < 0) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation"); + return; + } + + /* + * Note that this attribute binding won't go into effect until + * glLinkProgram is called again. + */ +} + + +static void +bind_frag_data_location(struct gl_context *ctx, GLuint program, + GLuint colorNumber, const GLchar *name) +{ + _mesa_problem(ctx, "bind_frag_data_location() not implemented yet"); +} + + +static GLuint +create_shader(struct gl_context *ctx, GLenum type) +{ + struct gl_shader *sh; + GLuint name; + + if (!validate_shader_target(ctx, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)"); + return 0; + } + + name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); + sh = ctx->Driver.NewShader(ctx, name, type); + _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh); + + return name; +} + + +static GLuint +create_shader_program(struct gl_context *ctx) +{ + GLuint name; + struct gl_shader_program *shProg; + + name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); + + shProg = ctx->Driver.NewShaderProgram(ctx, name); + + _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg); + + assert(shProg->RefCount == 1); + + return name; +} + + +/** + * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's + * DeleteProgramARB. + */ +static void +delete_shader_program(struct gl_context *ctx, GLuint name) +{ + /* + * NOTE: deleting shaders/programs works a bit differently than + * texture objects (and buffer objects, etc). Shader/program + * handles/IDs exist in the hash table until the object is really + * deleted (refcount==0). With texture objects, the handle/ID is + * removed from the hash table in glDeleteTextures() while the tex + * object itself might linger until its refcount goes to zero. + */ + struct gl_shader_program *shProg; + + shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram"); + if (!shProg) + return; + + shProg->DeletePending = GL_TRUE; + + /* effectively, decr shProg's refcount */ + _mesa_reference_shader_program(ctx, &shProg, NULL); +} + + +static void +delete_shader(struct gl_context *ctx, GLuint shader) +{ + struct gl_shader *sh; + + sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader"); + if (!sh) + return; + + sh->DeletePending = GL_TRUE; + + /* effectively, decr sh's refcount */ + _mesa_reference_shader(ctx, &sh, NULL); +} + + +static void +detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) +{ + struct gl_shader_program *shProg; + GLuint n; + GLuint i, j; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); + if (!shProg) + return; + + n = shProg->NumShaders; + + for (i = 0; i < n; i++) { + if (shProg->Shaders[i]->Name == shader) { + /* found it */ + struct gl_shader **newList; + + /* release */ + _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); + + /* alloc new, smaller array */ + newList = (struct gl_shader **) + malloc((n - 1) * sizeof(struct gl_shader *)); + if (!newList) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); + return; + } + for (j = 0; j < i; j++) { + newList[j] = shProg->Shaders[j]; + } + while (++i < n) + newList[j++] = shProg->Shaders[i]; + free(shProg->Shaders); + + shProg->Shaders = newList; + shProg->NumShaders = n - 1; + +#ifdef DEBUG + /* sanity check */ + { + for (j = 0; j < shProg->NumShaders; j++) { + assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || + shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); + assert(shProg->Shaders[j]->RefCount > 0); + } + } +#endif + + return; + } + } + + /* not found */ + { + GLenum err; + if (is_shader(ctx, shader)) + err = GL_INVALID_OPERATION; + else if (is_program(ctx, shader)) + err = GL_INVALID_OPERATION; + else + err = GL_INVALID_VALUE; + _mesa_error(ctx, err, "glDetachProgram(shader)"); + return; + } +} + + +static void +get_active_attrib(struct gl_context *ctx, GLuint program, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, + GLenum *type, GLchar *nameOut) +{ + const struct gl_program_parameter_list *attribs = NULL; + struct gl_shader_program *shProg; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); + if (!shProg) + return; + + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + + if (!attribs || index >= attribs->NumParameters) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); + return; + } + + _mesa_copy_string(nameOut, maxLength, length, + attribs->Parameters[index].Name); + + if (size) + *size = attribs->Parameters[index].Size + / _mesa_sizeof_glsl_type(attribs->Parameters[index].DataType); + + if (type) + *type = attribs->Parameters[index].DataType; +} + + +/** + * Return list of shaders attached to shader program. + */ +static void +get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount, + GLsizei *count, GLuint *obj) +{ + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders"); + if (shProg) { + GLuint i; + for (i = 0; i < (GLuint) maxCount && i < shProg->NumShaders; i++) { + obj[i] = shProg->Shaders[i]->Name; + } + if (count) + *count = i; + } +} + + +static GLint +get_frag_data_location(struct gl_context *ctx, GLuint program, + const GLchar *name) +{ + _mesa_problem(ctx, "get_frag_data_location() not implemented yet"); + return -1; +} + + + +/** + * glGetHandleARB() - return ID/name of currently bound shader program. + */ +static GLuint +get_handle(struct gl_context *ctx, GLenum pname) +{ + if (pname == GL_PROGRAM_OBJECT_ARB) { + if (ctx->Shader.ActiveProgram) + return ctx->Shader.ActiveProgram->Name; + else + return 0; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); + return 0; + } +} + + +/** + * glGetProgramiv() - get shader program state. + * Note that this is for GLSL shader programs, not ARB vertex/fragment + * programs (see glGetProgramivARB). + */ +static void +get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params) +{ + const struct gl_program_parameter_list *attribs; + struct gl_shader_program *shProg + = _mesa_lookup_shader_program(ctx, program); + + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); + return; + } + + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + else + attribs = NULL; + + switch (pname) { + case GL_DELETE_STATUS: + *params = shProg->DeletePending; + break; + case GL_LINK_STATUS: + *params = shProg->LinkStatus; + break; + case GL_VALIDATE_STATUS: + *params = shProg->Validated; + break; + case GL_INFO_LOG_LENGTH: + *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; + break; + case GL_ATTACHED_SHADERS: + *params = shProg->NumShaders; + break; + case GL_ACTIVE_ATTRIBUTES: + *params = attribs ? attribs->NumParameters : 0; + break; + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; + break; + case GL_ACTIVE_UNIFORMS: + *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; + break; + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + *params = _mesa_longest_uniform_name(shProg->Uniforms); + if (*params > 0) + (*params)++; /* add one for terminating zero */ + break; + case GL_PROGRAM_BINARY_LENGTH_OES: + *params = 0; + break; +#if FEATURE_EXT_transform_feedback + case GL_TRANSFORM_FEEDBACK_VARYINGS: + *params = shProg->TransformFeedback.NumVarying; + break; + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + *params = longest_feedback_varying_name(shProg) + 1; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + *params = shProg->TransformFeedback.BufferMode; + break; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_VERTICES_OUT_ARB: + *params = shProg->Geom.VerticesOut; + break; + case GL_GEOMETRY_INPUT_TYPE_ARB: + *params = shProg->Geom.InputType; + break; + case GL_GEOMETRY_OUTPUT_TYPE_ARB: + *params = shProg->Geom.OutputType; + break; +#endif + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); + return; + } +} + + +/** + * glGetShaderiv() - get GLSL shader state + */ +static void +get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) +{ + struct gl_shader *shader = + _mesa_lookup_shader_err(ctx, name, "glGetShaderiv"); + + if (!shader) { + return; + } + + switch (pname) { + case GL_SHADER_TYPE: + *params = shader->Type; + break; + case GL_DELETE_STATUS: + *params = shader->DeletePending; + break; + case GL_COMPILE_STATUS: + *params = shader->CompileStatus; + break; + case GL_INFO_LOG_LENGTH: + *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; + break; + case GL_SHADER_SOURCE_LENGTH: + *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); + return; + } +} + + +static void +get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + struct gl_shader_program *shProg + = _mesa_lookup_shader_program(ctx, program); + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); + return; + } + _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); +} + + +static void +get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); + if (!sh) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); + return; + } + _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); +} + + +/** + * Return shader source code. + */ +static void +get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength, + GLsizei *length, GLchar *sourceOut) +{ + struct gl_shader *sh; + sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource"); + if (!sh) { + return; + } + _mesa_copy_string(sourceOut, maxLength, length, sh->Source); +} + + +/** + * Set/replace shader source code. + */ +static void +shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source) +{ + struct gl_shader *sh; + + sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource"); + if (!sh) + return; + + /* free old shader source string and install new one */ + if (sh->Source) { + free((void *) sh->Source); + } + sh->Source = source; + sh->CompileStatus = GL_FALSE; +#ifdef DEBUG + sh->SourceChecksum = _mesa_str_checksum(sh->Source); +#endif +} + + +/** + * Compile a shader. + */ +static void +compile_shader(struct gl_context *ctx, GLuint shaderObj) +{ + struct gl_shader *sh; + struct gl_shader_compiler_options *options; + + sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); + if (!sh) + return; + + options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; + + /* set default pragma state for shader */ + sh->Pragmas = options->DefaultPragmas; + + /* this call will set the sh->CompileStatus field to indicate if + * compilation was successful. + */ + _mesa_glsl_compile_shader(ctx, sh); +} + + +/** + * Link a program's shaders. + */ +static void +link_program(struct gl_context *ctx, GLuint program) +{ + struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); + if (!shProg) + return; + + if (obj->Active + && (shProg == ctx->Shader.CurrentVertexProgram + || shProg == ctx->Shader.CurrentGeometryProgram + || shProg == ctx->Shader.CurrentFragmentProgram)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glLinkProgram(transform feedback active"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + _mesa_glsl_link_shader(ctx, shProg); + + /* debug code */ + if (0) { + GLuint i; + + printf("Link %u shaders in program %u: %s\n", + shProg->NumShaders, shProg->Name, + shProg->LinkStatus ? "Success" : "Failed"); + + for (i = 0; i < shProg->NumShaders; i++) { + printf(" shader %u, type 0x%x\n", + shProg->Shaders[i]->Name, + shProg->Shaders[i]->Type); + } + } +} + + +/** + * Print basic shader info (for debug). + */ +static void +print_shader_info(const struct gl_shader_program *shProg) +{ + GLuint i; + + printf("Mesa: glUseProgram(%u)\n", shProg->Name); + for (i = 0; i < shProg->NumShaders; i++) { + const char *s; + switch (shProg->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + s = "vertex"; + break; + case GL_FRAGMENT_SHADER: + s = "fragment"; + break; + case GL_GEOMETRY_SHADER: + s = "geometry"; + break; + default: + s = ""; + } + printf(" %s shader %u, checksum %u\n", s, + shProg->Shaders[i]->Name, + shProg->Shaders[i]->SourceChecksum); + } + if (shProg->VertexProgram) + printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); + if (shProg->FragmentProgram) + printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); +} + + +/** + * Use the named shader program for subsequent glUniform calls + */ +void +_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, + const char *caller) +{ + if ((shProg != NULL) && !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(program %u not linked)", caller, shProg->Name); + return; + } + + if (ctx->Shader.ActiveProgram != shProg) { + _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg); + } +} + +/** + */ +static bool +use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg) +{ + struct gl_shader_program **target; + + switch (type) { +#if FEATURE_ARB_vertex_shader + case GL_VERTEX_SHADER: + target = &ctx->Shader.CurrentVertexProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) { + shProg = NULL; + } + break; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_SHADER_ARB: + target = &ctx->Shader.CurrentGeometryProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) { + shProg = NULL; + } + break; +#endif +#if FEATURE_ARB_fragment_shader + case GL_FRAGMENT_SHADER: + target = &ctx->Shader.CurrentFragmentProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) { + shProg = NULL; + } + break; +#endif + default: + return false; + } + + if (*target != shProg) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + _mesa_reference_shader_program(ctx, target, shProg); + return true; + } + + return false; +} + +/** + * Use the named shader program for subsequent rendering. + */ +void +_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) +{ + use_shader_program(ctx, GL_VERTEX_SHADER, shProg); + use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); + use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); + _mesa_active_program(ctx, shProg, "glUseProgram"); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, shProg); +} + + +/** + * Validate a program's samplers. + * Specifically, check that there aren't two samplers of different types + * pointing to the same texture unit. + * \return GL_TRUE if valid, GL_FALSE if invalid + */ +static GLboolean +validate_samplers(const struct gl_program *prog, char *errMsg) +{ + static const char *targetName[] = { + "TEXTURE_2D_ARRAY", + "TEXTURE_1D_ARRAY", + "TEXTURE_CUBE", + "TEXTURE_3D", + "TEXTURE_RECT", + "TEXTURE_2D", + "TEXTURE_1D", + }; + GLint targetUsed[MAX_TEXTURE_IMAGE_UNITS]; + GLbitfield samplersUsed = prog->SamplersUsed; + GLuint i; + + assert(Elements(targetName) == NUM_TEXTURE_TARGETS); + + if (samplersUsed == 0x0) + return GL_TRUE; + + for (i = 0; i < Elements(targetUsed); i++) + targetUsed[i] = -1; + + /* walk over bits which are set in 'samplers' */ + while (samplersUsed) { + GLuint unit; + gl_texture_index target; + GLint sampler = _mesa_ffs(samplersUsed) - 1; + assert(sampler >= 0); + assert(sampler < MAX_TEXTURE_IMAGE_UNITS); + unit = prog->SamplerUnits[sampler]; + target = prog->SamplerTargets[sampler]; + if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) { + _mesa_snprintf(errMsg, 100, + "Texture unit %d is accessed both as %s and %s", + unit, targetName[targetUsed[unit]], targetName[target]); + return GL_FALSE; + } + targetUsed[unit] = target; + samplersUsed ^= (1 << sampler); + } + + return GL_TRUE; +} + + +/** + * Do validation of the given shader program. + * \param errMsg returns error message if validation fails. + * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg) + */ +static GLboolean +validate_shader_program(const struct gl_shader_program *shProg, + char *errMsg) +{ + const struct gl_vertex_program *vp = shProg->VertexProgram; + const struct gl_fragment_program *fp = shProg->FragmentProgram; + + if (!shProg->LinkStatus) { + return GL_FALSE; + } + + /* From the GL spec, a program is invalid if any of these are true: + + any two active samplers in the current program object are of + different types, but refer to the same texture image unit, + + any active sampler in the current program object refers to a texture + image unit where fixed-function fragment processing accesses a + texture target that does not match the sampler type, or + + the sum of the number of active samplers in the program and the + number of texture image units enabled for fixed-function fragment + processing exceeds the combined limit on the total number of texture + image units allowed. + */ + + + /* + * Check: any two active samplers in the current program object are of + * different types, but refer to the same texture image unit, + */ + if (vp && !validate_samplers(&vp->Base, errMsg)) { + return GL_FALSE; + } + if (fp && !validate_samplers(&fp->Base, errMsg)) { + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Called via glValidateProgram() + */ +static void +validate_program(struct gl_context *ctx, GLuint program) +{ + struct gl_shader_program *shProg; + char errMsg[100]; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram"); + if (!shProg) { + return; + } + + shProg->Validated = validate_shader_program(shProg, errMsg); + if (!shProg->Validated) { + /* update info log */ + if (shProg->InfoLog) { + talloc_free(shProg->InfoLog); + } + shProg->InfoLog = talloc_strdup(shProg, errMsg); + } +} + + + +void GLAPIENTRY +_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader) +{ + GET_CURRENT_CONTEXT(ctx); + attach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_AttachShader(GLuint program, GLuint shader) +{ + GET_CURRENT_CONTEXT(ctx); + attach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, + const GLcharARB *name) +{ + GET_CURRENT_CONTEXT(ctx); + bind_attrib_location(ctx, program, index, name); +} + + +/* GL_EXT_gpu_shader4, GL3 */ +void GLAPIENTRY +_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, + const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + bind_frag_data_location(ctx, program, colorNumber, name); +} + + +void GLAPIENTRY +_mesa_CompileShaderARB(GLhandleARB shaderObj) +{ + GET_CURRENT_CONTEXT(ctx); + compile_shader(ctx, shaderObj); +} + + +GLuint GLAPIENTRY +_mesa_CreateShader(GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader(ctx, type); +} + + +GLhandleARB GLAPIENTRY +_mesa_CreateShaderObjectARB(GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader(ctx, type); +} + + +GLuint GLAPIENTRY +_mesa_CreateProgram(void) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader_program(ctx); +} + + +GLhandleARB GLAPIENTRY +_mesa_CreateProgramObjectARB(void) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader_program(ctx); +} + + +void GLAPIENTRY +_mesa_DeleteObjectARB(GLhandleARB obj) +{ + if (obj) { + GET_CURRENT_CONTEXT(ctx); + if (is_program(ctx, obj)) { + delete_shader_program(ctx, obj); + } + else if (is_shader(ctx, obj)) { + delete_shader(ctx, obj); + } + else { + /* error? */ + } + } +} + + +void GLAPIENTRY +_mesa_DeleteProgram(GLuint name) +{ + if (name) { + GET_CURRENT_CONTEXT(ctx); + delete_shader_program(ctx, name); + } +} + + +void GLAPIENTRY +_mesa_DeleteShader(GLuint name) +{ + if (name) { + GET_CURRENT_CONTEXT(ctx); + delete_shader(ctx, name); + } +} + + +void GLAPIENTRY +_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) +{ + GET_CURRENT_CONTEXT(ctx); + detach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_DetachShader(GLuint program, GLuint shader) +{ + GET_CURRENT_CONTEXT(ctx); + detach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index, + GLsizei maxLength, GLsizei * length, GLint * size, + GLenum * type, GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + get_active_attrib(ctx, program, index, maxLength, length, size, type, name); +} + + +void GLAPIENTRY +_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount, + GLsizei * count, GLhandleARB * obj) +{ + GET_CURRENT_CONTEXT(ctx); + get_attached_shaders(ctx, container, maxCount, count, obj); +} + + +void GLAPIENTRY +_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, + GLsizei *count, GLuint *obj) +{ + GET_CURRENT_CONTEXT(ctx); + get_attached_shaders(ctx, program, maxCount, count, obj); +} + + +GLint GLAPIENTRY +_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + return get_attrib_location(ctx, program, name); +} + + +/* GL_EXT_gpu_shader4, GL3 */ +GLint GLAPIENTRY +_mesa_GetFragDataLocation(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + return get_frag_data_location(ctx, program, name); +} + + + +void GLAPIENTRY +_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, + GLcharARB * infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + if (is_program(ctx, object)) { + get_program_info_log(ctx, object, maxLength, length, infoLog); + } + else if (is_shader(ctx, object)) { + get_shader_info_log(ctx, object, maxLength, length, infoLog); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); + } +} + + +void GLAPIENTRY +_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + /* Implement in terms of GetProgramiv, GetShaderiv */ + if (is_program(ctx, object)) { + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_PROGRAM_OBJECT_ARB; + } + else { + get_programiv(ctx, object, pname, params); + } + } + else if (is_shader(ctx, object)) { + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_SHADER_OBJECT_ARB; + } + else { + get_shaderiv(ctx, object, pname, params); + } + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); + } +} + + +void GLAPIENTRY +_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname, + GLfloat *params) +{ + GLint iparams[1]; /* XXX is one element enough? */ + _mesa_GetObjectParameterivARB(object, pname, iparams); + params[0] = (GLfloat) iparams[0]; +} + + +void GLAPIENTRY +_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_programiv(ctx, program, pname, params); +} + + +void GLAPIENTRY +_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_shaderiv(ctx, shader, pname, params); +} + + +void GLAPIENTRY +_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + get_program_info_log(ctx, program, bufSize, length, infoLog); +} + + +void GLAPIENTRY +_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + get_shader_info_log(ctx, shader, bufSize, length, infoLog); +} + + +void GLAPIENTRY +_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength, + GLsizei *length, GLcharARB *sourceOut) +{ + GET_CURRENT_CONTEXT(ctx); + get_shader_source(ctx, shader, maxLength, length, sourceOut); +} + + +GLhandleARB GLAPIENTRY +_mesa_GetHandleARB(GLenum pname) +{ + GET_CURRENT_CONTEXT(ctx); + return get_handle(ctx, pname); +} + + +GLboolean GLAPIENTRY +_mesa_IsProgram(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + return is_program(ctx, name); +} + + +GLboolean GLAPIENTRY +_mesa_IsShader(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + return is_shader(ctx, name); +} + + +void GLAPIENTRY +_mesa_LinkProgramARB(GLhandleARB programObj) +{ + GET_CURRENT_CONTEXT(ctx); + link_program(ctx, programObj); +} + + + +/** + * Read shader source code from a file. + * Useful for debugging to override an app's shader. + */ +static GLcharARB * +read_shader(const char *fname) +{ + const int max = 50*1000; + FILE *f = fopen(fname, "r"); + GLcharARB *buffer, *shader; + int len; + + if (!f) { + return NULL; + } + + buffer = (char *) malloc(max); + len = fread(buffer, 1, max, f); + buffer[len] = 0; + + fclose(f); + + shader = _mesa_strdup(buffer); + free(buffer); + + return shader; +} + + +/** + * Called via glShaderSource() and glShaderSourceARB() API functions. + * Basically, concatenate the source code strings into one long string + * and pass it to _mesa_shader_source(). + */ +void GLAPIENTRY +_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, + const GLcharARB ** string, const GLint * length) +{ + GET_CURRENT_CONTEXT(ctx); + GLint *offsets; + GLsizei i, totalLength; + GLcharARB *source; + GLuint checksum; + + if (!shaderObj || string == NULL) { + _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); + return; + } + + /* + * This array holds offsets of where the appropriate string ends, thus the + * last element will be set to the total length of the source code. + */ + offsets = (GLint *) malloc(count * sizeof(GLint)); + if (offsets == NULL) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); + return; + } + + for (i = 0; i < count; i++) { + if (string[i] == NULL) { + free((GLvoid *) offsets); + _mesa_error(ctx, GL_INVALID_OPERATION, "glShaderSourceARB(null string)"); + return; + } + if (length == NULL || length[i] < 0) + offsets[i] = strlen(string[i]); + else + offsets[i] = length[i]; + /* accumulate string lengths */ + if (i > 0) + offsets[i] += offsets[i - 1]; + } + + /* Total length of source string is sum off all strings plus two. + * One extra byte for terminating zero, another extra byte to silence + * valgrind warnings in the parser/grammer code. + */ + totalLength = offsets[count - 1] + 2; + source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); + if (source == NULL) { + free((GLvoid *) offsets); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); + return; + } + + for (i = 0; i < count; i++) { + GLint start = (i > 0) ? offsets[i - 1] : 0; + memcpy(source + start, string[i], + (offsets[i] - start) * sizeof(GLcharARB)); + } + source[totalLength - 1] = '\0'; + source[totalLength - 2] = '\0'; + + if (SHADER_SUBST) { + /* Compute the shader's source code checksum then try to open a file + * named newshader_. If it exists, use it in place of the + * original shader source code. For debugging. + */ + char filename[100]; + GLcharARB *newSource; + + checksum = _mesa_str_checksum(source); + + _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum); + + newSource = read_shader(filename); + if (newSource) { + fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", + shaderObj, checksum, filename); + free(source); + source = newSource; + } + } + + shader_source(ctx, shaderObj, source); + + if (SHADER_SUBST) { + struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); + if (sh) + sh->SourceChecksum = checksum; /* save original checksum */ + } + + free(offsets); +} + + +void GLAPIENTRY +_mesa_UseProgramObjectARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(transform feedback active)"); + return; + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); + if (!shProg) { + return; + } + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(program %u not linked)", program); + return; + } + + /* debug code */ + if (ctx->Shader.Flags & GLSL_USE_PROG) { + print_shader_info(shProg); + } + } + else { + shProg = NULL; + } + + _mesa_use_program(ctx, shProg); +} + + +void GLAPIENTRY +_mesa_ValidateProgramARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + validate_program(ctx, program); +} + +#ifdef FEATURE_ES2 + +void GLAPIENTRY +_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, + GLint* range, GLint* precision) +{ + GET_CURRENT_CONTEXT(ctx); + (void) shadertype; + (void) precisiontype; + (void) range; + (void) precision; + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); +} + + +void GLAPIENTRY +_mesa_ReleaseShaderCompiler(void) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); +} + + +void GLAPIENTRY +_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, + const void* binary, GLint length) +{ + GET_CURRENT_CONTEXT(ctx); + (void) n; + (void) shaders; + (void) binaryformat; + (void) binary; + (void) length; + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); +} + +#endif /* FEATURE_ES2 */ + + +#if FEATURE_ARB_geometry_shader4 + +void GLAPIENTRY +_mesa_ProgramParameteriARB(GLuint program, GLenum pname, + GLint value) +{ + struct gl_shader_program *shProg; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glProgramParameteri"); + if (!shProg) + return; + + switch (pname) { + case GL_GEOMETRY_VERTICES_OUT_ARB: + if (value < 1 || + (unsigned) value > ctx->Const.GeometryProgram.MaxGeometryOutputVertices) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d", + value); + return; + } + shProg->Geom.VerticesOut = value; + break; + case GL_GEOMETRY_INPUT_TYPE_ARB: + switch (value) { + case GL_POINTS: + case GL_LINES: + case GL_LINES_ADJACENCY_ARB: + case GL_TRIANGLES: + case GL_TRIANGLES_ADJACENCY_ARB: + shProg->Geom.InputType = value; + break; + default: + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(geometry input type = %s", + _mesa_lookup_enum_by_nr(value)); + return; + } + break; + case GL_GEOMETRY_OUTPUT_TYPE_ARB: + switch (value) { + case GL_POINTS: + case GL_LINE_STRIP: + case GL_TRIANGLE_STRIP: + shProg->Geom.OutputType = value; + break; + default: + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(geometry output type = %s", + _mesa_lookup_enum_by_nr(value)); + return; + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); + break; + } +} + +#endif + +void +_mesa_use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg) +{ + use_shader_program(ctx, type, shProg); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, shProg); +} + +void GLAPIENTRY +_mesa_UseShaderProgramEXT(GLenum type, GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = NULL; + + if (!validate_shader_target(ctx, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)"); + return; + } + + if (ctx->TransformFeedback.CurrentObject->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseShaderProgramEXT(transform feedback is active)"); + return; + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glUseShaderProgramEXT"); + if (shProg == NULL) + return; + + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseShaderProgramEXT(program not linked)"); + return; + } + } + + _mesa_use_shader_program(ctx, type, shProg); +} + +void GLAPIENTRY +_mesa_ActiveProgramEXT(GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = (program != 0) + ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") + : NULL; + + _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); + return; +} + +GLuint GLAPIENTRY +_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint shader = create_shader(ctx, type); + GLuint program = 0; + + if (shader) { + shader_source(ctx, shader, _mesa_strdup(string)); + compile_shader(ctx, shader); + + program = create_shader_program(ctx); + if (program) { + struct gl_shader_program *shProg; + struct gl_shader *sh; + GLint compiled = GL_FALSE; + + shProg = _mesa_lookup_shader_program(ctx, program); + sh = _mesa_lookup_shader(ctx, shader); + + get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled); + if (compiled) { + attach_shader(ctx, program, shader); + link_program(ctx, program); + detach_shader(ctx, program, shader); + +#if 0 + /* Possibly... */ + if (active-user-defined-varyings-in-linked-program) { + append-error-to-info-log; + shProg->LinkStatus = GL_FALSE; + } +#endif + } + + shProg->InfoLog = talloc_strdup_append(shProg->InfoLog, sh->InfoLog); + } + + delete_shader(ctx, shader); + } + + return program; +} + +/** + * Plug in shader-related functions into API dispatch table. + */ +void +_mesa_init_shader_dispatch(struct _glapi_table *exec) +{ +#if FEATURE_GL + /* GL_ARB_vertex/fragment_shader */ + SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); + SET_GetHandleARB(exec, _mesa_GetHandleARB); + SET_DetachObjectARB(exec, _mesa_DetachObjectARB); + SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); + SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); + SET_CompileShaderARB(exec, _mesa_CompileShaderARB); + SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); + SET_AttachObjectARB(exec, _mesa_AttachObjectARB); + SET_LinkProgramARB(exec, _mesa_LinkProgramARB); + SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); + SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); + SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); + SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); + SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); + SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); + SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); + + /* OpenGL 2.0 */ + SET_AttachShader(exec, _mesa_AttachShader); + SET_CreateProgram(exec, _mesa_CreateProgram); + SET_CreateShader(exec, _mesa_CreateShader); + SET_DeleteProgram(exec, _mesa_DeleteProgram); + SET_DeleteShader(exec, _mesa_DeleteShader); + SET_DetachShader(exec, _mesa_DetachShader); + SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders); + SET_GetProgramiv(exec, _mesa_GetProgramiv); + SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog); + SET_GetShaderiv(exec, _mesa_GetShaderiv); + SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog); + SET_IsProgram(exec, _mesa_IsProgram); + SET_IsShader(exec, _mesa_IsShader); + +#if FEATURE_ARB_vertex_shader + SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB); + SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); + SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); +#endif + +#if FEATURE_ARB_geometry_shader4 + SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); +#endif + + SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); + SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); + SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); + SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); + +#endif /* FEATURE_GL */ +} + diff --git a/mesalib/src/mesa/main/shaderapi.h b/mesalib/src/mesa/main/shaderapi.h index 16e22530d..15c7c7ae6 100644 --- a/mesalib/src/mesa/main/shaderapi.h +++ b/mesalib/src/mesa/main/shaderapi.h @@ -1,169 +1,193 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. - */ - - -#ifndef SHADERAPI_H -#define SHADERAPI_H - - -#include "glheader.h" -#include "mtypes.h" - - -extern GLint -_mesa_sizeof_glsl_type(GLenum type); - -extern void -_mesa_copy_string(GLchar *dst, GLsizei maxLength, - GLsizei *length, const GLchar *src); - -extern void -_mesa_use_program(GLcontext *ctx, GLuint program); - - -extern void -_mesa_init_shader_dispatch(struct _glapi_table *exec); - - - -extern void GLAPIENTRY -_mesa_AttachObjectARB(GLhandleARB, GLhandleARB); - -extern void GLAPIENTRY -_mesa_CompileShaderARB(GLhandleARB); - -extern GLhandleARB GLAPIENTRY -_mesa_CreateProgramObjectARB(void); - -extern GLhandleARB GLAPIENTRY -_mesa_CreateShaderObjectARB(GLenum type); - -extern void GLAPIENTRY -_mesa_DeleteObjectARB(GLhandleARB obj); - -extern void GLAPIENTRY -_mesa_DetachObjectARB(GLhandleARB, GLhandleARB); - -extern void GLAPIENTRY -_mesa_GetAttachedObjectsARB(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); - -extern GLhandleARB GLAPIENTRY -_mesa_GetHandleARB(GLenum pname); - -extern void GLAPIENTRY -_mesa_GetInfoLogARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetObjectParameterfvARB(GLhandleARB, GLenum, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetObjectParameterivARB(GLhandleARB, GLenum, GLint *); - -extern void GLAPIENTRY -_mesa_GetShaderSourceARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); - -extern GLboolean GLAPIENTRY -_mesa_IsProgram(GLuint name); - -extern GLboolean GLAPIENTRY -_mesa_IsShader(GLuint name); - -extern void GLAPIENTRY -_mesa_LinkProgramARB(GLhandleARB programObj); - -extern void GLAPIENTRY -_mesa_ShaderSourceARB(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); - -extern void GLAPIENTRY -_mesa_UseProgramObjectARB(GLhandleARB); - -extern void GLAPIENTRY -_mesa_ValidateProgramARB(GLhandleARB); - - -extern void GLAPIENTRY -_mesa_BindAttribLocationARB(GLhandleARB, GLuint, const GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetActiveAttribARB(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, - GLenum *, GLcharARB *); - -extern GLint GLAPIENTRY -_mesa_GetAttribLocationARB(GLhandleARB, const GLcharARB *); - - - -extern void GLAPIENTRY -_mesa_AttachShader(GLuint program, GLuint shader); - -extern GLuint GLAPIENTRY -_mesa_CreateShader(GLenum); - -extern GLuint GLAPIENTRY -_mesa_CreateProgram(void); - -extern void GLAPIENTRY -_mesa_DeleteProgram(GLuint program); - -extern void GLAPIENTRY -_mesa_DeleteShader(GLuint shader); - -extern void GLAPIENTRY -_mesa_DetachShader(GLuint program, GLuint shader); - -extern void GLAPIENTRY -_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj); - -extern void GLAPIENTRY -_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog); - -extern void GLAPIENTRY -_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog); - - -extern void GLAPIENTRY -_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, - GLint *range, GLint *precision); - -extern void GLAPIENTRY -_mesa_ReleaseShaderCompiler(void); - -extern void GLAPIENTRY -_mesa_ShaderBinary(GLint n, const GLuint *shaders, GLenum binaryformat, - const void* binary, GLint length); - -extern void GLAPIENTRY -_mesa_ProgramParameteriARB(GLuint program, GLenum pname, - GLint value); - -#endif /* SHADERAPI_H */ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +#ifndef SHADERAPI_H +#define SHADERAPI_H + + +#include "glheader.h" + +struct _glapi_table; +struct gl_context; +struct gl_shader_program; + +extern GLint +_mesa_sizeof_glsl_type(GLenum type); + +extern void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src); + +extern void +_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg); + +extern void +_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, + const char *caller); + +extern void +_mesa_init_shader_dispatch(struct _glapi_table *exec); + + + +extern void GLAPIENTRY +_mesa_AttachObjectARB(GLhandleARB, GLhandleARB); + +extern void GLAPIENTRY +_mesa_CompileShaderARB(GLhandleARB); + +extern GLhandleARB GLAPIENTRY +_mesa_CreateProgramObjectARB(void); + +extern GLhandleARB GLAPIENTRY +_mesa_CreateShaderObjectARB(GLenum type); + +extern void GLAPIENTRY +_mesa_DeleteObjectARB(GLhandleARB obj); + +extern void GLAPIENTRY +_mesa_DetachObjectARB(GLhandleARB, GLhandleARB); + +extern void GLAPIENTRY +_mesa_GetAttachedObjectsARB(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); + +extern GLint GLAPIENTRY +_mesa_GetFragDataLocation(GLuint program, const GLchar *name); + +extern GLhandleARB GLAPIENTRY +_mesa_GetHandleARB(GLenum pname); + +extern void GLAPIENTRY +_mesa_GetInfoLogARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); + +extern void GLAPIENTRY +_mesa_GetObjectParameterfvARB(GLhandleARB, GLenum, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetObjectParameterivARB(GLhandleARB, GLenum, GLint *); + +extern void GLAPIENTRY +_mesa_GetShaderSourceARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); + +extern GLboolean GLAPIENTRY +_mesa_IsProgram(GLuint name); + +extern GLboolean GLAPIENTRY +_mesa_IsShader(GLuint name); + +extern void GLAPIENTRY +_mesa_LinkProgramARB(GLhandleARB programObj); + +extern void GLAPIENTRY +_mesa_ShaderSourceARB(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); + +extern void GLAPIENTRY +_mesa_UseProgramObjectARB(GLhandleARB); + +extern void GLAPIENTRY +_mesa_ValidateProgramARB(GLhandleARB); + + +extern void GLAPIENTRY +_mesa_BindAttribLocationARB(GLhandleARB, GLuint, const GLcharARB *); + +extern void GLAPIENTRY +_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, + const GLchar *name); + +extern void GLAPIENTRY +_mesa_GetActiveAttribARB(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, + GLenum *, GLcharARB *); + +extern GLint GLAPIENTRY +_mesa_GetAttribLocationARB(GLhandleARB, const GLcharARB *); + + + +extern void GLAPIENTRY +_mesa_AttachShader(GLuint program, GLuint shader); + +extern GLuint GLAPIENTRY +_mesa_CreateShader(GLenum); + +extern GLuint GLAPIENTRY +_mesa_CreateProgram(void); + +extern void GLAPIENTRY +_mesa_DeleteProgram(GLuint program); + +extern void GLAPIENTRY +_mesa_DeleteShader(GLuint shader); + +extern void GLAPIENTRY +_mesa_DetachShader(GLuint program, GLuint shader); + +extern void GLAPIENTRY +_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, + GLsizei *count, GLuint *obj); + +extern void GLAPIENTRY +_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, + GLsizei *length, GLchar *infoLog); + +extern void GLAPIENTRY +_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, + GLsizei *length, GLchar *infoLog); + + +extern void GLAPIENTRY +_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, + GLint *range, GLint *precision); + +extern void GLAPIENTRY +_mesa_ReleaseShaderCompiler(void); + +extern void GLAPIENTRY +_mesa_ShaderBinary(GLint n, const GLuint *shaders, GLenum binaryformat, + const void* binary, GLint length); + +extern void GLAPIENTRY +_mesa_ProgramParameteriARB(GLuint program, GLenum pname, + GLint value); +void +_mesa_use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg); + +extern void GLAPIENTRY +_mesa_UseShaderProgramEXT(GLenum type, GLuint program); + +extern void GLAPIENTRY +_mesa_ActiveProgramEXT(GLuint program); + +extern GLuint GLAPIENTRY +_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string); + +#endif /* SHADERAPI_H */ diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c index 2de8f2798..60f133691 100644 --- a/mesalib/src/mesa/main/shaderobj.c +++ b/mesalib/src/mesa/main/shaderobj.c @@ -1,408 +1,411 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file shaderobj.c - * \author Brian Paul - * - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/shaderobj.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_uniform.h" -#include "talloc.h" - -/**********************************************************************/ -/*** Shader object functions ***/ -/**********************************************************************/ - - -/** - * Set ptr to point to sh. - * If ptr is pointing to another shader, decrement its refcount (and delete - * if refcount hits zero). - * Then set ptr to point to sh, incrementing its refcount. - */ -void -_mesa_reference_shader(GLcontext *ctx, struct gl_shader **ptr, - struct gl_shader *sh) -{ - assert(ptr); - if (*ptr == sh) { - /* no-op */ - return; - } - if (*ptr) { - /* Unreference the old shader */ - GLboolean deleteFlag = GL_FALSE; - struct gl_shader *old = *ptr; - - ASSERT(old->RefCount > 0); - old->RefCount--; - /*printf("SHADER DECR %p (%d) to %d\n", - (void*) old, old->Name, old->RefCount);*/ - deleteFlag = (old->RefCount == 0); - - if (deleteFlag) { - _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); - ctx->Driver.DeleteShader(ctx, old); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (sh) { - /* reference new */ - sh->RefCount++; - /*printf("SHADER INCR %p (%d) to %d\n", - (void*) sh, sh->Name, sh->RefCount);*/ - *ptr = sh; - } -} - -void -_mesa_init_shader(GLcontext *ctx, struct gl_shader *shader) -{ - shader->RefCount = 1; -} - -/** - * Allocate a new gl_shader object, initialize it. - * Called via ctx->Driver.NewShader() - */ -struct gl_shader * -_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type) -{ - struct gl_shader *shader; - assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER || - type == GL_GEOMETRY_SHADER_ARB); - shader = talloc_zero(NULL, struct gl_shader); - if (shader) { - shader->Type = type; - shader->Name = name; - _mesa_init_shader(ctx, shader); - } - return shader; -} - - -/** - * Delete a shader object. - * Called via ctx->Driver.DeleteShader(). - */ -static void -_mesa_delete_shader(GLcontext *ctx, struct gl_shader *sh) -{ - if (sh->Source) - free((void *) sh->Source); - _mesa_reference_program(ctx, &sh->Program, NULL); - talloc_free(sh); -} - - -/** - * Lookup a GLSL shader object. - */ -struct gl_shader * -_mesa_lookup_shader(GLcontext *ctx, GLuint name) -{ - if (name) { - struct gl_shader *sh = (struct gl_shader *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - /* Note that both gl_shader and gl_shader_program objects are kept - * in the same hash table. Check the object's type to be sure it's - * what we're expecting. - */ - if (sh && sh->Type == GL_SHADER_PROGRAM_MESA) { - return NULL; - } - return sh; - } - return NULL; -} - - -/** - * As above, but record an error if shader is not found. - */ -struct gl_shader * -_mesa_lookup_shader_err(GLcontext *ctx, GLuint name, const char *caller) -{ - if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - else { - struct gl_shader *sh = (struct gl_shader *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - if (sh->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - return sh; - } -} - - - -/**********************************************************************/ -/*** Shader Program object functions ***/ -/**********************************************************************/ - - -/** - * Set ptr to point to shProg. - * If ptr is pointing to another object, decrement its refcount (and delete - * if refcount hits zero). - * Then set ptr to point to shProg, incrementing its refcount. - */ -void -_mesa_reference_shader_program(GLcontext *ctx, - struct gl_shader_program **ptr, - struct gl_shader_program *shProg) -{ - assert(ptr); - if (*ptr == shProg) { - /* no-op */ - return; - } - if (*ptr) { - /* Unreference the old shader program */ - GLboolean deleteFlag = GL_FALSE; - struct gl_shader_program *old = *ptr; - - ASSERT(old->RefCount > 0); - old->RefCount--; -#if 0 - printf("ShaderProgram %p ID=%u RefCount-- to %d\n", - (void *) old, old->Name, old->RefCount); -#endif - deleteFlag = (old->RefCount == 0); - - if (deleteFlag) { - _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); - ctx->Driver.DeleteShaderProgram(ctx, old); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (shProg) { - shProg->RefCount++; -#if 0 - printf("ShaderProgram %p ID=%u RefCount++ to %d\n", - (void *) shProg, shProg->Name, shProg->RefCount); -#endif - *ptr = shProg; - } -} - -void -_mesa_init_shader_program(GLcontext *ctx, struct gl_shader_program *prog) -{ - prog->Type = GL_SHADER_PROGRAM_MESA; - prog->RefCount = 1; - prog->Attributes = _mesa_new_parameter_list(); -#if FEATURE_ARB_geometry_shader4 - prog->Geom.VerticesOut = 0; - prog->Geom.InputType = GL_TRIANGLES; - prog->Geom.OutputType = GL_TRIANGLE_STRIP; -#endif -} - -/** - * Allocate a new gl_shader_program object, initialize it. - * Called via ctx->Driver.NewShaderProgram() - */ -static struct gl_shader_program * -_mesa_new_shader_program(GLcontext *ctx, GLuint name) -{ - struct gl_shader_program *shProg; - shProg = talloc_zero(NULL, struct gl_shader_program); - if (shProg) { - shProg->Name = name; - _mesa_init_shader_program(ctx, shProg); - } - return shProg; -} - - -/** - * Clear (free) the shader program state that gets produced by linking. - */ -void -_mesa_clear_shader_program_data(GLcontext *ctx, - struct gl_shader_program *shProg) -{ - _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL); - _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL); - _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL); - - if (shProg->Uniforms) { - _mesa_free_uniform_list(shProg->Uniforms); - shProg->Uniforms = NULL; - } - - if (shProg->Varying) { - _mesa_free_parameter_list(shProg->Varying); - shProg->Varying = NULL; - } -} - - -/** - * Free all the data that hangs off a shader program object, but not the - * object itself. - */ -void -_mesa_free_shader_program_data(GLcontext *ctx, - struct gl_shader_program *shProg) -{ - GLuint i; - - assert(shProg->Type == GL_SHADER_PROGRAM_MESA); - - _mesa_clear_shader_program_data(ctx, shProg); - - if (shProg->Attributes) { - _mesa_free_parameter_list(shProg->Attributes); - shProg->Attributes = NULL; - } - - /* detach shaders */ - for (i = 0; i < shProg->NumShaders; i++) { - _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); - } - shProg->NumShaders = 0; - - if (shProg->Shaders) { - free(shProg->Shaders); - shProg->Shaders = NULL; - } - - if (shProg->InfoLog) { - talloc_free(shProg->InfoLog); - shProg->InfoLog = NULL; - } - - /* Transform feedback varying vars */ - for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { - free(shProg->TransformFeedback.VaryingNames[i]); - } - free(shProg->TransformFeedback.VaryingNames); - shProg->TransformFeedback.VaryingNames = NULL; - shProg->TransformFeedback.NumVarying = 0; - - - for (i = 0; i < shProg->_NumLinkedShaders; i++) { - ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[i]); - } - shProg->_NumLinkedShaders = 0; -} - - -/** - * Free/delete a shader program object. - * Called via ctx->Driver.DeleteShaderProgram(). - */ -static void -_mesa_delete_shader_program(GLcontext *ctx, struct gl_shader_program *shProg) -{ - _mesa_free_shader_program_data(ctx, shProg); - - talloc_free(shProg); -} - - -/** - * Lookup a GLSL program object. - */ -struct gl_shader_program * -_mesa_lookup_shader_program(GLcontext *ctx, GLuint name) -{ - struct gl_shader_program *shProg; - if (name) { - shProg = (struct gl_shader_program *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - /* Note that both gl_shader and gl_shader_program objects are kept - * in the same hash table. Check the object's type to be sure it's - * what we're expecting. - */ - if (shProg && shProg->Type != GL_SHADER_PROGRAM_MESA) { - return NULL; - } - return shProg; - } - return NULL; -} - - -/** - * As above, but record an error if program is not found. - */ -struct gl_shader_program * -_mesa_lookup_shader_program_err(GLcontext *ctx, GLuint name, - const char *caller) -{ - if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - else { - struct gl_shader_program *shProg = (struct gl_shader_program *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - if (shProg->Type != GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - return shProg; - } -} - - -void -_mesa_init_shader_object_functions(struct dd_function_table *driver) -{ - driver->NewShader = _mesa_new_shader; - driver->DeleteShader = _mesa_delete_shader; - driver->NewShaderProgram = _mesa_new_shader_program; - driver->DeleteShaderProgram = _mesa_delete_shader_program; - driver->CompileShader = _mesa_ir_compile_shader; - driver->LinkShader = _mesa_ir_link_shader; -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file shaderobj.c + * \author Brian Paul + * + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/shaderobj.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "program/prog_uniform.h" +#include "talloc.h" + +/**********************************************************************/ +/*** Shader object functions ***/ +/**********************************************************************/ + + +/** + * Set ptr to point to sh. + * If ptr is pointing to another shader, decrement its refcount (and delete + * if refcount hits zero). + * Then set ptr to point to sh, incrementing its refcount. + */ +void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh) +{ + assert(ptr); + if (*ptr == sh) { + /* no-op */ + return; + } + if (*ptr) { + /* Unreference the old shader */ + GLboolean deleteFlag = GL_FALSE; + struct gl_shader *old = *ptr; + + ASSERT(old->RefCount > 0); + old->RefCount--; + /*printf("SHADER DECR %p (%d) to %d\n", + (void*) old, old->Name, old->RefCount);*/ + deleteFlag = (old->RefCount == 0); + + if (deleteFlag) { + _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); + ctx->Driver.DeleteShader(ctx, old); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (sh) { + /* reference new */ + sh->RefCount++; + /*printf("SHADER INCR %p (%d) to %d\n", + (void*) sh, sh->Name, sh->RefCount);*/ + *ptr = sh; + } +} + +void +_mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader) +{ + shader->RefCount = 1; +} + +/** + * Allocate a new gl_shader object, initialize it. + * Called via ctx->Driver.NewShader() + */ +struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) +{ + struct gl_shader *shader; + assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER || + type == GL_GEOMETRY_SHADER_ARB); + shader = talloc_zero(NULL, struct gl_shader); + if (shader) { + shader->Type = type; + shader->Name = name; + _mesa_init_shader(ctx, shader); + } + return shader; +} + + +/** + * Delete a shader object. + * Called via ctx->Driver.DeleteShader(). + */ +static void +_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) +{ + if (sh->Source) + free((void *) sh->Source); + _mesa_reference_program(ctx, &sh->Program, NULL); + talloc_free(sh); +} + + +/** + * Lookup a GLSL shader object. + */ +struct gl_shader * +_mesa_lookup_shader(struct gl_context *ctx, GLuint name) +{ + if (name) { + struct gl_shader *sh = (struct gl_shader *) + _mesa_HashLookup(ctx->Shared->ShaderObjects, name); + /* Note that both gl_shader and gl_shader_program objects are kept + * in the same hash table. Check the object's type to be sure it's + * what we're expecting. + */ + if (sh && sh->Type == GL_SHADER_PROGRAM_MESA) { + return NULL; + } + return sh; + } + return NULL; +} + + +/** + * As above, but record an error if shader is not found. + */ +struct gl_shader * +_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller) +{ + if (!name) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); + return NULL; + } + else { + struct gl_shader *sh = (struct gl_shader *) + _mesa_HashLookup(ctx->Shared->ShaderObjects, name); + if (!sh) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); + return NULL; + } + if (sh->Type == GL_SHADER_PROGRAM_MESA) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + return NULL; + } + return sh; + } +} + + + +/**********************************************************************/ +/*** Shader Program object functions ***/ +/**********************************************************************/ + + +/** + * Set ptr to point to shProg. + * If ptr is pointing to another object, decrement its refcount (and delete + * if refcount hits zero). + * Then set ptr to point to shProg, incrementing its refcount. + */ +void +_mesa_reference_shader_program(struct gl_context *ctx, + struct gl_shader_program **ptr, + struct gl_shader_program *shProg) +{ + assert(ptr); + if (*ptr == shProg) { + /* no-op */ + return; + } + if (*ptr) { + /* Unreference the old shader program */ + GLboolean deleteFlag = GL_FALSE; + struct gl_shader_program *old = *ptr; + + ASSERT(old->RefCount > 0); + old->RefCount--; +#if 0 + printf("ShaderProgram %p ID=%u RefCount-- to %d\n", + (void *) old, old->Name, old->RefCount); +#endif + deleteFlag = (old->RefCount == 0); + + if (deleteFlag) { + _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); + ctx->Driver.DeleteShaderProgram(ctx, old); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (shProg) { + shProg->RefCount++; +#if 0 + printf("ShaderProgram %p ID=%u RefCount++ to %d\n", + (void *) shProg, shProg->Name, shProg->RefCount); +#endif + *ptr = shProg; + } +} + +void +_mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog) +{ + prog->Type = GL_SHADER_PROGRAM_MESA; + prog->RefCount = 1; + prog->Attributes = _mesa_new_parameter_list(); +#if FEATURE_ARB_geometry_shader4 + prog->Geom.VerticesOut = 0; + prog->Geom.InputType = GL_TRIANGLES; + prog->Geom.OutputType = GL_TRIANGLE_STRIP; +#endif +} + +/** + * Allocate a new gl_shader_program object, initialize it. + * Called via ctx->Driver.NewShaderProgram() + */ +static struct gl_shader_program * +_mesa_new_shader_program(struct gl_context *ctx, GLuint name) +{ + struct gl_shader_program *shProg; + shProg = talloc_zero(NULL, struct gl_shader_program); + if (shProg) { + shProg->Name = name; + _mesa_init_shader_program(ctx, shProg); + } + return shProg; +} + + +/** + * Clear (free) the shader program state that gets produced by linking. + */ +void +_mesa_clear_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg) +{ + _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL); + _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL); + _mesa_reference_geomprog(ctx, &shProg->GeometryProgram, NULL); + + if (shProg->Uniforms) { + _mesa_free_uniform_list(shProg->Uniforms); + shProg->Uniforms = NULL; + } + + if (shProg->Varying) { + _mesa_free_parameter_list(shProg->Varying); + shProg->Varying = NULL; + } +} + + +/** + * Free all the data that hangs off a shader program object, but not the + * object itself. + */ +void +_mesa_free_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg) +{ + GLuint i; + gl_shader_type sh; + + assert(shProg->Type == GL_SHADER_PROGRAM_MESA); + + _mesa_clear_shader_program_data(ctx, shProg); + + if (shProg->Attributes) { + _mesa_free_parameter_list(shProg->Attributes); + shProg->Attributes = NULL; + } + + /* detach shaders */ + for (i = 0; i < shProg->NumShaders; i++) { + _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); + } + shProg->NumShaders = 0; + + if (shProg->Shaders) { + free(shProg->Shaders); + shProg->Shaders = NULL; + } + + if (shProg->InfoLog) { + talloc_free(shProg->InfoLog); + shProg->InfoLog = NULL; + } + + /* Transform feedback varying vars */ + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + free(shProg->TransformFeedback.VaryingNames[i]); + } + free(shProg->TransformFeedback.VaryingNames); + shProg->TransformFeedback.VaryingNames = NULL; + shProg->TransformFeedback.NumVarying = 0; + + + for (sh = 0; sh < MESA_SHADER_TYPES; sh++) { + if (shProg->_LinkedShaders[sh] != NULL) { + ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]); + shProg->_LinkedShaders[sh] = NULL; + } + } +} + + +/** + * Free/delete a shader program object. + * Called via ctx->Driver.DeleteShaderProgram(). + */ +static void +_mesa_delete_shader_program(struct gl_context *ctx, struct gl_shader_program *shProg) +{ + _mesa_free_shader_program_data(ctx, shProg); + + talloc_free(shProg); +} + + +/** + * Lookup a GLSL program object. + */ +struct gl_shader_program * +_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name) +{ + struct gl_shader_program *shProg; + if (name) { + shProg = (struct gl_shader_program *) + _mesa_HashLookup(ctx->Shared->ShaderObjects, name); + /* Note that both gl_shader and gl_shader_program objects are kept + * in the same hash table. Check the object's type to be sure it's + * what we're expecting. + */ + if (shProg && shProg->Type != GL_SHADER_PROGRAM_MESA) { + return NULL; + } + return shProg; + } + return NULL; +} + + +/** + * As above, but record an error if program is not found. + */ +struct gl_shader_program * +_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, + const char *caller) +{ + if (!name) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); + return NULL; + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) + _mesa_HashLookup(ctx->Shared->ShaderObjects, name); + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); + return NULL; + } + if (shProg->Type != GL_SHADER_PROGRAM_MESA) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); + return NULL; + } + return shProg; + } +} + + +void +_mesa_init_shader_object_functions(struct dd_function_table *driver) +{ + driver->NewShader = _mesa_new_shader; + driver->DeleteShader = _mesa_delete_shader; + driver->NewShaderProgram = _mesa_new_shader_program; + driver->DeleteShaderProgram = _mesa_delete_shader_program; + driver->CompileShader = _mesa_ir_compile_shader; + driver->LinkShader = _mesa_ir_link_shader; +} diff --git a/mesalib/src/mesa/main/shaderobj.h b/mesalib/src/mesa/main/shaderobj.h index cbe7ae7b0..881856a02 100644 --- a/mesalib/src/mesa/main/shaderobj.h +++ b/mesalib/src/mesa/main/shaderobj.h @@ -1,134 +1,137 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef SHADEROBJ_H -#define SHADEROBJ_H - - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "program/ir_to_mesa.h" - -#ifdef __cplusplus -extern "C" { -#endif -/** - * Internal functions - */ - -extern void -_mesa_init_shader_state(GLcontext * ctx); - -extern void -_mesa_free_shader_state(GLcontext *ctx); - - -extern void -_mesa_reference_shader(GLcontext *ctx, struct gl_shader **ptr, - struct gl_shader *sh); - -extern struct gl_shader * -_mesa_lookup_shader(GLcontext *ctx, GLuint name); - -extern struct gl_shader * -_mesa_lookup_shader_err(GLcontext *ctx, GLuint name, const char *caller); - - - -extern void -_mesa_reference_shader_program(GLcontext *ctx, - struct gl_shader_program **ptr, - struct gl_shader_program *shProg); -extern void -_mesa_init_shader(GLcontext *ctx, struct gl_shader *shader); - -extern struct gl_shader * -_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type); - -extern void -_mesa_init_shader_program(GLcontext *ctx, struct gl_shader_program *prog); - -extern struct gl_shader_program * -_mesa_lookup_shader_program(GLcontext *ctx, GLuint name); - -extern struct gl_shader_program * -_mesa_lookup_shader_program_err(GLcontext *ctx, GLuint name, - const char *caller); - -extern void -_mesa_clear_shader_program_data(GLcontext *ctx, - struct gl_shader_program *shProg); - -extern void -_mesa_free_shader_program_data(GLcontext *ctx, - struct gl_shader_program *shProg); - - - -extern void -_mesa_init_shader_object_functions(struct dd_function_table *driver); - -extern void -_mesa_init_shader_state(GLcontext *ctx); - -extern void -_mesa_free_shader_state(GLcontext *ctx); - -static INLINE GLuint -_mesa_shader_type_to_index(GLenum v) -{ - switch(v) - { - case GL_VERTEX_SHADER: - return MESA_SHADER_VERTEX; - case GL_FRAGMENT_SHADER: - return MESA_SHADER_FRAGMENT; - case GL_GEOMETRY_SHADER: - return MESA_SHADER_GEOMETRY; - default: - ASSERT(0); - return ~0; - } -} - -static INLINE GLenum -_mesa_shader_index_to_type(GLuint i) -{ - GLenum enums[MESA_SHADER_TYPES] = { - GL_VERTEX_SHADER, - GL_FRAGMENT_SHADER, - GL_GEOMETRY_SHADER , - }; - if(i >= MESA_SHADER_TYPES) - return 0; - else - return enums[i]; -} - -#ifdef __cplusplus -} -#endif - -#endif /* SHADEROBJ_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef SHADEROBJ_H +#define SHADEROBJ_H + + +#include "main/compiler.h" +#include "main/glheader.h" +#include "main/mtypes.h" +#include "program/ir_to_mesa.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * Internal functions + */ + +extern void +_mesa_init_shader_state(struct gl_context * ctx); + +extern void +_mesa_free_shader_state(struct gl_context *ctx); + + +extern void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh); + +extern struct gl_shader * +_mesa_lookup_shader(struct gl_context *ctx, GLuint name); + +extern struct gl_shader * +_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller); + + + +extern void +_mesa_reference_shader_program(struct gl_context *ctx, + struct gl_shader_program **ptr, + struct gl_shader_program *shProg); +extern void +_mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader); + +extern struct gl_shader * +_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); + +extern void +_mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog); + +extern struct gl_shader_program * +_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name); + +extern struct gl_shader_program * +_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, + const char *caller); + +extern void +_mesa_clear_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg); + +extern void +_mesa_free_shader_program_data(struct gl_context *ctx, + struct gl_shader_program *shProg); + + + +extern void +_mesa_init_shader_object_functions(struct dd_function_table *driver); + +extern void +_mesa_init_shader_state(struct gl_context *ctx); + +extern void +_mesa_free_shader_state(struct gl_context *ctx); + + +static INLINE gl_shader_type +_mesa_shader_type_to_index(GLenum v) +{ + switch (v) { + case GL_VERTEX_SHADER: + return MESA_SHADER_VERTEX; + case GL_FRAGMENT_SHADER: + return MESA_SHADER_FRAGMENT; + case GL_GEOMETRY_SHADER: + return MESA_SHADER_GEOMETRY; + default: + ASSERT(0 && "bad value in _mesa_shader_type_to_index()"); + return MESA_SHADER_TYPES; + } +} + + +static INLINE GLenum +_mesa_shader_index_to_type(GLuint i) +{ + static const GLenum enums[MESA_SHADER_TYPES] = { + GL_VERTEX_SHADER, + GL_FRAGMENT_SHADER, + GL_GEOMETRY_SHADER , + }; + if (i >= MESA_SHADER_TYPES) + return 0; + else + return enums[i]; +} + + +#ifdef __cplusplus +} +#endif + +#endif /* SHADEROBJ_H */ diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index a56c70fa7..bfbddaaa0 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -1,390 +1,390 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file shared.c - * Shared-context state - */ - - - -#include "imports.h" -#include "mtypes.h" -#include "hash.h" -#if FEATURE_ATI_fragment_shader -#include "atifragshader.h" -#endif -#include "bufferobj.h" -#include "shared.h" -#include "program/program.h" -#include "dlist.h" -#include "shaderobj.h" -#include "syncobj.h" - -/** - * Allocate and initialize a shared context state structure. - * Initializes the display list, texture objects and vertex programs hash - * tables, allocates the texture objects. If it runs out of memory, frees - * everything already allocated before returning NULL. - * - * \return pointer to a gl_shared_state structure on success, or NULL on - * failure. - */ -struct gl_shared_state * -_mesa_alloc_shared_state(GLcontext *ctx) -{ - struct gl_shared_state *shared; - GLuint i; - - shared = CALLOC_STRUCT(gl_shared_state); - if (!shared) - return NULL; - - _glthread_INIT_MUTEX(shared->Mutex); - - shared->DisplayList = _mesa_NewHashTable(); - shared->TexObjects = _mesa_NewHashTable(); - shared->Programs = _mesa_NewHashTable(); - -#if FEATURE_ARB_vertex_program - shared->DefaultVertexProgram = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ARB_fragment_program - shared->DefaultFragmentProgram = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ATI_fragment_shader - shared->ATIShaders = _mesa_NewHashTable(); - shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); -#endif - -#if FEATURE_ARB_shader_objects - shared->ShaderObjects = _mesa_NewHashTable(); -#endif - -#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object - shared->BufferObjects = _mesa_NewHashTable(); -#endif - - /* Allocate the default buffer object */ - shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); - - /* Create default texture objects */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ - static const GLenum targets[NUM_TEXTURE_TARGETS] = { - GL_TEXTURE_2D_ARRAY_EXT, - GL_TEXTURE_1D_ARRAY_EXT, - GL_TEXTURE_CUBE_MAP, - GL_TEXTURE_3D, - GL_TEXTURE_RECTANGLE_NV, - GL_TEXTURE_2D, - GL_TEXTURE_1D - }; - shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); - } - - /* sanity check */ - assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1); - - /* Mutex and timestamp for texobj state validation */ - _glthread_INIT_MUTEX(shared->TexMutex); - shared->TextureStateStamp = 0; - -#if FEATURE_EXT_framebuffer_object - shared->FrameBuffers = _mesa_NewHashTable(); - shared->RenderBuffers = _mesa_NewHashTable(); -#endif - - make_empty_list(& shared->SyncObjects); - - return shared; -} - - -/** - * Callback for deleting a display list. Called by _mesa_HashDeleteAll(). - */ -static void -delete_displaylist_cb(GLuint id, void *data, void *userData) -{ - struct gl_display_list *list = (struct gl_display_list *) data; - GLcontext *ctx = (GLcontext *) userData; - _mesa_delete_list(ctx, list); -} - - -/** - * Callback for deleting a texture object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_texture_cb(GLuint id, void *data, void *userData) -{ - struct gl_texture_object *texObj = (struct gl_texture_object *) data; - GLcontext *ctx = (GLcontext *) userData; - ctx->Driver.DeleteTexture(ctx, texObj); -} - - -/** - * Callback for deleting a program object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_program_cb(GLuint id, void *data, void *userData) -{ - struct gl_program *prog = (struct gl_program *) data; - GLcontext *ctx = (GLcontext *) userData; - if(prog != &_mesa_DummyProgram) { - ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ - prog->RefCount = 0; /* now going away */ - ctx->Driver.DeleteProgram(ctx, prog); - } -} - - -#if FEATURE_ATI_fragment_shader -/** - * Callback for deleting an ATI fragment shader object. - * Called by _mesa_HashDeleteAll(). - */ -static void -delete_fragshader_cb(GLuint id, void *data, void *userData) -{ - struct ati_fragment_shader *shader = (struct ati_fragment_shader *) data; - GLcontext *ctx = (GLcontext *) userData; - _mesa_delete_ati_fragment_shader(ctx, shader); -} -#endif - - -/** - * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_bufferobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; - GLcontext *ctx = (GLcontext *) userData; - if (_mesa_bufferobj_mapped(bufObj)) { - ctx->Driver.UnmapBuffer(ctx, 0, bufObj); - bufObj->Pointer = NULL; - } - _mesa_reference_buffer_object(ctx, &bufObj, NULL); -} - - -/** - * Callback for freeing shader program data. Call it before delete_shader_cb - * to avoid memory access error. - */ -static void -free_shader_program_data_cb(GLuint id, void *data, void *userData) -{ - GLcontext *ctx = (GLcontext *) userData; - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - - if (shProg->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_free_shader_program_data(ctx, shProg); - } -} - - -/** - * Callback for deleting shader and shader programs objects. - * Called by _mesa_HashDeleteAll(). - */ -static void -delete_shader_cb(GLuint id, void *data, void *userData) -{ - GLcontext *ctx = (GLcontext *) userData; - struct gl_shader *sh = (struct gl_shader *) data; - if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { - ctx->Driver.DeleteShader(ctx, sh); - } - else { - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); - ctx->Driver.DeleteShaderProgram(ctx, shProg); - } -} - - -/** - * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_framebuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - /* The fact that the framebuffer is in the hashtable means its refcount - * is one, but we're removing from the hashtable now. So clear refcount. - */ - /*assert(fb->RefCount == 1);*/ - fb->RefCount = 0; - - /* NOTE: Delete should always be defined but there are two reports - * of it being NULL (bugs 13507, 14293). Work-around for now. - */ - if (fb->Delete) - fb->Delete(fb); -} - - -/** - * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_renderbuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; - rb->RefCount = 0; /* see comment for FBOs above */ - if (rb->Delete) - rb->Delete(rb); -} - - -/** - * Deallocate a shared state object and all children structures. - * - * \param ctx GL context. - * \param shared shared state pointer. - * - * Frees the display lists, the texture objects (calling the driver texture - * deletion callback to free its private data) and the vertex programs, as well - * as their hash tables. - * - * \sa alloc_shared_state(). - */ -static void -free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) -{ - GLuint i; - - /* Free the dummy/fallback texture object */ - if (shared->FallbackTex) - ctx->Driver.DeleteTexture(ctx, shared->FallbackTex); - - /* - * Free display lists - */ - _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); - _mesa_DeleteHashTable(shared->DisplayList); - -#if FEATURE_ARB_shader_objects - _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); - _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); - _mesa_DeleteHashTable(shared->ShaderObjects); -#endif - - _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); - _mesa_DeleteHashTable(shared->Programs); - -#if FEATURE_ARB_vertex_program - _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); -#endif - -#if FEATURE_ARB_fragment_program - _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); -#endif - -#if FEATURE_ATI_fragment_shader - _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); - _mesa_DeleteHashTable(shared->ATIShaders); - _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); -#endif - -#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object - _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); - _mesa_DeleteHashTable(shared->BufferObjects); -#endif - -#if FEATURE_EXT_framebuffer_object - _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); - _mesa_DeleteHashTable(shared->FrameBuffers); - _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); - _mesa_DeleteHashTable(shared->RenderBuffers); -#endif - -#if FEATURE_ARB_vertex_buffer_object - _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); -#endif - - { - struct simple_node *node; - struct simple_node *temp; - - foreach_s(node, temp, & shared->SyncObjects) { - _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); - } - } - - /* - * Free texture objects (after FBOs since some textures might have - * been bound to FBOs). - */ - ASSERT(ctx->Driver.DeleteTexture); - /* the default textures */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); - } - - /* all other textures */ - _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); - _mesa_DeleteHashTable(shared->TexObjects); - - _glthread_DESTROY_MUTEX(shared->Mutex); - _glthread_DESTROY_MUTEX(shared->TexMutex); - - free(shared); -} - - -/** - * Decrement shared state object reference count and potentially free it - * and all children structures. - * - * \param ctx GL context. - * \param shared shared state pointer. - * - * \sa free_shared_state(). - */ -void -_mesa_release_shared_state(GLcontext *ctx, struct gl_shared_state *shared) -{ - GLint RefCount; - - _glthread_LOCK_MUTEX(shared->Mutex); - RefCount = --shared->RefCount; - _glthread_UNLOCK_MUTEX(shared->Mutex); - - assert(RefCount >= 0); - - if (RefCount == 0) { - /* free shared state */ - free_shared_state( ctx, shared ); - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file shared.c + * Shared-context state + */ + + + +#include "imports.h" +#include "mtypes.h" +#include "hash.h" +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif +#include "bufferobj.h" +#include "shared.h" +#include "program/program.h" +#include "dlist.h" +#include "shaderobj.h" +#include "syncobj.h" + +/** + * Allocate and initialize a shared context state structure. + * Initializes the display list, texture objects and vertex programs hash + * tables, allocates the texture objects. If it runs out of memory, frees + * everything already allocated before returning NULL. + * + * \return pointer to a gl_shared_state structure on success, or NULL on + * failure. + */ +struct gl_shared_state * +_mesa_alloc_shared_state(struct gl_context *ctx) +{ + struct gl_shared_state *shared; + GLuint i; + + shared = CALLOC_STRUCT(gl_shared_state); + if (!shared) + return NULL; + + _glthread_INIT_MUTEX(shared->Mutex); + + shared->DisplayList = _mesa_NewHashTable(); + shared->TexObjects = _mesa_NewHashTable(); + shared->Programs = _mesa_NewHashTable(); + +#if FEATURE_ARB_vertex_program + shared->DefaultVertexProgram = (struct gl_vertex_program *) + ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); +#endif + +#if FEATURE_ARB_fragment_program + shared->DefaultFragmentProgram = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); +#endif + +#if FEATURE_ATI_fragment_shader + shared->ATIShaders = _mesa_NewHashTable(); + shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); +#endif + +#if FEATURE_ARB_shader_objects + shared->ShaderObjects = _mesa_NewHashTable(); +#endif + +#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object + shared->BufferObjects = _mesa_NewHashTable(); +#endif + + /* Allocate the default buffer object */ + shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); + + /* Create default texture objects */ + for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { + /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ + static const GLenum targets[NUM_TEXTURE_TARGETS] = { + GL_TEXTURE_2D_ARRAY_EXT, + GL_TEXTURE_1D_ARRAY_EXT, + GL_TEXTURE_CUBE_MAP, + GL_TEXTURE_3D, + GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_2D, + GL_TEXTURE_1D + }; + shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); + } + + /* sanity check */ + assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1); + + /* Mutex and timestamp for texobj state validation */ + _glthread_INIT_MUTEX(shared->TexMutex); + shared->TextureStateStamp = 0; + +#if FEATURE_EXT_framebuffer_object + shared->FrameBuffers = _mesa_NewHashTable(); + shared->RenderBuffers = _mesa_NewHashTable(); +#endif + + make_empty_list(& shared->SyncObjects); + + return shared; +} + + +/** + * Callback for deleting a display list. Called by _mesa_HashDeleteAll(). + */ +static void +delete_displaylist_cb(GLuint id, void *data, void *userData) +{ + struct gl_display_list *list = (struct gl_display_list *) data; + struct gl_context *ctx = (struct gl_context *) userData; + _mesa_delete_list(ctx, list); +} + + +/** + * Callback for deleting a texture object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_texture_cb(GLuint id, void *data, void *userData) +{ + struct gl_texture_object *texObj = (struct gl_texture_object *) data; + struct gl_context *ctx = (struct gl_context *) userData; + ctx->Driver.DeleteTexture(ctx, texObj); +} + + +/** + * Callback for deleting a program object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_program_cb(GLuint id, void *data, void *userData) +{ + struct gl_program *prog = (struct gl_program *) data; + struct gl_context *ctx = (struct gl_context *) userData; + if(prog != &_mesa_DummyProgram) { + ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ + prog->RefCount = 0; /* now going away */ + ctx->Driver.DeleteProgram(ctx, prog); + } +} + + +#if FEATURE_ATI_fragment_shader +/** + * Callback for deleting an ATI fragment shader object. + * Called by _mesa_HashDeleteAll(). + */ +static void +delete_fragshader_cb(GLuint id, void *data, void *userData) +{ + struct ati_fragment_shader *shader = (struct ati_fragment_shader *) data; + struct gl_context *ctx = (struct gl_context *) userData; + _mesa_delete_ati_fragment_shader(ctx, shader); +} +#endif + + +/** + * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_bufferobj_cb(GLuint id, void *data, void *userData) +{ + struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; + struct gl_context *ctx = (struct gl_context *) userData; + if (_mesa_bufferobj_mapped(bufObj)) { + ctx->Driver.UnmapBuffer(ctx, 0, bufObj); + bufObj->Pointer = NULL; + } + _mesa_reference_buffer_object(ctx, &bufObj, NULL); +} + + +/** + * Callback for freeing shader program data. Call it before delete_shader_cb + * to avoid memory access error. + */ +static void +free_shader_program_data_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + + if (shProg->Type == GL_SHADER_PROGRAM_MESA) { + _mesa_free_shader_program_data(ctx, shProg); + } +} + + +/** + * Callback for deleting shader and shader programs objects. + * Called by _mesa_HashDeleteAll(). + */ +static void +delete_shader_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader *sh = (struct gl_shader *) data; + if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { + ctx->Driver.DeleteShader(ctx, sh); + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); + ctx->Driver.DeleteShaderProgram(ctx, shProg); + } +} + + +/** + * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_framebuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + /* The fact that the framebuffer is in the hashtable means its refcount + * is one, but we're removing from the hashtable now. So clear refcount. + */ + /*assert(fb->RefCount == 1);*/ + fb->RefCount = 0; + + /* NOTE: Delete should always be defined but there are two reports + * of it being NULL (bugs 13507, 14293). Work-around for now. + */ + if (fb->Delete) + fb->Delete(fb); +} + + +/** + * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_renderbuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; + rb->RefCount = 0; /* see comment for FBOs above */ + if (rb->Delete) + rb->Delete(rb); +} + + +/** + * Deallocate a shared state object and all children structures. + * + * \param ctx GL context. + * \param shared shared state pointer. + * + * Frees the display lists, the texture objects (calling the driver texture + * deletion callback to free its private data) and the vertex programs, as well + * as their hash tables. + * + * \sa alloc_shared_state(). + */ +static void +free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) +{ + GLuint i; + + /* Free the dummy/fallback texture object */ + if (shared->FallbackTex) + ctx->Driver.DeleteTexture(ctx, shared->FallbackTex); + + /* + * Free display lists + */ + _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); + _mesa_DeleteHashTable(shared->DisplayList); + +#if FEATURE_ARB_shader_objects + _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); + _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); + _mesa_DeleteHashTable(shared->ShaderObjects); +#endif + + _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); + _mesa_DeleteHashTable(shared->Programs); + +#if FEATURE_ARB_vertex_program + _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); +#endif + +#if FEATURE_ARB_fragment_program + _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); +#endif + +#if FEATURE_ATI_fragment_shader + _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); + _mesa_DeleteHashTable(shared->ATIShaders); + _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); +#endif + +#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object + _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); + _mesa_DeleteHashTable(shared->BufferObjects); +#endif + +#if FEATURE_EXT_framebuffer_object + _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); + _mesa_DeleteHashTable(shared->FrameBuffers); + _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); + _mesa_DeleteHashTable(shared->RenderBuffers); +#endif + +#if FEATURE_ARB_vertex_buffer_object + _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); +#endif + + { + struct simple_node *node; + struct simple_node *temp; + + foreach_s(node, temp, & shared->SyncObjects) { + _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); + } + } + + /* + * Free texture objects (after FBOs since some textures might have + * been bound to FBOs). + */ + ASSERT(ctx->Driver.DeleteTexture); + /* the default textures */ + for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { + ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); + } + + /* all other textures */ + _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); + _mesa_DeleteHashTable(shared->TexObjects); + + _glthread_DESTROY_MUTEX(shared->Mutex); + _glthread_DESTROY_MUTEX(shared->TexMutex); + + free(shared); +} + + +/** + * Decrement shared state object reference count and potentially free it + * and all children structures. + * + * \param ctx GL context. + * \param shared shared state pointer. + * + * \sa free_shared_state(). + */ +void +_mesa_release_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) +{ + GLint RefCount; + + _glthread_LOCK_MUTEX(shared->Mutex); + RefCount = --shared->RefCount; + _glthread_UNLOCK_MUTEX(shared->Mutex); + + assert(RefCount >= 0); + + if (RefCount == 0) { + /* free shared state */ + free_shared_state( ctx, shared ); + } +} diff --git a/mesalib/src/mesa/main/shared.h b/mesalib/src/mesa/main/shared.h index 5166a0ce5..870aadeb2 100644 --- a/mesalib/src/mesa/main/shared.h +++ b/mesalib/src/mesa/main/shared.h @@ -1,38 +1,38 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef SHARED_H -#define SHARED_H - -#include "mtypes.h" - -struct gl_shared_state * -_mesa_alloc_shared_state(GLcontext *ctx); - - -void -_mesa_release_shared_state(GLcontext *ctx, struct gl_shared_state *shared); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef SHARED_H +#define SHARED_H + +struct gl_context; + +struct gl_shared_state * +_mesa_alloc_shared_state(struct gl_context *ctx); + + +void +_mesa_release_shared_state(struct gl_context *ctx, struct gl_shared_state *shared); + + +#endif diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 4a3dffe4c..c07e2c380 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -1,734 +1,732 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file state.c - * State management. - * - * This file manages recalculation of derived values in GLcontext. - */ - - -#include "glheader.h" -#include "mtypes.h" -#include "context.h" -#include "debug.h" -#include "macros.h" -#include "ffvertex_prog.h" -#include "framebuffer.h" -#include "light.h" -#include "matrix.h" -#include "pixel.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "state.h" -#include "stencil.h" -#include "texenvprogram.h" -#include "texobj.h" -#include "texstate.h" - - -static void -update_separate_specular(GLcontext *ctx) -{ - if (NEED_SECONDARY_COLOR(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; - else - ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; -} - - -/** - * Compute the index of the last array element that can be safely accessed - * in a vertex array. We can really only do this when the array lives in - * a VBO. - * The array->_MaxElement field will be updated. - * Later in glDrawArrays/Elements/etc we can do some bounds checking. - */ -static void -compute_max_element(struct gl_client_array *array) -{ - assert(array->Enabled); - if (array->BufferObj->Name) { - GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; - GLsizeiptrARB obj_size = (GLsizeiptrARB) array->BufferObj->Size; - - if (offset < obj_size) { - array->_MaxElement = (obj_size - offset + - array->StrideB - - array->_ElementSize) / array->StrideB; - } else { - array->_MaxElement = 0; - } - } - else { - /* user-space array, no idea how big it is */ - array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ - } -} - - -/** - * Helper for update_arrays(). - * \return min(current min, array->_MaxElement). - */ -static GLuint -update_min(GLuint min, struct gl_client_array *array) -{ - compute_max_element(array); - return MIN2(min, array->_MaxElement); -} - - -/** - * Update ctx->Array._MaxElement (the max legal index into all enabled arrays). - * Need to do this upon new array state or new buffer object state. - */ -static void -update_arrays( GLcontext *ctx ) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i, min = ~0; - - /* find min of _MaxElement values for all enabled arrays */ - - /* 0 */ - if (ctx->VertexProgram._Current - && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); - } - else if (arrayObj->Vertex.Enabled) { - min = update_min(min, &arrayObj->Vertex); - } - - /* 1 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]); - } - /* no conventional vertex weight array */ - - /* 2 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); - } - else if (arrayObj->Normal.Enabled) { - min = update_min(min, &arrayObj->Normal); - } - - /* 3 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); - } - else if (arrayObj->Color.Enabled) { - min = update_min(min, &arrayObj->Color); - } - - /* 4 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); - } - else if (arrayObj->SecondaryColor.Enabled) { - min = update_min(min, &arrayObj->SecondaryColor); - } - - /* 5 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); - } - else if (arrayObj->FogCoord.Enabled) { - min = update_min(min, &arrayObj->FogCoord); - } - - /* 6 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); - } - else if (arrayObj->Index.Enabled) { - min = update_min(min, &arrayObj->Index); - } - - /* 7 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); - } - - /* 8..15 */ - for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); - } - else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits - && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) { - min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]); - } - } - - /* 16..31 */ - if (ctx->VertexProgram._Current) { - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { - if (arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); - } - } - } - - if (arrayObj->EdgeFlag.Enabled) { - min = update_min(min, &arrayObj->EdgeFlag); - } - - /* _MaxElement is one past the last legal array element */ - arrayObj->_MaxElement = min; -} - - -/** - * Update the following fields: - * ctx->VertexProgram._Enabled - * ctx->FragmentProgram._Enabled - * ctx->ATIFragmentShader._Enabled - * This needs to be done before texture state validation. - */ -static void -update_program_enables(GLcontext *ctx) -{ - /* These _Enabled flags indicate if the program is enabled AND valid. */ - ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled - && ctx->VertexProgram.Current->Base.Instructions; - ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled - && ctx->FragmentProgram.Current->Base.Instructions; - ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled - && ctx->ATIFragmentShader.Current->Instructions[0]; -} - - -/** - * Update vertex/fragment program state. In particular, update these fields: - * ctx->VertexProgram._Current - * ctx->VertexProgram._TnlProgram, - * These point to the highest priority enabled vertex/fragment program or are - * NULL if fixed-function processing is to be done. - * - * This function needs to be called after texture state validation in case - * we're generating a fragment program from fixed-function texture state. - * - * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex - * or fragment program is being used. - */ -static GLbitfield -update_program(GLcontext *ctx) -{ - const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; - const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; - const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; - const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; - GLbitfield new_state = 0x0; - - /* - * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current - * pointers to the programs that should be used for rendering. If either - * is NULL, use fixed-function code paths. - * - * These programs may come from several sources. The priority is as - * follows: - * 1. OpenGL 2.0/ARB vertex/fragment shaders - * 2. ARB/NV vertex/fragment programs - * 3. Programs derived from fixed-function state. - * - * Note: it's possible for a vertex shader to get used with a fragment - * program (and vice versa) here, but in practice that shouldn't ever - * come up, or matter. - */ - - if (shProg && shProg->LinkStatus && shProg->FragmentProgram) { - /* Use shader programs */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - shProg->FragmentProgram); - } - else if (ctx->FragmentProgram._Enabled) { - /* use user-defined vertex program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - ctx->FragmentProgram.Current); - } - else if (ctx->FragmentProgram._MaintainTexEnvProgram) { - /* Use fragment program generated from fixed-function state. - */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - _mesa_get_fixed_func_fragment_program(ctx)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - ctx->FragmentProgram._Current); - } - else { - /* no fragment program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - } - - if (shProg && shProg->LinkStatus && shProg->GeometryProgram) { - /* Use shader programs */ - _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, - shProg->GeometryProgram); - } else { - /* no fragment program */ - _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); - } - - /* Examine vertex program after fragment program as - * _mesa_get_fixed_func_vertex_program() needs to know active - * fragprog inputs. - */ - if (shProg && shProg->LinkStatus && shProg->VertexProgram) { - /* Use shader programs */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - shProg->VertexProgram); - } - else if (ctx->VertexProgram._Enabled) { - /* use user-defined vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - ctx->VertexProgram.Current); - } - else if (ctx->VertexProgram._MaintainTnlProgram) { - /* Use vertex program generated from fixed-function state. - */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - _mesa_get_fixed_func_vertex_program(ctx)); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, - ctx->VertexProgram._Current); - } - else { - /* no vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - } - - /* Let the driver know what's happening: - */ - if (ctx->FragmentProgram._Current != prevFP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, - (struct gl_program *) ctx->FragmentProgram._Current); - } - } - - if (ctx->GeometryProgram._Current != prevGP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM, - (struct gl_program *) ctx->GeometryProgram._Current); - } - } - - if (ctx->VertexProgram._Current != prevVP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, - (struct gl_program *) ctx->VertexProgram._Current); - } - } - - return new_state; -} - - -/** - * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0. - */ -static GLbitfield -update_program_constants(GLcontext *ctx) -{ - GLbitfield new_state = 0x0; - - if (ctx->FragmentProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->FragmentProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - if (ctx->GeometryProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->GeometryProgram._Current->Base.Parameters; - /*FIXME: StateFlags is always 0 because we have unnamed constant - * not state changes */ - if (params /*&& params->StateFlags & ctx->NewState*/) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - if (ctx->VertexProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->VertexProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - return new_state; -} - - - - -static void -update_viewport_matrix(GLcontext *ctx) -{ - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; - - ASSERT(depthMax > 0); - - /* Compute scale and bias values. This is really driver-specific - * and should be maintained elsewhere if at all. - * NOTE: RasterPos uses this. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - depthMax); -} - - -/** - * Update derived multisample state. - */ -static void -update_multisample(GLcontext *ctx) -{ - ctx->Multisample._Enabled = GL_FALSE; - if (ctx->Multisample.Enabled && - ctx->DrawBuffer && - ctx->DrawBuffer->Visual.sampleBuffers) - ctx->Multisample._Enabled = GL_TRUE; -} - - -/** - * Update derived color/blend/logicop state. - */ -static void -update_color(GLcontext *ctx) -{ - /* This is needed to support 1.1's RGB logic ops AND - * 1.0's blending logicops. - */ - ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx); -} - - -/* - * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET - * in ctx->_TriangleCaps if needed. - */ -static void -update_polygon(GLcontext *ctx) -{ - ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); - - if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - - if ( ctx->Polygon.OffsetPoint - || ctx->Polygon.OffsetLine - || ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; -} - - -/** - * Update the ctx->_TriangleCaps bitfield. - * XXX that bitfield should really go away someday! - * This function must be called after other update_*() functions since - * there are dependencies on some other derived values. - */ -#if 0 -static void -update_tricaps(GLcontext *ctx, GLbitfield new_state) -{ - ctx->_TriangleCaps = 0; - - /* - * Points - */ - if (1/*new_state & _NEW_POINT*/) { - if (ctx->Point.SmoothFlag) - ctx->_TriangleCaps |= DD_POINT_SMOOTH; - if (ctx->Point.Size != 1.0F) - ctx->_TriangleCaps |= DD_POINT_SIZE; - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - } - - /* - * Lines - */ - if (1/*new_state & _NEW_LINE*/) { - if (ctx->Line.SmoothFlag) - ctx->_TriangleCaps |= DD_LINE_SMOOTH; - if (ctx->Line.StippleFlag) - ctx->_TriangleCaps |= DD_LINE_STIPPLE; - if (ctx->Line.Width != 1.0) - ctx->_TriangleCaps |= DD_LINE_WIDTH; - } - - /* - * Polygons - */ - if (1/*new_state & _NEW_POLYGON*/) { - if (ctx->Polygon.SmoothFlag) - ctx->_TriangleCaps |= DD_TRI_SMOOTH; - if (ctx->Polygon.StippleFlag) - ctx->_TriangleCaps |= DD_TRI_STIPPLE; - if (ctx->Polygon.FrontMode != GL_FILL - || ctx->Polygon.BackMode != GL_FILL) - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - if (ctx->Polygon.CullFlag - && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; - } - - /* - * Lighting and shading - */ - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - if (ctx->Light.ShadeModel == GL_FLAT) - ctx->_TriangleCaps |= DD_FLATSHADE; - if (NEED_SECONDARY_COLOR(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; - - /* - * Stencil - */ - if (ctx->Stencil._TestTwoSide) - ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; -} -#endif - - -/** - * Compute derived GL state. - * If __GLcontextRec::NewState is non-zero then this function \b must - * be called before rendering anything. - * - * Calls dd_function_table::UpdateState to perform any internal state - * management necessary. - * - * \sa _mesa_update_modelview_project(), _mesa_update_texture(), - * _mesa_update_buffer_bounds(), - * _mesa_update_lighting() and _mesa_update_tnl_spaces(). - */ -void -_mesa_update_state_locked( GLcontext *ctx ) -{ - GLbitfield new_state = ctx->NewState; - GLbitfield prog_flags = _NEW_PROGRAM; - GLbitfield new_prog_state = 0x0; - - if (new_state == _NEW_CURRENT_ATTRIB) - goto out; - - if (MESA_VERBOSE & VERBOSE_STATE) - _mesa_print_state("_mesa_update_state", new_state); - - /* Determine which state flags effect vertex/fragment program state */ - if (ctx->FragmentProgram._MaintainTexEnvProgram) { - prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG | - _NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE | - _NEW_PROGRAM); - } - if (ctx->VertexProgram._MaintainTnlProgram) { - prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX | - _NEW_TRANSFORM | _NEW_POINT | - _NEW_FOG | _NEW_LIGHT | - _MESA_NEW_NEED_EYE_COORDS); - } - - /* - * Now update derived state info - */ - - if (new_state & prog_flags) - update_program_enables( ctx ); - - if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) - _mesa_update_modelview_project( ctx, new_state ); - - if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) - _mesa_update_texture( ctx, new_state ); - - if (new_state & _NEW_BUFFERS) - _mesa_update_framebuffer(ctx); - - if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) - _mesa_update_draw_buffer_bounds( ctx ); - - if (new_state & _NEW_POLYGON) - update_polygon( ctx ); - - if (new_state & _NEW_LIGHT) - _mesa_update_lighting( ctx ); - - if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) - _mesa_update_stencil( ctx ); - - if (new_state & _MESA_NEW_TRANSFER_STATE) - _mesa_update_pixel( ctx, new_state ); - - if (new_state & _DD_NEW_SEPARATE_SPECULAR) - update_separate_specular( ctx ); - - if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) - update_viewport_matrix(ctx); - - if (new_state & _NEW_MULTISAMPLE) - update_multisample( ctx ); - - if (new_state & _NEW_COLOR) - update_color( ctx ); - -#if 0 - if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT - | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) - update_tricaps( ctx, new_state ); -#endif - - /* ctx->_NeedEyeCoords is now up to date. - * - * If the truth value of this variable has changed, update for the - * new lighting space and recompute the positions of lights and the - * normal transform. - * - * If the lighting space hasn't changed, may still need to recompute - * light positions & normal transforms for other reasons. - */ - if (new_state & _MESA_NEW_NEED_EYE_COORDS) - _mesa_update_tnl_spaces( ctx, new_state ); - - if (new_state & prog_flags) { - /* When we generate programs from fixed-function vertex/fragment state - * this call may generate/bind a new program. If so, we need to - * propogate the _NEW_PROGRAM flag to the driver. - */ - new_prog_state |= update_program( ctx ); - } - - if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) - update_arrays( ctx ); - - out: - new_prog_state |= update_program_constants(ctx); - - /* - * Give the driver a chance to act upon the new_state flags. - * The driver might plug in different span functions, for example. - * Also, this is where the driver can invalidate the state of any - * active modules (such as swrast_setup, swrast, tnl, etc). - * - * Set ctx->NewState to zero to avoid recursion if - * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) - */ - new_state = ctx->NewState | new_prog_state; - ctx->NewState = 0; - ctx->Driver.UpdateState(ctx, new_state); - ctx->Array.NewState = 0; -} - - -/* This is the usual entrypoint for state updates: - */ -void -_mesa_update_state( GLcontext *ctx ) -{ - _mesa_lock_context_textures(ctx); - _mesa_update_state_locked(ctx); - _mesa_unlock_context_textures(ctx); -} - - - - -/** - * Want to figure out which fragment program inputs are actually - * constant/current values from ctx->Current. These should be - * referenced as a tracked state variable rather than a fragment - * program input, to save the overhead of putting a constant value in - * every submitted vertex, transferring it to hardware, interpolating - * it across the triangle, etc... - * - * When there is a VP bound, just use vp->outputs. But when we're - * generating vp from fixed function state, basically want to - * calculate: - * - * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | - * potential_vp_outputs ) - * - * Where potential_vp_outputs is calculated by looking at enabled - * texgen, etc. - * - * The generated fragment program should then only declare inputs that - * may vary or otherwise differ from the ctx->Current values. - * Otherwise, the fp should track them as state values instead. - */ -void -_mesa_set_varying_vp_inputs( GLcontext *ctx, - GLbitfield varying_inputs ) -{ - if (ctx->varying_vp_inputs != varying_inputs) { - ctx->varying_vp_inputs = varying_inputs; - ctx->NewState |= _NEW_ARRAY; - /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ - } -} - - -/** - * Used by drivers to tell core Mesa that the driver is going to - * install/ use its own vertex program. In particular, this will - * prevent generated fragment programs from using state vars instead - * of ordinary varyings/inputs. - */ -void -_mesa_set_vp_override(GLcontext *ctx, GLboolean flag) -{ - if (ctx->VertexProgram._Overriden != flag) { - ctx->VertexProgram._Overriden = flag; - - /* Set one of the bits which will trigger fragment program - * regeneration: - */ - ctx->NewState |= _NEW_PROGRAM; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file state.c + * State management. + * + * This file manages recalculation of derived values in struct gl_context. + */ + + +#include "glheader.h" +#include "mtypes.h" +#include "context.h" +#include "debug.h" +#include "macros.h" +#include "ffvertex_prog.h" +#include "framebuffer.h" +#include "light.h" +#include "matrix.h" +#include "pixel.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "state.h" +#include "stencil.h" +#include "texenvprogram.h" +#include "texobj.h" +#include "texstate.h" + + +static void +update_separate_specular(struct gl_context *ctx) +{ + if (NEED_SECONDARY_COLOR(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + else + ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; +} + + +/** + * Compute the index of the last array element that can be safely accessed + * in a vertex array. We can really only do this when the array lives in + * a VBO. + * The array->_MaxElement field will be updated. + * Later in glDrawArrays/Elements/etc we can do some bounds checking. + */ +static void +compute_max_element(struct gl_client_array *array) +{ + assert(array->Enabled); + if (array->BufferObj->Name) { + GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; + GLsizeiptrARB obj_size = (GLsizeiptrARB) array->BufferObj->Size; + + if (offset < obj_size) { + array->_MaxElement = (obj_size - offset + + array->StrideB - + array->_ElementSize) / array->StrideB; + } else { + array->_MaxElement = 0; + } + } + else { + /* user-space array, no idea how big it is */ + array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ + } +} + + +/** + * Helper for update_arrays(). + * \return min(current min, array->_MaxElement). + */ +static GLuint +update_min(GLuint min, struct gl_client_array *array) +{ + compute_max_element(array); + return MIN2(min, array->_MaxElement); +} + + +/** + * Update ctx->Array._MaxElement (the max legal index into all enabled arrays). + * Need to do this upon new array state or new buffer object state. + */ +static void +update_arrays( struct gl_context *ctx ) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint i, min = ~0; + + /* find min of _MaxElement values for all enabled arrays */ + + /* 0 */ + if (ctx->VertexProgram._Current + && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); + } + else if (arrayObj->Vertex.Enabled) { + min = update_min(min, &arrayObj->Vertex); + } + + /* 1 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]); + } + /* no conventional vertex weight array */ + + /* 2 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); + } + else if (arrayObj->Normal.Enabled) { + min = update_min(min, &arrayObj->Normal); + } + + /* 3 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); + } + else if (arrayObj->Color.Enabled) { + min = update_min(min, &arrayObj->Color); + } + + /* 4 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); + } + else if (arrayObj->SecondaryColor.Enabled) { + min = update_min(min, &arrayObj->SecondaryColor); + } + + /* 5 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); + } + else if (arrayObj->FogCoord.Enabled) { + min = update_min(min, &arrayObj->FogCoord); + } + + /* 6 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); + } + else if (arrayObj->Index.Enabled) { + min = update_min(min, &arrayObj->Index); + } + + /* 7 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); + } + + /* 8..15 */ + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[i].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[i]); + } + else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits + && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) { + min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]); + } + } + + /* 16..31 */ + if (ctx->VertexProgram._Current) { + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { + if (arrayObj->VertexAttrib[i].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[i]); + } + } + } + + if (arrayObj->EdgeFlag.Enabled) { + min = update_min(min, &arrayObj->EdgeFlag); + } + + /* _MaxElement is one past the last legal array element */ + arrayObj->_MaxElement = min; +} + + +/** + * Update the following fields: + * ctx->VertexProgram._Enabled + * ctx->FragmentProgram._Enabled + * ctx->ATIFragmentShader._Enabled + * This needs to be done before texture state validation. + */ +static void +update_program_enables(struct gl_context *ctx) +{ + /* These _Enabled flags indicate if the program is enabled AND valid. */ + ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled + && ctx->VertexProgram.Current->Base.Instructions; + ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled + && ctx->FragmentProgram.Current->Base.Instructions; + ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled + && ctx->ATIFragmentShader.Current->Instructions[0]; +} + + +/** + * Update vertex/fragment program state. In particular, update these fields: + * ctx->VertexProgram._Current + * ctx->VertexProgram._TnlProgram, + * These point to the highest priority enabled vertex/fragment program or are + * NULL if fixed-function processing is to be done. + * + * This function needs to be called after texture state validation in case + * we're generating a fragment program from fixed-function texture state. + * + * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex + * or fragment program is being used. + */ +static GLbitfield +update_program(struct gl_context *ctx) +{ + const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram; + const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram; + const struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram; + const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; + const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; + const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; + GLbitfield new_state = 0x0; + + /* + * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current + * pointers to the programs that should be used for rendering. If either + * is NULL, use fixed-function code paths. + * + * These programs may come from several sources. The priority is as + * follows: + * 1. OpenGL 2.0/ARB vertex/fragment shaders + * 2. ARB/NV vertex/fragment programs + * 3. Programs derived from fixed-function state. + * + * Note: it's possible for a vertex shader to get used with a fragment + * program (and vice versa) here, but in practice that shouldn't ever + * come up, or matter. + */ + + if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) { + /* Use shader programs */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + fsProg->FragmentProgram); + } + else if (ctx->FragmentProgram._Enabled) { + /* use user-defined vertex program */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + ctx->FragmentProgram.Current); + } + else if (ctx->FragmentProgram._MaintainTexEnvProgram) { + /* Use fragment program generated from fixed-function state. + */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + _mesa_get_fixed_func_fragment_program(ctx)); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + ctx->FragmentProgram._Current); + } + else { + /* no fragment program */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); + } + + if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) { + /* Use shader programs */ + _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, + gsProg->GeometryProgram); + } else { + /* no fragment program */ + _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); + } + + /* Examine vertex program after fragment program as + * _mesa_get_fixed_func_vertex_program() needs to know active + * fragprog inputs. + */ + if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) { + /* Use shader programs */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + vsProg->VertexProgram); + } + else if (ctx->VertexProgram._Enabled) { + /* use user-defined vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + ctx->VertexProgram.Current); + } + else if (ctx->VertexProgram._MaintainTnlProgram) { + /* Use vertex program generated from fixed-function state. + */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + _mesa_get_fixed_func_vertex_program(ctx)); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, + ctx->VertexProgram._Current); + } + else { + /* no vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); + } + + /* Let the driver know what's happening: + */ + if (ctx->FragmentProgram._Current != prevFP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, + (struct gl_program *) ctx->FragmentProgram._Current); + } + } + + if (ctx->GeometryProgram._Current != prevGP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM, + (struct gl_program *) ctx->GeometryProgram._Current); + } + } + + if (ctx->VertexProgram._Current != prevVP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, + (struct gl_program *) ctx->VertexProgram._Current); + } + } + + return new_state; +} + + +/** + * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0. + */ +static GLbitfield +update_program_constants(struct gl_context *ctx) +{ + GLbitfield new_state = 0x0; + + if (ctx->FragmentProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->FragmentProgram._Current->Base.Parameters; + if (params && params->StateFlags & ctx->NewState) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + if (ctx->GeometryProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->GeometryProgram._Current->Base.Parameters; + /*FIXME: StateFlags is always 0 because we have unnamed constant + * not state changes */ + if (params /*&& params->StateFlags & ctx->NewState*/) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + if (ctx->VertexProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->VertexProgram._Current->Base.Parameters; + if (params && params->StateFlags & ctx->NewState) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + return new_state; +} + + + + +static void +update_viewport_matrix(struct gl_context *ctx) +{ + const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + + ASSERT(depthMax > 0); + + /* Compute scale and bias values. This is really driver-specific + * and should be maintained elsewhere if at all. + * NOTE: RasterPos uses this. + */ + _math_matrix_viewport(&ctx->Viewport._WindowMap, + ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + ctx->Viewport.Near, ctx->Viewport.Far, + depthMax); +} + + +/** + * Update derived multisample state. + */ +static void +update_multisample(struct gl_context *ctx) +{ + ctx->Multisample._Enabled = GL_FALSE; + if (ctx->Multisample.Enabled && + ctx->DrawBuffer && + ctx->DrawBuffer->Visual.sampleBuffers) + ctx->Multisample._Enabled = GL_TRUE; +} + + +/** + * Update derived color/blend/logicop state. + */ +static void +update_color(struct gl_context *ctx) +{ + /* This is needed to support 1.1's RGB logic ops AND + * 1.0's blending logicops. + */ + ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx); +} + + +/* + * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET + * in ctx->_TriangleCaps if needed. + */ +static void +update_polygon(struct gl_context *ctx) +{ + ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); + + if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + + if ( ctx->Polygon.OffsetPoint + || ctx->Polygon.OffsetLine + || ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; +} + + +/** + * Update the ctx->_TriangleCaps bitfield. + * XXX that bitfield should really go away someday! + * This function must be called after other update_*() functions since + * there are dependencies on some other derived values. + */ +#if 0 +static void +update_tricaps(struct gl_context *ctx, GLbitfield new_state) +{ + ctx->_TriangleCaps = 0; + + /* + * Points + */ + if (1/*new_state & _NEW_POINT*/) { + if (ctx->Point.SmoothFlag) + ctx->_TriangleCaps |= DD_POINT_SMOOTH; + if (ctx->Point._Attenuated) + ctx->_TriangleCaps |= DD_POINT_ATTEN; + } + + /* + * Lines + */ + if (1/*new_state & _NEW_LINE*/) { + if (ctx->Line.SmoothFlag) + ctx->_TriangleCaps |= DD_LINE_SMOOTH; + if (ctx->Line.StippleFlag) + ctx->_TriangleCaps |= DD_LINE_STIPPLE; + } + + /* + * Polygons + */ + if (1/*new_state & _NEW_POLYGON*/) { + if (ctx->Polygon.SmoothFlag) + ctx->_TriangleCaps |= DD_TRI_SMOOTH; + if (ctx->Polygon.StippleFlag) + ctx->_TriangleCaps |= DD_TRI_STIPPLE; + if (ctx->Polygon.FrontMode != GL_FILL + || ctx->Polygon.BackMode != GL_FILL) + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + if (ctx->Polygon.CullFlag + && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; + } + + /* + * Lighting and shading + */ + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + if (ctx->Light.ShadeModel == GL_FLAT) + ctx->_TriangleCaps |= DD_FLATSHADE; + if (NEED_SECONDARY_COLOR(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + + /* + * Stencil + */ + if (ctx->Stencil._TestTwoSide) + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; +} +#endif + + +/** + * Compute derived GL state. + * If __struct gl_contextRec::NewState is non-zero then this function \b must + * be called before rendering anything. + * + * Calls dd_function_table::UpdateState to perform any internal state + * management necessary. + * + * \sa _mesa_update_modelview_project(), _mesa_update_texture(), + * _mesa_update_buffer_bounds(), + * _mesa_update_lighting() and _mesa_update_tnl_spaces(). + */ +void +_mesa_update_state_locked( struct gl_context *ctx ) +{ + GLbitfield new_state = ctx->NewState; + GLbitfield prog_flags = _NEW_PROGRAM; + GLbitfield new_prog_state = 0x0; + + if (new_state == _NEW_CURRENT_ATTRIB) + goto out; + + if (MESA_VERBOSE & VERBOSE_STATE) + _mesa_print_state("_mesa_update_state", new_state); + + /* Determine which state flags effect vertex/fragment program state */ + if (ctx->FragmentProgram._MaintainTexEnvProgram) { + prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG | + _NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE | + _NEW_PROGRAM); + } + if (ctx->VertexProgram._MaintainTnlProgram) { + prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX | + _NEW_TRANSFORM | _NEW_POINT | + _NEW_FOG | _NEW_LIGHT | + _MESA_NEW_NEED_EYE_COORDS); + } + + /* + * Now update derived state info + */ + + if (new_state & prog_flags) + update_program_enables( ctx ); + + if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) + _mesa_update_modelview_project( ctx, new_state ); + + if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) + _mesa_update_texture( ctx, new_state ); + + if (new_state & _NEW_BUFFERS) + _mesa_update_framebuffer(ctx); + + if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) + _mesa_update_draw_buffer_bounds( ctx ); + + if (new_state & _NEW_POLYGON) + update_polygon( ctx ); + + if (new_state & _NEW_LIGHT) + _mesa_update_lighting( ctx ); + + if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) + _mesa_update_stencil( ctx ); + + if (new_state & _MESA_NEW_TRANSFER_STATE) + _mesa_update_pixel( ctx, new_state ); + + if (new_state & _DD_NEW_SEPARATE_SPECULAR) + update_separate_specular( ctx ); + + if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) + update_viewport_matrix(ctx); + + if (new_state & _NEW_MULTISAMPLE) + update_multisample( ctx ); + + if (new_state & _NEW_COLOR) + update_color( ctx ); + +#if 0 + if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT + | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) + update_tricaps( ctx, new_state ); +#endif + + /* ctx->_NeedEyeCoords is now up to date. + * + * If the truth value of this variable has changed, update for the + * new lighting space and recompute the positions of lights and the + * normal transform. + * + * If the lighting space hasn't changed, may still need to recompute + * light positions & normal transforms for other reasons. + */ + if (new_state & _MESA_NEW_NEED_EYE_COORDS) + _mesa_update_tnl_spaces( ctx, new_state ); + + if (new_state & prog_flags) { + /* When we generate programs from fixed-function vertex/fragment state + * this call may generate/bind a new program. If so, we need to + * propogate the _NEW_PROGRAM flag to the driver. + */ + new_prog_state |= update_program( ctx ); + } + + if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) + update_arrays( ctx ); + + out: + new_prog_state |= update_program_constants(ctx); + + /* + * Give the driver a chance to act upon the new_state flags. + * The driver might plug in different span functions, for example. + * Also, this is where the driver can invalidate the state of any + * active modules (such as swrast_setup, swrast, tnl, etc). + * + * Set ctx->NewState to zero to avoid recursion if + * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) + */ + new_state = ctx->NewState | new_prog_state; + ctx->NewState = 0; + ctx->Driver.UpdateState(ctx, new_state); + ctx->Array.NewState = 0; +} + + +/* This is the usual entrypoint for state updates: + */ +void +_mesa_update_state( struct gl_context *ctx ) +{ + _mesa_lock_context_textures(ctx); + _mesa_update_state_locked(ctx); + _mesa_unlock_context_textures(ctx); +} + + + + +/** + * Want to figure out which fragment program inputs are actually + * constant/current values from ctx->Current. These should be + * referenced as a tracked state variable rather than a fragment + * program input, to save the overhead of putting a constant value in + * every submitted vertex, transferring it to hardware, interpolating + * it across the triangle, etc... + * + * When there is a VP bound, just use vp->outputs. But when we're + * generating vp from fixed function state, basically want to + * calculate: + * + * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | + * potential_vp_outputs ) + * + * Where potential_vp_outputs is calculated by looking at enabled + * texgen, etc. + * + * The generated fragment program should then only declare inputs that + * may vary or otherwise differ from the ctx->Current values. + * Otherwise, the fp should track them as state values instead. + */ +void +_mesa_set_varying_vp_inputs( struct gl_context *ctx, + GLbitfield varying_inputs ) +{ + if (ctx->varying_vp_inputs != varying_inputs) { + ctx->varying_vp_inputs = varying_inputs; + ctx->NewState |= _NEW_ARRAY; + /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ + } +} + + +/** + * Used by drivers to tell core Mesa that the driver is going to + * install/ use its own vertex program. In particular, this will + * prevent generated fragment programs from using state vars instead + * of ordinary varyings/inputs. + */ +void +_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag) +{ + if (ctx->VertexProgram._Overriden != flag) { + ctx->VertexProgram._Overriden = flag; + + /* Set one of the bits which will trigger fragment program + * regeneration: + */ + ctx->NewState |= _NEW_PROGRAM; + } +} diff --git a/mesalib/src/mesa/main/state.h b/mesalib/src/mesa/main/state.h index 29db08a0b..6714196dc 100644 --- a/mesalib/src/mesa/main/state.h +++ b/mesalib/src/mesa/main/state.h @@ -1,49 +1,49 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef STATE_H -#define STATE_H - -#include "mtypes.h" - -extern void -_mesa_update_state(GLcontext *ctx); - -/* As above but can only be called between _mesa_lock_context_textures() and - * _mesa_unlock_context_textures(). - */ -extern void -_mesa_update_state_locked(GLcontext *ctx); - - -extern void -_mesa_set_varying_vp_inputs(GLcontext *ctx, GLbitfield varying_inputs); - - -extern void -_mesa_set_vp_override(GLcontext *ctx, GLboolean flag); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef STATE_H +#define STATE_H + +#include "mtypes.h" + +extern void +_mesa_update_state(struct gl_context *ctx); + +/* As above but can only be called between _mesa_lock_context_textures() and + * _mesa_unlock_context_textures(). + */ +extern void +_mesa_update_state_locked(struct gl_context *ctx); + + +extern void +_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield varying_inputs); + + +extern void +_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag); + + +#endif diff --git a/mesalib/src/mesa/main/stencil.c b/mesalib/src/mesa/main/stencil.c index 15c98e201..c63b14d27 100644 --- a/mesalib/src/mesa/main/stencil.c +++ b/mesalib/src/mesa/main/stencil.c @@ -1,590 +1,590 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file stencil.c - * Stencil operations. - * - * Note: There's some conflict between GL_EXT_stencil_two_side and - * OpenGL 2.0's two-sided stencil feature. - * - * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the - * front OR back face state (as set by glActiveStencilFaceEXT) is set. - * - * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the - * front AND back state. - * - * Also, note that GL_ATI_separate_stencil is different as well: - * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. - * glStencilFuncSeparate(GLenum face, GLenum func, ...). - * - * This problem is solved by keeping three sets of stencil state: - * state[0] = GL_FRONT state. - * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. - * state[2] = GL_EXT_stencil_two_side GL_BACK state. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "stencil.h" -#include "mtypes.h" - - -static GLboolean -validate_stencil_op(GLcontext *ctx, GLenum op) -{ - switch (op) { - case GL_KEEP: - case GL_ZERO: - case GL_REPLACE: - case GL_INCR: - case GL_DECR: - case GL_INVERT: - return GL_TRUE; - case GL_INCR_WRAP_EXT: - case GL_DECR_WRAP_EXT: - if (ctx->Extensions.EXT_stencil_wrap) { - return GL_TRUE; - } - /* FALL-THROUGH */ - default: - return GL_FALSE; - } -} - - -static GLboolean -validate_stencil_func(GLcontext *ctx, GLenum func) -{ - switch (func) { - case GL_NEVER: - case GL_LESS: - case GL_LEQUAL: - case GL_GREATER: - case GL_GEQUAL: - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_ALWAYS: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Set the clear value for the stencil buffer. - * - * \param s clear value. - * - * \sa glClearStencil(). - * - * Updates gl_stencil_attrib::Clear. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::ClearStencil callback. - */ -void GLAPIENTRY -_mesa_ClearStencil( GLint s ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Stencil.Clear == (GLuint) s) - return; - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Clear = (GLuint) s; - - if (ctx->Driver.ClearStencil) { - ctx->Driver.ClearStencil( ctx, s ); - } -} - - -/** - * Set the function and reference value for stencil testing. - * - * \param frontfunc front test function. - * \param backfunc back test function. - * \param ref front and back reference value. - * \param mask front and back bitmask. - * - * \sa glStencilFunc(). - * - * Verifies the parameters and updates the respective values in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilFunc callback. - */ -void GLAPIENTRY -_mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_func(ctx, frontfunc)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glStencilFuncSeparateATI(frontfunc)"); - return; - } - if (!validate_stencil_func(ctx, backfunc)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glStencilFuncSeparateATI(backfunc)"); - return; - } - - ref = CLAMP( ref, 0, stencilMax ); - - /* set both front and back state */ - if (ctx->Stencil.Function[0] == frontfunc && - ctx->Stencil.Function[1] == backfunc && - ctx->Stencil.ValueMask[0] == mask && - ctx->Stencil.ValueMask[1] == mask && - ctx->Stencil.Ref[0] == ref && - ctx->Stencil.Ref[1] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[0] = frontfunc; - ctx->Stencil.Function[1] = backfunc; - ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, - frontfunc, ref, mask); - ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, - backfunc, ref, mask); - } -} - - -/** - * Set the function and reference value for stencil testing. - * - * \param func test function. - * \param ref reference value. - * \param mask bitmask. - * - * \sa glStencilFunc(). - * - * Verifies the parameters and updates the respective values in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilFunc callback. - */ -void GLAPIENTRY -_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - const GLint face = ctx->Stencil.ActiveFace; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_func(ctx, func)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)"); - return; - } - - ref = CLAMP( ref, 0, stencilMax ); - - if (face != 0) { - if (ctx->Stencil.Function[face] == func && - ctx->Stencil.ValueMask[face] == mask && - ctx->Stencil.Ref[face] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[face] = func; - ctx->Stencil.Ref[face] = ref; - ctx->Stencil.ValueMask[face] = mask; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilFuncSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, func, ref, mask); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.Function[0] == func && - ctx->Stencil.Function[1] == func && - ctx->Stencil.ValueMask[0] == mask && - ctx->Stencil.ValueMask[1] == mask && - ctx->Stencil.Ref[0] == ref && - ctx->Stencil.Ref[1] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[0] = ctx->Stencil.Function[1] = func; - ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - func, ref, mask); - } - } -} - - -/** - * Set the stencil writing mask. - * - * \param mask bit-mask to enable/disable writing of individual bits in the - * stencil planes. - * - * \sa glStencilMask(). - * - * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and - * notifies the driver via the dd_function_table::StencilMask callback. - */ -void GLAPIENTRY -_mesa_StencilMask( GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint face = ctx->Stencil.ActiveFace; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (face != 0) { - /* Only modify the EXT_stencil_two_side back-face state. - */ - if (ctx->Stencil.WriteMask[face] == mask) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.WriteMask[face] = mask; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilMaskSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, mask); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.WriteMask[0] == mask && - ctx->Stencil.WriteMask[1] == mask) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask; - if (ctx->Driver.StencilMaskSeparate) { - ctx->Driver.StencilMaskSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - mask); - } - } -} - - -/** - * Set the stencil test actions. - * - * \param fail action to take when stencil test fails. - * \param zfail action to take when stencil test passes, but depth test fails. - * \param zpass action to take when stencil test passes and the depth test - * passes (or depth testing is not enabled). - * - * \sa glStencilOp(). - * - * Verifies the parameters and updates the respective fields in - * __GLcontextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilOp callback. - */ -void GLAPIENTRY -_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint face = ctx->Stencil.ActiveFace; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_op(ctx, fail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)"); - return; - } - - if (face != 0) { - /* only set active face state */ - if (ctx->Stencil.ZFailFunc[face] == zfail && - ctx->Stencil.ZPassFunc[face] == zpass && - ctx->Stencil.FailFunc[face] == fail) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[face] = zfail; - ctx->Stencil.ZPassFunc[face] = zpass; - ctx->Stencil.FailFunc[face] = fail; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilOpSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilOpSeparate(ctx, GL_BACK, fail, zfail, zpass); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.ZFailFunc[0] == zfail && - ctx->Stencil.ZFailFunc[1] == zfail && - ctx->Stencil.ZPassFunc[0] == zpass && - ctx->Stencil.ZPassFunc[1] == zpass && - ctx->Stencil.FailFunc[0] == fail && - ctx->Stencil.FailFunc[1] == fail) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[0] = ctx->Stencil.ZFailFunc[1] = zfail; - ctx->Stencil.ZPassFunc[0] = ctx->Stencil.ZPassFunc[1] = zpass; - ctx->Stencil.FailFunc[0] = ctx->Stencil.FailFunc[1] = fail; - if (ctx->Driver.StencilOpSeparate) { - ctx->Driver.StencilOpSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - fail, zfail, zpass); - } - } -} - - - -#if _HAVE_FULL_GL -/* GL_EXT_stencil_two_side */ -void GLAPIENTRY -_mesa_ActiveStencilFaceEXT(GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_stencil_two_side) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveStencilFaceEXT"); - return; - } - - if (face == GL_FRONT || face == GL_BACK) { - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 2; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveStencilFaceEXT(face)"); - } -} -#endif - - - -/** - * OpenGL 2.0 function. - * \todo Make StencilOp() call this function. And eventually remove the - * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate - * instead. - */ -void GLAPIENTRY -_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) -{ - GLboolean set = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_op(ctx, sfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); - return; - } - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); - return; - } - - if (face != GL_BACK) { - /* set front */ - if (ctx->Stencil.ZFailFunc[0] != zfail || - ctx->Stencil.ZPassFunc[0] != zpass || - ctx->Stencil.FailFunc[0] != sfail){ - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[0] = zfail; - ctx->Stencil.ZPassFunc[0] = zpass; - ctx->Stencil.FailFunc[0] = sfail; - set = GL_TRUE; - } - } - if (face != GL_FRONT) { - /* set back */ - if (ctx->Stencil.ZFailFunc[1] != zfail || - ctx->Stencil.ZPassFunc[1] != zpass || - ctx->Stencil.FailFunc[1] != sfail) { - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[1] = zfail; - ctx->Stencil.ZPassFunc[1] = zpass; - ctx->Stencil.FailFunc[1] = sfail; - set = GL_TRUE; - } - } - if (set && ctx->Driver.StencilOpSeparate) { - ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass); - } -} - - -/* OpenGL 2.0 */ -void GLAPIENTRY -_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)"); - return; - } - if (!validate_stencil_func(ctx, func)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)"); - return; - } - - ref = CLAMP(ref, 0, stencilMax); - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - - if (face != GL_BACK) { - /* set front */ - ctx->Stencil.Function[0] = func; - ctx->Stencil.Ref[0] = ref; - ctx->Stencil.ValueMask[0] = mask; - } - if (face != GL_FRONT) { - /* set back */ - ctx->Stencil.Function[1] = func; - ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[1] = mask; - } - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask); - } -} - - -/* OpenGL 2.0 */ -void GLAPIENTRY -_mesa_StencilMaskSeparate(GLenum face, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - - if (face != GL_BACK) { - ctx->Stencil.WriteMask[0] = mask; - } - if (face != GL_FRONT) { - ctx->Stencil.WriteMask[1] = mask; - } - if (ctx->Driver.StencilMaskSeparate) { - ctx->Driver.StencilMaskSeparate(ctx, face, mask); - } -} - - -/** - * Update derived stencil state. - */ -void -_mesa_update_stencil(GLcontext *ctx) -{ - const GLint face = ctx->Stencil._BackFace; - - ctx->Stencil._Enabled = (ctx->Stencil.Enabled && - ctx->DrawBuffer->Visual.stencilBits > 0); - - ctx->Stencil._TestTwoSide = - ctx->Stencil._Enabled && - (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || - ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || - ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || - ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] || - ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] || - ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] || - ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]); -} - - -/** - * Initialize the context stipple state. - * - * \param ctx GL context. - * - * Initializes __GLcontextRec::Stencil attribute group. - */ -void -_mesa_init_stencil(GLcontext *ctx) -{ - ctx->Stencil.Enabled = GL_FALSE; - ctx->Stencil.TestTwoSide = GL_FALSE; - ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */ - ctx->Stencil.Function[0] = GL_ALWAYS; - ctx->Stencil.Function[1] = GL_ALWAYS; - ctx->Stencil.Function[2] = GL_ALWAYS; - ctx->Stencil.FailFunc[0] = GL_KEEP; - ctx->Stencil.FailFunc[1] = GL_KEEP; - ctx->Stencil.FailFunc[2] = GL_KEEP; - ctx->Stencil.ZPassFunc[0] = GL_KEEP; - ctx->Stencil.ZPassFunc[1] = GL_KEEP; - ctx->Stencil.ZPassFunc[2] = GL_KEEP; - ctx->Stencil.ZFailFunc[0] = GL_KEEP; - ctx->Stencil.ZFailFunc[1] = GL_KEEP; - ctx->Stencil.ZFailFunc[2] = GL_KEEP; - ctx->Stencil.Ref[0] = 0; - ctx->Stencil.Ref[1] = 0; - ctx->Stencil.Ref[2] = 0; - ctx->Stencil.ValueMask[0] = ~0U; - ctx->Stencil.ValueMask[1] = ~0U; - ctx->Stencil.ValueMask[2] = ~0U; - ctx->Stencil.WriteMask[0] = ~0U; - ctx->Stencil.WriteMask[1] = ~0U; - ctx->Stencil.WriteMask[2] = ~0U; - ctx->Stencil.Clear = 0; - ctx->Stencil._BackFace = 1; -} +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file stencil.c + * Stencil operations. + * + * Note: There's some conflict between GL_EXT_stencil_two_side and + * OpenGL 2.0's two-sided stencil feature. + * + * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the + * front OR back face state (as set by glActiveStencilFaceEXT) is set. + * + * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the + * front AND back state. + * + * Also, note that GL_ATI_separate_stencil is different as well: + * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. + * glStencilFuncSeparate(GLenum face, GLenum func, ...). + * + * This problem is solved by keeping three sets of stencil state: + * state[0] = GL_FRONT state. + * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. + * state[2] = GL_EXT_stencil_two_side GL_BACK state. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "macros.h" +#include "stencil.h" +#include "mtypes.h" + + +static GLboolean +validate_stencil_op(struct gl_context *ctx, GLenum op) +{ + switch (op) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + return GL_TRUE; + case GL_INCR_WRAP_EXT: + case GL_DECR_WRAP_EXT: + if (ctx->Extensions.EXT_stencil_wrap) { + return GL_TRUE; + } + /* FALL-THROUGH */ + default: + return GL_FALSE; + } +} + + +static GLboolean +validate_stencil_func(struct gl_context *ctx, GLenum func) +{ + switch (func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Set the clear value for the stencil buffer. + * + * \param s clear value. + * + * \sa glClearStencil(). + * + * Updates gl_stencil_attrib::Clear. On change + * flushes the vertices and notifies the driver via + * the dd_function_table::ClearStencil callback. + */ +void GLAPIENTRY +_mesa_ClearStencil( GLint s ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Stencil.Clear == (GLuint) s) + return; + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Clear = (GLuint) s; + + if (ctx->Driver.ClearStencil) { + ctx->Driver.ClearStencil( ctx, s ); + } +} + + +/** + * Set the function and reference value for stencil testing. + * + * \param frontfunc front test function. + * \param backfunc back test function. + * \param ref front and back reference value. + * \param mask front and back bitmask. + * + * \sa glStencilFunc(). + * + * Verifies the parameters and updates the respective values in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilFunc callback. + */ +void GLAPIENTRY +_mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_stencil_func(ctx, frontfunc)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glStencilFuncSeparateATI(frontfunc)"); + return; + } + if (!validate_stencil_func(ctx, backfunc)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glStencilFuncSeparateATI(backfunc)"); + return; + } + + ref = CLAMP( ref, 0, stencilMax ); + + /* set both front and back state */ + if (ctx->Stencil.Function[0] == frontfunc && + ctx->Stencil.Function[1] == backfunc && + ctx->Stencil.ValueMask[0] == mask && + ctx->Stencil.ValueMask[1] == mask && + ctx->Stencil.Ref[0] == ref && + ctx->Stencil.Ref[1] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[0] = frontfunc; + ctx->Stencil.Function[1] = backfunc; + ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, + frontfunc, ref, mask); + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, + backfunc, ref, mask); + } +} + + +/** + * Set the function and reference value for stencil testing. + * + * \param func test function. + * \param ref reference value. + * \param mask bitmask. + * + * \sa glStencilFunc(). + * + * Verifies the parameters and updates the respective values in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilFunc callback. + */ +void GLAPIENTRY +_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + const GLint face = ctx->Stencil.ActiveFace; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_stencil_func(ctx, func)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)"); + return; + } + + ref = CLAMP( ref, 0, stencilMax ); + + if (face != 0) { + if (ctx->Stencil.Function[face] == func && + ctx->Stencil.ValueMask[face] == mask && + ctx->Stencil.Ref[face] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[face] = func; + ctx->Stencil.Ref[face] = ref; + ctx->Stencil.ValueMask[face] = mask; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilFuncSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, func, ref, mask); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.Function[0] == func && + ctx->Stencil.Function[1] == func && + ctx->Stencil.ValueMask[0] == mask && + ctx->Stencil.ValueMask[1] == mask && + ctx->Stencil.Ref[0] == ref && + ctx->Stencil.Ref[1] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[0] = ctx->Stencil.Function[1] = func; + ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + func, ref, mask); + } + } +} + + +/** + * Set the stencil writing mask. + * + * \param mask bit-mask to enable/disable writing of individual bits in the + * stencil planes. + * + * \sa glStencilMask(). + * + * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and + * notifies the driver via the dd_function_table::StencilMask callback. + */ +void GLAPIENTRY +_mesa_StencilMask( GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint face = ctx->Stencil.ActiveFace; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (face != 0) { + /* Only modify the EXT_stencil_two_side back-face state. + */ + if (ctx->Stencil.WriteMask[face] == mask) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.WriteMask[face] = mask; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilMaskSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, mask); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.WriteMask[0] == mask && + ctx->Stencil.WriteMask[1] == mask) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask; + if (ctx->Driver.StencilMaskSeparate) { + ctx->Driver.StencilMaskSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + mask); + } + } +} + + +/** + * Set the stencil test actions. + * + * \param fail action to take when stencil test fails. + * \param zfail action to take when stencil test passes, but depth test fails. + * \param zpass action to take when stencil test passes and the depth test + * passes (or depth testing is not enabled). + * + * \sa glStencilOp(). + * + * Verifies the parameters and updates the respective fields in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilOp callback. + */ +void GLAPIENTRY +_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint face = ctx->Stencil.ActiveFace; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_stencil_op(ctx, fail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)"); + return; + } + if (!validate_stencil_op(ctx, zfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)"); + return; + } + if (!validate_stencil_op(ctx, zpass)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)"); + return; + } + + if (face != 0) { + /* only set active face state */ + if (ctx->Stencil.ZFailFunc[face] == zfail && + ctx->Stencil.ZPassFunc[face] == zpass && + ctx->Stencil.FailFunc[face] == fail) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[face] = zfail; + ctx->Stencil.ZPassFunc[face] = zpass; + ctx->Stencil.FailFunc[face] = fail; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilOpSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilOpSeparate(ctx, GL_BACK, fail, zfail, zpass); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.ZFailFunc[0] == zfail && + ctx->Stencil.ZFailFunc[1] == zfail && + ctx->Stencil.ZPassFunc[0] == zpass && + ctx->Stencil.ZPassFunc[1] == zpass && + ctx->Stencil.FailFunc[0] == fail && + ctx->Stencil.FailFunc[1] == fail) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[0] = ctx->Stencil.ZFailFunc[1] = zfail; + ctx->Stencil.ZPassFunc[0] = ctx->Stencil.ZPassFunc[1] = zpass; + ctx->Stencil.FailFunc[0] = ctx->Stencil.FailFunc[1] = fail; + if (ctx->Driver.StencilOpSeparate) { + ctx->Driver.StencilOpSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + fail, zfail, zpass); + } + } +} + + + +#if _HAVE_FULL_GL +/* GL_EXT_stencil_two_side */ +void GLAPIENTRY +_mesa_ActiveStencilFaceEXT(GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.EXT_stencil_two_side) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveStencilFaceEXT"); + return; + } + + if (face == GL_FRONT || face == GL_BACK) { + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 2; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveStencilFaceEXT(face)"); + } +} +#endif + + + +/** + * OpenGL 2.0 function. + * \todo Make StencilOp() call this function. And eventually remove the + * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate + * instead. + */ +void GLAPIENTRY +_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) +{ + GLboolean set = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_stencil_op(ctx, sfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); + return; + } + if (!validate_stencil_op(ctx, zfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); + return; + } + if (!validate_stencil_op(ctx, zpass)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); + return; + } + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); + return; + } + + if (face != GL_BACK) { + /* set front */ + if (ctx->Stencil.ZFailFunc[0] != zfail || + ctx->Stencil.ZPassFunc[0] != zpass || + ctx->Stencil.FailFunc[0] != sfail){ + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[0] = zfail; + ctx->Stencil.ZPassFunc[0] = zpass; + ctx->Stencil.FailFunc[0] = sfail; + set = GL_TRUE; + } + } + if (face != GL_FRONT) { + /* set back */ + if (ctx->Stencil.ZFailFunc[1] != zfail || + ctx->Stencil.ZPassFunc[1] != zpass || + ctx->Stencil.FailFunc[1] != sfail) { + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[1] = zfail; + ctx->Stencil.ZPassFunc[1] = zpass; + ctx->Stencil.FailFunc[1] = sfail; + set = GL_TRUE; + } + } + if (set && ctx->Driver.StencilOpSeparate) { + ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass); + } +} + + +/* OpenGL 2.0 */ +void GLAPIENTRY +_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)"); + return; + } + if (!validate_stencil_func(ctx, func)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)"); + return; + } + + ref = CLAMP(ref, 0, stencilMax); + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + + if (face != GL_BACK) { + /* set front */ + ctx->Stencil.Function[0] = func; + ctx->Stencil.Ref[0] = ref; + ctx->Stencil.ValueMask[0] = mask; + } + if (face != GL_FRONT) { + /* set back */ + ctx->Stencil.Function[1] = func; + ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[1] = mask; + } + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask); + } +} + + +/* OpenGL 2.0 */ +void GLAPIENTRY +_mesa_StencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + + if (face != GL_BACK) { + ctx->Stencil.WriteMask[0] = mask; + } + if (face != GL_FRONT) { + ctx->Stencil.WriteMask[1] = mask; + } + if (ctx->Driver.StencilMaskSeparate) { + ctx->Driver.StencilMaskSeparate(ctx, face, mask); + } +} + + +/** + * Update derived stencil state. + */ +void +_mesa_update_stencil(struct gl_context *ctx) +{ + const GLint face = ctx->Stencil._BackFace; + + ctx->Stencil._Enabled = (ctx->Stencil.Enabled && + ctx->DrawBuffer->Visual.stencilBits > 0); + + ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled && + (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || + ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || + ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || + ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] || + ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] || + ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] || + ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]); +} + + +/** + * Initialize the context stipple state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Stencil attribute group. + */ +void +_mesa_init_stencil(struct gl_context *ctx) +{ + ctx->Stencil.Enabled = GL_FALSE; + ctx->Stencil.TestTwoSide = GL_FALSE; + ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */ + ctx->Stencil.Function[0] = GL_ALWAYS; + ctx->Stencil.Function[1] = GL_ALWAYS; + ctx->Stencil.Function[2] = GL_ALWAYS; + ctx->Stencil.FailFunc[0] = GL_KEEP; + ctx->Stencil.FailFunc[1] = GL_KEEP; + ctx->Stencil.FailFunc[2] = GL_KEEP; + ctx->Stencil.ZPassFunc[0] = GL_KEEP; + ctx->Stencil.ZPassFunc[1] = GL_KEEP; + ctx->Stencil.ZPassFunc[2] = GL_KEEP; + ctx->Stencil.ZFailFunc[0] = GL_KEEP; + ctx->Stencil.ZFailFunc[1] = GL_KEEP; + ctx->Stencil.ZFailFunc[2] = GL_KEEP; + ctx->Stencil.Ref[0] = 0; + ctx->Stencil.Ref[1] = 0; + ctx->Stencil.Ref[2] = 0; + ctx->Stencil.ValueMask[0] = ~0U; + ctx->Stencil.ValueMask[1] = ~0U; + ctx->Stencil.ValueMask[2] = ~0U; + ctx->Stencil.WriteMask[0] = ~0U; + ctx->Stencil.WriteMask[1] = ~0U; + ctx->Stencil.WriteMask[2] = ~0U; + ctx->Stencil.Clear = 0; + ctx->Stencil._BackFace = 1; +} diff --git a/mesalib/src/mesa/main/stencil.h b/mesalib/src/mesa/main/stencil.h index 252ac932a..f3a33db70 100644 --- a/mesalib/src/mesa/main/stencil.h +++ b/mesalib/src/mesa/main/stencil.h @@ -1,80 +1,81 @@ -/** - * \file stencil.h - * Stencil operations. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef STENCIL_H -#define STENCIL_H - - -#include "mtypes.h" - - -extern void GLAPIENTRY -_mesa_ClearStencil( GLint s ); - - -extern void GLAPIENTRY -_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ); - - -extern void GLAPIENTRY -_mesa_StencilMask( GLuint mask ); - - -extern void GLAPIENTRY -_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ); - - -extern void GLAPIENTRY -_mesa_ActiveStencilFaceEXT(GLenum face); - - -extern void GLAPIENTRY -_mesa_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - - -extern void GLAPIENTRY -_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); - - -extern void GLAPIENTRY -_mesa_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - -extern void GLAPIENTRY -_mesa_StencilMaskSeparate(GLenum face, GLuint mask); - - -extern void -_mesa_update_stencil(GLcontext *ctx); - - -extern void -_mesa_init_stencil( GLcontext * ctx ); - -#endif +/** + * \file stencil.h + * Stencil operations. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef STENCIL_H +#define STENCIL_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_ClearStencil( GLint s ); + + +extern void GLAPIENTRY +_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ); + + +extern void GLAPIENTRY +_mesa_StencilMask( GLuint mask ); + + +extern void GLAPIENTRY +_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + + +extern void GLAPIENTRY +_mesa_ActiveStencilFaceEXT(GLenum face); + + +extern void GLAPIENTRY +_mesa_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + + +extern void GLAPIENTRY +_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); + + +extern void GLAPIENTRY +_mesa_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + +extern void GLAPIENTRY +_mesa_StencilMaskSeparate(GLenum face, GLuint mask); + + +extern void +_mesa_update_stencil(struct gl_context *ctx); + + +extern void +_mesa_init_stencil( struct gl_context * ctx ); + +#endif diff --git a/mesalib/src/mesa/main/syncobj.c b/mesalib/src/mesa/main/syncobj.c index ac948cc1e..eaffbfb9d 100644 --- a/mesalib/src/mesa/main/syncobj.c +++ b/mesalib/src/mesa/main/syncobj.c @@ -1,424 +1,424 @@ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -/** - * \file syncobj.c - * Sync object management. - * - * Unlike textures and other objects that are shared between contexts, sync - * objects are not bound to the context. As a result, the reference counting - * and delete behavior of sync objects is slightly different. References to - * sync objects are added: - * - * - By \c glFencSynce. This sets the initial reference count to 1. - * - At the start of \c glClientWaitSync. The reference is held for the - * duration of the wait call. - * - * References are removed: - * - * - By \c glDeleteSync. - * - At the end of \c glClientWaitSync. - * - * Additionally, drivers may call \c _mesa_ref_sync_object and - * \c _mesa_unref_sync_object as needed to implement \c ServerWaitSync. - * - * As with shader objects, sync object names become invalid as soon as - * \c glDeleteSync is called. For this reason \c glDeleteSync sets the - * \c DeletePending flag. All functions validate object handles by testing - * this flag. - * - * \note - * Only \c GL_ARB_sync objects are shared between contexts. If support is ever - * added for either \c GL_NV_fence or \c GL_APPLE_fence different semantics - * will need to be implemented. - * - * \author Ian Romanick - */ - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "get.h" -#include "dispatch.h" - -#if FEATURE_ARB_sync -#include "syncobj.h" - -static struct gl_sync_object * -_mesa_new_sync_object(GLcontext *ctx, GLenum type) -{ - struct gl_sync_object *s = MALLOC_STRUCT(gl_sync_object); - (void) ctx; - (void) type; - - return s; -} - - -static void -_mesa_delete_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - (void) ctx; - free(syncObj); -} - - -static void -_mesa_fence_sync(GLcontext *ctx, struct gl_sync_object *syncObj, - GLenum condition, GLbitfield flags) -{ - (void) ctx; - (void) condition; - (void) flags; - - syncObj->StatusFlag = 1; -} - - -static void -_mesa_check_sync(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - (void) ctx; - (void) syncObj; - - /* No-op for software rendering. Hardware drivers will need to determine - * whether the state of the sync object has changed. - */ -} - - -static void -_mesa_wait_sync(GLcontext *ctx, struct gl_sync_object *syncObj, - GLbitfield flags, GLuint64 timeout) -{ - (void) ctx; - (void) syncObj; - (void) flags; - (void) timeout; - - /* No-op for software rendering. Hardware drivers will need to wait until - * the state of the sync object changes or the timeout expires. - */ -} - - -void -_mesa_init_sync_object_functions(struct dd_function_table *driver) -{ - driver->NewSyncObject = _mesa_new_sync_object; - driver->FenceSync = _mesa_fence_sync; - driver->DeleteSyncObject = _mesa_delete_sync_object; - driver->CheckSync = _mesa_check_sync; - - /* Use the same no-op wait function for both. - */ - driver->ClientWaitSync = _mesa_wait_sync; - driver->ServerWaitSync = _mesa_wait_sync; -} - - -void -_mesa_init_sync_dispatch(struct _glapi_table *disp) -{ - SET_IsSync(disp, _mesa_IsSync); - SET_DeleteSync(disp, _mesa_DeleteSync); - SET_FenceSync(disp, _mesa_FenceSync); - SET_ClientWaitSync(disp, _mesa_ClientWaitSync); - SET_WaitSync(disp, _mesa_WaitSync); - SET_GetInteger64v(disp, _mesa_GetInteger64v); - SET_GetSynciv(disp, _mesa_GetSynciv); -} - - -/** - * Allocate/init the context state related to sync objects. - */ -void -_mesa_init_sync(GLcontext *ctx) -{ - (void) ctx; -} - - -/** - * Free the context state related to sync objects. - */ -void -_mesa_free_sync_data(GLcontext *ctx) -{ - (void) ctx; -} - - -static int -_mesa_validate_sync(struct gl_sync_object *syncObj) -{ - return (syncObj != NULL) - && (syncObj->Type == GL_SYNC_FENCE) - && !syncObj->DeletePending; -} - - -void -_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - syncObj->RefCount++; - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -void -_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - syncObj->RefCount--; - if (syncObj->RefCount == 0) { - remove_from_list(& syncObj->link); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - ctx->Driver.DeleteSyncObject(ctx, syncObj); - } else { - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } -} - - -GLboolean GLAPIENTRY -_mesa_IsSync(GLsync sync) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - return _mesa_validate_sync(syncObj) ? GL_TRUE : GL_FALSE; -} - - -void GLAPIENTRY -_mesa_DeleteSync(GLsync sync) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* From the GL_ARB_sync spec: - * - * DeleteSync will silently ignore a value of zero. An - * INVALID_VALUE error is generated if is neither zero nor the - * name of a sync object. - */ - if (sync == 0) { - return; - } - - if (!_mesa_validate_sync(syncObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteSync"); - return; - } - - /* If there are no client-waits or server-waits pending on this sync, delete - * the underlying object. - */ - syncObj->DeletePending = GL_TRUE; - _mesa_unref_sync_object(ctx, syncObj); -} - - -GLsync GLAPIENTRY -_mesa_FenceSync(GLenum condition, GLbitfield flags) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *syncObj; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFenceSync(condition=0x%x)", - condition); - return 0; - } - - if (flags != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glFenceSync(flags=0x%x)", - condition); - return 0; - } - - syncObj = ctx->Driver.NewSyncObject(ctx, GL_SYNC_FENCE); - if (syncObj != NULL) { - syncObj->Type = GL_SYNC_FENCE; - /* The name is not currently used, and it is never visible to - * applications. If sync support is extended to provide support for - * NV_fence, this field will be used. We'll also need to add an object - * ID hashtable. - */ - syncObj->Name = 1; - syncObj->RefCount = 1; - syncObj->DeletePending = GL_FALSE; - syncObj->SyncCondition = condition; - syncObj->Flags = flags; - syncObj->StatusFlag = 0; - - ctx->Driver.FenceSync(ctx, syncObj, condition, flags); - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - insert_at_tail(& ctx->Shared->SyncObjects, & syncObj->link); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return (GLsync) syncObj; - } - - return NULL; -} - - -GLenum GLAPIENTRY -_mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - GLenum ret; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED); - - if (!_mesa_validate_sync(syncObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync"); - return GL_WAIT_FAILED; - } - - if ((flags & ~GL_SYNC_FLUSH_COMMANDS_BIT) != 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClientWaitSync(flags=0x%x)", flags); - return GL_WAIT_FAILED; - } - - _mesa_ref_sync_object(ctx, syncObj); - - /* From the GL_ARB_sync spec: - * - * ClientWaitSync returns one of four status values. A return value of - * ALREADY_SIGNALED indicates that was signaled at the time - * ClientWaitSync was called. ALREADY_SIGNALED will always be returned - * if was signaled, even if the value of is zero. - */ - ctx->Driver.CheckSync(ctx, syncObj); - if (syncObj->StatusFlag) { - ret = GL_ALREADY_SIGNALED; - } else { - ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout); - - ret = syncObj->StatusFlag ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; - } - - _mesa_unref_sync_object(ctx, syncObj); - return ret; -} - - -void GLAPIENTRY -_mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!_mesa_validate_sync(syncObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync"); - return; - } - - if (flags != 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glWaitSync(flags=0x%x)", flags); - return; - } - - /* From the GL_ARB_sync spec: - * - * If the value of is zero, then WaitSync does nothing. - */ - if (timeout == 0) { - return; - } - - ctx->Driver.ServerWaitSync(ctx, syncObj, flags, timeout); -} - - -void GLAPIENTRY -_mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, - GLint *values) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - GLsizei size = 0; - GLint v[1]; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!_mesa_validate_sync(syncObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv"); - return; - } - - switch (pname) { - case GL_OBJECT_TYPE: - v[0] = syncObj->Type; - size = 1; - break; - - case GL_SYNC_CONDITION: - v[0] = syncObj->SyncCondition; - size = 1; - break; - - case GL_SYNC_STATUS: - /* Update the state of the sync by dipping into the driver. Note that - * this call won't block. It just updates state in the common object - * data from the current driver state. - */ - ctx->Driver.CheckSync(ctx, syncObj); - - v[0] = (syncObj->StatusFlag) ? GL_SIGNALED : GL_UNSIGNALED; - size = 1; - break; - - case GL_SYNC_FLAGS: - v[0] = syncObj->Flags; - size = 1; - break; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSynciv(pname=0x%x)\n", pname); - return; - } - - if (size > 0) { - const GLsizei copy_count = MIN2(size, bufSize); - - memcpy(values, v, sizeof(GLint) * copy_count); - } - - if (length != NULL) { - *length = size; - } -} - -#endif /* FEATURE_ARB_sync */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +/** + * \file syncobj.c + * Sync object management. + * + * Unlike textures and other objects that are shared between contexts, sync + * objects are not bound to the context. As a result, the reference counting + * and delete behavior of sync objects is slightly different. References to + * sync objects are added: + * + * - By \c glFencSynce. This sets the initial reference count to 1. + * - At the start of \c glClientWaitSync. The reference is held for the + * duration of the wait call. + * + * References are removed: + * + * - By \c glDeleteSync. + * - At the end of \c glClientWaitSync. + * + * Additionally, drivers may call \c _mesa_ref_sync_object and + * \c _mesa_unref_sync_object as needed to implement \c ServerWaitSync. + * + * As with shader objects, sync object names become invalid as soon as + * \c glDeleteSync is called. For this reason \c glDeleteSync sets the + * \c DeletePending flag. All functions validate object handles by testing + * this flag. + * + * \note + * Only \c GL_ARB_sync objects are shared between contexts. If support is ever + * added for either \c GL_NV_fence or \c GL_APPLE_fence different semantics + * will need to be implemented. + * + * \author Ian Romanick + */ + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "macros.h" +#include "get.h" +#include "dispatch.h" + +#if FEATURE_ARB_sync +#include "syncobj.h" + +static struct gl_sync_object * +_mesa_new_sync_object(struct gl_context *ctx, GLenum type) +{ + struct gl_sync_object *s = MALLOC_STRUCT(gl_sync_object); + (void) ctx; + (void) type; + + return s; +} + + +static void +_mesa_delete_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + (void) ctx; + free(syncObj); +} + + +static void +_mesa_fence_sync(struct gl_context *ctx, struct gl_sync_object *syncObj, + GLenum condition, GLbitfield flags) +{ + (void) ctx; + (void) condition; + (void) flags; + + syncObj->StatusFlag = 1; +} + + +static void +_mesa_check_sync(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + (void) ctx; + (void) syncObj; + + /* No-op for software rendering. Hardware drivers will need to determine + * whether the state of the sync object has changed. + */ +} + + +static void +_mesa_wait_sync(struct gl_context *ctx, struct gl_sync_object *syncObj, + GLbitfield flags, GLuint64 timeout) +{ + (void) ctx; + (void) syncObj; + (void) flags; + (void) timeout; + + /* No-op for software rendering. Hardware drivers will need to wait until + * the state of the sync object changes or the timeout expires. + */ +} + + +void +_mesa_init_sync_object_functions(struct dd_function_table *driver) +{ + driver->NewSyncObject = _mesa_new_sync_object; + driver->FenceSync = _mesa_fence_sync; + driver->DeleteSyncObject = _mesa_delete_sync_object; + driver->CheckSync = _mesa_check_sync; + + /* Use the same no-op wait function for both. + */ + driver->ClientWaitSync = _mesa_wait_sync; + driver->ServerWaitSync = _mesa_wait_sync; +} + + +void +_mesa_init_sync_dispatch(struct _glapi_table *disp) +{ + SET_IsSync(disp, _mesa_IsSync); + SET_DeleteSync(disp, _mesa_DeleteSync); + SET_FenceSync(disp, _mesa_FenceSync); + SET_ClientWaitSync(disp, _mesa_ClientWaitSync); + SET_WaitSync(disp, _mesa_WaitSync); + SET_GetInteger64v(disp, _mesa_GetInteger64v); + SET_GetSynciv(disp, _mesa_GetSynciv); +} + + +/** + * Allocate/init the context state related to sync objects. + */ +void +_mesa_init_sync(struct gl_context *ctx) +{ + (void) ctx; +} + + +/** + * Free the context state related to sync objects. + */ +void +_mesa_free_sync_data(struct gl_context *ctx) +{ + (void) ctx; +} + + +static int +_mesa_validate_sync(struct gl_sync_object *syncObj) +{ + return (syncObj != NULL) + && (syncObj->Type == GL_SYNC_FENCE) + && !syncObj->DeletePending; +} + + +void +_mesa_ref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + syncObj->RefCount++; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +void +_mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + syncObj->RefCount--; + if (syncObj->RefCount == 0) { + remove_from_list(& syncObj->link); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + ctx->Driver.DeleteSyncObject(ctx, syncObj); + } else { + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } +} + + +GLboolean GLAPIENTRY +_mesa_IsSync(GLsync sync) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + return _mesa_validate_sync(syncObj) ? GL_TRUE : GL_FALSE; +} + + +void GLAPIENTRY +_mesa_DeleteSync(GLsync sync) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* From the GL_ARB_sync spec: + * + * DeleteSync will silently ignore a value of zero. An + * INVALID_VALUE error is generated if is neither zero nor the + * name of a sync object. + */ + if (sync == 0) { + return; + } + + if (!_mesa_validate_sync(syncObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteSync"); + return; + } + + /* If there are no client-waits or server-waits pending on this sync, delete + * the underlying object. + */ + syncObj->DeletePending = GL_TRUE; + _mesa_unref_sync_object(ctx, syncObj); +} + + +GLsync GLAPIENTRY +_mesa_FenceSync(GLenum condition, GLbitfield flags) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *syncObj; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glFenceSync(condition=0x%x)", + condition); + return 0; + } + + if (flags != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glFenceSync(flags=0x%x)", + condition); + return 0; + } + + syncObj = ctx->Driver.NewSyncObject(ctx, GL_SYNC_FENCE); + if (syncObj != NULL) { + syncObj->Type = GL_SYNC_FENCE; + /* The name is not currently used, and it is never visible to + * applications. If sync support is extended to provide support for + * NV_fence, this field will be used. We'll also need to add an object + * ID hashtable. + */ + syncObj->Name = 1; + syncObj->RefCount = 1; + syncObj->DeletePending = GL_FALSE; + syncObj->SyncCondition = condition; + syncObj->Flags = flags; + syncObj->StatusFlag = 0; + + ctx->Driver.FenceSync(ctx, syncObj, condition, flags); + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + insert_at_tail(& ctx->Shared->SyncObjects, & syncObj->link); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + return (GLsync) syncObj; + } + + return NULL; +} + + +GLenum GLAPIENTRY +_mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + GLenum ret; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED); + + if (!_mesa_validate_sync(syncObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync"); + return GL_WAIT_FAILED; + } + + if ((flags & ~GL_SYNC_FLUSH_COMMANDS_BIT) != 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClientWaitSync(flags=0x%x)", flags); + return GL_WAIT_FAILED; + } + + _mesa_ref_sync_object(ctx, syncObj); + + /* From the GL_ARB_sync spec: + * + * ClientWaitSync returns one of four status values. A return value of + * ALREADY_SIGNALED indicates that was signaled at the time + * ClientWaitSync was called. ALREADY_SIGNALED will always be returned + * if was signaled, even if the value of is zero. + */ + ctx->Driver.CheckSync(ctx, syncObj); + if (syncObj->StatusFlag) { + ret = GL_ALREADY_SIGNALED; + } else { + ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout); + + ret = syncObj->StatusFlag ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; + } + + _mesa_unref_sync_object(ctx, syncObj); + return ret; +} + + +void GLAPIENTRY +_mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!_mesa_validate_sync(syncObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync"); + return; + } + + if (flags != 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glWaitSync(flags=0x%x)", flags); + return; + } + + /* From the GL_ARB_sync spec: + * + * If the value of is zero, then WaitSync does nothing. + */ + if (timeout == 0) { + return; + } + + ctx->Driver.ServerWaitSync(ctx, syncObj, flags, timeout); +} + + +void GLAPIENTRY +_mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, + GLint *values) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + GLsizei size = 0; + GLint v[1]; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!_mesa_validate_sync(syncObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv"); + return; + } + + switch (pname) { + case GL_OBJECT_TYPE: + v[0] = syncObj->Type; + size = 1; + break; + + case GL_SYNC_CONDITION: + v[0] = syncObj->SyncCondition; + size = 1; + break; + + case GL_SYNC_STATUS: + /* Update the state of the sync by dipping into the driver. Note that + * this call won't block. It just updates state in the common object + * data from the current driver state. + */ + ctx->Driver.CheckSync(ctx, syncObj); + + v[0] = (syncObj->StatusFlag) ? GL_SIGNALED : GL_UNSIGNALED; + size = 1; + break; + + case GL_SYNC_FLAGS: + v[0] = syncObj->Flags; + size = 1; + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSynciv(pname=0x%x)\n", pname); + return; + } + + if (size > 0) { + const GLsizei copy_count = MIN2(size, bufSize); + + memcpy(values, v, sizeof(GLint) * copy_count); + } + + if (length != NULL) { + *length = size; + } +} + +#endif /* FEATURE_ARB_sync */ diff --git a/mesalib/src/mesa/main/syncobj.h b/mesalib/src/mesa/main/syncobj.h index 82e141d40..ac1384f61 100644 --- a/mesalib/src/mesa/main/syncobj.h +++ b/mesalib/src/mesa/main/syncobj.h @@ -1,115 +1,119 @@ -/* - * Copyright © 2009 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * 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. - */ - -/** - * \file syncobj.h - * Sync object management. - * - * \author Ian Romanick - */ - -#ifndef SYNCOBJ_H -#define SYNCOBJ_H - -#include "main/mtypes.h" - -struct dd_function_table; - -#if FEATURE_ARB_sync - -extern void -_mesa_init_sync_object_functions(struct dd_function_table *driver); - -extern void -_mesa_init_sync_dispatch(struct _glapi_table *disp); - -extern void -_mesa_init_sync(GLcontext *); - -extern void -_mesa_free_sync_data(GLcontext *); - -extern void -_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj); - -extern void -_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj); - -extern GLboolean GLAPIENTRY -_mesa_IsSync(GLsync sync); - -extern void GLAPIENTRY -_mesa_DeleteSync(GLsync sync); - -extern GLsync GLAPIENTRY -_mesa_FenceSync(GLenum condition, GLbitfield flags); - -extern GLenum GLAPIENTRY -_mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); - -extern void GLAPIENTRY -_mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); - -extern void GLAPIENTRY -_mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, - GLint *values); - -#else /* FEATURE_ARB_sync */ - -#include "main/compiler.h" - -static INLINE void -_mesa_init_sync_object_functions(struct dd_function_table *driver) -{ -} - -static INLINE void -_mesa_init_sync_dispatch(struct _glapi_table *disp) -{ -} - -static INLINE void -_mesa_init_sync(GLcontext *ctx) -{ -} - -static INLINE void -_mesa_free_sync_data(GLcontext *ctx) -{ -} - -static INLINE void -_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - ASSERT_NO_FEATURE(); -} - -static INLINE void -_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) -{ - ASSERT_NO_FEATURE(); -} - -#endif /* FEATURE_ARB_sync */ - -#endif /* SYNCOBJ_H */ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * 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. + */ + +/** + * \file syncobj.h + * Sync object management. + * + * \author Ian Romanick + */ + +#ifndef SYNCOBJ_H +#define SYNCOBJ_H + +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct dd_function_table; +struct gl_context; +struct gl_sync_object; + +#if FEATURE_ARB_sync + +extern void +_mesa_init_sync_object_functions(struct dd_function_table *driver); + +extern void +_mesa_init_sync_dispatch(struct _glapi_table *disp); + +extern void +_mesa_init_sync(struct gl_context *); + +extern void +_mesa_free_sync_data(struct gl_context *); + +extern void +_mesa_ref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj); + +extern void +_mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj); + +extern GLboolean GLAPIENTRY +_mesa_IsSync(GLsync sync); + +extern void GLAPIENTRY +_mesa_DeleteSync(GLsync sync); + +extern GLsync GLAPIENTRY +_mesa_FenceSync(GLenum condition, GLbitfield flags); + +extern GLenum GLAPIENTRY +_mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); + +extern void GLAPIENTRY +_mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout); + +extern void GLAPIENTRY +_mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, + GLint *values); + +#else /* FEATURE_ARB_sync */ + +#include "main/compiler.h" + +static INLINE void +_mesa_init_sync_object_functions(struct dd_function_table *driver) +{ +} + +static INLINE void +_mesa_init_sync_dispatch(struct _glapi_table *disp) +{ +} + +static INLINE void +_mesa_init_sync(struct gl_context *ctx) +{ +} + +static INLINE void +_mesa_free_sync_data(struct gl_context *ctx) +{ +} + +static INLINE void +_mesa_ref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj) +{ + ASSERT_NO_FEATURE(); +} + +#endif /* FEATURE_ARB_sync */ + +#endif /* SYNCOBJ_H */ diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index e911524cb..52954ece4 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -1,247 +1,247 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texcompress.c - * Helper functions for texture compression. - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "formats.h" -#include "texcompress.h" - - -/** - * Return list of (and count of) all specific texture compression - * formats that are supported. - * - * \param ctx the GL context - * \param formats the resulting format list (may be NULL). - * \param all if true return all formats, even those with some kind - * of restrictions/limitations (See GL_ARB_texture_compression - * spec for more info). - * - * \return number of formats. - */ -GLuint -_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) -{ - GLuint n = 0; - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; - formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - else { - n += 2; - } - } - if (ctx->Extensions.EXT_texture_compression_s3tc) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - /* This format has some restrictions/limitations and so should - * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query. - * Specifically, all transparent pixels become black. NVIDIA - * omits this format too. - */ - if (all) - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else { - n += 3; - if (all) - n += 1; - } - } - if (ctx->Extensions.S3_s3tc) { - if (formats) { - formats[n++] = GL_RGB_S3TC; - formats[n++] = GL_RGB4_S3TC; - formats[n++] = GL_RGBA_S3TC; - formats[n++] = GL_RGBA4_S3TC; - } - else { - n += 4; - } - } -#if FEATURE_EXT_texture_sRGB - if (ctx->Extensions.EXT_texture_sRGB) { - if (formats) { - formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; - } - else { - n += 4; - } - } -#endif /* FEATURE_EXT_texture_sRGB */ - return n; - -#if FEATURE_ES1 || FEATURE_ES2 - if (formats) { - formats[n++] = GL_PALETTE4_RGB8_OES; - formats[n++] = GL_PALETTE4_RGBA8_OES; - formats[n++] = GL_PALETTE4_R5_G6_B5_OES; - formats[n++] = GL_PALETTE4_RGBA4_OES; - formats[n++] = GL_PALETTE4_RGB5_A1_OES; - formats[n++] = GL_PALETTE8_RGB8_OES; - formats[n++] = GL_PALETTE8_RGBA8_OES; - formats[n++] = GL_PALETTE8_R5_G6_B5_OES; - formats[n++] = GL_PALETTE8_RGBA4_OES; - formats[n++] = GL_PALETTE8_RGB5_A1_OES; - } - else { - n += 10; - } -#endif -} - - -/** - * Convert a compressed MESA_FORMAT_x to a GLenum. - */ -gl_format -_mesa_glenum_to_compressed_format(GLenum format) -{ - switch (format) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT5; - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGB_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGBA_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - return MESA_FORMAT_SRGBA_DXT3; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return MESA_FORMAT_SRGBA_DXT5; - - default: - return MESA_FORMAT_NONE; - } -} - - -/** - * Given a compressed MESA_FORMAT_x value, return the corresponding - * GLenum for that format. - * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) - * which must return the specific texture format used when the user might - * have originally specified a generic compressed format in their - * glTexImage2D() call. - * For non-compressed textures, we always return the user-specified - * internal format unchanged. - */ -GLenum -_mesa_compressed_format_to_glenum(GLcontext *ctx, GLuint mesaFormat) -{ - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - return GL_COMPRESSED_RGB_FXT1_3DFX; - case MESA_FORMAT_RGBA_FXT1: - return GL_COMPRESSED_RGBA_FXT1_3DFX; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT1: - return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT3: - return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - case MESA_FORMAT_RGBA_DXT5: - return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT1: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT3: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - case MESA_FORMAT_SRGBA_DXT5: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; -#endif -#endif - default: - _mesa_problem(ctx, "Unexpected mesa texture format in" - " _mesa_compressed_format_to_glenum()"); - return 0; - } -} - - -/* - * Return the address of the pixel at (col, row, img) in a - * compressed texture image. - * \param col, row, img - image position (3D), should be a multiple of the - * format's block size. - * \param format - compressed image format - * \param width - image width (stride) in pixels - * \param image - the image address - * \return address of pixel at (row, col, img) - */ -GLubyte * -_mesa_compressed_image_address(GLint col, GLint row, GLint img, - gl_format mesaFormat, - GLsizei width, const GLubyte *image) -{ - /* XXX only 2D images implemented, not 3D */ - const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); - GLuint bw, bh; - GLint offset; - - _mesa_get_format_block_size(mesaFormat, &bw, &bh); - - ASSERT(col % bw == 0); - ASSERT(row % bh == 0); - - offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; - offset *= blockSize; - - return (GLubyte *) image + offset; -} +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress.c + * Helper functions for texture compression. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "formats.h" +#include "texcompress.h" + + +/** + * Return list of (and count of) all specific texture compression + * formats that are supported. + * + * \param ctx the GL context + * \param formats the resulting format list (may be NULL). + * \param all if true return all formats, even those with some kind + * of restrictions/limitations (See GL_ARB_texture_compression + * spec for more info). + * + * \return number of formats. + */ +GLuint +_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all) +{ + GLuint n = 0; + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; + formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; + } + else { + n += 2; + } + } + if (ctx->Extensions.EXT_texture_compression_s3tc) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + /* This format has some restrictions/limitations and so should + * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query. + * Specifically, all transparent pixels become black. NVIDIA + * omits this format too. + */ + if (all) + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else { + n += 3; + if (all) + n += 1; + } + } + if (ctx->Extensions.S3_s3tc) { + if (formats) { + formats[n++] = GL_RGB_S3TC; + formats[n++] = GL_RGB4_S3TC; + formats[n++] = GL_RGBA_S3TC; + formats[n++] = GL_RGBA4_S3TC; + } + else { + n += 4; + } + } +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + if (formats) { + formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + } + else { + n += 4; + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + return n; + +#if FEATURE_ES1 || FEATURE_ES2 + if (formats) { + formats[n++] = GL_PALETTE4_RGB8_OES; + formats[n++] = GL_PALETTE4_RGBA8_OES; + formats[n++] = GL_PALETTE4_R5_G6_B5_OES; + formats[n++] = GL_PALETTE4_RGBA4_OES; + formats[n++] = GL_PALETTE4_RGB5_A1_OES; + formats[n++] = GL_PALETTE8_RGB8_OES; + formats[n++] = GL_PALETTE8_RGBA8_OES; + formats[n++] = GL_PALETTE8_R5_G6_B5_OES; + formats[n++] = GL_PALETTE8_RGBA4_OES; + formats[n++] = GL_PALETTE8_RGB5_A1_OES; + } + else { + n += 10; + } +#endif +} + + +/** + * Convert a compressed MESA_FORMAT_x to a GLenum. + */ +gl_format +_mesa_glenum_to_compressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return MESA_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return MESA_FORMAT_RGBA_FXT1; + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_RGB_S3TC: + return MESA_FORMAT_RGB_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_RGB4_S3TC: + return MESA_FORMAT_RGBA_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_RGBA_S3TC: + return MESA_FORMAT_RGBA_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_RGBA4_S3TC: + return MESA_FORMAT_RGBA_DXT5; + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGB_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGBA_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return MESA_FORMAT_SRGBA_DXT3; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return MESA_FORMAT_SRGBA_DXT5; + + default: + return MESA_FORMAT_NONE; + } +} + + +/** + * Given a compressed MESA_FORMAT_x value, return the corresponding + * GLenum for that format. + * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) + * which must return the specific texture format used when the user might + * have originally specified a generic compressed format in their + * glTexImage2D() call. + * For non-compressed textures, we always return the user-specified + * internal format unchanged. + */ +GLenum +_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) +{ + switch (mesaFormat) { +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + return GL_COMPRESSED_RGB_FXT1_3DFX; + case MESA_FORMAT_RGBA_FXT1: + return GL_COMPRESSED_RGBA_FXT1_3DFX; +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT1: + return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT3: + return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case MESA_FORMAT_RGBA_DXT5: + return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT1: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT3: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case MESA_FORMAT_SRGBA_DXT5: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; +#endif +#endif + default: + _mesa_problem(ctx, "Unexpected mesa texture format in" + " _mesa_compressed_format_to_glenum()"); + return 0; + } +} + + +/* + * Return the address of the pixel at (col, row, img) in a + * compressed texture image. + * \param col, row, img - image position (3D), should be a multiple of the + * format's block size. + * \param format - compressed image format + * \param width - image width (stride) in pixels + * \param image - the image address + * \return address of pixel at (row, col, img) + */ +GLubyte * +_mesa_compressed_image_address(GLint col, GLint row, GLint img, + gl_format mesaFormat, + GLsizei width, const GLubyte *image) +{ + /* XXX only 2D images implemented, not 3D */ + const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); + GLuint bw, bh; + GLint offset; + + _mesa_get_format_block_size(mesaFormat, &bw, &bh); + + ASSERT(col % bw == 0); + ASSERT(row % bh == 0); + + offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; + offset *= blockSize; + + return (GLubyte *) image + offset; +} diff --git a/mesalib/src/mesa/main/texcompress.h b/mesalib/src/mesa/main/texcompress.h index 5e73a3149..fd42f6402 100644 --- a/mesalib/src/mesa/main/texcompress.h +++ b/mesalib/src/mesa/main/texcompress.h @@ -1,56 +1,59 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TEXCOMPRESS_H -#define TEXCOMPRESS_H - -#include "mtypes.h" -#include "formats.h" - -#if _HAVE_FULL_GL - -extern GLuint -_mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all); - -extern gl_format -_mesa_glenum_to_compressed_format(GLenum format); - -extern GLenum -_mesa_compressed_format_to_glenum(GLcontext *ctx, GLuint mesaFormat); - -extern GLubyte * -_mesa_compressed_image_address(GLint col, GLint row, GLint img, - gl_format mesaFormat, - GLsizei width, const GLubyte *image); - -#else /* _HAVE_FULL_GL */ - -/* no-op macros */ -#define _mesa_get_compressed_formats( c, f ) 0 -#define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0 -#define _mesa_compress_teximage( c, w, h, sF, s, sRS, dF, d, drs ) ((void)0) - -#endif /* _HAVE_FULL_GL */ - -#endif /* TEXCOMPRESS_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef TEXCOMPRESS_H +#define TEXCOMPRESS_H + +#include "formats.h" +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; + +#if _HAVE_FULL_GL + +extern GLuint +_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all); + +extern gl_format +_mesa_glenum_to_compressed_format(GLenum format); + +extern GLenum +_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat); + +extern GLubyte * +_mesa_compressed_image_address(GLint col, GLint row, GLint img, + gl_format mesaFormat, + GLsizei width, const GLubyte *image); + +#else /* _HAVE_FULL_GL */ + +/* no-op macros */ +#define _mesa_get_compressed_formats( c, f ) 0 +#define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0 +#define _mesa_compress_teximage( c, w, h, sF, s, sRS, dF, d, drs ) ((void)0) + +#endif /* _HAVE_FULL_GL */ + +#endif /* TEXCOMPRESS_H */ diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c index c8b45bd3a..e6dd7f364 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.c +++ b/mesalib/src/mesa/main/texcompress_fxt1.c @@ -1,1653 +1,1650 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texcompress_fxt1.c - * GL_EXT_texture_compression_fxt1 support. - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "convolve.h" -#include "image.h" -#include "macros.h" -#include "mipmap.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texstore.h" - - -#if FEATURE_texture_fxt1 - - -static void -fxt1_encode (GLuint width, GLuint height, GLint comps, - const void *source, GLint srcRowStride, - void *dest, GLint destRowStride); - -void -fxt1_decode_1 (const void *texture, GLint stride, - GLint i, GLint j, GLchan *rgba); - - -/** - * Store user's image in rgb_fxt1 format. - */ -GLboolean -_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1); - ASSERT(dstXoffset % 8 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGB || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGB/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 3 * srcWidth; - srcFormat = GL_RGB; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - - fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride, - dst, dstRowStride); - - if (tempImage) - free((void*) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_fxt1 format. - */ -GLboolean -_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1); - ASSERT(dstXoffset % 8 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 4 * srcWidth; - srcFormat = GL_RGBA; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - - fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride, - dst, dstRowStride); - - if (tempImage) - free((void*) tempImage); - - return GL_TRUE; -} - - -void -_mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - (void) k; - fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -void -_mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - (void) k; - fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = 1.0F; -} - - - -/***************************************************************************\ - * FXT1 encoder - * - * The encoder was built by reversing the decoder, - * and is vaguely based on Texus2 by 3dfx. Note that this code - * is merely a proof of concept, since it is highly UNoptimized; - * moreover, it is sub-optimal due to initial conditions passed - * to Lloyd's algorithm (the interpolation modes are even worse). -\***************************************************************************/ - - -#define MAX_COMP 4 /* ever needed maximum number of components in texel */ -#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ -#define N_TEXELS 32 /* number of texels in a block (always 32) */ -#define LL_N_REP 50 /* number of iterations in lloyd's vq */ -#define LL_RMS_D 10 /* fault tolerance (maximum delta) */ -#define LL_RMS_E 255 /* fault tolerance (maximum error) */ -#define ALPHA_TS 2 /* alpha threshold: (255 - ALPHA_TS) deemed opaque */ -#define ISTBLACK(v) (*((GLuint *)(v)) == 0) - - -/* - * Define a 64-bit unsigned integer type and macros - */ -#if 1 - -#define FX64_NATIVE 1 - -typedef uint64_t Fx64; - -#define FX64_MOV32(a, b) a = b -#define FX64_OR32(a, b) a |= b -#define FX64_SHL(a, c) a <<= c - -#else - -#define FX64_NATIVE 0 - -typedef struct { - GLuint lo, hi; -} Fx64; - -#define FX64_MOV32(a, b) a.lo = b -#define FX64_OR32(a, b) a.lo |= b - -#define FX64_SHL(a, c) \ - do { \ - if ((c) >= 32) { \ - a.hi = a.lo << ((c) - 32); \ - a.lo = 0; \ - } else { \ - a.hi = (a.hi << (c)) | (a.lo >> (32 - (c))); \ - a.lo <<= (c); \ - } \ - } while (0) - -#endif - - -#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */ -#define SAFECDOT 1 /* for paranoids */ - -#define MAKEIVEC(NV, NC, IV, B, V0, V1) \ - do { \ - /* compute interpolation vector */ \ - GLfloat d2 = 0.0F; \ - GLfloat rd2; \ - \ - for (i = 0; i < NC; i++) { \ - IV[i] = (V1[i] - V0[i]) * F(i); \ - d2 += IV[i] * IV[i]; \ - } \ - rd2 = (GLfloat)NV / d2; \ - B = 0; \ - for (i = 0; i < NC; i++) { \ - IV[i] *= F(i); \ - B -= IV[i] * V0[i]; \ - IV[i] *= rd2; \ - } \ - B = B * rd2 + 0.5f; \ - } while (0) - -#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\ - do { \ - GLfloat dot = 0.0F; \ - for (i = 0; i < NC; i++) { \ - dot += V[i] * IV[i]; \ - } \ - TEXEL = (GLint)(dot + B); \ - if (SAFECDOT) { \ - if (TEXEL < 0) { \ - TEXEL = 0; \ - } else if (TEXEL > NV) { \ - TEXEL = NV; \ - } \ - } \ - } while (0) - - -static GLint -fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv, - GLubyte input[MAX_COMP], GLint nc) -{ - GLint i, j, best = -1; - GLfloat err = 1e9; /* big enough */ - - for (j = 0; j < nv; j++) { - GLfloat e = 0.0F; - for (i = 0; i < nc; i++) { - e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]); - } - if (e < err) { - err = e; - best = j; - } - } - - return best; -} - - -static GLint -fxt1_worst (GLfloat vec[MAX_COMP], - GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) -{ - GLint i, k, worst = -1; - GLfloat err = -1.0F; /* small enough */ - - for (k = 0; k < n; k++) { - GLfloat e = 0.0F; - for (i = 0; i < nc; i++) { - e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]); - } - if (e > err) { - err = e; - worst = k; - } - } - - return worst; -} - - -static GLint -fxt1_variance (GLdouble variance[MAX_COMP], - GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) -{ - GLint i, k, best = 0; - GLint sx, sx2; - GLdouble var, maxvar = -1; /* small enough */ - GLdouble teenth = 1.0 / n; - - for (i = 0; i < nc; i++) { - sx = sx2 = 0; - for (k = 0; k < n; k++) { - GLint t = input[k][i]; - sx += t; - sx2 += t * t; - } - var = sx2 * teenth - sx * sx * teenth * teenth; - if (maxvar < var) { - maxvar = var; - best = i; - } - if (variance) { - variance[i] = var; - } - } - - return best; -} - - -static GLint -fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv, - GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) -{ -#if 0 - /* Choose colors from a grid. - */ - GLint i, j; - - for (j = 0; j < nv; j++) { - GLint m = j * (n - 1) / (nv - 1); - for (i = 0; i < nc; i++) { - vec[j][i] = input[m][i]; - } - } -#else - /* Our solution here is to find the darkest and brightest colors in - * the 8x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ - GLint i, j, k; - GLint minSum = 2000; /* big enough */ - GLint maxSum = -1; /* small enough */ - GLint minCol = 0; /* phoudoin: silent compiler! */ - GLint maxCol = 0; /* phoudoin: silent compiler! */ - - struct { - GLint flag; - GLint key; - GLint freq; - GLint idx; - } hist[N_TEXELS]; - GLint lenh = 0; - - memset(hist, 0, sizeof(hist)); - - for (k = 0; k < n; k++) { - GLint l; - GLint key = 0; - GLint sum = 0; - for (i = 0; i < nc; i++) { - key <<= 8; - key |= input[k][i]; - sum += input[k][i]; - } - for (l = 0; l < n; l++) { - if (!hist[l].flag) { - /* alloc new slot */ - hist[l].flag = !0; - hist[l].key = key; - hist[l].freq = 1; - hist[l].idx = k; - lenh = l + 1; - break; - } else if (hist[l].key == key) { - hist[l].freq++; - break; - } - } - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } - } - - if (lenh <= nv) { - for (j = 0; j < lenh; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = (GLfloat)input[hist[j].idx][i]; - } - } - for (; j < nv; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = vec[0][i]; - } - } - return 0; - } - - for (j = 0; j < nv; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (GLfloat)(nv - 1); - } - } -#endif - - return !0; -} - - -static GLint -fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv, - GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) -{ - /* Use the generalized lloyd's algorithm for VQ: - * find 4 color vectors. - * - * for each sample color - * sort to nearest vector. - * - * replace each vector with the centroid of its matching colors. - * - * repeat until RMS doesn't improve. - * - * if a color vector has no samples, or becomes the same as another - * vector, replace it with the color which is farthest from a sample. - * - * vec[][MAX_COMP] initial vectors and resulting colors - * nv number of resulting colors required - * input[N_TEXELS][MAX_COMP] input texels - * nc number of components in input / vec - * n number of input samples - */ - - GLint sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */ - GLint cnt[MAX_VECT]; /* how many times a certain vector was chosen */ - GLfloat error, lasterror = 1e9; - - GLint i, j, k, rep; - - /* the quantizer */ - for (rep = 0; rep < LL_N_REP; rep++) { - /* reset sums & counters */ - for (j = 0; j < nv; j++) { - for (i = 0; i < nc; i++) { - sum[j][i] = 0; - } - cnt[j] = 0; - } - error = 0; - - /* scan whole block */ - for (k = 0; k < n; k++) { -#if 1 - GLint best = -1; - GLfloat err = 1e9; /* big enough */ - /* determine best vector */ - for (j = 0; j < nv; j++) { - GLfloat e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) + - (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) + - (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]); - if (nc == 4) { - e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]); - } - if (e < err) { - err = e; - best = j; - } - } -#else - GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err); -#endif - assert(best >= 0); - /* add in closest color */ - for (i = 0; i < nc; i++) { - sum[best][i] += input[k][i]; - } - /* mark this vector as used */ - cnt[best]++; - /* accumulate error */ - error += err; - } - - /* check RMS */ - if ((error < LL_RMS_E) || - ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) { - return !0; /* good match */ - } - lasterror = error; - - /* move each vector to the barycenter of its closest colors */ - for (j = 0; j < nv; j++) { - if (cnt[j]) { - GLfloat div = 1.0F / cnt[j]; - for (i = 0; i < nc; i++) { - vec[j][i] = div * sum[j][i]; - } - } else { - /* this vec has no samples or is identical with a previous vec */ - GLint worst = fxt1_worst(vec[j], input, nc, n); - for (i = 0; i < nc; i++) { - vec[j][i] = input[worst][i]; - } - } - } - } - - return 0; /* could not converge fast enough */ -} - - -static void -fxt1_quantize_CHROMA (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP]) -{ - const GLint n_vect = 4; /* 4 base vectors to find */ - const GLint n_comp = 3; /* 3 components: R, G, B */ - GLfloat vec[MAX_VECT][MAX_COMP]; - GLint i, j, k; - Fx64 hi; /* high quadword */ - GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ - - if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) { - fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS); - } - - FX64_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */ - for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - FX64_SHL(hi, 5); - FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); - } - } - ((Fx64 *)cc)[1] = hi; - - lohi = lolo = 0; - /* right microtile */ - for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) { - lohi <<= 2; - lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp); - } - /* left microtile */ - for (; k >= 0; k--) { - lolo <<= 2; - lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp); - } - cc[1] = lohi; - cc[0] = lolo; -} - - -static void -fxt1_quantize_ALPHA0 (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP], - GLubyte reord[N_TEXELS][MAX_COMP], GLint n) -{ - const GLint n_vect = 3; /* 3 base vectors to find */ - const GLint n_comp = 4; /* 4 components: R, G, B, A */ - GLfloat vec[MAX_VECT][MAX_COMP]; - GLint i, j, k; - Fx64 hi; /* high quadword */ - GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ - - /* the last vector indicates zero */ - for (i = 0; i < n_comp; i++) { - vec[n_vect][i] = 0; - } - - /* the first n texels in reord are guaranteed to be non-zero */ - if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) { - fxt1_lloyd(vec, n_vect, reord, n_comp, n); - } - - FX64_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */ - for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ - FX64_SHL(hi, 5); - FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F)); - } - for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ - FX64_SHL(hi, 5); - FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); - } - } - ((Fx64 *)cc)[1] = hi; - - lohi = lolo = 0; - /* right microtile */ - for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) { - lohi <<= 2; - lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); - } - /* left microtile */ - for (; k >= 0; k--) { - lolo <<= 2; - lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); - } - cc[1] = lohi; - cc[0] = lolo; -} - - -static void -fxt1_quantize_ALPHA1 (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP]) -{ - const GLint n_vect = 3; /* highest vector number in each microtile */ - const GLint n_comp = 4; /* 4 components: R, G, B, A */ - GLfloat vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */ - GLfloat b, iv[MAX_COMP]; /* interpolation vector */ - GLint i, j, k; - Fx64 hi; /* high quadword */ - GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ - - GLint minSum; - GLint maxSum; - GLint minColL = 0, maxColL = 0; - GLint minColR = 0, maxColR = 0; - GLint sumL = 0, sumR = 0; - GLint nn_comp; - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ - nn_comp = n_comp; - while ((minColL == maxColL) && nn_comp) { - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (k = 0; k < N_TEXELS / 2; k++) { - GLint sum = 0; - for (i = 0; i < nn_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - sumL += sum; - } - - nn_comp--; - } - - nn_comp = n_comp; - while ((minColR == maxColR) && nn_comp) { - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (k = N_TEXELS / 2; k < N_TEXELS; k++) { - GLint sum = 0; - for (i = 0; i < nn_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - sumR += sum; - } - - nn_comp--; - } - - /* choose the common vector (yuck!) */ - { - GLint j1, j2; - GLint v1 = 0, v2 = 0; - GLfloat err = 1e9; /* big enough */ - GLfloat tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - for (i = 0; i < n_comp; i++) { - tv[0][i] = input[minColL][i]; - tv[1][i] = input[maxColL][i]; - tv[2][i] = input[minColR][i]; - tv[3][i] = input[maxColR][i]; - } - for (j1 = 0; j1 < 2; j1++) { - for (j2 = 2; j2 < 4; j2++) { - GLfloat e = 0.0F; - for (i = 0; i < n_comp; i++) { - e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]); - } - if (e < err) { - err = e; - v1 = j1; - v2 = j2; - } - } - } - for (i = 0; i < n_comp; i++) { - vec[0][i] = tv[1 - v1][i]; - vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR); - vec[2][i] = tv[5 - v2][i]; - } - } - - /* left microtile */ - cc[0] = 0; - if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - GLint texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } - - cc[0] = lolo; - } - - /* right microtile */ - cc[1] = 0; - if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]); - - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - GLint texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } - - cc[1] = lohi; - } - - FX64_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */ - for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ - FX64_SHL(hi, 5); - FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F)); - } - for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ - FX64_SHL(hi, 5); - FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); - } - } - ((Fx64 *)cc)[1] = hi; -} - - -static void -fxt1_quantize_HI (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP], - GLubyte reord[N_TEXELS][MAX_COMP], GLint n) -{ - const GLint n_vect = 6; /* highest vector number */ - const GLint n_comp = 3; /* 3 components: R, G, B */ - GLfloat b = 0.0F; /* phoudoin: silent compiler! */ - GLfloat iv[MAX_COMP]; /* interpolation vector */ - GLint i, k; - GLuint hihi; /* high quadword: hi dword */ - - GLint minSum = 2000; /* big enough */ - GLint maxSum = -1; /* small enough */ - GLint minCol = 0; /* phoudoin: silent compiler! */ - GLint maxCol = 0; /* phoudoin: silent compiler! */ - - /* Our solution here is to find the darkest and brightest colors in - * the 8x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ - for (k = 0; k < n; k++) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += reord[k][i]; - } - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } - } - - hihi = 0; /* cc-hi = "00" */ - for (i = 0; i < n_comp; i++) { - /* add in colors */ - hihi <<= 5; - hihi |= reord[maxCol][i] >> 3; - } - for (i = 0; i < n_comp; i++) { - /* add in colors */ - hihi <<= 5; - hihi |= reord[minCol][i] >> 3; - } - cc[3] = hihi; - cc[0] = cc[1] = cc[2] = 0; - - /* compute interpolation vector */ - if (minCol != maxCol) { - MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]); - } - - /* add in texels */ - for (k = N_TEXELS - 1; k >= 0; k--) { - GLint t = k * 3; - GLuint *kk = (GLuint *)((char *)cc + t / 8); - GLint texel = n_vect + 1; /* transparent black */ - - if (!ISTBLACK(input[k])) { - if (minCol != maxCol) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - kk[0] |= texel << (t & 7); - } - } else { - /* add in texel */ - kk[0] |= texel << (t & 7); - } - } -} - - -static void -fxt1_quantize_MIXED1 (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP]) -{ - const GLint n_vect = 2; /* highest vector number in each microtile */ - const GLint n_comp = 3; /* 3 components: R, G, B */ - GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - GLfloat b, iv[MAX_COMP]; /* interpolation vector */ - GLint i, j, k; - Fx64 hi; /* high quadword */ - GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ - - GLint minSum; - GLint maxSum; - GLint minColL = 0, maxColL = -1; - GLint minColR = 0, maxColR = -1; - - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (k = 0; k < N_TEXELS / 2; k++) { - if (!ISTBLACK(input[k])) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - } - } - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (; k < N_TEXELS; k++) { - if (!ISTBLACK(input[k])) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - } - } - - /* left microtile */ - if (maxColL == -1) { - /* all transparent black */ - cc[0] = ~0u; - for (i = 0; i < n_comp; i++) { - vec[0][i] = 0; - vec[1][i] = 0; - } - } else { - cc[0] = 0; - for (i = 0; i < n_comp; i++) { - vec[0][i] = input[minColL][i]; - vec[1][i] = input[maxColL][i]; - } - if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - GLint texel = n_vect + 1; /* transparent black */ - if (!ISTBLACK(input[k])) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - } - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } - cc[0] = lolo; - } - } - - /* right microtile */ - if (maxColR == -1) { - /* all transparent black */ - cc[1] = ~0u; - for (i = 0; i < n_comp; i++) { - vec[2][i] = 0; - vec[3][i] = 0; - } - } else { - cc[1] = 0; - for (i = 0; i < n_comp; i++) { - vec[2][i] = input[minColR][i]; - vec[3][i] = input[maxColR][i]; - } - if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - GLint texel = n_vect + 1; /* transparent black */ - if (!ISTBLACK(input[k])) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - } - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } - cc[1] = lohi; - } - } - - FX64_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ - for (j = 2 * 2 - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - FX64_SHL(hi, 5); - FX64_OR32(hi, vec[j][i] >> 3); - } - } - ((Fx64 *)cc)[1] = hi; -} - - -static void -fxt1_quantize_MIXED0 (GLuint *cc, - GLubyte input[N_TEXELS][MAX_COMP]) -{ - const GLint n_vect = 3; /* highest vector number in each microtile */ - const GLint n_comp = 3; /* 3 components: R, G, B */ - GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - GLfloat b, iv[MAX_COMP]; /* interpolation vector */ - GLint i, j, k; - Fx64 hi; /* high quadword */ - GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ - - GLint minColL = 0, maxColL = 0; - GLint minColR = 0, maxColR = 0; -#if 0 - GLint minSum; - GLint maxSum; - - /* Our solution here is to find the darkest and brightest colors in - * the 4x4 tile and use those as the two representative colors. - * There are probably better algorithms to use (histogram-based). - */ - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (k = 0; k < N_TEXELS / 2; k++) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - } - minSum = 2000; /* big enough */ - maxSum = -1; /* small enough */ - for (; k < N_TEXELS; k++) { - GLint sum = 0; - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - } -#else - GLint minVal; - GLint maxVal; - GLint maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2); - GLint maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2); - - /* Scan the channel with max variance for lo & hi - * and use those as the two representative colors. - */ - minVal = 2000; /* big enough */ - maxVal = -1; /* small enough */ - for (k = 0; k < N_TEXELS / 2; k++) { - GLint t = input[k][maxVarL]; - if (minVal > t) { - minVal = t; - minColL = k; - } - if (maxVal < t) { - maxVal = t; - maxColL = k; - } - } - minVal = 2000; /* big enough */ - maxVal = -1; /* small enough */ - for (; k < N_TEXELS; k++) { - GLint t = input[k][maxVarR]; - if (minVal > t) { - minVal = t; - minColR = k; - } - if (maxVal < t) { - maxVal = t; - maxColR = k; - } - } -#endif - - /* left microtile */ - cc[0] = 0; - for (i = 0; i < n_comp; i++) { - vec[0][i] = input[minColL][i]; - vec[1][i] = input[maxColL][i]; - } - if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - GLint texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } - - /* funky encoding for LSB of green */ - if ((GLint)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) { - for (i = 0; i < n_comp; i++) { - vec[1][i] = input[minColL][i]; - vec[0][i] = input[maxColL][i]; - } - lolo = ~lolo; - } - - cc[0] = lolo; - } - - /* right microtile */ - cc[1] = 0; - for (i = 0; i < n_comp; i++) { - vec[2][i] = input[minColR][i]; - vec[3][i] = input[maxColR][i]; - } - if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - GLint texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } - - /* funky encoding for LSB of green */ - if ((GLint)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) { - for (i = 0; i < n_comp; i++) { - vec[3][i] = input[minColR][i]; - vec[2][i] = input[maxColR][i]; - } - lohi = ~lohi; - } - - cc[1] = lohi; - } - - FX64_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ - for (j = 2 * 2 - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - FX64_SHL(hi, 5); - FX64_OR32(hi, vec[j][i] >> 3); - } - } - ((Fx64 *)cc)[1] = hi; -} - - -static void -fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps) -{ - GLint trualpha; - GLubyte reord[N_TEXELS][MAX_COMP]; - - GLubyte input[N_TEXELS][MAX_COMP]; - GLint i, k, l; - - if (comps == 3) { - /* make the whole block opaque */ - memset(input, -1, sizeof(input)); - } - - /* 8 texels each line */ - for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } - for (; k < 8; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4 + 12][i] = *lines[l]++; - } - } - } - - /* block layout: - * 00, 01, 02, 03, 08, 09, 0a, 0b - * 10, 11, 12, 13, 18, 19, 1a, 1b - * 04, 05, 06, 07, 0c, 0d, 0e, 0f - * 14, 15, 16, 17, 1c, 1d, 1e, 1f - */ - - /* [dBorca] - * stupidity flows forth from this - */ - l = N_TEXELS; - trualpha = 0; - if (comps == 4) { - /* skip all transparent black texels */ - l = 0; - for (k = 0; k < N_TEXELS; k++) { - /* test all components against 0 */ - if (!ISTBLACK(input[k])) { - /* texel is not transparent black */ - COPY_4UBV(reord[l], input[k]); - if (reord[l][ACOMP] < (255 - ALPHA_TS)) { - /* non-opaque texel */ - trualpha = !0; - } - l++; - } - } - } - -#if 0 - if (trualpha) { - fxt1_quantize_ALPHA0(cc, input, reord, l); - } else if (l == 0) { - cc[0] = cc[1] = cc[2] = -1; - cc[3] = 0; - } else if (l < N_TEXELS) { - fxt1_quantize_HI(cc, input, reord, l); - } else { - fxt1_quantize_CHROMA(cc, input); - } - (void)fxt1_quantize_ALPHA1; - (void)fxt1_quantize_MIXED1; - (void)fxt1_quantize_MIXED0; -#else - if (trualpha) { - fxt1_quantize_ALPHA1(cc, input); - } else if (l == 0) { - cc[0] = cc[1] = cc[2] = ~0u; - cc[3] = 0; - } else if (l < N_TEXELS) { - fxt1_quantize_MIXED1(cc, input); - } else { - fxt1_quantize_MIXED0(cc, input); - } - (void)fxt1_quantize_ALPHA0; - (void)fxt1_quantize_HI; - (void)fxt1_quantize_CHROMA; -#endif -} - - -static void -fxt1_encode (GLuint width, GLuint height, GLint comps, - const void *source, GLint srcRowStride, - void *dest, GLint destRowStride) -{ - GLuint x, y; - const GLubyte *data; - GLuint *encoded = (GLuint *)dest; - void *newSource = NULL; - - assert(comps == 3 || comps == 4); - - /* Replicate image if width is not M8 or height is not M4 */ - if ((width & 7) | (height & 3)) { - GLint newWidth = (width + 7) & ~7; - GLint newHeight = (height + 3) & ~3; - newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan)); - if (!newSource) { - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression"); - goto cleanUp; - } - _mesa_upscale_teximage2d(width, height, newWidth, newHeight, - comps, (const GLchan *) source, - srcRowStride, (GLchan *) newSource); - source = newSource; - width = newWidth; - height = newHeight; - srcRowStride = comps * newWidth; - } - - /* convert from 16/32-bit channels to GLubyte if needed */ - if (CHAN_TYPE != GL_UNSIGNED_BYTE) { - const GLuint n = width * height * comps; - const GLchan *src = (const GLchan *) source; - GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte)); - GLuint i; - if (!dest) { - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression"); - goto cleanUp; - } - for (i = 0; i < n; i++) { - dest[i] = CHAN_TO_UBYTE(src[i]); - } - if (newSource != NULL) { - free(newSource); - } - newSource = dest; /* we'll free this buffer before returning */ - source = dest; /* the new, GLubyte incoming image */ - } - - data = (const GLubyte *) source; - destRowStride = (destRowStride - width * 2) / 4; - for (y = 0; y < height; y += 4) { - GLuint offs = 0 + (y + 0) * srcRowStride; - for (x = 0; x < width; x += 8) { - const GLubyte *lines[4]; - lines[0] = &data[offs]; - lines[1] = lines[0] + srcRowStride; - lines[2] = lines[1] + srcRowStride; - lines[3] = lines[2] + srcRowStride; - offs += 8 * comps; - fxt1_quantize(encoded, lines, comps); - /* 128 bits per 8x4 block */ - encoded += 4; - } - encoded += destRowStride; - } - - cleanUp: - if (newSource != NULL) { - free(newSource); - } -} - - -/***************************************************************************\ - * FXT1 decoder - * - * The decoder is based on GL_3DFX_texture_compression_FXT1 - * specification and serves as a concept for the encoder. -\***************************************************************************/ - - -/* lookup table for scaling 5 bit colors up to 8 bits */ -static const GLubyte _rgb_scale_5[] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - -/* lookup table for scaling 6 bit colors up to 8 bits */ -static const GLubyte _rgb_scale_6[] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 36, 40, 45, 49, 53, 57, 61, - 65, 69, 73, 77, 81, 85, 89, 93, - 97, 101, 105, 109, 113, 117, 121, 125, - 130, 134, 138, 142, 146, 150, 154, 158, - 162, 166, 170, 174, 178, 182, 186, 190, - 194, 198, 202, 206, 210, 215, 219, 223, - 227, 231, 235, 239, 243, 247, 251, 255 -}; - - -#define CC_SEL(cc, which) (((GLuint *)(cc))[(which) / 32] >> ((which) & 31)) -#define UP5(c) _rgb_scale_5[(c) & 31] -#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)] -#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n) - - -static void -fxt1_decode_1HI (const GLubyte *code, GLint t, GLchan *rgba) -{ - const GLuint *cc; - - t *= 3; - cc = (const GLuint *)(code + t / 8); - t = (cc[0] >> (t & 7)) & 7; - - if (t == 7) { - rgba[RCOMP] = rgba[GCOMP] = rgba[BCOMP] = rgba[ACOMP] = 0; - } else { - GLubyte r, g, b; - cc = (const GLuint *)(code + 12); - if (t == 0) { - b = UP5(CC_SEL(cc, 0)); - g = UP5(CC_SEL(cc, 5)); - r = UP5(CC_SEL(cc, 10)); - } else if (t == 6) { - b = UP5(CC_SEL(cc, 15)); - g = UP5(CC_SEL(cc, 20)); - r = UP5(CC_SEL(cc, 25)); - } else { - b = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15))); - g = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20))); - r = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25))); - } - rgba[RCOMP] = UBYTE_TO_CHAN(r); - rgba[GCOMP] = UBYTE_TO_CHAN(g); - rgba[BCOMP] = UBYTE_TO_CHAN(b); - rgba[ACOMP] = CHAN_MAX; - } -} - - -static void -fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLchan *rgba) -{ - const GLuint *cc; - GLuint kk; - - cc = (const GLuint *)code; - if (t & 16) { - cc++; - t &= 15; - } - t = (cc[0] >> (t * 2)) & 3; - - t *= 15; - cc = (const GLuint *)(code + 8 + t / 8); - kk = cc[0] >> (t & 7); - rgba[BCOMP] = UBYTE_TO_CHAN( UP5(kk) ); - rgba[GCOMP] = UBYTE_TO_CHAN( UP5(kk >> 5) ); - rgba[RCOMP] = UBYTE_TO_CHAN( UP5(kk >> 10) ); - rgba[ACOMP] = CHAN_MAX; -} - - -static void -fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLchan *rgba) -{ - const GLuint *cc; - GLuint col[2][3]; - GLint glsb, selb; - - cc = (const GLuint *)code; - if (t & 16) { - t &= 15; - t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ - col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6; - col[0][GCOMP] = CC_SEL(cc, 99); - col[0][RCOMP] = CC_SEL(cc, 104); - /* col 3 */ - col[1][BCOMP] = CC_SEL(cc, 109); - col[1][GCOMP] = CC_SEL(cc, 114); - col[1][RCOMP] = CC_SEL(cc, 119); - glsb = CC_SEL(cc, 126); - selb = CC_SEL(cc, 33); - } else { - t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ - col[0][BCOMP] = CC_SEL(cc, 64); - col[0][GCOMP] = CC_SEL(cc, 69); - col[0][RCOMP] = CC_SEL(cc, 74); - /* col 1 */ - col[1][BCOMP] = CC_SEL(cc, 79); - col[1][GCOMP] = CC_SEL(cc, 84); - col[1][RCOMP] = CC_SEL(cc, 89); - glsb = CC_SEL(cc, 125); - selb = CC_SEL(cc, 1); - } - - if (CC_SEL(cc, 124) & 1) { - /* alpha[0] == 1 */ - - if (t == 3) { - /* zero */ - rgba[RCOMP] = rgba[BCOMP] = rgba[GCOMP] = rgba[ACOMP] = 0; - } else { - GLubyte r, g, b; - if (t == 0) { - b = UP5(col[0][BCOMP]); - g = UP5(col[0][GCOMP]); - r = UP5(col[0][RCOMP]); - } else if (t == 2) { - b = UP5(col[1][BCOMP]); - g = UP6(col[1][GCOMP], glsb); - r = UP5(col[1][RCOMP]); - } else { - b = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2; - g = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2; - r = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2; - } - rgba[RCOMP] = UBYTE_TO_CHAN(r); - rgba[GCOMP] = UBYTE_TO_CHAN(g); - rgba[BCOMP] = UBYTE_TO_CHAN(b); - rgba[ACOMP] = CHAN_MAX; - } - } else { - /* alpha[0] == 0 */ - GLubyte r, g, b; - if (t == 0) { - b = UP5(col[0][BCOMP]); - g = UP6(col[0][GCOMP], glsb ^ selb); - r = UP5(col[0][RCOMP]); - } else if (t == 3) { - b = UP5(col[1][BCOMP]); - g = UP6(col[1][GCOMP], glsb); - r = UP5(col[1][RCOMP]); - } else { - b = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP])); - g = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb), - UP6(col[1][GCOMP], glsb)); - r = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP])); - } - rgba[RCOMP] = UBYTE_TO_CHAN(r); - rgba[GCOMP] = UBYTE_TO_CHAN(g); - rgba[BCOMP] = UBYTE_TO_CHAN(b); - rgba[ACOMP] = CHAN_MAX; - } -} - - -static void -fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLchan *rgba) -{ - const GLuint *cc; - GLubyte r, g, b, a; - - cc = (const GLuint *)code; - if (CC_SEL(cc, 124) & 1) { - /* lerp == 1 */ - GLuint col0[4]; - - if (t & 16) { - t &= 15; - t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ - col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6; - col0[GCOMP] = CC_SEL(cc, 99); - col0[RCOMP] = CC_SEL(cc, 104); - col0[ACOMP] = CC_SEL(cc, 119); - } else { - t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ - col0[BCOMP] = CC_SEL(cc, 64); - col0[GCOMP] = CC_SEL(cc, 69); - col0[RCOMP] = CC_SEL(cc, 74); - col0[ACOMP] = CC_SEL(cc, 109); - } - - if (t == 0) { - b = UP5(col0[BCOMP]); - g = UP5(col0[GCOMP]); - r = UP5(col0[RCOMP]); - a = UP5(col0[ACOMP]); - } else if (t == 3) { - b = UP5(CC_SEL(cc, 79)); - g = UP5(CC_SEL(cc, 84)); - r = UP5(CC_SEL(cc, 89)); - a = UP5(CC_SEL(cc, 114)); - } else { - b = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79))); - g = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84))); - r = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89))); - a = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114))); - } - } else { - /* lerp == 0 */ - - if (t & 16) { - cc++; - t &= 15; - } - t = (cc[0] >> (t * 2)) & 3; - - if (t == 3) { - /* zero */ - r = g = b = a = 0; - } else { - GLuint kk; - cc = (const GLuint *)code; - a = UP5(cc[3] >> (t * 5 + 13)); - t *= 15; - cc = (const GLuint *)(code + 8 + t / 8); - kk = cc[0] >> (t & 7); - b = UP5(kk); - g = UP5(kk >> 5); - r = UP5(kk >> 10); - } - } - rgba[RCOMP] = UBYTE_TO_CHAN(r); - rgba[GCOMP] = UBYTE_TO_CHAN(g); - rgba[BCOMP] = UBYTE_TO_CHAN(b); - rgba[ACOMP] = UBYTE_TO_CHAN(a); -} - - -void -fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */ - GLint i, GLint j, GLchan *rgba) -{ - static void (*decode_1[]) (const GLubyte *, GLint, GLchan *) = { - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1CHROMA, /* cc-chroma = "010" */ - fxt1_decode_1ALPHA, /* alpha = "011" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED /* mixed = "1??" */ - }; - - const GLubyte *code = (const GLubyte *)texture + - ((j / 4) * (stride / 8) + (i / 8)) * 16; - GLint mode = CC_SEL(code, 125); - GLint t = i & 7; - - if (t & 4) { - t += 12; - } - t += (j & 3) * 4; - - decode_1[mode](code, t, rgba); -} - - -#endif /* FEATURE_texture_fxt1 */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress_fxt1.c + * GL_3DFX_texture_compression_FXT1 support. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mipmap.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texstore.h" + + +#if FEATURE_texture_fxt1 + + +static void +fxt1_encode (GLuint width, GLuint height, GLint comps, + const void *source, GLint srcRowStride, + void *dest, GLint destRowStride); + +void +fxt1_decode_1 (const void *texture, GLint stride, + GLint i, GLint j, GLchan *rgba); + + +/** + * Store user's image in rgb_fxt1 format. + */ +GLboolean +_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1); + ASSERT(dstXoffset % 8 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGB || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGB/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 3 * srcWidth; + srcFormat = GL_RGB; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride, + dst, dstRowStride); + + if (tempImage) + free((void*) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_fxt1 format. + */ +GLboolean +_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1); + ASSERT(dstXoffset % 8 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 4 * srcWidth; + srcFormat = GL_RGBA; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride, + dst, dstRowStride); + + if (tempImage) + free((void*) tempImage); + + return GL_TRUE; +} + + +void +_mesa_fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + (void) k; + fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +void +_mesa_fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + (void) k; + fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = 1.0F; +} + + + +/***************************************************************************\ + * FXT1 encoder + * + * The encoder was built by reversing the decoder, + * and is vaguely based on Texus2 by 3dfx. Note that this code + * is merely a proof of concept, since it is highly UNoptimized; + * moreover, it is sub-optimal due to initial conditions passed + * to Lloyd's algorithm (the interpolation modes are even worse). +\***************************************************************************/ + + +#define MAX_COMP 4 /* ever needed maximum number of components in texel */ +#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ +#define N_TEXELS 32 /* number of texels in a block (always 32) */ +#define LL_N_REP 50 /* number of iterations in lloyd's vq */ +#define LL_RMS_D 10 /* fault tolerance (maximum delta) */ +#define LL_RMS_E 255 /* fault tolerance (maximum error) */ +#define ALPHA_TS 2 /* alpha threshold: (255 - ALPHA_TS) deemed opaque */ +#define ISTBLACK(v) (*((GLuint *)(v)) == 0) + + +/* + * Define a 64-bit unsigned integer type and macros + */ +#if 1 + +#define FX64_NATIVE 1 + +typedef uint64_t Fx64; + +#define FX64_MOV32(a, b) a = b +#define FX64_OR32(a, b) a |= b +#define FX64_SHL(a, c) a <<= c + +#else + +#define FX64_NATIVE 0 + +typedef struct { + GLuint lo, hi; +} Fx64; + +#define FX64_MOV32(a, b) a.lo = b +#define FX64_OR32(a, b) a.lo |= b + +#define FX64_SHL(a, c) \ + do { \ + if ((c) >= 32) { \ + a.hi = a.lo << ((c) - 32); \ + a.lo = 0; \ + } else { \ + a.hi = (a.hi << (c)) | (a.lo >> (32 - (c))); \ + a.lo <<= (c); \ + } \ + } while (0) + +#endif + + +#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */ +#define SAFECDOT 1 /* for paranoids */ + +#define MAKEIVEC(NV, NC, IV, B, V0, V1) \ + do { \ + /* compute interpolation vector */ \ + GLfloat d2 = 0.0F; \ + GLfloat rd2; \ + \ + for (i = 0; i < NC; i++) { \ + IV[i] = (V1[i] - V0[i]) * F(i); \ + d2 += IV[i] * IV[i]; \ + } \ + rd2 = (GLfloat)NV / d2; \ + B = 0; \ + for (i = 0; i < NC; i++) { \ + IV[i] *= F(i); \ + B -= IV[i] * V0[i]; \ + IV[i] *= rd2; \ + } \ + B = B * rd2 + 0.5f; \ + } while (0) + +#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\ + do { \ + GLfloat dot = 0.0F; \ + for (i = 0; i < NC; i++) { \ + dot += V[i] * IV[i]; \ + } \ + TEXEL = (GLint)(dot + B); \ + if (SAFECDOT) { \ + if (TEXEL < 0) { \ + TEXEL = 0; \ + } else if (TEXEL > NV) { \ + TEXEL = NV; \ + } \ + } \ + } while (0) + + +static GLint +fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv, + GLubyte input[MAX_COMP], GLint nc) +{ + GLint i, j, best = -1; + GLfloat err = 1e9; /* big enough */ + + for (j = 0; j < nv; j++) { + GLfloat e = 0.0F; + for (i = 0; i < nc; i++) { + e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]); + } + if (e < err) { + err = e; + best = j; + } + } + + return best; +} + + +static GLint +fxt1_worst (GLfloat vec[MAX_COMP], + GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) +{ + GLint i, k, worst = -1; + GLfloat err = -1.0F; /* small enough */ + + for (k = 0; k < n; k++) { + GLfloat e = 0.0F; + for (i = 0; i < nc; i++) { + e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]); + } + if (e > err) { + err = e; + worst = k; + } + } + + return worst; +} + + +static GLint +fxt1_variance (GLdouble variance[MAX_COMP], + GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) +{ + GLint i, k, best = 0; + GLint sx, sx2; + GLdouble var, maxvar = -1; /* small enough */ + GLdouble teenth = 1.0 / n; + + for (i = 0; i < nc; i++) { + sx = sx2 = 0; + for (k = 0; k < n; k++) { + GLint t = input[k][i]; + sx += t; + sx2 += t * t; + } + var = sx2 * teenth - sx * sx * teenth * teenth; + if (maxvar < var) { + maxvar = var; + best = i; + } + if (variance) { + variance[i] = var; + } + } + + return best; +} + + +static GLint +fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv, + GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) +{ +#if 0 + /* Choose colors from a grid. + */ + GLint i, j; + + for (j = 0; j < nv; j++) { + GLint m = j * (n - 1) / (nv - 1); + for (i = 0; i < nc; i++) { + vec[j][i] = input[m][i]; + } + } +#else + /* Our solution here is to find the darkest and brightest colors in + * the 8x4 tile and use those as the two representative colors. + * There are probably better algorithms to use (histogram-based). + */ + GLint i, j, k; + GLint minSum = 2000; /* big enough */ + GLint maxSum = -1; /* small enough */ + GLint minCol = 0; /* phoudoin: silent compiler! */ + GLint maxCol = 0; /* phoudoin: silent compiler! */ + + struct { + GLint flag; + GLint key; + GLint freq; + GLint idx; + } hist[N_TEXELS]; + GLint lenh = 0; + + memset(hist, 0, sizeof(hist)); + + for (k = 0; k < n; k++) { + GLint l; + GLint key = 0; + GLint sum = 0; + for (i = 0; i < nc; i++) { + key <<= 8; + key |= input[k][i]; + sum += input[k][i]; + } + for (l = 0; l < n; l++) { + if (!hist[l].flag) { + /* alloc new slot */ + hist[l].flag = !0; + hist[l].key = key; + hist[l].freq = 1; + hist[l].idx = k; + lenh = l + 1; + break; + } else if (hist[l].key == key) { + hist[l].freq++; + break; + } + } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } + } + + if (lenh <= nv) { + for (j = 0; j < lenh; j++) { + for (i = 0; i < nc; i++) { + vec[j][i] = (GLfloat)input[hist[j].idx][i]; + } + } + for (; j < nv; j++) { + for (i = 0; i < nc; i++) { + vec[j][i] = vec[0][i]; + } + } + return 0; + } + + for (j = 0; j < nv; j++) { + for (i = 0; i < nc; i++) { + vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (GLfloat)(nv - 1); + } + } +#endif + + return !0; +} + + +static GLint +fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv, + GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n) +{ + /* Use the generalized lloyd's algorithm for VQ: + * find 4 color vectors. + * + * for each sample color + * sort to nearest vector. + * + * replace each vector with the centroid of its matching colors. + * + * repeat until RMS doesn't improve. + * + * if a color vector has no samples, or becomes the same as another + * vector, replace it with the color which is farthest from a sample. + * + * vec[][MAX_COMP] initial vectors and resulting colors + * nv number of resulting colors required + * input[N_TEXELS][MAX_COMP] input texels + * nc number of components in input / vec + * n number of input samples + */ + + GLint sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */ + GLint cnt[MAX_VECT]; /* how many times a certain vector was chosen */ + GLfloat error, lasterror = 1e9; + + GLint i, j, k, rep; + + /* the quantizer */ + for (rep = 0; rep < LL_N_REP; rep++) { + /* reset sums & counters */ + for (j = 0; j < nv; j++) { + for (i = 0; i < nc; i++) { + sum[j][i] = 0; + } + cnt[j] = 0; + } + error = 0; + + /* scan whole block */ + for (k = 0; k < n; k++) { +#if 1 + GLint best = -1; + GLfloat err = 1e9; /* big enough */ + /* determine best vector */ + for (j = 0; j < nv; j++) { + GLfloat e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) + + (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) + + (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]); + if (nc == 4) { + e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]); + } + if (e < err) { + err = e; + best = j; + } + } +#else + GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err); +#endif + assert(best >= 0); + /* add in closest color */ + for (i = 0; i < nc; i++) { + sum[best][i] += input[k][i]; + } + /* mark this vector as used */ + cnt[best]++; + /* accumulate error */ + error += err; + } + + /* check RMS */ + if ((error < LL_RMS_E) || + ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) { + return !0; /* good match */ + } + lasterror = error; + + /* move each vector to the barycenter of its closest colors */ + for (j = 0; j < nv; j++) { + if (cnt[j]) { + GLfloat div = 1.0F / cnt[j]; + for (i = 0; i < nc; i++) { + vec[j][i] = div * sum[j][i]; + } + } else { + /* this vec has no samples or is identical with a previous vec */ + GLint worst = fxt1_worst(vec[j], input, nc, n); + for (i = 0; i < nc; i++) { + vec[j][i] = input[worst][i]; + } + } + } + } + + return 0; /* could not converge fast enough */ +} + + +static void +fxt1_quantize_CHROMA (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP]) +{ + const GLint n_vect = 4; /* 4 base vectors to find */ + const GLint n_comp = 3; /* 3 components: R, G, B */ + GLfloat vec[MAX_VECT][MAX_COMP]; + GLint i, j, k; + Fx64 hi; /* high quadword */ + GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ + + if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) { + fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS); + } + + FX64_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */ + for (j = n_vect - 1; j >= 0; j--) { + for (i = 0; i < n_comp; i++) { + /* add in colors */ + FX64_SHL(hi, 5); + FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); + } + } + ((Fx64 *)cc)[1] = hi; + + lohi = lolo = 0; + /* right microtile */ + for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) { + lohi <<= 2; + lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp); + } + /* left microtile */ + for (; k >= 0; k--) { + lolo <<= 2; + lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp); + } + cc[1] = lohi; + cc[0] = lolo; +} + + +static void +fxt1_quantize_ALPHA0 (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP], + GLubyte reord[N_TEXELS][MAX_COMP], GLint n) +{ + const GLint n_vect = 3; /* 3 base vectors to find */ + const GLint n_comp = 4; /* 4 components: R, G, B, A */ + GLfloat vec[MAX_VECT][MAX_COMP]; + GLint i, j, k; + Fx64 hi; /* high quadword */ + GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ + + /* the last vector indicates zero */ + for (i = 0; i < n_comp; i++) { + vec[n_vect][i] = 0; + } + + /* the first n texels in reord are guaranteed to be non-zero */ + if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) { + fxt1_lloyd(vec, n_vect, reord, n_comp, n); + } + + FX64_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */ + for (j = n_vect - 1; j >= 0; j--) { + /* add in alphas */ + FX64_SHL(hi, 5); + FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F)); + } + for (j = n_vect - 1; j >= 0; j--) { + for (i = 0; i < n_comp - 1; i++) { + /* add in colors */ + FX64_SHL(hi, 5); + FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); + } + } + ((Fx64 *)cc)[1] = hi; + + lohi = lolo = 0; + /* right microtile */ + for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) { + lohi <<= 2; + lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); + } + /* left microtile */ + for (; k >= 0; k--) { + lolo <<= 2; + lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); + } + cc[1] = lohi; + cc[0] = lolo; +} + + +static void +fxt1_quantize_ALPHA1 (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP]) +{ + const GLint n_vect = 3; /* highest vector number in each microtile */ + const GLint n_comp = 4; /* 4 components: R, G, B, A */ + GLfloat vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */ + GLfloat b, iv[MAX_COMP]; /* interpolation vector */ + GLint i, j, k; + Fx64 hi; /* high quadword */ + GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ + + GLint minSum; + GLint maxSum; + GLint minColL = 0, maxColL = 0; + GLint minColR = 0, maxColR = 0; + GLint sumL = 0, sumR = 0; + GLint nn_comp; + /* Our solution here is to find the darkest and brightest colors in + * the 4x4 tile and use those as the two representative colors. + * There are probably better algorithms to use (histogram-based). + */ + nn_comp = n_comp; + while ((minColL == maxColL) && nn_comp) { + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = 0; k < N_TEXELS / 2; k++) { + GLint sum = 0; + for (i = 0; i < nn_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + sumL += sum; + } + + nn_comp--; + } + + nn_comp = n_comp; + while ((minColR == maxColR) && nn_comp) { + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = N_TEXELS / 2; k < N_TEXELS; k++) { + GLint sum = 0; + for (i = 0; i < nn_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + sumR += sum; + } + + nn_comp--; + } + + /* choose the common vector (yuck!) */ + { + GLint j1, j2; + GLint v1 = 0, v2 = 0; + GLfloat err = 1e9; /* big enough */ + GLfloat tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ + for (i = 0; i < n_comp; i++) { + tv[0][i] = input[minColL][i]; + tv[1][i] = input[maxColL][i]; + tv[2][i] = input[minColR][i]; + tv[3][i] = input[maxColR][i]; + } + for (j1 = 0; j1 < 2; j1++) { + for (j2 = 2; j2 < 4; j2++) { + GLfloat e = 0.0F; + for (i = 0; i < n_comp; i++) { + e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]); + } + if (e < err) { + err = e; + v1 = j1; + v2 = j2; + } + } + } + for (i = 0; i < n_comp; i++) { + vec[0][i] = tv[1 - v1][i]; + vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR); + vec[2][i] = tv[5 - v2][i]; + } + } + + /* left microtile */ + cc[0] = 0; + if (minColL != maxColL) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + GLint texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } + + cc[0] = lolo; + } + + /* right microtile */ + cc[1] = 0; + if (minColR != maxColR) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]); + + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + GLint texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } + + cc[1] = lohi; + } + + FX64_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */ + for (j = n_vect - 1; j >= 0; j--) { + /* add in alphas */ + FX64_SHL(hi, 5); + FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F)); + } + for (j = n_vect - 1; j >= 0; j--) { + for (i = 0; i < n_comp - 1; i++) { + /* add in colors */ + FX64_SHL(hi, 5); + FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F)); + } + } + ((Fx64 *)cc)[1] = hi; +} + + +static void +fxt1_quantize_HI (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP], + GLubyte reord[N_TEXELS][MAX_COMP], GLint n) +{ + const GLint n_vect = 6; /* highest vector number */ + const GLint n_comp = 3; /* 3 components: R, G, B */ + GLfloat b = 0.0F; /* phoudoin: silent compiler! */ + GLfloat iv[MAX_COMP]; /* interpolation vector */ + GLint i, k; + GLuint hihi; /* high quadword: hi dword */ + + GLint minSum = 2000; /* big enough */ + GLint maxSum = -1; /* small enough */ + GLint minCol = 0; /* phoudoin: silent compiler! */ + GLint maxCol = 0; /* phoudoin: silent compiler! */ + + /* Our solution here is to find the darkest and brightest colors in + * the 8x4 tile and use those as the two representative colors. + * There are probably better algorithms to use (histogram-based). + */ + for (k = 0; k < n; k++) { + GLint sum = 0; + for (i = 0; i < n_comp; i++) { + sum += reord[k][i]; + } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } + } + + hihi = 0; /* cc-hi = "00" */ + for (i = 0; i < n_comp; i++) { + /* add in colors */ + hihi <<= 5; + hihi |= reord[maxCol][i] >> 3; + } + for (i = 0; i < n_comp; i++) { + /* add in colors */ + hihi <<= 5; + hihi |= reord[minCol][i] >> 3; + } + cc[3] = hihi; + cc[0] = cc[1] = cc[2] = 0; + + /* compute interpolation vector */ + if (minCol != maxCol) { + MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]); + } + + /* add in texels */ + for (k = N_TEXELS - 1; k >= 0; k--) { + GLint t = k * 3; + GLuint *kk = (GLuint *)((char *)cc + t / 8); + GLint texel = n_vect + 1; /* transparent black */ + + if (!ISTBLACK(input[k])) { + if (minCol != maxCol) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + kk[0] |= texel << (t & 7); + } + } else { + /* add in texel */ + kk[0] |= texel << (t & 7); + } + } +} + + +static void +fxt1_quantize_MIXED1 (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP]) +{ + const GLint n_vect = 2; /* highest vector number in each microtile */ + const GLint n_comp = 3; /* 3 components: R, G, B */ + GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ + GLfloat b, iv[MAX_COMP]; /* interpolation vector */ + GLint i, j, k; + Fx64 hi; /* high quadword */ + GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ + + GLint minSum; + GLint maxSum; + GLint minColL = 0, maxColL = -1; + GLint minColR = 0, maxColR = -1; + + /* Our solution here is to find the darkest and brightest colors in + * the 4x4 tile and use those as the two representative colors. + * There are probably better algorithms to use (histogram-based). + */ + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = 0; k < N_TEXELS / 2; k++) { + if (!ISTBLACK(input[k])) { + GLint sum = 0; + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + } + } + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (; k < N_TEXELS; k++) { + if (!ISTBLACK(input[k])) { + GLint sum = 0; + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + } + } + + /* left microtile */ + if (maxColL == -1) { + /* all transparent black */ + cc[0] = ~0u; + for (i = 0; i < n_comp; i++) { + vec[0][i] = 0; + vec[1][i] = 0; + } + } else { + cc[0] = 0; + for (i = 0; i < n_comp; i++) { + vec[0][i] = input[minColL][i]; + vec[1][i] = input[maxColL][i]; + } + if (minColL != maxColL) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + GLint texel = n_vect + 1; /* transparent black */ + if (!ISTBLACK(input[k])) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + } + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } + cc[0] = lolo; + } + } + + /* right microtile */ + if (maxColR == -1) { + /* all transparent black */ + cc[1] = ~0u; + for (i = 0; i < n_comp; i++) { + vec[2][i] = 0; + vec[3][i] = 0; + } + } else { + cc[1] = 0; + for (i = 0; i < n_comp; i++) { + vec[2][i] = input[minColR][i]; + vec[3][i] = input[maxColR][i]; + } + if (minColR != maxColR) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); + + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + GLint texel = n_vect + 1; /* transparent black */ + if (!ISTBLACK(input[k])) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + } + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } + cc[1] = lohi; + } + } + + FX64_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ + for (j = 2 * 2 - 1; j >= 0; j--) { + for (i = 0; i < n_comp; i++) { + /* add in colors */ + FX64_SHL(hi, 5); + FX64_OR32(hi, vec[j][i] >> 3); + } + } + ((Fx64 *)cc)[1] = hi; +} + + +static void +fxt1_quantize_MIXED0 (GLuint *cc, + GLubyte input[N_TEXELS][MAX_COMP]) +{ + const GLint n_vect = 3; /* highest vector number in each microtile */ + const GLint n_comp = 3; /* 3 components: R, G, B */ + GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ + GLfloat b, iv[MAX_COMP]; /* interpolation vector */ + GLint i, j, k; + Fx64 hi; /* high quadword */ + GLuint lohi, lolo; /* low quadword: hi dword, lo dword */ + + GLint minColL = 0, maxColL = 0; + GLint minColR = 0, maxColR = 0; +#if 0 + GLint minSum; + GLint maxSum; + + /* Our solution here is to find the darkest and brightest colors in + * the 4x4 tile and use those as the two representative colors. + * There are probably better algorithms to use (histogram-based). + */ + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (k = 0; k < N_TEXELS / 2; k++) { + GLint sum = 0; + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + } + minSum = 2000; /* big enough */ + maxSum = -1; /* small enough */ + for (; k < N_TEXELS; k++) { + GLint sum = 0; + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + } +#else + GLint minVal; + GLint maxVal; + GLint maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2); + GLint maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2); + + /* Scan the channel with max variance for lo & hi + * and use those as the two representative colors. + */ + minVal = 2000; /* big enough */ + maxVal = -1; /* small enough */ + for (k = 0; k < N_TEXELS / 2; k++) { + GLint t = input[k][maxVarL]; + if (minVal > t) { + minVal = t; + minColL = k; + } + if (maxVal < t) { + maxVal = t; + maxColL = k; + } + } + minVal = 2000; /* big enough */ + maxVal = -1; /* small enough */ + for (; k < N_TEXELS; k++) { + GLint t = input[k][maxVarR]; + if (minVal > t) { + minVal = t; + minColR = k; + } + if (maxVal < t) { + maxVal = t; + maxColR = k; + } + } +#endif + + /* left microtile */ + cc[0] = 0; + for (i = 0; i < n_comp; i++) { + vec[0][i] = input[minColL][i]; + vec[1][i] = input[maxColL][i]; + } + if (minColL != maxColL) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + GLint texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } + + /* funky encoding for LSB of green */ + if ((GLint)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) { + for (i = 0; i < n_comp; i++) { + vec[1][i] = input[minColL][i]; + vec[0][i] = input[maxColL][i]; + } + lolo = ~lolo; + } + + cc[0] = lolo; + } + + /* right microtile */ + cc[1] = 0; + for (i = 0; i < n_comp; i++) { + vec[2][i] = input[minColR][i]; + vec[3][i] = input[maxColR][i]; + } + if (minColR != maxColR) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); + + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + GLint texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } + + /* funky encoding for LSB of green */ + if ((GLint)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) { + for (i = 0; i < n_comp; i++) { + vec[3][i] = input[minColR][i]; + vec[2][i] = input[maxColR][i]; + } + lohi = ~lohi; + } + + cc[1] = lohi; + } + + FX64_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ + for (j = 2 * 2 - 1; j >= 0; j--) { + for (i = 0; i < n_comp; i++) { + /* add in colors */ + FX64_SHL(hi, 5); + FX64_OR32(hi, vec[j][i] >> 3); + } + } + ((Fx64 *)cc)[1] = hi; +} + + +static void +fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps) +{ + GLint trualpha; + GLubyte reord[N_TEXELS][MAX_COMP]; + + GLubyte input[N_TEXELS][MAX_COMP]; + GLint i, k, l; + + if (comps == 3) { + /* make the whole block opaque */ + memset(input, -1, sizeof(input)); + } + + /* 8 texels each line */ + for (l = 0; l < 4; l++) { + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } + for (; k < 8; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4 + 12][i] = *lines[l]++; + } + } + } + + /* block layout: + * 00, 01, 02, 03, 08, 09, 0a, 0b + * 10, 11, 12, 13, 18, 19, 1a, 1b + * 04, 05, 06, 07, 0c, 0d, 0e, 0f + * 14, 15, 16, 17, 1c, 1d, 1e, 1f + */ + + /* [dBorca] + * stupidity flows forth from this + */ + l = N_TEXELS; + trualpha = 0; + if (comps == 4) { + /* skip all transparent black texels */ + l = 0; + for (k = 0; k < N_TEXELS; k++) { + /* test all components against 0 */ + if (!ISTBLACK(input[k])) { + /* texel is not transparent black */ + COPY_4UBV(reord[l], input[k]); + if (reord[l][ACOMP] < (255 - ALPHA_TS)) { + /* non-opaque texel */ + trualpha = !0; + } + l++; + } + } + } + +#if 0 + if (trualpha) { + fxt1_quantize_ALPHA0(cc, input, reord, l); + } else if (l == 0) { + cc[0] = cc[1] = cc[2] = -1; + cc[3] = 0; + } else if (l < N_TEXELS) { + fxt1_quantize_HI(cc, input, reord, l); + } else { + fxt1_quantize_CHROMA(cc, input); + } + (void)fxt1_quantize_ALPHA1; + (void)fxt1_quantize_MIXED1; + (void)fxt1_quantize_MIXED0; +#else + if (trualpha) { + fxt1_quantize_ALPHA1(cc, input); + } else if (l == 0) { + cc[0] = cc[1] = cc[2] = ~0u; + cc[3] = 0; + } else if (l < N_TEXELS) { + fxt1_quantize_MIXED1(cc, input); + } else { + fxt1_quantize_MIXED0(cc, input); + } + (void)fxt1_quantize_ALPHA0; + (void)fxt1_quantize_HI; + (void)fxt1_quantize_CHROMA; +#endif +} + + +static void +fxt1_encode (GLuint width, GLuint height, GLint comps, + const void *source, GLint srcRowStride, + void *dest, GLint destRowStride) +{ + GLuint x, y; + const GLubyte *data; + GLuint *encoded = (GLuint *)dest; + void *newSource = NULL; + + assert(comps == 3 || comps == 4); + + /* Replicate image if width is not M8 or height is not M4 */ + if ((width & 7) | (height & 3)) { + GLint newWidth = (width + 7) & ~7; + GLint newHeight = (height + 3) & ~3; + newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan)); + if (!newSource) { + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression"); + goto cleanUp; + } + _mesa_upscale_teximage2d(width, height, newWidth, newHeight, + comps, (const GLchan *) source, + srcRowStride, (GLchan *) newSource); + source = newSource; + width = newWidth; + height = newHeight; + srcRowStride = comps * newWidth; + } + + /* convert from 16/32-bit channels to GLubyte if needed */ + if (CHAN_TYPE != GL_UNSIGNED_BYTE) { + const GLuint n = width * height * comps; + const GLchan *src = (const GLchan *) source; + GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte)); + GLuint i; + if (!dest) { + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression"); + goto cleanUp; + } + for (i = 0; i < n; i++) { + dest[i] = CHAN_TO_UBYTE(src[i]); + } + if (newSource != NULL) { + free(newSource); + } + newSource = dest; /* we'll free this buffer before returning */ + source = dest; /* the new, GLubyte incoming image */ + } + + data = (const GLubyte *) source; + destRowStride = (destRowStride - width * 2) / 4; + for (y = 0; y < height; y += 4) { + GLuint offs = 0 + (y + 0) * srcRowStride; + for (x = 0; x < width; x += 8) { + const GLubyte *lines[4]; + lines[0] = &data[offs]; + lines[1] = lines[0] + srcRowStride; + lines[2] = lines[1] + srcRowStride; + lines[3] = lines[2] + srcRowStride; + offs += 8 * comps; + fxt1_quantize(encoded, lines, comps); + /* 128 bits per 8x4 block */ + encoded += 4; + } + encoded += destRowStride; + } + + cleanUp: + if (newSource != NULL) { + free(newSource); + } +} + + +/***************************************************************************\ + * FXT1 decoder + * + * The decoder is based on GL_3DFX_texture_compression_FXT1 + * specification and serves as a concept for the encoder. +\***************************************************************************/ + + +/* lookup table for scaling 5 bit colors up to 8 bits */ +static const GLubyte _rgb_scale_5[] = { + 0, 8, 16, 25, 33, 41, 49, 58, + 66, 74, 82, 90, 99, 107, 115, 123, + 132, 140, 148, 156, 165, 173, 181, 189, + 197, 206, 214, 222, 230, 239, 247, 255 +}; + +/* lookup table for scaling 6 bit colors up to 8 bits */ +static const GLubyte _rgb_scale_6[] = { + 0, 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 45, 49, 53, 57, 61, + 65, 69, 73, 77, 81, 85, 89, 93, + 97, 101, 105, 109, 113, 117, 121, 125, + 130, 134, 138, 142, 146, 150, 154, 158, + 162, 166, 170, 174, 178, 182, 186, 190, + 194, 198, 202, 206, 210, 215, 219, 223, + 227, 231, 235, 239, 243, 247, 251, 255 +}; + + +#define CC_SEL(cc, which) (((GLuint *)(cc))[(which) / 32] >> ((which) & 31)) +#define UP5(c) _rgb_scale_5[(c) & 31] +#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)] +#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n) + + +static void +fxt1_decode_1HI (const GLubyte *code, GLint t, GLchan *rgba) +{ + const GLuint *cc; + + t *= 3; + cc = (const GLuint *)(code + t / 8); + t = (cc[0] >> (t & 7)) & 7; + + if (t == 7) { + rgba[RCOMP] = rgba[GCOMP] = rgba[BCOMP] = rgba[ACOMP] = 0; + } else { + GLubyte r, g, b; + cc = (const GLuint *)(code + 12); + if (t == 0) { + b = UP5(CC_SEL(cc, 0)); + g = UP5(CC_SEL(cc, 5)); + r = UP5(CC_SEL(cc, 10)); + } else if (t == 6) { + b = UP5(CC_SEL(cc, 15)); + g = UP5(CC_SEL(cc, 20)); + r = UP5(CC_SEL(cc, 25)); + } else { + b = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15))); + g = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20))); + r = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25))); + } + rgba[RCOMP] = UBYTE_TO_CHAN(r); + rgba[GCOMP] = UBYTE_TO_CHAN(g); + rgba[BCOMP] = UBYTE_TO_CHAN(b); + rgba[ACOMP] = CHAN_MAX; + } +} + + +static void +fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLchan *rgba) +{ + const GLuint *cc; + GLuint kk; + + cc = (const GLuint *)code; + if (t & 16) { + cc++; + t &= 15; + } + t = (cc[0] >> (t * 2)) & 3; + + t *= 15; + cc = (const GLuint *)(code + 8 + t / 8); + kk = cc[0] >> (t & 7); + rgba[BCOMP] = UBYTE_TO_CHAN( UP5(kk) ); + rgba[GCOMP] = UBYTE_TO_CHAN( UP5(kk >> 5) ); + rgba[RCOMP] = UBYTE_TO_CHAN( UP5(kk >> 10) ); + rgba[ACOMP] = CHAN_MAX; +} + + +static void +fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLchan *rgba) +{ + const GLuint *cc; + GLuint col[2][3]; + GLint glsb, selb; + + cc = (const GLuint *)code; + if (t & 16) { + t &= 15; + t = (cc[1] >> (t * 2)) & 3; + /* col 2 */ + col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6; + col[0][GCOMP] = CC_SEL(cc, 99); + col[0][RCOMP] = CC_SEL(cc, 104); + /* col 3 */ + col[1][BCOMP] = CC_SEL(cc, 109); + col[1][GCOMP] = CC_SEL(cc, 114); + col[1][RCOMP] = CC_SEL(cc, 119); + glsb = CC_SEL(cc, 126); + selb = CC_SEL(cc, 33); + } else { + t = (cc[0] >> (t * 2)) & 3; + /* col 0 */ + col[0][BCOMP] = CC_SEL(cc, 64); + col[0][GCOMP] = CC_SEL(cc, 69); + col[0][RCOMP] = CC_SEL(cc, 74); + /* col 1 */ + col[1][BCOMP] = CC_SEL(cc, 79); + col[1][GCOMP] = CC_SEL(cc, 84); + col[1][RCOMP] = CC_SEL(cc, 89); + glsb = CC_SEL(cc, 125); + selb = CC_SEL(cc, 1); + } + + if (CC_SEL(cc, 124) & 1) { + /* alpha[0] == 1 */ + + if (t == 3) { + /* zero */ + rgba[RCOMP] = rgba[BCOMP] = rgba[GCOMP] = rgba[ACOMP] = 0; + } else { + GLubyte r, g, b; + if (t == 0) { + b = UP5(col[0][BCOMP]); + g = UP5(col[0][GCOMP]); + r = UP5(col[0][RCOMP]); + } else if (t == 2) { + b = UP5(col[1][BCOMP]); + g = UP6(col[1][GCOMP], glsb); + r = UP5(col[1][RCOMP]); + } else { + b = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2; + g = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2; + r = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2; + } + rgba[RCOMP] = UBYTE_TO_CHAN(r); + rgba[GCOMP] = UBYTE_TO_CHAN(g); + rgba[BCOMP] = UBYTE_TO_CHAN(b); + rgba[ACOMP] = CHAN_MAX; + } + } else { + /* alpha[0] == 0 */ + GLubyte r, g, b; + if (t == 0) { + b = UP5(col[0][BCOMP]); + g = UP6(col[0][GCOMP], glsb ^ selb); + r = UP5(col[0][RCOMP]); + } else if (t == 3) { + b = UP5(col[1][BCOMP]); + g = UP6(col[1][GCOMP], glsb); + r = UP5(col[1][RCOMP]); + } else { + b = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP])); + g = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb), + UP6(col[1][GCOMP], glsb)); + r = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP])); + } + rgba[RCOMP] = UBYTE_TO_CHAN(r); + rgba[GCOMP] = UBYTE_TO_CHAN(g); + rgba[BCOMP] = UBYTE_TO_CHAN(b); + rgba[ACOMP] = CHAN_MAX; + } +} + + +static void +fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLchan *rgba) +{ + const GLuint *cc; + GLubyte r, g, b, a; + + cc = (const GLuint *)code; + if (CC_SEL(cc, 124) & 1) { + /* lerp == 1 */ + GLuint col0[4]; + + if (t & 16) { + t &= 15; + t = (cc[1] >> (t * 2)) & 3; + /* col 2 */ + col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6; + col0[GCOMP] = CC_SEL(cc, 99); + col0[RCOMP] = CC_SEL(cc, 104); + col0[ACOMP] = CC_SEL(cc, 119); + } else { + t = (cc[0] >> (t * 2)) & 3; + /* col 0 */ + col0[BCOMP] = CC_SEL(cc, 64); + col0[GCOMP] = CC_SEL(cc, 69); + col0[RCOMP] = CC_SEL(cc, 74); + col0[ACOMP] = CC_SEL(cc, 109); + } + + if (t == 0) { + b = UP5(col0[BCOMP]); + g = UP5(col0[GCOMP]); + r = UP5(col0[RCOMP]); + a = UP5(col0[ACOMP]); + } else if (t == 3) { + b = UP5(CC_SEL(cc, 79)); + g = UP5(CC_SEL(cc, 84)); + r = UP5(CC_SEL(cc, 89)); + a = UP5(CC_SEL(cc, 114)); + } else { + b = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79))); + g = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84))); + r = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89))); + a = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114))); + } + } else { + /* lerp == 0 */ + + if (t & 16) { + cc++; + t &= 15; + } + t = (cc[0] >> (t * 2)) & 3; + + if (t == 3) { + /* zero */ + r = g = b = a = 0; + } else { + GLuint kk; + cc = (const GLuint *)code; + a = UP5(cc[3] >> (t * 5 + 13)); + t *= 15; + cc = (const GLuint *)(code + 8 + t / 8); + kk = cc[0] >> (t & 7); + b = UP5(kk); + g = UP5(kk >> 5); + r = UP5(kk >> 10); + } + } + rgba[RCOMP] = UBYTE_TO_CHAN(r); + rgba[GCOMP] = UBYTE_TO_CHAN(g); + rgba[BCOMP] = UBYTE_TO_CHAN(b); + rgba[ACOMP] = UBYTE_TO_CHAN(a); +} + + +void +fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */ + GLint i, GLint j, GLchan *rgba) +{ + static void (*decode_1[]) (const GLubyte *, GLint, GLchan *) = { + fxt1_decode_1HI, /* cc-high = "00?" */ + fxt1_decode_1HI, /* cc-high = "00?" */ + fxt1_decode_1CHROMA, /* cc-chroma = "010" */ + fxt1_decode_1ALPHA, /* alpha = "011" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED /* mixed = "1??" */ + }; + + const GLubyte *code = (const GLubyte *)texture + + ((j / 4) * (stride / 8) + (i / 8)) * 16; + GLint mode = CC_SEL(code, 125); + GLint t = i & 7; + + if (t & 4) { + t += 12; + } + t += (j & 3) * 4; + + decode_1[mode](code, t, rgba); +} + + +#endif /* FEATURE_texture_fxt1 */ diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index 45a2f9c17..307ca9436 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -1,577 +1,572 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texcompress_s3tc.c - * GL_EXT_texture_compression_s3tc support. - */ - -#ifndef USE_EXTERNAL_DXTN_LIB -#define USE_EXTERNAL_DXTN_LIB 1 -#endif - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "convolve.h" -#include "dlopen.h" -#include "image.h" -#include "macros.h" -#include "texcompress.h" -#include "texcompress_s3tc.h" -#include "texstore.h" - - -#if FEATURE_texture_s3tc - - -#if defined(_WIN32) || defined(WIN32) -#define DXTN_LIBNAME "dxtn.dll" -#define RTLD_LAZY 0 -#define RTLD_GLOBAL 0 -#elif defined(__DJGPP__) -#define DXTN_LIBNAME "dxtn.dxe" -#else -#define DXTN_LIBNAME "libtxc_dxtn.so" -#endif - -#if FEATURE_EXT_texture_sRGB -/** - * Convert an 8-bit sRGB value from non-linear space to a - * linear RGB value in [0, 1]. - * Implemented with a 256-entry lookup table. - */ -static INLINE GLfloat -nonlinear_to_linear(GLubyte cs8) -{ - static GLfloat table[256]; - static GLboolean tableReady = GL_FALSE; - if (!tableReady) { - /* compute lookup table now */ - GLuint i; - for (i = 0; i < 256; i++) { - const GLfloat cs = UBYTE_TO_FLOAT(i); - if (cs <= 0.04045) { - table[i] = cs / 12.92f; - } - else { - table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); - } - } - tableReady = GL_TRUE; - } - return table[cs8]; -} -#endif /* FEATURE_EXT_texture_sRGB */ - -typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); - -dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; - -typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, - GLint height, const GLchan *srcPixData, - GLenum destformat, GLubyte *dest, - GLint dstRowStride); - -static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; - -static void *dxtlibhandle = NULL; - - -void -_mesa_init_texture_s3tc( GLcontext *ctx ) -{ - /* called during context initialization */ - ctx->Mesa_DXTn = GL_FALSE; -#if USE_EXTERNAL_DXTN_LIB - if (!dxtlibhandle) { - dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); - if (!dxtlibhandle) { - _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " - "compression/decompression unavailable"); - } - else { - /* the fetch functions are not per context! Might be problematic... */ - fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); - fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); - fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); - fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); - ext_tx_compress_dxtn = (dxtCompressTexFuncExt) - _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); - - if (!fetch_ext_rgb_dxt1 || - !fetch_ext_rgba_dxt1 || - !fetch_ext_rgba_dxt3 || - !fetch_ext_rgba_dxt5 || - !ext_tx_compress_dxtn) { - _mesa_warning(ctx, "couldn't reference all symbols in " - DXTN_LIBNAME ", software DXTn compression/decompression " - "unavailable"); - fetch_ext_rgb_dxt1 = NULL; - fetch_ext_rgba_dxt1 = NULL; - fetch_ext_rgba_dxt3 = NULL; - fetch_ext_rgba_dxt5 = NULL; - ext_tx_compress_dxtn = NULL; - _mesa_dlclose(dxtlibhandle); - dxtlibhandle = NULL; - } - } - } - if (dxtlibhandle) { - ctx->Mesa_DXTn = GL_TRUE; - } -#else - (void) ctx; -#endif -} - -/** - * Store user's image in rgb_dxt1 format. - */ -GLboolean -_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || - dstFormat == MESA_FORMAT_SRGB_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGB || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGB/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 3 * srcWidth; - srcFormat = GL_RGB; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt1 format. - */ -GLboolean -_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || - dstFormat == MESA_FORMAT_SRGBA_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 4 * srcWidth; - srcFormat = GL_RGBA; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); - } - - if (tempImage) - free((void*) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt3 format. - */ -GLboolean -_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || - dstFormat == MESA_FORMAT_SRGBA_DXT3); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 4 * srcWidth; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt5 format. - */ -GLboolean -_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLint srcRowStride; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || - dstFormat == MESA_FORMAT_SRGBA_DXT5); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - pixels = tempImage; - srcRowStride = 4 * srcWidth; - } - else { - pixels = (const GLchan *) srcAddr; - srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, - srcType) / sizeof(GLchan); - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -static void -fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgb_dxt1) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - fetch_ext_rgb_dxt1(texImage->RowStride, - (GLubyte *)(texImage)->Data, i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); -} - - -void -_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt1) { - fetch_ext_rgba_dxt1(texImage->RowStride, - (GLubyte *)(texImage)->Data, i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt3) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, - i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt5) { - fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, - i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -#if FEATURE_EXT_texture_sRGB -void -_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} -#endif /* FEATURE_EXT_texture_sRGB */ - - -#endif /* FEATURE_texture_s3tc */ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress_s3tc.c + * GL_EXT_texture_compression_s3tc support. + */ + +#ifndef USE_EXTERNAL_DXTN_LIB +#define USE_EXTERNAL_DXTN_LIB 1 +#endif + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "dlopen.h" +#include "image.h" +#include "macros.h" +#include "texcompress.h" +#include "texcompress_s3tc.h" +#include "texstore.h" + + +#if FEATURE_texture_s3tc + + +#if defined(_WIN32) || defined(WIN32) +#define DXTN_LIBNAME "dxtn.dll" +#define RTLD_LAZY 0 +#define RTLD_GLOBAL 0 +#elif defined(__DJGPP__) +#define DXTN_LIBNAME "dxtn.dxe" +#else +#define DXTN_LIBNAME "libtxc_dxtn.so" +#endif + +#if FEATURE_EXT_texture_sRGB +/** + * Convert an 8-bit sRGB value from non-linear space to a + * linear RGB value in [0, 1]. + * Implemented with a 256-entry lookup table. + */ +static INLINE GLfloat +nonlinear_to_linear(GLubyte cs8) +{ + static GLfloat table[256]; + static GLboolean tableReady = GL_FALSE; + if (!tableReady) { + /* compute lookup table now */ + GLuint i; + for (i = 0; i < 256; i++) { + const GLfloat cs = UBYTE_TO_FLOAT(i); + if (cs <= 0.04045) { + table[i] = cs / 12.92f; + } + else { + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); + } + } + tableReady = GL_TRUE; + } + return table[cs8]; +} +#endif /* FEATURE_EXT_texture_sRGB */ + +typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); + +dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; + +typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, + GLint height, const GLchan *srcPixData, + GLenum destformat, GLubyte *dest, + GLint dstRowStride); + +static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; + +static void *dxtlibhandle = NULL; + + +void +_mesa_init_texture_s3tc( struct gl_context *ctx ) +{ + /* called during context initialization */ + ctx->Mesa_DXTn = GL_FALSE; +#if USE_EXTERNAL_DXTN_LIB + if (!dxtlibhandle) { + dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); + if (!dxtlibhandle) { + _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " + "compression/decompression unavailable"); + } + else { + /* the fetch functions are not per context! Might be problematic... */ + fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); + fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); + fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); + fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); + ext_tx_compress_dxtn = (dxtCompressTexFuncExt) + _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); + + if (!fetch_ext_rgb_dxt1 || + !fetch_ext_rgba_dxt1 || + !fetch_ext_rgba_dxt3 || + !fetch_ext_rgba_dxt5 || + !ext_tx_compress_dxtn) { + _mesa_warning(ctx, "couldn't reference all symbols in " + DXTN_LIBNAME ", software DXTn compression/decompression " + "unavailable"); + fetch_ext_rgb_dxt1 = NULL; + fetch_ext_rgba_dxt1 = NULL; + fetch_ext_rgba_dxt3 = NULL; + fetch_ext_rgba_dxt5 = NULL; + ext_tx_compress_dxtn = NULL; + _mesa_dlclose(dxtlibhandle); + dxtlibhandle = NULL; + } + } + } + if (dxtlibhandle) { + ctx->Mesa_DXTn = GL_TRUE; + } +#else + (void) ctx; +#endif +} + +/** + * Store user's image in rgb_dxt1 format. + */ +GLboolean +_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || + dstFormat == MESA_FORMAT_SRGB_DXT1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGB || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGB/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 3 * srcWidth; + srcFormat = GL_RGB; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt1 format. + */ +GLboolean +_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || + dstFormat == MESA_FORMAT_SRGBA_DXT1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 4 * srcWidth; + srcFormat = GL_RGBA; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); + } + + if (tempImage) + free((void*) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt3 format. + */ +GLboolean +_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || + dstFormat == MESA_FORMAT_SRGBA_DXT3); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 4 * srcWidth; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt5 format. + */ +GLboolean +_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLint srcRowStride; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || + dstFormat == MESA_FORMAT_SRGBA_DXT5); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcRowStride = 4 * srcWidth; + } + else { + pixels = (const GLchan *) srcAddr; + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, + srcType) / sizeof(GLchan); + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +static void +fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgb_dxt1) { + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgb_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); +} + + +void +_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt1) { + fetch_ext_rgba_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt3) { + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt5) { + fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +#if FEATURE_EXT_texture_sRGB +void +_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} +#endif /* FEATURE_EXT_texture_sRGB */ + + +#endif /* FEATURE_texture_s3tc */ diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h index 2e7688d36..555cff9c2 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.h +++ b/mesalib/src/mesa/main/texcompress_s3tc.h @@ -1,106 +1,110 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TEXCOMPRESS_S3TC_H -#define TEXCOMPRESS_S3TC_H - -#include "main/mtypes.h" -#include "texstore.h" - - -#if FEATURE_texture_s3tc - -extern GLboolean -_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS); - -extern void -_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_srgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_init_texture_s3tc(GLcontext *ctx); - -#else /* FEATURE_texture_s3tc */ - -/* these are used only in texstore_funcs[] */ -#define _mesa_texstore_rgb_dxt1 NULL -#define _mesa_texstore_rgba_dxt1 NULL -#define _mesa_texstore_rgba_dxt3 NULL -#define _mesa_texstore_rgba_dxt5 NULL - -/* these are used only in texfetch_funcs[] */ -#define _mesa_fetch_texel_2d_f_rgb_dxt1 NULL -#define _mesa_fetch_texel_2d_f_rgba_dxt1 NULL -#define _mesa_fetch_texel_2d_f_rgba_dxt3 NULL -#define _mesa_fetch_texel_2d_f_rgba_dxt5 NULL -#define _mesa_fetch_texel_2d_f_srgb_dxt1 NULL -#define _mesa_fetch_texel_2d_f_srgba_dxt1 NULL -#define _mesa_fetch_texel_2d_f_srgba_dxt3 NULL -#define _mesa_fetch_texel_2d_f_srgba_dxt5 NULL - -static INLINE void -_mesa_init_texture_s3tc(GLcontext *ctx) -{ -} - -#endif /* FEATURE_texture_s3tc */ - -#endif /* TEXCOMPRESS_S3TC_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef TEXCOMPRESS_S3TC_H +#define TEXCOMPRESS_S3TC_H + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" +#include "texstore.h" + +struct gl_context; +struct gl_texture_image; + +#if FEATURE_texture_s3tc + +extern GLboolean +_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS); + +extern void +_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_srgb_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_init_texture_s3tc(struct gl_context *ctx); + +#else /* FEATURE_texture_s3tc */ + +/* these are used only in texstore_funcs[] */ +#define _mesa_texstore_rgb_dxt1 NULL +#define _mesa_texstore_rgba_dxt1 NULL +#define _mesa_texstore_rgba_dxt3 NULL +#define _mesa_texstore_rgba_dxt5 NULL + +/* these are used only in texfetch_funcs[] */ +#define _mesa_fetch_texel_2d_f_rgb_dxt1 NULL +#define _mesa_fetch_texel_2d_f_rgba_dxt1 NULL +#define _mesa_fetch_texel_2d_f_rgba_dxt3 NULL +#define _mesa_fetch_texel_2d_f_rgba_dxt5 NULL +#define _mesa_fetch_texel_2d_f_srgb_dxt1 NULL +#define _mesa_fetch_texel_2d_f_srgba_dxt1 NULL +#define _mesa_fetch_texel_2d_f_srgba_dxt3 NULL +#define _mesa_fetch_texel_2d_f_srgba_dxt5 NULL + +static INLINE void +_mesa_init_texture_s3tc(struct gl_context *ctx) +{ +} + +#endif /* FEATURE_texture_s3tc */ + +#endif /* TEXCOMPRESS_S3TC_H */ diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c index 3a55128c7..5669cc4bc 100644 --- a/mesalib/src/mesa/main/texenv.c +++ b/mesalib/src/mesa/main/texenv.c @@ -1,1036 +1,1036 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texenv.c - * - * glTexEnv-related functions - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/enums.h" -#include "main/macros.h" -#include "main/texenv.h" -#include "main/texstate.h" - - -#define TE_ERROR(errCode, msg, value) \ - _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); - - -/** Set texture env mode */ -static void -set_env_mode(GLcontext *ctx, - struct gl_texture_unit *texUnit, - GLenum mode) -{ - GLboolean legal; - - if (texUnit->EnvMode == mode) - return; - - switch (mode) { - case GL_MODULATE: - case GL_BLEND: - case GL_DECAL: - case GL_REPLACE: - legal = GL_TRUE; - break; - case GL_REPLACE_EXT: - mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */ - legal = GL_TRUE; - break; - case GL_ADD: - legal = ctx->Extensions.EXT_texture_env_add; - break; - case GL_COMBINE: - legal = (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine); - break; - case GL_COMBINE4_NV: - legal = ctx->Extensions.NV_texture_env_combine4; - break; - default: - legal = GL_FALSE; - } - - if (legal) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->EnvMode = mode; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - } -} - - -static void -set_env_color(GLcontext *ctx, - struct gl_texture_unit *texUnit, - const GLfloat *color) -{ - GLfloat tmp[4]; - tmp[0] = CLAMP(color[0], 0.0F, 1.0F); - tmp[1] = CLAMP(color[1], 0.0F, 1.0F); - tmp[2] = CLAMP(color[2], 0.0F, 1.0F); - tmp[3] = CLAMP(color[3], 0.0F, 1.0F); - if (TEST_EQ_4V(tmp, texUnit->EnvColor)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EnvColor, tmp); -} - - -/** Set an RGB or A combiner mode/function */ -static void -set_combiner_mode(GLcontext *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum mode) -{ - GLboolean legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - case GL_ADD: - case GL_ADD_SIGNED: - case GL_INTERPOLATE: - legal = GL_TRUE; - break; - case GL_SUBTRACT: - legal = ctx->Extensions.ARB_texture_env_combine; - break; - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - legal = (ctx->Extensions.EXT_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - legal = (ctx->Extensions.ARB_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - case GL_BUMP_ENVMAP_ATI: - legal = (ctx->Extensions.ATI_envmap_bumpmap && - pname == GL_COMBINE_RGB); - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - return; - } - - switch (pname) { - case GL_COMBINE_RGB: - if (texUnit->Combine.ModeRGB == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeRGB = mode; - break; - - case GL_COMBINE_ALPHA: - if (texUnit->Combine.ModeA == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeA = mode; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -/** Set an RGB or A combiner source term */ -static void -set_combiner_source(GLcontext *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - /* - * Translate pname to (term, alpha). - * - * The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - term = pname - GL_SOURCE0_RGB; - alpha = GL_FALSE; - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - term = pname - GL_SOURCE0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source term) - */ - switch (param) { - case GL_TEXTURE: - case GL_CONSTANT: - case GL_PRIMARY_COLOR: - case GL_PREVIOUS: - legal = GL_TRUE; - break; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - case GL_TEXTURE4: - case GL_TEXTURE5: - case GL_TEXTURE6: - case GL_TEXTURE7: - legal = (ctx->Extensions.ARB_texture_env_crossbar && - param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); - break; - case GL_ZERO: - legal = (ctx->Extensions.ATI_texture_env_combine3 || - ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.SourceA[term] = param; - else - texUnit->Combine.SourceRGB[term] = param; -} - - -/** Set an RGB or A combiner operand term */ -static void -set_combiner_operand(GLcontext *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - /* The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - term = pname - GL_OPERAND0_RGB; - alpha = GL_FALSE; - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - term = pname - GL_OPERAND0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source operand) - */ - switch (param) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT - * version. In the ARB and NV versions they can be used for any RGB - * operand. - */ - legal = !alpha - && ((term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE_MINUS_SRC_ALPHA: - /* GL_ONE_MINUS_SRC_ALPHA can only be used with - * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV - * versions it can be used for any operand. - */ - legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4; - break; - case GL_SRC_ALPHA: - legal = GL_TRUE; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.OperandA[term] = param; - else - texUnit->Combine.OperandRGB[term] = param; -} - - -static void -set_combiner_scale(GLcontext *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLfloat scale) -{ - GLuint shift; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - if (scale == 1.0F) { - shift = 0; - } - else if (scale == 2.0F) { - shift = 1; - } - else if (scale == 4.0F) { - shift = 2; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, - "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); - return; - } - - switch (pname) { - case GL_RGB_SCALE: - if (texUnit->Combine.ScaleShiftRGB == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftRGB = shift; - break; - case GL_ALPHA_SCALE: - if (texUnit->Combine.ScaleShiftA == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftA = shift; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -void GLAPIENTRY -_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) -{ - GLuint maxUnit; - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - switch (pname) { - case GL_TEXTURE_ENV_MODE: - set_env_mode(ctx, texUnit, (GLenum) (GLint) param[0]); - break; - case GL_TEXTURE_ENV_COLOR: - set_env_color(ctx, texUnit, param); - break; - case GL_COMBINE_RGB: - case GL_COMBINE_ALPHA: - set_combiner_mode(ctx, texUnit, pname, (GLenum) (GLint) param[0]); - break; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - set_combiner_source(ctx, texUnit, pname, (GLenum) (GLint) param[0]); - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - set_combiner_operand(ctx, texUnit, pname, (GLenum) (GLint) param[0]); - break; - case GL_RGB_SCALE: - case GL_ALPHA_SCALE: - set_combiner_scale(ctx, texUnit, pname, param[0]); - break; - case GL_BUMP_TARGET_ATI: - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - if (((GLenum) (GLint) param[0] < GL_TEXTURE0) || - ((GLenum) (GLint) param[0] > GL_TEXTURE31)) { - /* spec doesn't say this but it seems logical */ - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", (GLenum) (GLint) param[0]); - return; - } - if (!((1 << ((GLenum) (GLint) param[0] - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", (GLenum) (GLint) param[0]); - return; - } - else { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->BumpTarget = (GLenum) (GLint) param[0]; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); - return; - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - if (texUnit->LodBias == param[0]) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->LodBias = param[0]; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - const GLenum value = (GLenum) param[0]; - if (value == GL_TRUE || value == GL_FALSE) { - /* It's kind of weird to set point state via glTexEnv, - * but that's what the spec calls for. - */ - const GLboolean state = (GLboolean) value; - if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", value); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(pname), - *param, - _mesa_lookup_enum_by_nr((GLenum) (GLint) *param)); - - /* Tell device driver about the new texture environment */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, target, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - - -void GLAPIENTRY -_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - -void GLAPIENTRY -_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ - } - _mesa_TexEnvfv( target, pname, p ); -} - - - -/** - * Helper for glGetTexEnvi/f() - * \return value of queried pname or -1 if error. - */ -static GLint -get_texenvi(GLcontext *ctx, const struct gl_texture_unit *texUnit, - GLenum pname) -{ - switch (pname) { - case GL_TEXTURE_ENV_MODE: - return texUnit->EnvMode; - break; - case GL_COMBINE_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return texUnit->Combine.ModeRGB; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_COMBINE_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return texUnit->Combine.ModeA; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned rgb_idx = pname - GL_SOURCE0_RGB; - return texUnit->Combine.SourceRGB[rgb_idx]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned alpha_idx = pname - GL_SOURCE0_ALPHA; - return texUnit->Combine.SourceA[alpha_idx]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned op_rgb = pname - GL_OPERAND0_RGB; - return texUnit->Combine.OperandRGB[op_rgb]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned op_alpha = pname - GL_OPERAND0_ALPHA; - return texUnit->Combine.OperandA[op_alpha]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_RGB_SCALE: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return 1 << texUnit->Combine.ScaleShiftRGB; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_ALPHA_SCALE: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return 1 << texUnit->Combine.ScaleShiftA; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_BUMP_TARGET_ATI: - /* spec doesn't say so, but I think this should be queryable */ - if (ctx->Extensions.ATI_envmap_bumpmap) { - return texUnit->BumpTarget; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - - default: - ; - } - - return -1; /* error */ -} - - - -void GLAPIENTRY -_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) -{ - GLuint maxUnit; - const struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - COPY_4FV( params, texUnit->EnvColor ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = (GLfloat) val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) -{ - GLuint maxUnit; - const struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); - params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); - params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] ); - params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = (GLint) texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } -} - - -/** - * Why does ATI_envmap_bumpmap require new entrypoints? Should just - * reuse TexEnv ones... - */ -void GLAPIENTRY -_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - /* This isn't an "official" error case, but let's tell the user - * that something's wrong. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); - return; - } - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ - } - _mesa_TexBumpParameterfvATI( pname, p ); -} - - -void GLAPIENTRY -_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) -{ - struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - if (TEST_EQ_4V(param, texUnit->RotMatrix)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->RotMatrix, param); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); - return; - } - /* Drivers might want to know about this, instead of dedicated function - just shove it into TexEnv where it really belongs anyway */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps almost certainly would not understand it and - thus fail to submit matrices correctly) so hardcode this. */ - *param = 4; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); - param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); - param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); - param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = i + GL_TEXTURE0; - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps might not understand it) so hardcode this. */ - *param = 4.0F; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - param[0] = texUnit->RotMatrix[0]; - param[1] = texUnit->RotMatrix[1]; - param[2] = texUnit->RotMatrix[2]; - param[3] = texUnit->RotMatrix[3]; - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = (GLfloat) count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = (GLfloat) (i + GL_TEXTURE0); - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file texenv.c + * + * glTexEnv-related functions + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/texenv.h" +#include "main/texstate.h" + + +#define TE_ERROR(errCode, msg, value) \ + _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); + + +/** Set texture env mode */ +static void +set_env_mode(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum mode) +{ + GLboolean legal; + + if (texUnit->EnvMode == mode) + return; + + switch (mode) { + case GL_MODULATE: + case GL_BLEND: + case GL_DECAL: + case GL_REPLACE: + legal = GL_TRUE; + break; + case GL_REPLACE_EXT: + mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */ + legal = GL_TRUE; + break; + case GL_ADD: + legal = ctx->Extensions.EXT_texture_env_add; + break; + case GL_COMBINE: + legal = (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine); + break; + case GL_COMBINE4_NV: + legal = ctx->Extensions.NV_texture_env_combine4; + break; + default: + legal = GL_FALSE; + } + + if (legal) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->EnvMode = mode; + } + else { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); + } +} + + +static void +set_env_color(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + const GLfloat *color) +{ + GLfloat tmp[4]; + tmp[0] = CLAMP(color[0], 0.0F, 1.0F); + tmp[1] = CLAMP(color[1], 0.0F, 1.0F); + tmp[2] = CLAMP(color[2], 0.0F, 1.0F); + tmp[3] = CLAMP(color[3], 0.0F, 1.0F); + if (TEST_EQ_4V(tmp, texUnit->EnvColor)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EnvColor, tmp); +} + + +/** Set an RGB or A combiner mode/function */ +static void +set_combiner_mode(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum mode) +{ + GLboolean legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + switch (mode) { + case GL_REPLACE: + case GL_MODULATE: + case GL_ADD: + case GL_ADD_SIGNED: + case GL_INTERPOLATE: + legal = GL_TRUE; + break; + case GL_SUBTRACT: + legal = ctx->Extensions.ARB_texture_env_combine; + break; + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + legal = (ctx->Extensions.EXT_texture_env_dot3 && + pname == GL_COMBINE_RGB); + break; + case GL_DOT3_RGB: + case GL_DOT3_RGBA: + legal = (ctx->Extensions.ARB_texture_env_dot3 && + pname == GL_COMBINE_RGB); + break; + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + legal = ctx->Extensions.ATI_texture_env_combine3; + break; + case GL_BUMP_ENVMAP_ATI: + legal = (ctx->Extensions.ATI_envmap_bumpmap && + pname == GL_COMBINE_RGB); + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); + return; + } + + switch (pname) { + case GL_COMBINE_RGB: + if (texUnit->Combine.ModeRGB == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ModeRGB = mode; + break; + + case GL_COMBINE_ALPHA: + if (texUnit->Combine.ModeA == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ModeA = mode; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + } +} + + + +/** Set an RGB or A combiner source term */ +static void +set_combiner_source(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum param) +{ + GLuint term; + GLboolean alpha, legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + /* + * Translate pname to (term, alpha). + * + * The enums were given sequential values for a reason. + */ + switch (pname) { + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + case GL_SOURCE3_RGB_NV: + term = pname - GL_SOURCE0_RGB; + alpha = GL_FALSE; + break; + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + case GL_SOURCE3_ALPHA_NV: + term = pname - GL_SOURCE0_ALPHA; + alpha = GL_TRUE; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + assert(term < MAX_COMBINER_TERMS); + + /* + * Error-check param (the source term) + */ + switch (param) { + case GL_TEXTURE: + case GL_CONSTANT: + case GL_PRIMARY_COLOR: + case GL_PREVIOUS: + legal = GL_TRUE; + break; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + legal = (ctx->Extensions.ARB_texture_env_crossbar && + param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); + break; + case GL_ZERO: + legal = (ctx->Extensions.ATI_texture_env_combine3 || + ctx->Extensions.NV_texture_env_combine4); + break; + case GL_ONE: + legal = ctx->Extensions.ATI_texture_env_combine3; + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); + return; + } + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + if (alpha) + texUnit->Combine.SourceA[term] = param; + else + texUnit->Combine.SourceRGB[term] = param; +} + + +/** Set an RGB or A combiner operand term */ +static void +set_combiner_operand(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum param) +{ + GLuint term; + GLboolean alpha, legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + /* The enums were given sequential values for a reason. + */ + switch (pname) { + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND3_RGB_NV: + term = pname - GL_OPERAND0_RGB; + alpha = GL_FALSE; + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_OPERAND3_ALPHA_NV: + term = pname - GL_OPERAND0_ALPHA; + alpha = GL_TRUE; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + assert(term < MAX_COMBINER_TERMS); + + /* + * Error-check param (the source operand) + */ + switch (param) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT + * version. In the ARB and NV versions they can be used for any RGB + * operand. + */ + legal = !alpha + && ((term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4); + break; + case GL_ONE_MINUS_SRC_ALPHA: + /* GL_ONE_MINUS_SRC_ALPHA can only be used with + * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV + * versions it can be used for any operand. + */ + legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4; + break; + case GL_SRC_ALPHA: + legal = GL_TRUE; + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); + return; + } + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + if (alpha) + texUnit->Combine.OperandA[term] = param; + else + texUnit->Combine.OperandRGB[term] = param; +} + + +static void +set_combiner_scale(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLfloat scale) +{ + GLuint shift; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + if (scale == 1.0F) { + shift = 0; + } + else if (scale == 2.0F) { + shift = 1; + } + else if (scale == 4.0F) { + shift = 2; + } + else { + _mesa_error( ctx, GL_INVALID_VALUE, + "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); + return; + } + + switch (pname) { + case GL_RGB_SCALE: + if (texUnit->Combine.ScaleShiftRGB == shift) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ScaleShiftRGB = shift; + break; + case GL_ALPHA_SCALE: + if (texUnit->Combine.ScaleShiftA == shift) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ScaleShiftA = shift; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + } +} + + + +void GLAPIENTRY +_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) +{ + GLuint maxUnit; + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + switch (pname) { + case GL_TEXTURE_ENV_MODE: + set_env_mode(ctx, texUnit, (GLenum) (GLint) param[0]); + break; + case GL_TEXTURE_ENV_COLOR: + set_env_color(ctx, texUnit, param); + break; + case GL_COMBINE_RGB: + case GL_COMBINE_ALPHA: + set_combiner_mode(ctx, texUnit, pname, (GLenum) (GLint) param[0]); + break; + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + case GL_SOURCE3_RGB_NV: + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + case GL_SOURCE3_ALPHA_NV: + set_combiner_source(ctx, texUnit, pname, (GLenum) (GLint) param[0]); + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND3_RGB_NV: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_OPERAND3_ALPHA_NV: + set_combiner_operand(ctx, texUnit, pname, (GLenum) (GLint) param[0]); + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + set_combiner_scale(ctx, texUnit, pname, param[0]); + break; + case GL_BUMP_TARGET_ATI: + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); + return; + } + if (((GLenum) (GLint) param[0] < GL_TEXTURE0) || + ((GLenum) (GLint) param[0] > GL_TEXTURE31)) { + /* spec doesn't say this but it seems logical */ + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", (GLenum) (GLint) param[0]); + return; + } + if (!((1 << ((GLenum) (GLint) param[0] - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", (GLenum) (GLint) param[0]); + return; + } + else { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->BumpTarget = (GLenum) (GLint) param[0]; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + return; + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + if (texUnit->LodBias == param[0]) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->LodBias = param[0]; + } + else { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + const GLenum value = (GLenum) param[0]; + if (value == GL_TRUE || value == GL_FALSE) { + /* It's kind of weird to set point state via glTexEnv, + * but that's what the spec calls for. + */ + const GLboolean state = (GLboolean) value; + if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; + } + else { + _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", value); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); + return; + } + + if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(pname), + *param, + _mesa_lookup_enum_by_nr((GLenum) (GLint) *param)); + + /* Tell device driver about the new texture environment */ + if (ctx->Driver.TexEnv) { + (*ctx->Driver.TexEnv)( ctx, target, pname, param ); + } +} + + +void GLAPIENTRY +_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0; + _mesa_TexEnvfv( target, pname, p ); +} + + + +void GLAPIENTRY +_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + _mesa_TexEnvfv( target, pname, p ); +} + + +void GLAPIENTRY +_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ + } + _mesa_TexEnvfv( target, pname, p ); +} + + + +/** + * Helper for glGetTexEnvi/f() + * \return value of queried pname or -1 if error. + */ +static GLint +get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, + GLenum pname) +{ + switch (pname) { + case GL_TEXTURE_ENV_MODE: + return texUnit->EnvMode; + break; + case GL_COMBINE_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return texUnit->Combine.ModeRGB; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_COMBINE_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return texUnit->Combine.ModeA; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned rgb_idx = pname - GL_SOURCE0_RGB; + return texUnit->Combine.SourceRGB[rgb_idx]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE3_RGB_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.SourceRGB[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned alpha_idx = pname - GL_SOURCE0_ALPHA; + return texUnit->Combine.SourceA[alpha_idx]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE3_ALPHA_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.SourceA[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned op_rgb = pname - GL_OPERAND0_RGB; + return texUnit->Combine.OperandRGB[op_rgb]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND3_RGB_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.OperandRGB[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned op_alpha = pname - GL_OPERAND0_ALPHA; + return texUnit->Combine.OperandA[op_alpha]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND3_ALPHA_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.OperandA[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_RGB_SCALE: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return 1 << texUnit->Combine.ScaleShiftRGB; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_ALPHA_SCALE: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return 1 << texUnit->Combine.ScaleShiftA; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_BUMP_TARGET_ATI: + /* spec doesn't say so, but I think this should be queryable */ + if (ctx->Extensions.ATI_envmap_bumpmap) { + return texUnit->BumpTarget; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + + default: + ; + } + + return -1; /* error */ +} + + + +void GLAPIENTRY +_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) +{ + GLuint maxUnit; + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + if (pname == GL_TEXTURE_ENV_COLOR) { + COPY_4FV( params, texUnit->EnvColor ); + } + else { + GLint val = get_texenvi(ctx, texUnit, pname); + if (val >= 0) { + *params = (GLfloat) val; + } + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + *params = texUnit->LodBias; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } +} + + +void GLAPIENTRY +_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) +{ + GLuint maxUnit; + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + if (pname == GL_TEXTURE_ENV_COLOR) { + params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); + params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); + params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] ); + params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); + } + else { + GLint val = get_texenvi(ctx, texUnit, pname); + if (val >= 0) { + *params = val; + } + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + *params = (GLint) texUnit->LodBias; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } +} + + +/** + * Why does ATI_envmap_bumpmap require new entrypoints? Should just + * reuse TexEnv ones... + */ +void GLAPIENTRY +_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + /* This isn't an "official" error case, but let's tell the user + * that something's wrong. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); + return; + } + + if (pname == GL_BUMP_ROT_MATRIX_ATI) { + /* hope that conversion is correct here */ + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ + } + _mesa_TexBumpParameterfvATI( pname, p ); +} + + +void GLAPIENTRY +_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) +{ + struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_ATI) { + if (TEST_EQ_4V(param, texUnit->RotMatrix)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->RotMatrix, param); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); + return; + } + /* Drivers might want to know about this, instead of dedicated function + just shove it into TexEnv where it really belongs anyway */ + if (ctx->Driver.TexEnv) { + (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); + } +} + + +void GLAPIENTRY +_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) +{ + const struct gl_texture_unit *texUnit; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { + /* spec leaves open to support larger matrices. + Don't think anyone would ever want to use it + (and apps almost certainly would not understand it and + thus fail to submit matrices correctly) so hardcode this. */ + *param = 4; + } + else if (pname == GL_BUMP_ROT_MATRIX_ATI) { + /* hope that conversion is correct here */ + param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); + param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); + param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); + param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); + } + else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { + GLint count = 0; + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + count++; + } + } + *param = count; + } + else if (pname == GL_BUMP_TEX_UNITS_ATI) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + *param++ = i + GL_TEXTURE0; + } + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); + return; + } +} + + +void GLAPIENTRY +_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) +{ + const struct gl_texture_unit *texUnit; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { + /* spec leaves open to support larger matrices. + Don't think anyone would ever want to use it + (and apps might not understand it) so hardcode this. */ + *param = 4.0F; + } + else if (pname == GL_BUMP_ROT_MATRIX_ATI) { + param[0] = texUnit->RotMatrix[0]; + param[1] = texUnit->RotMatrix[1]; + param[2] = texUnit->RotMatrix[2]; + param[3] = texUnit->RotMatrix[3]; + } + else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { + GLint count = 0; + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + count++; + } + } + *param = (GLfloat) count; + } + else if (pname == GL_BUMP_TEX_UNITS_ATI) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + *param++ = (GLfloat) (i + GL_TEXTURE0); + } + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); + return; + } +} diff --git a/mesalib/src/mesa/main/texenvprogram.c b/mesalib/src/mesa/main/texenvprogram.c index 20f02cefe..aa318f7de 100644 --- a/mesalib/src/mesa/main/texenvprogram.c +++ b/mesalib/src/mesa/main/texenvprogram.c @@ -1,1616 +1,1617 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "glheader.h" -#include "imports.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_cache.h" -#include "program/prog_instruction.h" -#include "program/prog_print.h" -#include "program/prog_statevars.h" -#include "program/programopt.h" -#include "texenvprogram.h" - - -/* - * Note on texture units: - * - * The number of texture units supported by fixed-function fragment - * processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS. - * That's because there's a one-to-one correspondence between texture - * coordinates and samplers in fixed-function processing. - * - * Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS - * sets of texcoords, so is fixed-function fragment processing. - * - * We can safely use ctx->Const.MaxTextureUnits for loop bounds. - */ - - -struct texenvprog_cache_item -{ - GLuint hash; - void *key; - struct gl_fragment_program *data; - struct texenvprog_cache_item *next; -}; - -static GLboolean -texenv_doing_secondary_color(GLcontext *ctx) -{ - if (ctx->Light.Enabled && - (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) - return GL_TRUE; - - if (ctx->Fog.ColorSumEnabled) - return GL_TRUE; - - return GL_FALSE; -} - -/** - * Up to nine instructions per tex unit, plus fog, specular color. - */ -#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12) - -#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) - -struct mode_opt { -#ifdef __GNUC__ - __extension__ GLubyte Source:4; /**< SRC_x */ - __extension__ GLubyte Operand:3; /**< OPR_x */ -#else - GLubyte Source; /**< SRC_x */ - GLubyte Operand; /**< OPR_x */ -#endif -}; - -struct state_key { - GLuint nr_enabled_units:8; - GLuint enabled_units:8; - GLuint separate_specular:1; - GLuint fog_enabled:1; - GLuint fog_mode:2; /**< FOG_x */ - GLuint inputs_available:12; - GLuint num_draw_buffers:4; - - /* NOTE: This array of structs must be last! (see "keySize" below) */ - struct { - GLuint enabled:1; - GLuint source_index:3; /**< TEXTURE_x_INDEX */ - GLuint shadow:1; - GLuint ScaleShiftRGB:2; - GLuint ScaleShiftA:2; - - GLuint NumArgsRGB:3; /**< up to MAX_COMBINER_TERMS */ - GLuint ModeRGB:5; /**< MODE_x */ - - GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */ - GLuint ModeA:5; /**< MODE_x */ - - GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */ - - struct mode_opt OptRGB[MAX_COMBINER_TERMS]; - struct mode_opt OptA[MAX_COMBINER_TERMS]; - } unit[MAX_TEXTURE_UNITS]; -}; - -#define FOG_LINEAR 0 -#define FOG_EXP 1 -#define FOG_EXP2 2 -#define FOG_UNKNOWN 3 - -static GLuint translate_fog_mode( GLenum mode ) -{ - switch (mode) { - case GL_LINEAR: return FOG_LINEAR; - case GL_EXP: return FOG_EXP; - case GL_EXP2: return FOG_EXP2; - default: return FOG_UNKNOWN; - } -} - -#define OPR_SRC_COLOR 0 -#define OPR_ONE_MINUS_SRC_COLOR 1 -#define OPR_SRC_ALPHA 2 -#define OPR_ONE_MINUS_SRC_ALPHA 3 -#define OPR_ZERO 4 -#define OPR_ONE 5 -#define OPR_UNKNOWN 7 - -static GLuint translate_operand( GLenum operand ) -{ - switch (operand) { - case GL_SRC_COLOR: return OPR_SRC_COLOR; - case GL_ONE_MINUS_SRC_COLOR: return OPR_ONE_MINUS_SRC_COLOR; - case GL_SRC_ALPHA: return OPR_SRC_ALPHA; - case GL_ONE_MINUS_SRC_ALPHA: return OPR_ONE_MINUS_SRC_ALPHA; - case GL_ZERO: return OPR_ZERO; - case GL_ONE: return OPR_ONE; - default: - assert(0); - return OPR_UNKNOWN; - } -} - -#define SRC_TEXTURE 0 -#define SRC_TEXTURE0 1 -#define SRC_TEXTURE1 2 -#define SRC_TEXTURE2 3 -#define SRC_TEXTURE3 4 -#define SRC_TEXTURE4 5 -#define SRC_TEXTURE5 6 -#define SRC_TEXTURE6 7 -#define SRC_TEXTURE7 8 -#define SRC_CONSTANT 9 -#define SRC_PRIMARY_COLOR 10 -#define SRC_PREVIOUS 11 -#define SRC_ZERO 12 -#define SRC_UNKNOWN 15 - -static GLuint translate_source( GLenum src ) -{ - switch (src) { - case GL_TEXTURE: return SRC_TEXTURE; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - case GL_TEXTURE4: - case GL_TEXTURE5: - case GL_TEXTURE6: - case GL_TEXTURE7: return SRC_TEXTURE0 + (src - GL_TEXTURE0); - case GL_CONSTANT: return SRC_CONSTANT; - case GL_PRIMARY_COLOR: return SRC_PRIMARY_COLOR; - case GL_PREVIOUS: return SRC_PREVIOUS; - case GL_ZERO: - return SRC_ZERO; - default: - assert(0); - return SRC_UNKNOWN; - } -} - -#define MODE_REPLACE 0 /* r = a0 */ -#define MODE_MODULATE 1 /* r = a0 * a1 */ -#define MODE_ADD 2 /* r = a0 + a1 */ -#define MODE_ADD_SIGNED 3 /* r = a0 + a1 - 0.5 */ -#define MODE_INTERPOLATE 4 /* r = a0 * a2 + a1 * (1 - a2) */ -#define MODE_SUBTRACT 5 /* r = a0 - a1 */ -#define MODE_DOT3_RGB 6 /* r = a0 . a1 */ -#define MODE_DOT3_RGB_EXT 7 /* r = a0 . a1 */ -#define MODE_DOT3_RGBA 8 /* r = a0 . a1 */ -#define MODE_DOT3_RGBA_EXT 9 /* r = a0 . a1 */ -#define MODE_MODULATE_ADD_ATI 10 /* r = a0 * a2 + a1 */ -#define MODE_MODULATE_SIGNED_ADD_ATI 11 /* r = a0 * a2 + a1 - 0.5 */ -#define MODE_MODULATE_SUBTRACT_ATI 12 /* r = a0 * a2 - a1 */ -#define MODE_ADD_PRODUCTS 13 /* r = a0 * a1 + a2 * a3 */ -#define MODE_ADD_PRODUCTS_SIGNED 14 /* r = a0 * a1 + a2 * a3 - 0.5 */ -#define MODE_BUMP_ENVMAP_ATI 15 /* special */ -#define MODE_UNKNOWN 16 - -/** - * Translate GL combiner state into a MODE_x value - */ -static GLuint translate_mode( GLenum envMode, GLenum mode ) -{ - switch (mode) { - case GL_REPLACE: return MODE_REPLACE; - case GL_MODULATE: return MODE_MODULATE; - case GL_ADD: - if (envMode == GL_COMBINE4_NV) - return MODE_ADD_PRODUCTS; - else - return MODE_ADD; - case GL_ADD_SIGNED: - if (envMode == GL_COMBINE4_NV) - return MODE_ADD_PRODUCTS_SIGNED; - else - return MODE_ADD_SIGNED; - case GL_INTERPOLATE: return MODE_INTERPOLATE; - case GL_SUBTRACT: return MODE_SUBTRACT; - case GL_DOT3_RGB: return MODE_DOT3_RGB; - case GL_DOT3_RGB_EXT: return MODE_DOT3_RGB_EXT; - case GL_DOT3_RGBA: return MODE_DOT3_RGBA; - case GL_DOT3_RGBA_EXT: return MODE_DOT3_RGBA_EXT; - case GL_MODULATE_ADD_ATI: return MODE_MODULATE_ADD_ATI; - case GL_MODULATE_SIGNED_ADD_ATI: return MODE_MODULATE_SIGNED_ADD_ATI; - case GL_MODULATE_SUBTRACT_ATI: return MODE_MODULATE_SUBTRACT_ATI; - case GL_BUMP_ENVMAP_ATI: return MODE_BUMP_ENVMAP_ATI; - default: - assert(0); - return MODE_UNKNOWN; - } -} - - -/** - * Do we need to clamp the results of the given texture env/combine mode? - * If the inputs to the mode are in [0,1] we don't always have to clamp - * the results. - */ -static GLboolean -need_saturate( GLuint mode ) -{ - switch (mode) { - case MODE_REPLACE: - case MODE_MODULATE: - case MODE_INTERPOLATE: - return GL_FALSE; - case MODE_ADD: - case MODE_ADD_SIGNED: - case MODE_SUBTRACT: - case MODE_DOT3_RGB: - case MODE_DOT3_RGB_EXT: - case MODE_DOT3_RGBA: - case MODE_DOT3_RGBA_EXT: - case MODE_MODULATE_ADD_ATI: - case MODE_MODULATE_SIGNED_ADD_ATI: - case MODE_MODULATE_SUBTRACT_ATI: - case MODE_ADD_PRODUCTS: - case MODE_ADD_PRODUCTS_SIGNED: - case MODE_BUMP_ENVMAP_ATI: - return GL_TRUE; - default: - assert(0); - return GL_FALSE; - } -} - - - -/** - * Translate TEXTURE_x_BIT to TEXTURE_x_INDEX. - */ -static GLuint translate_tex_src_bit( GLbitfield bit ) -{ - ASSERT(bit); - return _mesa_ffs(bit) - 1; -} - - -#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) -#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) - -/** - * Identify all possible varying inputs. The fragment program will - * never reference non-varying inputs, but will track them via state - * constants instead. - * - * This function figures out all the inputs that the fragment program - * has access to. The bitmask is later reduced to just those which - * are actually referenced. - */ -static GLbitfield get_fp_input_mask( GLcontext *ctx ) -{ - /* _NEW_PROGRAM */ - const GLboolean vertexShader = (ctx->Shader.CurrentProgram && - ctx->Shader.CurrentProgram->LinkStatus && - ctx->Shader.CurrentProgram->VertexProgram); - const GLboolean vertexProgram = ctx->VertexProgram._Enabled; - GLbitfield fp_inputs = 0x0; - - if (ctx->VertexProgram._Overriden) { - /* Somebody's messing with the vertex program and we don't have - * a clue what's happening. Assume that it could be producing - * all possible outputs. - */ - fp_inputs = ~0; - } - else if (ctx->RenderMode == GL_FEEDBACK) { - /* _NEW_RENDERMODE */ - fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); - } - else if (!(vertexProgram || vertexShader) || - !ctx->VertexProgram._Current) { - /* Fixed function vertex logic */ - /* _NEW_ARRAY */ - GLbitfield varying_inputs = ctx->varying_vp_inputs; - - /* These get generated in the setup routine regardless of the - * vertex program: - */ - /* _NEW_POINT */ - if (ctx->Point.PointSprite) - varying_inputs |= FRAG_BITS_TEX_ANY; - - /* First look at what values may be computed by the generated - * vertex program: - */ - /* _NEW_LIGHT */ - if (ctx->Light.Enabled) { - fp_inputs |= FRAG_BIT_COL0; - - if (texenv_doing_secondary_color(ctx)) - fp_inputs |= FRAG_BIT_COL1; - } - - /* _NEW_TEXTURE */ - fp_inputs |= (ctx->Texture._TexGenEnabled | - ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0; - - /* Then look at what might be varying as a result of enabled - * arrays, etc: - */ - if (varying_inputs & VERT_BIT_COLOR0) - fp_inputs |= FRAG_BIT_COL0; - if (varying_inputs & VERT_BIT_COLOR1) - fp_inputs |= FRAG_BIT_COL1; - - fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) - << FRAG_ATTRIB_TEX0); - - } - else { - /* calculate from vp->outputs */ - struct gl_vertex_program *vprog; - GLbitfield64 vp_outputs; - - /* Choose GLSL vertex shader over ARB vertex program. Need this - * since vertex shader state validation comes after fragment state - * validation (see additional comments in state.c). - */ - if (vertexShader) - vprog = ctx->Shader.CurrentProgram->VertexProgram; - else - vprog = ctx->VertexProgram.Current; - - vp_outputs = vprog->Base.OutputsWritten; - - /* These get generated in the setup routine regardless of the - * vertex program: - */ - /* _NEW_POINT */ - if (ctx->Point.PointSprite) - vp_outputs |= FRAG_BITS_TEX_ANY; - - if (vp_outputs & (1 << VERT_RESULT_COL0)) - fp_inputs |= FRAG_BIT_COL0; - if (vp_outputs & (1 << VERT_RESULT_COL1)) - fp_inputs |= FRAG_BIT_COL1; - - fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) - << FRAG_ATTRIB_TEX0); - } - - return fp_inputs; -} - - -/** - * Examine current texture environment state and generate a unique - * key to identify it. - */ -static GLuint make_state_key( GLcontext *ctx, struct state_key *key ) -{ - GLuint i, j; - GLbitfield inputs_referenced = FRAG_BIT_COL0; - const GLbitfield inputs_available = get_fp_input_mask( ctx ); - GLuint keySize; - - memset(key, 0, sizeof(*key)); - - /* _NEW_TEXTURE */ - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; - const struct gl_texture_object *texObj = texUnit->_Current; - const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine; - GLenum format; - - if (!texUnit->_ReallyEnabled || !texUnit->Enabled) - continue; - - format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; - - key->unit[i].enabled = 1; - key->enabled_units |= (1<nr_enabled_units = i + 1; - inputs_referenced |= FRAG_BIT_TEX(i); - - key->unit[i].source_index = - translate_tex_src_bit(texUnit->_ReallyEnabled); - - key->unit[i].shadow = ((texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE) && - ((format == GL_DEPTH_COMPONENT) || - (format == GL_DEPTH_STENCIL_EXT))); - - key->unit[i].NumArgsRGB = comb->_NumArgsRGB; - key->unit[i].NumArgsA = comb->_NumArgsA; - - key->unit[i].ModeRGB = - translate_mode(texUnit->EnvMode, comb->ModeRGB); - key->unit[i].ModeA = - translate_mode(texUnit->EnvMode, comb->ModeA); - - key->unit[i].ScaleShiftRGB = comb->ScaleShiftRGB; - key->unit[i].ScaleShiftA = comb->ScaleShiftA; - - for (j = 0; j < MAX_COMBINER_TERMS; j++) { - key->unit[i].OptRGB[j].Operand = translate_operand(comb->OperandRGB[j]); - key->unit[i].OptA[j].Operand = translate_operand(comb->OperandA[j]); - key->unit[i].OptRGB[j].Source = translate_source(comb->SourceRGB[j]); - key->unit[i].OptA[j].Source = translate_source(comb->SourceA[j]); - } - - if (key->unit[i].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - /* requires some special translation */ - key->unit[i].NumArgsRGB = 2; - key->unit[i].ScaleShiftRGB = 0; - key->unit[i].OptRGB[0].Operand = OPR_SRC_COLOR; - key->unit[i].OptRGB[0].Source = SRC_TEXTURE; - key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR; - key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0; - } - - /* this is a back-door for enabling cylindrical texture wrap mode */ - if (texObj->Priority == 0.125) - key->unit[i].texture_cyl_wrap = 1; - } - - /* _NEW_LIGHT | _NEW_FOG */ - if (texenv_doing_secondary_color(ctx)) { - key->separate_specular = 1; - inputs_referenced |= FRAG_BIT_COL1; - } - - /* _NEW_FOG */ - if (ctx->Fog.Enabled) { - key->fog_enabled = 1; - key->fog_mode = translate_fog_mode(ctx->Fog.Mode); - inputs_referenced |= FRAG_BIT_FOGC; /* maybe */ - } - - /* _NEW_BUFFERS */ - key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers; - - key->inputs_available = (inputs_available & inputs_referenced); - - /* compute size of state key, ignoring unused texture units */ - keySize = sizeof(*key) - sizeof(key->unit) - + key->nr_enabled_units * sizeof(key->unit[0]); - - return keySize; -} - - -/** - * Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. - * - * NOTE: These are passed by value extensively in this file rather - * than as usual by pointer reference. If this disturbs you, try - * remembering they are just 32bits in size. - * - * GCC is smart enough to deal with these dword-sized structures in - * much the same way as if I had defined them as dwords and was using - * macros to access and set the fields. This is much nicer and easier - * to evolve. - */ -struct ureg { - GLuint file:4; - GLuint idx:8; - GLuint negatebase:1; - GLuint swz:12; - GLuint pad:7; -}; - -static const struct ureg undef = { - PROGRAM_UNDEFINED, - ~0, - 0, - 0, - 0 -}; - - -/** State used to build the fragment program: - */ -struct texenv_fragment_program { - struct gl_fragment_program *program; - struct state_key *state; - - GLbitfield alu_temps; /**< Track texture indirections, see spec. */ - GLbitfield temps_output; /**< Track texture indirections, see spec. */ - GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ - GLboolean error; - - struct ureg src_texture[MAX_TEXTURE_COORD_UNITS]; - /* Reg containing each texture unit's sampled texture color, - * else undef. - */ - - struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS]; - /* Reg containing texcoord for a texture unit, - * needed for bump mapping, else undef. - */ - - struct ureg src_previous; /**< Reg containing color from previous - * stage. May need to be decl'd. - */ - - GLuint last_tex_stage; /**< Number of last enabled texture unit */ - - struct ureg half; - struct ureg one; - struct ureg zero; -}; - - - -static struct ureg make_ureg(GLuint file, GLuint idx) -{ - struct ureg reg; - reg.file = file; - reg.idx = idx; - reg.negatebase = 0; - reg.swz = SWIZZLE_NOOP; - reg.pad = 0; - return reg; -} - -static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) -{ - reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), - GET_SWZ(reg.swz, y), - GET_SWZ(reg.swz, z), - GET_SWZ(reg.swz, w)); - - return reg; -} - -static struct ureg swizzle1( struct ureg reg, int x ) -{ - return swizzle(reg, x, x, x, x); -} - -static struct ureg negate( struct ureg reg ) -{ - reg.negatebase ^= 1; - return reg; -} - -static GLboolean is_undef( struct ureg reg ) -{ - return reg.file == PROGRAM_UNDEFINED; -} - - -static struct ureg get_temp( struct texenv_fragment_program *p ) -{ - GLint bit; - - /* First try and reuse temps which have been used already: - */ - bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); -} - -static struct ureg get_tex_temp( struct texenv_fragment_program *p ) -{ - int bit; - - /* First try to find available temp not previously used (to avoid - * starting a new texture indirection). According to the spec, the - * ~p->temps_output isn't necessary, but will keep it there for - * now: - */ - bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); -} - - -/** Mark a temp reg as being no longer allocatable. */ -static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) -{ - if (r.file == PROGRAM_TEMPORARY) - p->temps_output |= (1 << r.idx); -} - - -static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p ) -{ - GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; - - /* KW: To support tex_env_crossbar, don't release the registers in - * temps_output. - */ - if (max_temp >= sizeof(int) * 8) - p->temp_in_use = p->temps_output; - else - p->temp_in_use = ~((1<temps_output; -} - - -static struct ureg register_param5( struct texenv_fragment_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4) -{ - gl_state_index tokens[STATE_LENGTH]; - GLuint idx; - tokens[0] = s0; - tokens[1] = s1; - tokens[2] = s2; - tokens[3] = s3; - tokens[4] = s4; - idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); - return make_ureg(PROGRAM_STATE_VAR, idx); -} - - -#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) -#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) -#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) - -static GLuint frag_to_vert_attrib( GLuint attrib ) -{ - switch (attrib) { - case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; - case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; - default: - assert(attrib >= FRAG_ATTRIB_TEX0); - assert(attrib <= FRAG_ATTRIB_TEX7); - return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; - } -} - - -static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) -{ - if (p->state->inputs_available & (1<program->Base.InputsRead |= (1 << input); - return make_ureg(PROGRAM_INPUT, input); - } - else { - GLuint idx = frag_to_vert_attrib( input ); - return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx ); - } -} - - -static void emit_arg( struct prog_src_register *reg, - struct ureg ureg ) -{ - reg->File = ureg.file; - reg->Index = ureg.idx; - reg->Swizzle = ureg.swz; - reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE; - reg->Abs = GL_FALSE; -} - -static void emit_dst( struct prog_dst_register *dst, - struct ureg ureg, GLuint mask ) -{ - dst->File = ureg.file; - dst->Index = ureg.idx; - dst->WriteMask = mask; - dst->CondMask = COND_TR; /* always pass cond test */ - dst->CondSwizzle = SWIZZLE_NOOP; -} - -static struct prog_instruction * -emit_op(struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - const GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Base.Instructions[nr]; - - assert(nr < MAX_INSTRUCTIONS); - - _mesa_init_instructions(inst, 1); - inst->Opcode = op; - - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); - - inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF; - - emit_dst( &inst->DstReg, dest, mask ); - -#if 0 - /* Accounting for indirection tracking: - */ - if (dest.file == PROGRAM_TEMPORARY) - p->temps_output |= 1 << dest.idx; -#endif - - return inst; -} - - -static struct ureg emit_arith( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - emit_op(p, op, dest, mask, saturate, src0, src1, src2); - - /* Accounting for indirection tracking: - */ - if (src0.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src0.idx; - - if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src1.idx; - - if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src2.idx; - - if (dest.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << dest.idx; - - p->program->Base.NumAluInstructions++; - return dest; -} - -static struct ureg emit_texld( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint destmask, - GLuint tex_unit, - GLuint tex_idx, - GLuint tex_shadow, - struct ureg coord ) -{ - struct prog_instruction *inst = emit_op( p, op, - dest, destmask, - GL_FALSE, /* don't saturate? */ - coord, /* arg 0? */ - undef, - undef); - - inst->TexSrcTarget = tex_idx; - inst->TexSrcUnit = tex_unit; - inst->TexShadow = tex_shadow; - - p->program->Base.NumTexInstructions++; - - /* Accounting for indirection tracking: - */ - reserve_temp(p, dest); - -#if 0 - /* Is this a texture indirection? - */ - if ((coord.file == PROGRAM_TEMPORARY && - (p->temps_output & (1<alu_temps & (1<program->Base.NumTexIndirections++; - p->temps_output = 1<alu_temps = 0; - assert(0); /* KW: texture env crossbar */ - } -#endif - - return dest; -} - - -static struct ureg register_const4f( struct texenv_fragment_program *p, - GLfloat s0, - GLfloat s1, - GLfloat s2, - GLfloat s3) -{ - GLfloat values[4]; - GLuint idx, swizzle; - struct ureg r; - values[0] = s0; - values[1] = s1; - values[2] = s2; - values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, - &swizzle ); - r = make_ureg(PROGRAM_CONSTANT, idx); - r.swz = swizzle; - return r; -} - -#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) -#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) -#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) - - -static struct ureg get_one( struct texenv_fragment_program *p ) -{ - if (is_undef(p->one)) - p->one = register_scalar_const(p, 1.0); - return p->one; -} - -static struct ureg get_half( struct texenv_fragment_program *p ) -{ - if (is_undef(p->half)) - p->half = register_scalar_const(p, 0.5); - return p->half; -} - -static struct ureg get_zero( struct texenv_fragment_program *p ) -{ - if (is_undef(p->zero)) - p->zero = register_scalar_const(p, 0.0); - return p->zero; -} - - -static void program_error( struct texenv_fragment_program *p, const char *msg ) -{ - _mesa_problem(NULL, "%s", msg); - p->error = 1; -} - -static struct ureg get_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) -{ - switch (src) { - case SRC_TEXTURE: - assert(!is_undef(p->src_texture[unit])); - return p->src_texture[unit]; - - case SRC_TEXTURE0: - case SRC_TEXTURE1: - case SRC_TEXTURE2: - case SRC_TEXTURE3: - case SRC_TEXTURE4: - case SRC_TEXTURE5: - case SRC_TEXTURE6: - case SRC_TEXTURE7: - assert(!is_undef(p->src_texture[src - SRC_TEXTURE0])); - return p->src_texture[src - SRC_TEXTURE0]; - - case SRC_CONSTANT: - return register_param2(p, STATE_TEXENV_COLOR, unit); - - case SRC_PRIMARY_COLOR: - return register_input(p, FRAG_ATTRIB_COL0); - - case SRC_ZERO: - return get_zero(p); - - case SRC_PREVIOUS: - if (is_undef(p->src_previous)) - return register_input(p, FRAG_ATTRIB_COL0); - else - return p->src_previous; - - default: - assert(0); - return undef; - } -} - -static struct ureg emit_combine_source( struct texenv_fragment_program *p, - GLuint mask, - GLuint unit, - GLuint source, - GLuint operand ) -{ - struct ureg arg, src, one; - - src = get_source(p, source, unit); - - switch (operand) { - case OPR_ONE_MINUS_SRC_COLOR: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.xyzw - */ - arg = get_temp( p ); - one = get_one( p ); - return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef); - - case OPR_SRC_ALPHA: - if (mask == WRITEMASK_W) - return src; - else - return swizzle1( src, SWIZZLE_W ); - case OPR_ONE_MINUS_SRC_ALPHA: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.wwww - */ - arg = get_temp(p); - one = get_one(p); - return emit_arith(p, OPCODE_SUB, arg, mask, 0, - one, swizzle1(src, SWIZZLE_W), undef); - case OPR_ZERO: - return get_zero(p); - case OPR_ONE: - return get_one(p); - case OPR_SRC_COLOR: - return src; - default: - assert(0); - return src; - } -} - -/** - * Check if the RGB and Alpha sources and operands match for the given - * texture unit's combinder state. When the RGB and A sources and - * operands match, we can emit fewer instructions. - */ -static GLboolean args_match( const struct state_key *key, GLuint unit ) -{ - GLuint i, numArgs = key->unit[unit].NumArgsRGB; - - for (i = 0; i < numArgs; i++) { - if (key->unit[unit].OptA[i].Source != key->unit[unit].OptRGB[i].Source) - return GL_FALSE; - - switch (key->unit[unit].OptA[i].Operand) { - case OPR_SRC_ALPHA: - switch (key->unit[unit].OptRGB[i].Operand) { - case OPR_SRC_COLOR: - case OPR_SRC_ALPHA: - break; - default: - return GL_FALSE; - } - break; - case OPR_ONE_MINUS_SRC_ALPHA: - switch (key->unit[unit].OptRGB[i].Operand) { - case OPR_ONE_MINUS_SRC_COLOR: - case OPR_ONE_MINUS_SRC_ALPHA: - break; - default: - return GL_FALSE; - } - break; - default: - return GL_FALSE; /* impossible */ - } - } - - return GL_TRUE; -} - -static struct ureg emit_combine( struct texenv_fragment_program *p, - struct ureg dest, - GLuint mask, - GLboolean saturate, - GLuint unit, - GLuint nr, - GLuint mode, - const struct mode_opt *opt) -{ - struct ureg src[MAX_COMBINER_TERMS]; - struct ureg tmp, half; - GLuint i; - - assert(nr <= MAX_COMBINER_TERMS); - - for (i = 0; i < nr; i++) - src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand ); - - switch (mode) { - case MODE_REPLACE: - if (mask == WRITEMASK_XYZW && !saturate) - return src[0]; - else - return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef ); - case MODE_MODULATE: - return emit_arith( p, OPCODE_MUL, dest, mask, saturate, - src[0], src[1], undef ); - case MODE_ADD: - return emit_arith( p, OPCODE_ADD, dest, mask, saturate, - src[0], src[1], undef ); - case MODE_ADD_SIGNED: - /* tmp = arg0 + arg1 - * result = tmp - .5 - */ - half = get_half(p); - tmp = get_temp( p ); - emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef ); - return dest; - case MODE_INTERPOLATE: - /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered: - */ - return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] ); - - case MODE_SUBTRACT: - return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef ); - - case MODE_DOT3_RGBA: - case MODE_DOT3_RGBA_EXT: - case MODE_DOT3_RGB_EXT: - case MODE_DOT3_RGB: { - struct ureg tmp0 = get_temp( p ); - struct ureg tmp1 = get_temp( p ); - struct ureg neg1 = register_scalar_const(p, -1); - struct ureg two = register_scalar_const(p, 2); - - /* tmp0 = 2*src0 - 1 - * tmp1 = 2*src1 - 1 - * - * dst = tmp0 dot3 tmp1 - */ - emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, - two, src[0], neg1); - - if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) - tmp1 = tmp0; - else - emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, - two, src[1], neg1); - emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef); - return dest; - } - case MODE_MODULATE_ADD_ATI: - /* Arg0 * Arg2 + Arg1 */ - return emit_arith( p, OPCODE_MAD, dest, mask, saturate, - src[0], src[2], src[1] ); - case MODE_MODULATE_SIGNED_ADD_ATI: { - /* Arg0 * Arg2 + Arg1 - 0.5 */ - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - return dest; - } - case MODE_MODULATE_SUBTRACT_ATI: - /* Arg0 * Arg2 - Arg1 */ - emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) ); - return dest; - case MODE_ADD_PRODUCTS: - /* Arg0 * Arg1 + Arg2 * Arg3 */ - { - struct ureg tmp0 = get_temp(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 ); - } - return dest; - case MODE_ADD_PRODUCTS_SIGNED: - /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */ - { - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - } - return dest; - case MODE_BUMP_ENVMAP_ATI: - /* special - not handled here */ - assert(0); - return src[0]; - default: - assert(0); - return src[0]; - } -} - - -/** - * Generate instructions for one texture unit's env/combiner mode. - */ -static struct ureg -emit_texenv(struct texenv_fragment_program *p, GLuint unit) -{ - const struct state_key *key = p->state; - GLboolean rgb_saturate, alpha_saturate; - GLuint rgb_shift, alpha_shift; - struct ureg out, dest; - - if (!key->unit[unit].enabled) { - return get_source(p, SRC_PREVIOUS, 0); - } - if (key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - /* this isn't really a env stage delivering a color and handled elsewhere */ - return get_source(p, SRC_PREVIOUS, 0); - } - - switch (key->unit[unit].ModeRGB) { - case MODE_DOT3_RGB_EXT: - alpha_shift = key->unit[unit].ScaleShiftA; - rgb_shift = 0; - break; - case MODE_DOT3_RGBA_EXT: - alpha_shift = 0; - rgb_shift = 0; - break; - default: - rgb_shift = key->unit[unit].ScaleShiftRGB; - alpha_shift = key->unit[unit].ScaleShiftA; - break; - } - - /* If we'll do rgb/alpha shifting don't saturate in emit_combine(). - * We don't want to clamp twice. - */ - if (rgb_shift) - rgb_saturate = GL_FALSE; /* saturate after rgb shift */ - else if (need_saturate(key->unit[unit].ModeRGB)) - rgb_saturate = GL_TRUE; - else - rgb_saturate = GL_FALSE; - - if (alpha_shift) - alpha_saturate = GL_FALSE; /* saturate after alpha shift */ - else if (need_saturate(key->unit[unit].ModeA)) - alpha_saturate = GL_TRUE; - else - alpha_saturate = GL_FALSE; - - /* If this is the very last calculation (and various other conditions - * are met), emit directly to the color output register. Otherwise, - * emit to a temporary register. - */ - if (key->separate_specular || - unit != p->last_tex_stage || - alpha_shift || - key->num_draw_buffers != 1 || - rgb_shift) - dest = get_temp( p ); - else - dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); - - /* Emit the RGB and A combine ops - */ - if (key->unit[unit].ModeRGB == key->unit[unit].ModeA && - args_match(key, unit)) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - } - else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || - key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - } - else { - /* Need to do something to stop from re-emitting identical - * argument calculations here: - */ - out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate, - unit, - key->unit[unit].NumArgsA, - key->unit[unit].ModeA, - key->unit[unit].OptA); - } - - /* Deal with the final shift: - */ - if (alpha_shift || rgb_shift) { - struct ureg shift; - GLboolean saturate = GL_TRUE; /* always saturate at this point */ - - if (rgb_shift == alpha_shift) { - shift = register_scalar_const(p, (GLfloat)(1<src_texture[unit])) { - const GLuint texTarget = p->state->unit[unit].source_index; - struct ureg texcoord; - struct ureg tmp = get_tex_temp( p ); - - if (is_undef(p->texcoord_tex[unit])) { - texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit); - } - else { - /* might want to reuse this reg for tex output actually */ - texcoord = p->texcoord_tex[unit]; - } - - /* TODO: Use D0_MASK_XY where possible. - */ - if (p->state->unit[unit].enabled) { - GLboolean shadow = GL_FALSE; - - if (p->state->unit[unit].shadow) { - p->program->Base.ShadowSamplers |= 1 << unit; - shadow = GL_TRUE; - } - - p->src_texture[unit] = emit_texld( p, OPCODE_TXP, - tmp, WRITEMASK_XYZW, - unit, texTarget, shadow, - texcoord ); - - p->program->Base.SamplersUsed |= (1 << unit); - /* This identity mapping should already be in place - * (see _mesa_init_program_struct()) but let's be safe. - */ - p->program->Base.SamplerUnits[unit] = unit; - } - else - p->src_texture[unit] = get_zero(p); - - if (p->state->unit[unit].texture_cyl_wrap) { - /* set flag which is checked by Mesa->Gallium program translation */ - p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP; - } - - } -} - -static GLboolean load_texenv_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) -{ - switch (src) { - case SRC_TEXTURE: - load_texture(p, unit); - break; - - case SRC_TEXTURE0: - case SRC_TEXTURE1: - case SRC_TEXTURE2: - case SRC_TEXTURE3: - case SRC_TEXTURE4: - case SRC_TEXTURE5: - case SRC_TEXTURE6: - case SRC_TEXTURE7: - load_texture(p, src - SRC_TEXTURE0); - break; - - default: - /* not a texture src - do nothing */ - break; - } - - return GL_TRUE; -} - - -/** - * Generate instructions for loading all texture source terms. - */ -static GLboolean -load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) -{ - const struct state_key *key = p->state; - GLuint i; - - for (i = 0; i < key->unit[unit].NumArgsRGB; i++) { - load_texenv_source( p, key->unit[unit].OptRGB[i].Source, unit ); - } - - for (i = 0; i < key->unit[unit].NumArgsA; i++) { - load_texenv_source( p, key->unit[unit].OptA[i].Source, unit ); - } - - return GL_TRUE; -} - -/** - * Generate instructions for loading bump map textures. - */ -static GLboolean -load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit ) -{ - const struct state_key *key = p->state; - GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0; - struct ureg texcDst, bumpMapRes; - struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0); - struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr); - struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit ); - struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit ); - - load_texenv_source( p, unit + SRC_TEXTURE0, unit ); - - bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit); - texcDst = get_tex_temp( p ); - p->texcoord_tex[bumpedUnitNr] = texcDst; - - /* Apply rot matrix and add coords to be available in next phase. - * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1) - * note only 2 coords are affected the rest are left unchanged (mul by 0) - */ - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc ); - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst ); - - /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish - * enough to access this later, should optimize away. - */ - emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0, - constdudvcolor, undef, undef ); - - return GL_TRUE; -} - -/** - * Generate a new fragment program which implements the context's - * current texture env/combine mode. - */ -static void -create_new_program(GLcontext *ctx, struct state_key *key, - struct gl_fragment_program *program) -{ - struct prog_instruction instBuffer[MAX_INSTRUCTIONS]; - struct texenv_fragment_program p; - GLuint unit; - struct ureg cf, out; - int i; - - memset(&p, 0, sizeof(p)); - p.state = key; - p.program = program; - - /* During code generation, use locally-allocated instruction buffer, - * then alloc dynamic storage below. - */ - p.program->Base.Instructions = instBuffer; - p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; - p.program->Base.String = NULL; - p.program->Base.NumTexIndirections = 1; /* is this right? */ - p.program->Base.NumTexInstructions = 0; - p.program->Base.NumAluInstructions = 0; - p.program->Base.NumInstructions = 0; - p.program->Base.NumTemporaries = 0; - p.program->Base.NumParameters = 0; - p.program->Base.NumAttributes = 0; - p.program->Base.NumAddressRegs = 0; - p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->Base.InputsRead = 0x0; - - if (key->num_draw_buffers == 1) - p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; - else { - for (i = 0; i < key->num_draw_buffers; i++) - p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i)); - } - - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - p.src_texture[unit] = undef; - p.texcoord_tex[unit] = undef; - } - - p.src_previous = undef; - p.half = undef; - p.zero = undef; - p.one = undef; - - p.last_tex_stage = 0; - release_temps(ctx, &p); - - if (key->enabled_units) { - GLboolean needbumpstage = GL_FALSE; - - /* Zeroth pass - bump map textures first */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled && - key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - needbumpstage = GL_TRUE; - load_texunit_bumpmap( &p, unit ); - } - if (needbumpstage) - p.program->Base.NumTexIndirections++; - - /* First pass - to support texture_env_crossbar, first identify - * all referenced texture sources and emit texld instructions - * for each: - */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled) { - load_texunit_sources( &p, unit ); - p.last_tex_stage = unit; - } - - /* Second pass - emit combine instructions to build final color: - */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled) { - p.src_previous = emit_texenv( &p, unit ); - reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */ - release_temps(ctx, &p); /* release all temps */ - } - } - - cf = get_source( &p, SRC_PREVIOUS, 0 ); - - for (i = 0; i < key->num_draw_buffers; i++) { - if (key->num_draw_buffers == 1) - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR ); - else { - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i ); - } - - if (key->separate_specular) { - /* Emit specular add. - */ - struct ureg s = register_input(&p, FRAG_ATTRIB_COL1); - emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); - } - else if (memcmp(&cf, &out, sizeof(cf)) != 0) { - /* Will wind up in here if no texture enabled or a couple of - * other scenarios (GL_REPLACE for instance). - */ - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef ); - } - } - /* Finish up: - */ - emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); - - if (key->fog_enabled) { - /* Pull fog mode from GLcontext, the value in the state key is - * a reduced value and not what is expected in FogOption - */ - p.program->FogOption = ctx->Fog.Mode; - p.program->Base.InputsRead |= FRAG_BIT_FOGC; - } - else { - p.program->FogOption = GL_NONE; - } - - if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections) - program_error(&p, "Exceeded max nr indirect texture lookups"); - - if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions) - program_error(&p, "Exceeded max TEX instructions"); - - if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions) - program_error(&p, "Exceeded max ALU instructions"); - - ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); - - /* Allocate final instruction array */ - p.program->Base.Instructions - = _mesa_alloc_instructions(p.program->Base.NumInstructions); - if (!p.program->Base.Instructions) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "generating tex env program"); - return; - } - _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, - p.program->Base.NumInstructions); - - if (p.program->FogOption) { - _mesa_append_fog_code(ctx, p.program); - p.program->FogOption = GL_NONE; - } - - - /* Notify driver the fragment program has (actually) changed. - */ - if (ctx->Driver.ProgramStringNotify) { - GLboolean ok = ctx->Driver.ProgramStringNotify(ctx, - GL_FRAGMENT_PROGRAM_ARB, - &p.program->Base); - /* Driver should be able to handle any texenv programs as long as - * the driver correctly reported max number of texture units correctly, - * etc. - */ - ASSERT(ok); - (void) ok; /* silence unused var warning */ - } - - if (DISASSEM) { - _mesa_print_program(&p.program->Base); - printf("\n"); - } -} - - -/** - * Return a fragment program which implements the current - * fixed-function texture, fog and color-sum operations. - */ -struct gl_fragment_program * -_mesa_get_fixed_func_fragment_program(GLcontext *ctx) -{ - struct gl_fragment_program *prog; - struct state_key key; - GLuint keySize; - - keySize = make_state_key(ctx, &key); - - prog = (struct gl_fragment_program *) - _mesa_search_program_cache(ctx->FragmentProgram.Cache, - &key, keySize); - - if (!prog) { - prog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); - - create_new_program(ctx, &key, prog); - - _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache, - &key, keySize, &prog->Base); - } - - return prog; -} +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "glheader.h" +#include "imports.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "program/prog_cache.h" +#include "program/prog_instruction.h" +#include "program/prog_print.h" +#include "program/prog_statevars.h" +#include "program/programopt.h" +#include "texenvprogram.h" + + +/* + * Note on texture units: + * + * The number of texture units supported by fixed-function fragment + * processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS. + * That's because there's a one-to-one correspondence between texture + * coordinates and samplers in fixed-function processing. + * + * Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS + * sets of texcoords, so is fixed-function fragment processing. + * + * We can safely use ctx->Const.MaxTextureUnits for loop bounds. + */ + + +struct texenvprog_cache_item +{ + GLuint hash; + void *key; + struct gl_fragment_program *data; + struct texenvprog_cache_item *next; +}; + +static GLboolean +texenv_doing_secondary_color(struct gl_context *ctx) +{ + if (ctx->Light.Enabled && + (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) + return GL_TRUE; + + if (ctx->Fog.ColorSumEnabled) + return GL_TRUE; + + return GL_FALSE; +} + +/** + * Up to nine instructions per tex unit, plus fog, specular color. + */ +#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12) + +#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) + +struct mode_opt { +#ifdef __GNUC__ + __extension__ GLubyte Source:4; /**< SRC_x */ + __extension__ GLubyte Operand:3; /**< OPR_x */ +#else + GLubyte Source; /**< SRC_x */ + GLubyte Operand; /**< OPR_x */ +#endif +}; + +struct state_key { + GLuint nr_enabled_units:8; + GLuint enabled_units:8; + GLuint separate_specular:1; + GLuint fog_enabled:1; + GLuint fog_mode:2; /**< FOG_x */ + GLuint inputs_available:12; + GLuint num_draw_buffers:4; + + /* NOTE: This array of structs must be last! (see "keySize" below) */ + struct { + GLuint enabled:1; + GLuint source_index:3; /**< TEXTURE_x_INDEX */ + GLuint shadow:1; + GLuint ScaleShiftRGB:2; + GLuint ScaleShiftA:2; + + GLuint NumArgsRGB:3; /**< up to MAX_COMBINER_TERMS */ + GLuint ModeRGB:5; /**< MODE_x */ + + GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */ + GLuint ModeA:5; /**< MODE_x */ + + GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */ + + struct mode_opt OptRGB[MAX_COMBINER_TERMS]; + struct mode_opt OptA[MAX_COMBINER_TERMS]; + } unit[MAX_TEXTURE_UNITS]; +}; + +#define FOG_LINEAR 0 +#define FOG_EXP 1 +#define FOG_EXP2 2 +#define FOG_UNKNOWN 3 + +static GLuint translate_fog_mode( GLenum mode ) +{ + switch (mode) { + case GL_LINEAR: return FOG_LINEAR; + case GL_EXP: return FOG_EXP; + case GL_EXP2: return FOG_EXP2; + default: return FOG_UNKNOWN; + } +} + +#define OPR_SRC_COLOR 0 +#define OPR_ONE_MINUS_SRC_COLOR 1 +#define OPR_SRC_ALPHA 2 +#define OPR_ONE_MINUS_SRC_ALPHA 3 +#define OPR_ZERO 4 +#define OPR_ONE 5 +#define OPR_UNKNOWN 7 + +static GLuint translate_operand( GLenum operand ) +{ + switch (operand) { + case GL_SRC_COLOR: return OPR_SRC_COLOR; + case GL_ONE_MINUS_SRC_COLOR: return OPR_ONE_MINUS_SRC_COLOR; + case GL_SRC_ALPHA: return OPR_SRC_ALPHA; + case GL_ONE_MINUS_SRC_ALPHA: return OPR_ONE_MINUS_SRC_ALPHA; + case GL_ZERO: return OPR_ZERO; + case GL_ONE: return OPR_ONE; + default: + assert(0); + return OPR_UNKNOWN; + } +} + +#define SRC_TEXTURE 0 +#define SRC_TEXTURE0 1 +#define SRC_TEXTURE1 2 +#define SRC_TEXTURE2 3 +#define SRC_TEXTURE3 4 +#define SRC_TEXTURE4 5 +#define SRC_TEXTURE5 6 +#define SRC_TEXTURE6 7 +#define SRC_TEXTURE7 8 +#define SRC_CONSTANT 9 +#define SRC_PRIMARY_COLOR 10 +#define SRC_PREVIOUS 11 +#define SRC_ZERO 12 +#define SRC_UNKNOWN 15 + +static GLuint translate_source( GLenum src ) +{ + switch (src) { + case GL_TEXTURE: return SRC_TEXTURE; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: return SRC_TEXTURE0 + (src - GL_TEXTURE0); + case GL_CONSTANT: return SRC_CONSTANT; + case GL_PRIMARY_COLOR: return SRC_PRIMARY_COLOR; + case GL_PREVIOUS: return SRC_PREVIOUS; + case GL_ZERO: + return SRC_ZERO; + default: + assert(0); + return SRC_UNKNOWN; + } +} + +#define MODE_REPLACE 0 /* r = a0 */ +#define MODE_MODULATE 1 /* r = a0 * a1 */ +#define MODE_ADD 2 /* r = a0 + a1 */ +#define MODE_ADD_SIGNED 3 /* r = a0 + a1 - 0.5 */ +#define MODE_INTERPOLATE 4 /* r = a0 * a2 + a1 * (1 - a2) */ +#define MODE_SUBTRACT 5 /* r = a0 - a1 */ +#define MODE_DOT3_RGB 6 /* r = a0 . a1 */ +#define MODE_DOT3_RGB_EXT 7 /* r = a0 . a1 */ +#define MODE_DOT3_RGBA 8 /* r = a0 . a1 */ +#define MODE_DOT3_RGBA_EXT 9 /* r = a0 . a1 */ +#define MODE_MODULATE_ADD_ATI 10 /* r = a0 * a2 + a1 */ +#define MODE_MODULATE_SIGNED_ADD_ATI 11 /* r = a0 * a2 + a1 - 0.5 */ +#define MODE_MODULATE_SUBTRACT_ATI 12 /* r = a0 * a2 - a1 */ +#define MODE_ADD_PRODUCTS 13 /* r = a0 * a1 + a2 * a3 */ +#define MODE_ADD_PRODUCTS_SIGNED 14 /* r = a0 * a1 + a2 * a3 - 0.5 */ +#define MODE_BUMP_ENVMAP_ATI 15 /* special */ +#define MODE_UNKNOWN 16 + +/** + * Translate GL combiner state into a MODE_x value + */ +static GLuint translate_mode( GLenum envMode, GLenum mode ) +{ + switch (mode) { + case GL_REPLACE: return MODE_REPLACE; + case GL_MODULATE: return MODE_MODULATE; + case GL_ADD: + if (envMode == GL_COMBINE4_NV) + return MODE_ADD_PRODUCTS; + else + return MODE_ADD; + case GL_ADD_SIGNED: + if (envMode == GL_COMBINE4_NV) + return MODE_ADD_PRODUCTS_SIGNED; + else + return MODE_ADD_SIGNED; + case GL_INTERPOLATE: return MODE_INTERPOLATE; + case GL_SUBTRACT: return MODE_SUBTRACT; + case GL_DOT3_RGB: return MODE_DOT3_RGB; + case GL_DOT3_RGB_EXT: return MODE_DOT3_RGB_EXT; + case GL_DOT3_RGBA: return MODE_DOT3_RGBA; + case GL_DOT3_RGBA_EXT: return MODE_DOT3_RGBA_EXT; + case GL_MODULATE_ADD_ATI: return MODE_MODULATE_ADD_ATI; + case GL_MODULATE_SIGNED_ADD_ATI: return MODE_MODULATE_SIGNED_ADD_ATI; + case GL_MODULATE_SUBTRACT_ATI: return MODE_MODULATE_SUBTRACT_ATI; + case GL_BUMP_ENVMAP_ATI: return MODE_BUMP_ENVMAP_ATI; + default: + assert(0); + return MODE_UNKNOWN; + } +} + + +/** + * Do we need to clamp the results of the given texture env/combine mode? + * If the inputs to the mode are in [0,1] we don't always have to clamp + * the results. + */ +static GLboolean +need_saturate( GLuint mode ) +{ + switch (mode) { + case MODE_REPLACE: + case MODE_MODULATE: + case MODE_INTERPOLATE: + return GL_FALSE; + case MODE_ADD: + case MODE_ADD_SIGNED: + case MODE_SUBTRACT: + case MODE_DOT3_RGB: + case MODE_DOT3_RGB_EXT: + case MODE_DOT3_RGBA: + case MODE_DOT3_RGBA_EXT: + case MODE_MODULATE_ADD_ATI: + case MODE_MODULATE_SIGNED_ADD_ATI: + case MODE_MODULATE_SUBTRACT_ATI: + case MODE_ADD_PRODUCTS: + case MODE_ADD_PRODUCTS_SIGNED: + case MODE_BUMP_ENVMAP_ATI: + return GL_TRUE; + default: + assert(0); + return GL_FALSE; + } +} + + + +/** + * Translate TEXTURE_x_BIT to TEXTURE_x_INDEX. + */ +static GLuint translate_tex_src_bit( GLbitfield bit ) +{ + ASSERT(bit); + return _mesa_ffs(bit) - 1; +} + + +#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) +#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) + +/** + * Identify all possible varying inputs. The fragment program will + * never reference non-varying inputs, but will track them via state + * constants instead. + * + * This function figures out all the inputs that the fragment program + * has access to. The bitmask is later reduced to just those which + * are actually referenced. + */ +static GLbitfield get_fp_input_mask( struct gl_context *ctx ) +{ + /* _NEW_PROGRAM */ + const GLboolean vertexShader = + (ctx->Shader.CurrentVertexProgram && + ctx->Shader.CurrentVertexProgram->LinkStatus && + ctx->Shader.CurrentVertexProgram->VertexProgram); + const GLboolean vertexProgram = ctx->VertexProgram._Enabled; + GLbitfield fp_inputs = 0x0; + + if (ctx->VertexProgram._Overriden) { + /* Somebody's messing with the vertex program and we don't have + * a clue what's happening. Assume that it could be producing + * all possible outputs. + */ + fp_inputs = ~0; + } + else if (ctx->RenderMode == GL_FEEDBACK) { + /* _NEW_RENDERMODE */ + fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); + } + else if (!(vertexProgram || vertexShader) || + !ctx->VertexProgram._Current) { + /* Fixed function vertex logic */ + /* _NEW_ARRAY */ + GLbitfield varying_inputs = ctx->varying_vp_inputs; + + /* These get generated in the setup routine regardless of the + * vertex program: + */ + /* _NEW_POINT */ + if (ctx->Point.PointSprite) + varying_inputs |= FRAG_BITS_TEX_ANY; + + /* First look at what values may be computed by the generated + * vertex program: + */ + /* _NEW_LIGHT */ + if (ctx->Light.Enabled) { + fp_inputs |= FRAG_BIT_COL0; + + if (texenv_doing_secondary_color(ctx)) + fp_inputs |= FRAG_BIT_COL1; + } + + /* _NEW_TEXTURE */ + fp_inputs |= (ctx->Texture._TexGenEnabled | + ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0; + + /* Then look at what might be varying as a result of enabled + * arrays, etc: + */ + if (varying_inputs & VERT_BIT_COLOR0) + fp_inputs |= FRAG_BIT_COL0; + if (varying_inputs & VERT_BIT_COLOR1) + fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) + << FRAG_ATTRIB_TEX0); + + } + else { + /* calculate from vp->outputs */ + struct gl_vertex_program *vprog; + GLbitfield64 vp_outputs; + + /* Choose GLSL vertex shader over ARB vertex program. Need this + * since vertex shader state validation comes after fragment state + * validation (see additional comments in state.c). + */ + if (vertexShader) + vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + else + vprog = ctx->VertexProgram.Current; + + vp_outputs = vprog->Base.OutputsWritten; + + /* These get generated in the setup routine regardless of the + * vertex program: + */ + /* _NEW_POINT */ + if (ctx->Point.PointSprite) + vp_outputs |= FRAG_BITS_TEX_ANY; + + if (vp_outputs & (1 << VERT_RESULT_COL0)) + fp_inputs |= FRAG_BIT_COL0; + if (vp_outputs & (1 << VERT_RESULT_COL1)) + fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) + << FRAG_ATTRIB_TEX0); + } + + return fp_inputs; +} + + +/** + * Examine current texture environment state and generate a unique + * key to identify it. + */ +static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) +{ + GLuint i, j; + GLbitfield inputs_referenced = FRAG_BIT_COL0; + const GLbitfield inputs_available = get_fp_input_mask( ctx ); + GLuint keySize; + + memset(key, 0, sizeof(*key)); + + /* _NEW_TEXTURE */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + const struct gl_texture_object *texObj = texUnit->_Current; + const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine; + GLenum format; + + if (!texUnit->_ReallyEnabled || !texUnit->Enabled) + continue; + + format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; + + key->unit[i].enabled = 1; + key->enabled_units |= (1<nr_enabled_units = i + 1; + inputs_referenced |= FRAG_BIT_TEX(i); + + key->unit[i].source_index = + translate_tex_src_bit(texUnit->_ReallyEnabled); + + key->unit[i].shadow = ((texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE) && + ((format == GL_DEPTH_COMPONENT) || + (format == GL_DEPTH_STENCIL_EXT))); + + key->unit[i].NumArgsRGB = comb->_NumArgsRGB; + key->unit[i].NumArgsA = comb->_NumArgsA; + + key->unit[i].ModeRGB = + translate_mode(texUnit->EnvMode, comb->ModeRGB); + key->unit[i].ModeA = + translate_mode(texUnit->EnvMode, comb->ModeA); + + key->unit[i].ScaleShiftRGB = comb->ScaleShiftRGB; + key->unit[i].ScaleShiftA = comb->ScaleShiftA; + + for (j = 0; j < MAX_COMBINER_TERMS; j++) { + key->unit[i].OptRGB[j].Operand = translate_operand(comb->OperandRGB[j]); + key->unit[i].OptA[j].Operand = translate_operand(comb->OperandA[j]); + key->unit[i].OptRGB[j].Source = translate_source(comb->SourceRGB[j]); + key->unit[i].OptA[j].Source = translate_source(comb->SourceA[j]); + } + + if (key->unit[i].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + /* requires some special translation */ + key->unit[i].NumArgsRGB = 2; + key->unit[i].ScaleShiftRGB = 0; + key->unit[i].OptRGB[0].Operand = OPR_SRC_COLOR; + key->unit[i].OptRGB[0].Source = SRC_TEXTURE; + key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR; + key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0; + } + + /* this is a back-door for enabling cylindrical texture wrap mode */ + if (texObj->Priority == 0.125) + key->unit[i].texture_cyl_wrap = 1; + } + + /* _NEW_LIGHT | _NEW_FOG */ + if (texenv_doing_secondary_color(ctx)) { + key->separate_specular = 1; + inputs_referenced |= FRAG_BIT_COL1; + } + + /* _NEW_FOG */ + if (ctx->Fog.Enabled) { + key->fog_enabled = 1; + key->fog_mode = translate_fog_mode(ctx->Fog.Mode); + inputs_referenced |= FRAG_BIT_FOGC; /* maybe */ + } + + /* _NEW_BUFFERS */ + key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers; + + key->inputs_available = (inputs_available & inputs_referenced); + + /* compute size of state key, ignoring unused texture units */ + keySize = sizeof(*key) - sizeof(key->unit) + + key->nr_enabled_units * sizeof(key->unit[0]); + + return keySize; +} + + +/** + * Use uregs to represent registers internally, translate to Mesa's + * expected formats on emit. + * + * NOTE: These are passed by value extensively in this file rather + * than as usual by pointer reference. If this disturbs you, try + * remembering they are just 32bits in size. + * + * GCC is smart enough to deal with these dword-sized structures in + * much the same way as if I had defined them as dwords and was using + * macros to access and set the fields. This is much nicer and easier + * to evolve. + */ +struct ureg { + GLuint file:4; + GLuint idx:8; + GLuint negatebase:1; + GLuint swz:12; + GLuint pad:7; +}; + +static const struct ureg undef = { + PROGRAM_UNDEFINED, + ~0, + 0, + 0, + 0 +}; + + +/** State used to build the fragment program: + */ +struct texenv_fragment_program { + struct gl_fragment_program *program; + struct state_key *state; + + GLbitfield alu_temps; /**< Track texture indirections, see spec. */ + GLbitfield temps_output; /**< Track texture indirections, see spec. */ + GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ + GLboolean error; + + struct ureg src_texture[MAX_TEXTURE_COORD_UNITS]; + /* Reg containing each texture unit's sampled texture color, + * else undef. + */ + + struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS]; + /* Reg containing texcoord for a texture unit, + * needed for bump mapping, else undef. + */ + + struct ureg src_previous; /**< Reg containing color from previous + * stage. May need to be decl'd. + */ + + GLuint last_tex_stage; /**< Number of last enabled texture unit */ + + struct ureg half; + struct ureg one; + struct ureg zero; +}; + + + +static struct ureg make_ureg(GLuint file, GLuint idx) +{ + struct ureg reg; + reg.file = file; + reg.idx = idx; + reg.negatebase = 0; + reg.swz = SWIZZLE_NOOP; + reg.pad = 0; + return reg; +} + +static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) +{ + reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), + GET_SWZ(reg.swz, y), + GET_SWZ(reg.swz, z), + GET_SWZ(reg.swz, w)); + + return reg; +} + +static struct ureg swizzle1( struct ureg reg, int x ) +{ + return swizzle(reg, x, x, x, x); +} + +static struct ureg negate( struct ureg reg ) +{ + reg.negatebase ^= 1; + return reg; +} + +static GLboolean is_undef( struct ureg reg ) +{ + return reg.file == PROGRAM_UNDEFINED; +} + + +static struct ureg get_temp( struct texenv_fragment_program *p ) +{ + GLint bit; + + /* First try and reuse temps which have been used already: + */ + bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps ); + + /* Then any unused temporary: + */ + if (!bit) + bit = _mesa_ffs( ~p->temp_in_use ); + + if (!bit) { + _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); + exit(1); + } + + if ((GLuint) bit > p->program->Base.NumTemporaries) + p->program->Base.NumTemporaries = bit; + + p->temp_in_use |= 1<<(bit-1); + return make_ureg(PROGRAM_TEMPORARY, (bit-1)); +} + +static struct ureg get_tex_temp( struct texenv_fragment_program *p ) +{ + int bit; + + /* First try to find available temp not previously used (to avoid + * starting a new texture indirection). According to the spec, the + * ~p->temps_output isn't necessary, but will keep it there for + * now: + */ + bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); + + /* Then any unused temporary: + */ + if (!bit) + bit = _mesa_ffs( ~p->temp_in_use ); + + if (!bit) { + _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); + exit(1); + } + + if ((GLuint) bit > p->program->Base.NumTemporaries) + p->program->Base.NumTemporaries = bit; + + p->temp_in_use |= 1<<(bit-1); + return make_ureg(PROGRAM_TEMPORARY, (bit-1)); +} + + +/** Mark a temp reg as being no longer allocatable. */ +static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) +{ + if (r.file == PROGRAM_TEMPORARY) + p->temps_output |= (1 << r.idx); +} + + +static void release_temps(struct gl_context *ctx, struct texenv_fragment_program *p ) +{ + GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; + + /* KW: To support tex_env_crossbar, don't release the registers in + * temps_output. + */ + if (max_temp >= sizeof(int) * 8) + p->temp_in_use = p->temps_output; + else + p->temp_in_use = ~((1<temps_output; +} + + +static struct ureg register_param5( struct texenv_fragment_program *p, + GLint s0, + GLint s1, + GLint s2, + GLint s3, + GLint s4) +{ + gl_state_index tokens[STATE_LENGTH]; + GLuint idx; + tokens[0] = s0; + tokens[1] = s1; + tokens[2] = s2; + tokens[3] = s3; + tokens[4] = s4; + idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); + return make_ureg(PROGRAM_STATE_VAR, idx); +} + + +#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) +#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) +#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) +#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) + +static GLuint frag_to_vert_attrib( GLuint attrib ) +{ + switch (attrib) { + case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; + case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; + default: + assert(attrib >= FRAG_ATTRIB_TEX0); + assert(attrib <= FRAG_ATTRIB_TEX7); + return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; + } +} + + +static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) +{ + if (p->state->inputs_available & (1<program->Base.InputsRead |= (1 << input); + return make_ureg(PROGRAM_INPUT, input); + } + else { + GLuint idx = frag_to_vert_attrib( input ); + return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx ); + } +} + + +static void emit_arg( struct prog_src_register *reg, + struct ureg ureg ) +{ + reg->File = ureg.file; + reg->Index = ureg.idx; + reg->Swizzle = ureg.swz; + reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE; + reg->Abs = GL_FALSE; +} + +static void emit_dst( struct prog_dst_register *dst, + struct ureg ureg, GLuint mask ) +{ + dst->File = ureg.file; + dst->Index = ureg.idx; + dst->WriteMask = mask; + dst->CondMask = COND_TR; /* always pass cond test */ + dst->CondSwizzle = SWIZZLE_NOOP; +} + +static struct prog_instruction * +emit_op(struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint mask, + GLboolean saturate, + struct ureg src0, + struct ureg src1, + struct ureg src2 ) +{ + const GLuint nr = p->program->Base.NumInstructions++; + struct prog_instruction *inst = &p->program->Base.Instructions[nr]; + + assert(nr < MAX_INSTRUCTIONS); + + _mesa_init_instructions(inst, 1); + inst->Opcode = op; + + emit_arg( &inst->SrcReg[0], src0 ); + emit_arg( &inst->SrcReg[1], src1 ); + emit_arg( &inst->SrcReg[2], src2 ); + + inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF; + + emit_dst( &inst->DstReg, dest, mask ); + +#if 0 + /* Accounting for indirection tracking: + */ + if (dest.file == PROGRAM_TEMPORARY) + p->temps_output |= 1 << dest.idx; +#endif + + return inst; +} + + +static struct ureg emit_arith( struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint mask, + GLboolean saturate, + struct ureg src0, + struct ureg src1, + struct ureg src2 ) +{ + emit_op(p, op, dest, mask, saturate, src0, src1, src2); + + /* Accounting for indirection tracking: + */ + if (src0.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src0.idx; + + if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src1.idx; + + if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src2.idx; + + if (dest.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << dest.idx; + + p->program->Base.NumAluInstructions++; + return dest; +} + +static struct ureg emit_texld( struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint destmask, + GLuint tex_unit, + GLuint tex_idx, + GLuint tex_shadow, + struct ureg coord ) +{ + struct prog_instruction *inst = emit_op( p, op, + dest, destmask, + GL_FALSE, /* don't saturate? */ + coord, /* arg 0? */ + undef, + undef); + + inst->TexSrcTarget = tex_idx; + inst->TexSrcUnit = tex_unit; + inst->TexShadow = tex_shadow; + + p->program->Base.NumTexInstructions++; + + /* Accounting for indirection tracking: + */ + reserve_temp(p, dest); + +#if 0 + /* Is this a texture indirection? + */ + if ((coord.file == PROGRAM_TEMPORARY && + (p->temps_output & (1<alu_temps & (1<program->Base.NumTexIndirections++; + p->temps_output = 1<alu_temps = 0; + assert(0); /* KW: texture env crossbar */ + } +#endif + + return dest; +} + + +static struct ureg register_const4f( struct texenv_fragment_program *p, + GLfloat s0, + GLfloat s1, + GLfloat s2, + GLfloat s3) +{ + GLfloat values[4]; + GLuint idx, swizzle; + struct ureg r; + values[0] = s0; + values[1] = s1; + values[2] = s2; + values[3] = s3; + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, + &swizzle ); + r = make_ureg(PROGRAM_CONSTANT, idx); + r.swz = swizzle; + return r; +} + +#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) +#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) +#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) +#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) + + +static struct ureg get_one( struct texenv_fragment_program *p ) +{ + if (is_undef(p->one)) + p->one = register_scalar_const(p, 1.0); + return p->one; +} + +static struct ureg get_half( struct texenv_fragment_program *p ) +{ + if (is_undef(p->half)) + p->half = register_scalar_const(p, 0.5); + return p->half; +} + +static struct ureg get_zero( struct texenv_fragment_program *p ) +{ + if (is_undef(p->zero)) + p->zero = register_scalar_const(p, 0.0); + return p->zero; +} + + +static void program_error( struct texenv_fragment_program *p, const char *msg ) +{ + _mesa_problem(NULL, "%s", msg); + p->error = 1; +} + +static struct ureg get_source( struct texenv_fragment_program *p, + GLuint src, GLuint unit ) +{ + switch (src) { + case SRC_TEXTURE: + assert(!is_undef(p->src_texture[unit])); + return p->src_texture[unit]; + + case SRC_TEXTURE0: + case SRC_TEXTURE1: + case SRC_TEXTURE2: + case SRC_TEXTURE3: + case SRC_TEXTURE4: + case SRC_TEXTURE5: + case SRC_TEXTURE6: + case SRC_TEXTURE7: + assert(!is_undef(p->src_texture[src - SRC_TEXTURE0])); + return p->src_texture[src - SRC_TEXTURE0]; + + case SRC_CONSTANT: + return register_param2(p, STATE_TEXENV_COLOR, unit); + + case SRC_PRIMARY_COLOR: + return register_input(p, FRAG_ATTRIB_COL0); + + case SRC_ZERO: + return get_zero(p); + + case SRC_PREVIOUS: + if (is_undef(p->src_previous)) + return register_input(p, FRAG_ATTRIB_COL0); + else + return p->src_previous; + + default: + assert(0); + return undef; + } +} + +static struct ureg emit_combine_source( struct texenv_fragment_program *p, + GLuint mask, + GLuint unit, + GLuint source, + GLuint operand ) +{ + struct ureg arg, src, one; + + src = get_source(p, source, unit); + + switch (operand) { + case OPR_ONE_MINUS_SRC_COLOR: + /* Get unused tmp, + * Emit tmp = 1.0 - arg.xyzw + */ + arg = get_temp( p ); + one = get_one( p ); + return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef); + + case OPR_SRC_ALPHA: + if (mask == WRITEMASK_W) + return src; + else + return swizzle1( src, SWIZZLE_W ); + case OPR_ONE_MINUS_SRC_ALPHA: + /* Get unused tmp, + * Emit tmp = 1.0 - arg.wwww + */ + arg = get_temp(p); + one = get_one(p); + return emit_arith(p, OPCODE_SUB, arg, mask, 0, + one, swizzle1(src, SWIZZLE_W), undef); + case OPR_ZERO: + return get_zero(p); + case OPR_ONE: + return get_one(p); + case OPR_SRC_COLOR: + return src; + default: + assert(0); + return src; + } +} + +/** + * Check if the RGB and Alpha sources and operands match for the given + * texture unit's combinder state. When the RGB and A sources and + * operands match, we can emit fewer instructions. + */ +static GLboolean args_match( const struct state_key *key, GLuint unit ) +{ + GLuint i, numArgs = key->unit[unit].NumArgsRGB; + + for (i = 0; i < numArgs; i++) { + if (key->unit[unit].OptA[i].Source != key->unit[unit].OptRGB[i].Source) + return GL_FALSE; + + switch (key->unit[unit].OptA[i].Operand) { + case OPR_SRC_ALPHA: + switch (key->unit[unit].OptRGB[i].Operand) { + case OPR_SRC_COLOR: + case OPR_SRC_ALPHA: + break; + default: + return GL_FALSE; + } + break; + case OPR_ONE_MINUS_SRC_ALPHA: + switch (key->unit[unit].OptRGB[i].Operand) { + case OPR_ONE_MINUS_SRC_COLOR: + case OPR_ONE_MINUS_SRC_ALPHA: + break; + default: + return GL_FALSE; + } + break; + default: + return GL_FALSE; /* impossible */ + } + } + + return GL_TRUE; +} + +static struct ureg emit_combine( struct texenv_fragment_program *p, + struct ureg dest, + GLuint mask, + GLboolean saturate, + GLuint unit, + GLuint nr, + GLuint mode, + const struct mode_opt *opt) +{ + struct ureg src[MAX_COMBINER_TERMS]; + struct ureg tmp, half; + GLuint i; + + assert(nr <= MAX_COMBINER_TERMS); + + for (i = 0; i < nr; i++) + src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand ); + + switch (mode) { + case MODE_REPLACE: + if (mask == WRITEMASK_XYZW && !saturate) + return src[0]; + else + return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef ); + case MODE_MODULATE: + return emit_arith( p, OPCODE_MUL, dest, mask, saturate, + src[0], src[1], undef ); + case MODE_ADD: + return emit_arith( p, OPCODE_ADD, dest, mask, saturate, + src[0], src[1], undef ); + case MODE_ADD_SIGNED: + /* tmp = arg0 + arg1 + * result = tmp - .5 + */ + half = get_half(p); + tmp = get_temp( p ); + emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef ); + return dest; + case MODE_INTERPOLATE: + /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered: + */ + return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] ); + + case MODE_SUBTRACT: + return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef ); + + case MODE_DOT3_RGBA: + case MODE_DOT3_RGBA_EXT: + case MODE_DOT3_RGB_EXT: + case MODE_DOT3_RGB: { + struct ureg tmp0 = get_temp( p ); + struct ureg tmp1 = get_temp( p ); + struct ureg neg1 = register_scalar_const(p, -1); + struct ureg two = register_scalar_const(p, 2); + + /* tmp0 = 2*src0 - 1 + * tmp1 = 2*src1 - 1 + * + * dst = tmp0 dot3 tmp1 + */ + emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, + two, src[0], neg1); + + if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) + tmp1 = tmp0; + else + emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, + two, src[1], neg1); + emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef); + return dest; + } + case MODE_MODULATE_ADD_ATI: + /* Arg0 * Arg2 + Arg1 */ + return emit_arith( p, OPCODE_MAD, dest, mask, saturate, + src[0], src[2], src[1] ); + case MODE_MODULATE_SIGNED_ADD_ATI: { + /* Arg0 * Arg2 + Arg1 - 0.5 */ + struct ureg tmp0 = get_temp(p); + half = get_half(p); + emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); + return dest; + } + case MODE_MODULATE_SUBTRACT_ATI: + /* Arg0 * Arg2 - Arg1 */ + emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) ); + return dest; + case MODE_ADD_PRODUCTS: + /* Arg0 * Arg1 + Arg2 * Arg3 */ + { + struct ureg tmp0 = get_temp(p); + emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 ); + } + return dest; + case MODE_ADD_PRODUCTS_SIGNED: + /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */ + { + struct ureg tmp0 = get_temp(p); + half = get_half(p); + emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); + } + return dest; + case MODE_BUMP_ENVMAP_ATI: + /* special - not handled here */ + assert(0); + return src[0]; + default: + assert(0); + return src[0]; + } +} + + +/** + * Generate instructions for one texture unit's env/combiner mode. + */ +static struct ureg +emit_texenv(struct texenv_fragment_program *p, GLuint unit) +{ + const struct state_key *key = p->state; + GLboolean rgb_saturate, alpha_saturate; + GLuint rgb_shift, alpha_shift; + struct ureg out, dest; + + if (!key->unit[unit].enabled) { + return get_source(p, SRC_PREVIOUS, 0); + } + if (key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + /* this isn't really a env stage delivering a color and handled elsewhere */ + return get_source(p, SRC_PREVIOUS, 0); + } + + switch (key->unit[unit].ModeRGB) { + case MODE_DOT3_RGB_EXT: + alpha_shift = key->unit[unit].ScaleShiftA; + rgb_shift = 0; + break; + case MODE_DOT3_RGBA_EXT: + alpha_shift = 0; + rgb_shift = 0; + break; + default: + rgb_shift = key->unit[unit].ScaleShiftRGB; + alpha_shift = key->unit[unit].ScaleShiftA; + break; + } + + /* If we'll do rgb/alpha shifting don't saturate in emit_combine(). + * We don't want to clamp twice. + */ + if (rgb_shift) + rgb_saturate = GL_FALSE; /* saturate after rgb shift */ + else if (need_saturate(key->unit[unit].ModeRGB)) + rgb_saturate = GL_TRUE; + else + rgb_saturate = GL_FALSE; + + if (alpha_shift) + alpha_saturate = GL_FALSE; /* saturate after alpha shift */ + else if (need_saturate(key->unit[unit].ModeA)) + alpha_saturate = GL_TRUE; + else + alpha_saturate = GL_FALSE; + + /* If this is the very last calculation (and various other conditions + * are met), emit directly to the color output register. Otherwise, + * emit to a temporary register. + */ + if (key->separate_specular || + unit != p->last_tex_stage || + alpha_shift || + key->num_draw_buffers != 1 || + rgb_shift) + dest = get_temp( p ); + else + dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); + + /* Emit the RGB and A combine ops + */ + if (key->unit[unit].ModeRGB == key->unit[unit].ModeA && + args_match(key, unit)) { + out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + } + else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || + key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { + out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + } + else { + /* Need to do something to stop from re-emitting identical + * argument calculations here: + */ + out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate, + unit, + key->unit[unit].NumArgsA, + key->unit[unit].ModeA, + key->unit[unit].OptA); + } + + /* Deal with the final shift: + */ + if (alpha_shift || rgb_shift) { + struct ureg shift; + GLboolean saturate = GL_TRUE; /* always saturate at this point */ + + if (rgb_shift == alpha_shift) { + shift = register_scalar_const(p, (GLfloat)(1<src_texture[unit])) { + const GLuint texTarget = p->state->unit[unit].source_index; + struct ureg texcoord; + struct ureg tmp = get_tex_temp( p ); + + if (is_undef(p->texcoord_tex[unit])) { + texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit); + } + else { + /* might want to reuse this reg for tex output actually */ + texcoord = p->texcoord_tex[unit]; + } + + /* TODO: Use D0_MASK_XY where possible. + */ + if (p->state->unit[unit].enabled) { + GLboolean shadow = GL_FALSE; + + if (p->state->unit[unit].shadow) { + p->program->Base.ShadowSamplers |= 1 << unit; + shadow = GL_TRUE; + } + + p->src_texture[unit] = emit_texld( p, OPCODE_TXP, + tmp, WRITEMASK_XYZW, + unit, texTarget, shadow, + texcoord ); + + p->program->Base.SamplersUsed |= (1 << unit); + /* This identity mapping should already be in place + * (see _mesa_init_program_struct()) but let's be safe. + */ + p->program->Base.SamplerUnits[unit] = unit; + } + else + p->src_texture[unit] = get_zero(p); + + if (p->state->unit[unit].texture_cyl_wrap) { + /* set flag which is checked by Mesa->Gallium program translation */ + p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP; + } + + } +} + +static GLboolean load_texenv_source( struct texenv_fragment_program *p, + GLuint src, GLuint unit ) +{ + switch (src) { + case SRC_TEXTURE: + load_texture(p, unit); + break; + + case SRC_TEXTURE0: + case SRC_TEXTURE1: + case SRC_TEXTURE2: + case SRC_TEXTURE3: + case SRC_TEXTURE4: + case SRC_TEXTURE5: + case SRC_TEXTURE6: + case SRC_TEXTURE7: + load_texture(p, src - SRC_TEXTURE0); + break; + + default: + /* not a texture src - do nothing */ + break; + } + + return GL_TRUE; +} + + +/** + * Generate instructions for loading all texture source terms. + */ +static GLboolean +load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) +{ + const struct state_key *key = p->state; + GLuint i; + + for (i = 0; i < key->unit[unit].NumArgsRGB; i++) { + load_texenv_source( p, key->unit[unit].OptRGB[i].Source, unit ); + } + + for (i = 0; i < key->unit[unit].NumArgsA; i++) { + load_texenv_source( p, key->unit[unit].OptA[i].Source, unit ); + } + + return GL_TRUE; +} + +/** + * Generate instructions for loading bump map textures. + */ +static GLboolean +load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit ) +{ + const struct state_key *key = p->state; + GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0; + struct ureg texcDst, bumpMapRes; + struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0); + struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr); + struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit ); + struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit ); + + load_texenv_source( p, unit + SRC_TEXTURE0, unit ); + + bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit); + texcDst = get_tex_temp( p ); + p->texcoord_tex[bumpedUnitNr] = texcDst; + + /* Apply rot matrix and add coords to be available in next phase. + * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1) + * note only 2 coords are affected the rest are left unchanged (mul by 0) + */ + emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, + swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc ); + emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, + swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst ); + + /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish + * enough to access this later, should optimize away. + */ + emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0, + constdudvcolor, undef, undef ); + + return GL_TRUE; +} + +/** + * Generate a new fragment program which implements the context's + * current texture env/combine mode. + */ +static void +create_new_program(struct gl_context *ctx, struct state_key *key, + struct gl_fragment_program *program) +{ + struct prog_instruction instBuffer[MAX_INSTRUCTIONS]; + struct texenv_fragment_program p; + GLuint unit; + struct ureg cf, out; + int i; + + memset(&p, 0, sizeof(p)); + p.state = key; + p.program = program; + + /* During code generation, use locally-allocated instruction buffer, + * then alloc dynamic storage below. + */ + p.program->Base.Instructions = instBuffer; + p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; + p.program->Base.String = NULL; + p.program->Base.NumTexIndirections = 1; /* is this right? */ + p.program->Base.NumTexInstructions = 0; + p.program->Base.NumAluInstructions = 0; + p.program->Base.NumInstructions = 0; + p.program->Base.NumTemporaries = 0; + p.program->Base.NumParameters = 0; + p.program->Base.NumAttributes = 0; + p.program->Base.NumAddressRegs = 0; + p.program->Base.Parameters = _mesa_new_parameter_list(); + p.program->Base.InputsRead = 0x0; + + if (key->num_draw_buffers == 1) + p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; + else { + for (i = 0; i < key->num_draw_buffers; i++) + p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i)); + } + + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + p.src_texture[unit] = undef; + p.texcoord_tex[unit] = undef; + } + + p.src_previous = undef; + p.half = undef; + p.zero = undef; + p.one = undef; + + p.last_tex_stage = 0; + release_temps(ctx, &p); + + if (key->enabled_units) { + GLboolean needbumpstage = GL_FALSE; + + /* Zeroth pass - bump map textures first */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled && + key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + needbumpstage = GL_TRUE; + load_texunit_bumpmap( &p, unit ); + } + if (needbumpstage) + p.program->Base.NumTexIndirections++; + + /* First pass - to support texture_env_crossbar, first identify + * all referenced texture sources and emit texld instructions + * for each: + */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled) { + load_texunit_sources( &p, unit ); + p.last_tex_stage = unit; + } + + /* Second pass - emit combine instructions to build final color: + */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled) { + p.src_previous = emit_texenv( &p, unit ); + reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */ + release_temps(ctx, &p); /* release all temps */ + } + } + + cf = get_source( &p, SRC_PREVIOUS, 0 ); + + for (i = 0; i < key->num_draw_buffers; i++) { + if (key->num_draw_buffers == 1) + out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR ); + else { + out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i ); + } + + if (key->separate_specular) { + /* Emit specular add. + */ + struct ureg s = register_input(&p, FRAG_ATTRIB_COL1); + emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); + emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); + } + else if (memcmp(&cf, &out, sizeof(cf)) != 0) { + /* Will wind up in here if no texture enabled or a couple of + * other scenarios (GL_REPLACE for instance). + */ + emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef ); + } + } + /* Finish up: + */ + emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); + + if (key->fog_enabled) { + /* Pull fog mode from struct gl_context, the value in the state key is + * a reduced value and not what is expected in FogOption + */ + p.program->FogOption = ctx->Fog.Mode; + p.program->Base.InputsRead |= FRAG_BIT_FOGC; + } + else { + p.program->FogOption = GL_NONE; + } + + if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections) + program_error(&p, "Exceeded max nr indirect texture lookups"); + + if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions) + program_error(&p, "Exceeded max TEX instructions"); + + if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions) + program_error(&p, "Exceeded max ALU instructions"); + + ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); + + /* Allocate final instruction array */ + p.program->Base.Instructions + = _mesa_alloc_instructions(p.program->Base.NumInstructions); + if (!p.program->Base.Instructions) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "generating tex env program"); + return; + } + _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, + p.program->Base.NumInstructions); + + if (p.program->FogOption) { + _mesa_append_fog_code(ctx, p.program); + p.program->FogOption = GL_NONE; + } + + + /* Notify driver the fragment program has (actually) changed. + */ + if (ctx->Driver.ProgramStringNotify) { + GLboolean ok = ctx->Driver.ProgramStringNotify(ctx, + GL_FRAGMENT_PROGRAM_ARB, + &p.program->Base); + /* Driver should be able to handle any texenv programs as long as + * the driver correctly reported max number of texture units correctly, + * etc. + */ + ASSERT(ok); + (void) ok; /* silence unused var warning */ + } + + if (DISASSEM) { + _mesa_print_program(&p.program->Base); + printf("\n"); + } +} + + +/** + * Return a fragment program which implements the current + * fixed-function texture, fog and color-sum operations. + */ +struct gl_fragment_program * +_mesa_get_fixed_func_fragment_program(struct gl_context *ctx) +{ + struct gl_fragment_program *prog; + struct state_key key; + GLuint keySize; + + keySize = make_state_key(ctx, &key); + + prog = (struct gl_fragment_program *) + _mesa_search_program_cache(ctx->FragmentProgram.Cache, + &key, keySize); + + if (!prog) { + prog = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + + create_new_program(ctx, &key, prog); + + _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache, + &key, keySize, &prog->Base); + } + + return prog; +} diff --git a/mesalib/src/mesa/main/texenvprogram.h b/mesalib/src/mesa/main/texenvprogram.h index 0a162d2e7..0895ebacb 100644 --- a/mesalib/src/mesa/main/texenvprogram.h +++ b/mesalib/src/mesa/main/texenvprogram.h @@ -1,35 +1,35 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXENVPROGRAM_H -#define TEXENVPROGRAM_H - - -#include "mtypes.h" - -extern struct gl_fragment_program * -_mesa_get_fixed_func_fragment_program(GLcontext *ctx); - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXENVPROGRAM_H +#define TEXENVPROGRAM_H + + +struct gl_context; + +extern struct gl_fragment_program * +_mesa_get_fixed_func_fragment_program(struct gl_context *ctx); + +#endif diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/main/texfetch.c index c03bc71cd..812243a7b 100644 --- a/mesalib/src/mesa/main/texfetch.c +++ b/mesalib/src/mesa/main/texfetch.c @@ -1,798 +1,869 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texfetch.c - * - * Texel fetch/store functions - * - * \author Gareth Hughes - */ - - -#include "colormac.h" -#include "macros.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_s3tc.h" -#include "texfetch.h" - - -/** - * Convert an 8-bit sRGB value from non-linear space to a - * linear RGB value in [0, 1]. - * Implemented with a 256-entry lookup table. - */ -static INLINE GLfloat -nonlinear_to_linear(GLubyte cs8) -{ - static GLfloat table[256]; - static GLboolean tableReady = GL_FALSE; - if (!tableReady) { - /* compute lookup table now */ - GLuint i; - for (i = 0; i < 256; i++) { - const GLfloat cs = UBYTE_TO_FLOAT(i); - if (cs <= 0.04045) { - table[i] = cs / 12.92f; - } - else { - table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); - } - } - tableReady = GL_TRUE; - } - return table[cs8]; -} - - - -/* Texel fetch routines for all supported formats - */ -#define DIM 1 -#include "texfetch_tmp.h" - -#define DIM 2 -#include "texfetch_tmp.h" - -#define DIM 3 -#include "texfetch_tmp.h" - -/** - * Null texel fetch function. - * - * Have to have this so the FetchTexel function pointer is never NULL. - */ -static void fetch_null_texelf( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - (void) texImage; (void) i; (void) j; (void) k; - texel[RCOMP] = 0.0; - texel[GCOMP] = 0.0; - texel[BCOMP] = 0.0; - texel[ACOMP] = 0.0; - _mesa_warning(NULL, "fetch_null_texelf() called!"); -} - -static void store_null_texel(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* no-op */ -} - - - -/** - * Table to map MESA_FORMAT_ to texel fetch/store funcs. - * XXX this is somewhat temporary. - */ -static struct { - gl_format Name; - FetchTexelFuncF Fetch1D; - FetchTexelFuncF Fetch2D; - FetchTexelFuncF Fetch3D; - StoreTexelFunc StoreTexel; -} -texfetch_funcs[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, - fetch_null_texelf, - fetch_null_texelf, - fetch_null_texelf, - store_null_texel - }, - - { - MESA_FORMAT_RGBA8888, - fetch_texel_1d_f_rgba8888, - fetch_texel_2d_f_rgba8888, - fetch_texel_3d_f_rgba8888, - store_texel_rgba8888 - }, - { - MESA_FORMAT_RGBA8888_REV, - fetch_texel_1d_f_rgba8888_rev, - fetch_texel_2d_f_rgba8888_rev, - fetch_texel_3d_f_rgba8888_rev, - store_texel_rgba8888_rev - }, - { - MESA_FORMAT_ARGB8888, - fetch_texel_1d_f_argb8888, - fetch_texel_2d_f_argb8888, - fetch_texel_3d_f_argb8888, - store_texel_argb8888 - }, - { - MESA_FORMAT_ARGB8888_REV, - fetch_texel_1d_f_argb8888_rev, - fetch_texel_2d_f_argb8888_rev, - fetch_texel_3d_f_argb8888_rev, - store_texel_argb8888_rev - }, - { - MESA_FORMAT_XRGB8888, - fetch_texel_1d_f_xrgb8888, - fetch_texel_2d_f_xrgb8888, - fetch_texel_3d_f_xrgb8888, - store_texel_xrgb8888 - }, - { - MESA_FORMAT_XRGB8888_REV, - fetch_texel_1d_f_xrgb8888_rev, - fetch_texel_2d_f_xrgb8888_rev, - fetch_texel_3d_f_xrgb8888_rev, - store_texel_xrgb8888_rev, - }, - { - MESA_FORMAT_RGB888, - fetch_texel_1d_f_rgb888, - fetch_texel_2d_f_rgb888, - fetch_texel_3d_f_rgb888, - store_texel_rgb888 - }, - { - MESA_FORMAT_BGR888, - fetch_texel_1d_f_bgr888, - fetch_texel_2d_f_bgr888, - fetch_texel_3d_f_bgr888, - store_texel_bgr888 - }, - { - MESA_FORMAT_RGB565, - fetch_texel_1d_f_rgb565, - fetch_texel_2d_f_rgb565, - fetch_texel_3d_f_rgb565, - store_texel_rgb565 - }, - { - MESA_FORMAT_RGB565_REV, - fetch_texel_1d_f_rgb565_rev, - fetch_texel_2d_f_rgb565_rev, - fetch_texel_3d_f_rgb565_rev, - store_texel_rgb565_rev - }, - { - MESA_FORMAT_ARGB4444, - fetch_texel_1d_f_argb4444, - fetch_texel_2d_f_argb4444, - fetch_texel_3d_f_argb4444, - store_texel_argb4444 - }, - { - MESA_FORMAT_ARGB4444_REV, - fetch_texel_1d_f_argb4444_rev, - fetch_texel_2d_f_argb4444_rev, - fetch_texel_3d_f_argb4444_rev, - store_texel_argb4444_rev - }, - { - MESA_FORMAT_RGBA5551, - fetch_texel_1d_f_rgba5551, - fetch_texel_2d_f_rgba5551, - fetch_texel_3d_f_rgba5551, - store_texel_rgba5551 - }, - { - MESA_FORMAT_ARGB1555, - fetch_texel_1d_f_argb1555, - fetch_texel_2d_f_argb1555, - fetch_texel_3d_f_argb1555, - store_texel_argb1555 - }, - { - MESA_FORMAT_ARGB1555_REV, - fetch_texel_1d_f_argb1555_rev, - fetch_texel_2d_f_argb1555_rev, - fetch_texel_3d_f_argb1555_rev, - store_texel_argb1555_rev - }, - { - MESA_FORMAT_AL88, - fetch_texel_1d_f_al88, - fetch_texel_2d_f_al88, - fetch_texel_3d_f_al88, - store_texel_al88 - }, - { - MESA_FORMAT_AL88_REV, - fetch_texel_1d_f_al88_rev, - fetch_texel_2d_f_al88_rev, - fetch_texel_3d_f_al88_rev, - store_texel_al88_rev - }, - { - MESA_FORMAT_AL1616, - fetch_texel_1d_f_al1616, - fetch_texel_2d_f_al1616, - fetch_texel_3d_f_al1616, - store_texel_al1616 - }, - { - MESA_FORMAT_AL1616_REV, - fetch_texel_1d_f_al1616_rev, - fetch_texel_2d_f_al1616_rev, - fetch_texel_3d_f_al1616_rev, - store_texel_al1616_rev - }, - { - MESA_FORMAT_RGB332, - fetch_texel_1d_f_rgb332, - fetch_texel_2d_f_rgb332, - fetch_texel_3d_f_rgb332, - store_texel_rgb332 - }, - { - MESA_FORMAT_A8, - fetch_texel_1d_f_a8, - fetch_texel_2d_f_a8, - fetch_texel_3d_f_a8, - store_texel_a8 - }, - { - MESA_FORMAT_L8, - fetch_texel_1d_f_l8, - fetch_texel_2d_f_l8, - fetch_texel_3d_f_l8, - store_texel_l8 - }, - { - MESA_FORMAT_I8, - fetch_texel_1d_f_i8, - fetch_texel_2d_f_i8, - fetch_texel_3d_f_i8, - store_texel_i8 - }, - { - MESA_FORMAT_CI8, - fetch_texel_1d_f_ci8, - fetch_texel_2d_f_ci8, - fetch_texel_3d_f_ci8, - store_texel_ci8 - }, - { - MESA_FORMAT_YCBCR, - fetch_texel_1d_f_ycbcr, - fetch_texel_2d_f_ycbcr, - fetch_texel_3d_f_ycbcr, - store_texel_ycbcr - }, - { - MESA_FORMAT_YCBCR_REV, - fetch_texel_1d_f_ycbcr_rev, - fetch_texel_2d_f_ycbcr_rev, - fetch_texel_3d_f_ycbcr_rev, - store_texel_ycbcr_rev - }, - { - MESA_FORMAT_Z24_S8, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 - }, - { - MESA_FORMAT_S8_Z24, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 - }, - { - MESA_FORMAT_Z16, - fetch_texel_1d_f_z16, - fetch_texel_2d_f_z16, - fetch_texel_3d_f_z16, - store_texel_z16 - }, - { - MESA_FORMAT_X8_Z24, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 - }, - { - MESA_FORMAT_Z24_X8, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 - }, - { - MESA_FORMAT_Z32, - fetch_texel_1d_f_z32, - fetch_texel_2d_f_z32, - fetch_texel_3d_f_z32, - store_texel_z32 - }, - { - MESA_FORMAT_S8, - NULL, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_SRGB8, - fetch_texel_1d_srgb8, - fetch_texel_2d_srgb8, - fetch_texel_3d_srgb8, - store_texel_srgb8 - }, - { - MESA_FORMAT_SRGBA8, - fetch_texel_1d_srgba8, - fetch_texel_2d_srgba8, - fetch_texel_3d_srgba8, - store_texel_srgba8 - }, - { - MESA_FORMAT_SARGB8, - fetch_texel_1d_sargb8, - fetch_texel_2d_sargb8, - fetch_texel_3d_sargb8, - store_texel_sargb8 - }, - { - MESA_FORMAT_SL8, - fetch_texel_1d_sl8, - fetch_texel_2d_sl8, - fetch_texel_3d_sl8, - store_texel_sl8 - }, - { - MESA_FORMAT_SLA8, - fetch_texel_1d_sla8, - fetch_texel_2d_sla8, - fetch_texel_3d_sla8, - store_texel_sla8 - }, - { - MESA_FORMAT_SRGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt5, - NULL, - NULL - }, - - { - MESA_FORMAT_RGB_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt5, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FLOAT32, - fetch_texel_1d_f_rgba_f32, - fetch_texel_2d_f_rgba_f32, - fetch_texel_3d_f_rgba_f32, - store_texel_rgba_f32 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - fetch_texel_1d_f_rgba_f16, - fetch_texel_2d_f_rgba_f16, - fetch_texel_3d_f_rgba_f16, - store_texel_rgba_f16 - }, - { - MESA_FORMAT_RGB_FLOAT32, - fetch_texel_1d_f_rgb_f32, - fetch_texel_2d_f_rgb_f32, - fetch_texel_3d_f_rgb_f32, - store_texel_rgb_f32 - }, - { - MESA_FORMAT_RGB_FLOAT16, - fetch_texel_1d_f_rgb_f16, - fetch_texel_2d_f_rgb_f16, - fetch_texel_3d_f_rgb_f16, - store_texel_rgb_f16 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - fetch_texel_1d_f_alpha_f32, - fetch_texel_2d_f_alpha_f32, - fetch_texel_3d_f_alpha_f32, - store_texel_alpha_f32 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - fetch_texel_1d_f_alpha_f16, - fetch_texel_2d_f_alpha_f16, - fetch_texel_3d_f_alpha_f16, - store_texel_alpha_f16 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - fetch_texel_1d_f_luminance_f32, - fetch_texel_2d_f_luminance_f32, - fetch_texel_3d_f_luminance_f32, - store_texel_luminance_f32 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - fetch_texel_1d_f_luminance_f16, - fetch_texel_2d_f_luminance_f16, - fetch_texel_3d_f_luminance_f16, - store_texel_luminance_f16 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - fetch_texel_1d_f_luminance_alpha_f32, - fetch_texel_2d_f_luminance_alpha_f32, - fetch_texel_3d_f_luminance_alpha_f32, - store_texel_luminance_alpha_f32 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - fetch_texel_1d_f_luminance_alpha_f16, - fetch_texel_2d_f_luminance_alpha_f16, - fetch_texel_3d_f_luminance_alpha_f16, - store_texel_luminance_alpha_f16 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - fetch_texel_1d_f_intensity_f32, - fetch_texel_2d_f_intensity_f32, - fetch_texel_3d_f_intensity_f32, - store_texel_intensity_f32 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - fetch_texel_1d_f_intensity_f16, - fetch_texel_2d_f_intensity_f16, - fetch_texel_3d_f_intensity_f16, - store_texel_intensity_f16 - }, - - /* non-normalized, signed int */ - { - MESA_FORMAT_RGBA_INT8, - fetch_texel_1d_rgba_int8, - fetch_texel_2d_rgba_int8, - fetch_texel_3d_rgba_int8, - store_texel_rgba_int8 - }, - { - MESA_FORMAT_RGBA_INT16, - fetch_texel_1d_rgba_int16, - fetch_texel_2d_rgba_int16, - fetch_texel_3d_rgba_int16, - store_texel_rgba_int16 - }, - { - MESA_FORMAT_RGBA_INT32, - fetch_texel_1d_rgba_int32, - fetch_texel_2d_rgba_int32, - fetch_texel_3d_rgba_int32, - store_texel_rgba_int32 - }, - - /* non-normalized, unsigned int */ - { - MESA_FORMAT_RGBA_UINT8, - fetch_texel_1d_rgba_uint8, - fetch_texel_2d_rgba_uint8, - fetch_texel_3d_rgba_uint8, - store_texel_rgba_uint8 - }, - { - MESA_FORMAT_RGBA_UINT16, - fetch_texel_1d_rgba_uint16, - fetch_texel_2d_rgba_uint16, - fetch_texel_3d_rgba_uint16, - store_texel_rgba_uint16 - }, - { - MESA_FORMAT_RGBA_UINT32, - fetch_texel_1d_rgba_uint32, - fetch_texel_2d_rgba_uint32, - fetch_texel_3d_rgba_uint32, - store_texel_rgba_uint32 - }, - - /* dudv */ - { - MESA_FORMAT_DUDV8, - fetch_texel_1d_dudv8, - fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8, - NULL - }, - - /* signed, normalized */ - { - MESA_FORMAT_SIGNED_R8, - fetch_texel_1d_signed_r8, - fetch_texel_2d_signed_r8, - fetch_texel_3d_signed_r8, - store_texel_signed_r8 - }, - { - MESA_FORMAT_SIGNED_RG88, - fetch_texel_1d_signed_rg88, - fetch_texel_2d_signed_rg88, - fetch_texel_3d_signed_rg88, - store_texel_signed_rg88 - }, - { - MESA_FORMAT_SIGNED_RGBX8888, - fetch_texel_1d_signed_rgbx8888, - fetch_texel_2d_signed_rgbx8888, - fetch_texel_3d_signed_rgbx8888, - store_texel_signed_rgbx8888 - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - fetch_texel_1d_signed_rgba8888, - fetch_texel_2d_signed_rgba8888, - fetch_texel_3d_signed_rgba8888, - store_texel_signed_rgba8888 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - fetch_texel_1d_signed_rgba8888_rev, - fetch_texel_2d_signed_rgba8888_rev, - fetch_texel_3d_signed_rgba8888_rev, - store_texel_signed_rgba8888_rev - }, - { - MESA_FORMAT_SIGNED_R_16, - fetch_texel_1d_signed_r_16, - fetch_texel_2d_signed_r_16, - fetch_texel_3d_signed_r_16, - store_texel_signed_r_16 - }, - { - MESA_FORMAT_SIGNED_RG_16, - fetch_texel_1d_signed_rg_16, - fetch_texel_2d_signed_rg_16, - fetch_texel_3d_signed_rg_16, - store_texel_signed_rg_16 - }, - { - MESA_FORMAT_SIGNED_RGB_16, - fetch_texel_1d_signed_rgb_16, - fetch_texel_2d_signed_rgb_16, - fetch_texel_3d_signed_rgb_16, - store_texel_signed_rgb_16 - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - fetch_texel_1d_signed_rgba_16, - fetch_texel_2d_signed_rgba_16, - fetch_texel_3d_signed_rgba_16, - store_texel_signed_rgba_16 - }, - { - MESA_FORMAT_RGBA_16, - fetch_texel_1d_rgba_16, - fetch_texel_2d_rgba_16, - fetch_texel_3d_rgba_16, - store_texel_rgba_16 - } -}; - - -static FetchTexelFuncF -_mesa_get_texel_fetch_func(gl_format format, GLuint dims) -{ -#ifdef DEBUG - /* check that the table entries are sorted by format name */ - gl_format fmt; - for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { - assert(texfetch_funcs[fmt].Name == fmt); - } -#endif - - assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); - assert(format < MESA_FORMAT_COUNT); - - switch (dims) { - case 1: - return texfetch_funcs[format].Fetch1D; - case 2: - return texfetch_funcs[format].Fetch2D; - case 3: - return texfetch_funcs[format].Fetch3D; - default: - assert(0 && "bad dims in _mesa_get_texel_fetch_func"); - return NULL; - } -} - - -StoreTexelFunc -_mesa_get_texel_store_func(gl_format format) -{ - assert(format < MESA_FORMAT_COUNT); - return texfetch_funcs[format].StoreTexel; -} - - -/** - * Adaptor for fetching a GLchan texel from a float-valued texture. - */ -static void -fetch_texel_float_to_chan(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texelOut) -{ - GLfloat temp[4]; - GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - ASSERT(texImage->FetchTexelf); - texImage->FetchTexelf(texImage, i, j, k, temp); - if (baseFormat == GL_DEPTH_COMPONENT || - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* just one channel */ - UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); - } - else { - /* four channels */ - UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]); - } -} - - -#if 0 -/** - * Adaptor for fetching a float texel from a GLchan-valued texture. - */ -static void -fetch_texel_chan_to_float(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texelOut) -{ - GLchan temp[4]; - GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - ASSERT(texImage->FetchTexelc); - texImage->FetchTexelc(texImage, i, j, k, temp); - if (baseFormat == GL_DEPTH_COMPONENT || - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* just one channel */ - texelOut[0] = CHAN_TO_FLOAT(temp[0]); - } - else { - /* four channels */ - texelOut[0] = CHAN_TO_FLOAT(temp[0]); - texelOut[1] = CHAN_TO_FLOAT(temp[1]); - texelOut[2] = CHAN_TO_FLOAT(temp[2]); - texelOut[3] = CHAN_TO_FLOAT(temp[3]); - } -} -#endif - - -/** - * Initialize the texture image's FetchTexelc and FetchTexelf methods. - */ -void -_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) -{ - ASSERT(dims == 1 || dims == 2 || dims == 3); - ASSERT(texImage->TexFormat); - - if (!texImage->FetchTexelf) { - texImage->FetchTexelf = - _mesa_get_texel_fetch_func(texImage->TexFormat, dims); - } - - /* now check if we need to use a float/chan adaptor */ - if (!texImage->FetchTexelc) { - texImage->FetchTexelc = fetch_texel_float_to_chan; - } - - ASSERT(texImage->FetchTexelc); - ASSERT(texImage->FetchTexelf); -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texfetch.c + * + * Texel fetch/store functions + * + * \author Gareth Hughes + */ + + +#include "colormac.h" +#include "macros.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_s3tc.h" +#include "texfetch.h" + + +/** + * Convert an 8-bit sRGB value from non-linear space to a + * linear RGB value in [0, 1]. + * Implemented with a 256-entry lookup table. + */ +static INLINE GLfloat +nonlinear_to_linear(GLubyte cs8) +{ + static GLfloat table[256]; + static GLboolean tableReady = GL_FALSE; + if (!tableReady) { + /* compute lookup table now */ + GLuint i; + for (i = 0; i < 256; i++) { + const GLfloat cs = UBYTE_TO_FLOAT(i); + if (cs <= 0.04045) { + table[i] = cs / 12.92f; + } + else { + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); + } + } + tableReady = GL_TRUE; + } + return table[cs8]; +} + + + +/* Texel fetch routines for all supported formats + */ +#define DIM 1 +#include "texfetch_tmp.h" + +#define DIM 2 +#include "texfetch_tmp.h" + +#define DIM 3 +#include "texfetch_tmp.h" + +/** + * Null texel fetch function. + * + * Have to have this so the FetchTexel function pointer is never NULL. + */ +static void fetch_null_texelf( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + (void) texImage; (void) i; (void) j; (void) k; + texel[RCOMP] = 0.0; + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 0.0; + _mesa_warning(NULL, "fetch_null_texelf() called!"); +} + +static void store_null_texel(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; + /* no-op */ +} + + + +/** + * Table to map MESA_FORMAT_ to texel fetch/store funcs. + * XXX this is somewhat temporary. + */ +static struct { + gl_format Name; + FetchTexelFuncF Fetch1D; + FetchTexelFuncF Fetch2D; + FetchTexelFuncF Fetch3D; + StoreTexelFunc StoreTexel; +} +texfetch_funcs[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, + fetch_null_texelf, + fetch_null_texelf, + fetch_null_texelf, + store_null_texel + }, + + { + MESA_FORMAT_RGBA8888, + fetch_texel_1d_f_rgba8888, + fetch_texel_2d_f_rgba8888, + fetch_texel_3d_f_rgba8888, + store_texel_rgba8888 + }, + { + MESA_FORMAT_RGBA8888_REV, + fetch_texel_1d_f_rgba8888_rev, + fetch_texel_2d_f_rgba8888_rev, + fetch_texel_3d_f_rgba8888_rev, + store_texel_rgba8888_rev + }, + { + MESA_FORMAT_ARGB8888, + fetch_texel_1d_f_argb8888, + fetch_texel_2d_f_argb8888, + fetch_texel_3d_f_argb8888, + store_texel_argb8888 + }, + { + MESA_FORMAT_ARGB8888_REV, + fetch_texel_1d_f_argb8888_rev, + fetch_texel_2d_f_argb8888_rev, + fetch_texel_3d_f_argb8888_rev, + store_texel_argb8888_rev + }, + { + MESA_FORMAT_XRGB8888, + fetch_texel_1d_f_xrgb8888, + fetch_texel_2d_f_xrgb8888, + fetch_texel_3d_f_xrgb8888, + store_texel_xrgb8888 + }, + { + MESA_FORMAT_XRGB8888_REV, + fetch_texel_1d_f_xrgb8888_rev, + fetch_texel_2d_f_xrgb8888_rev, + fetch_texel_3d_f_xrgb8888_rev, + store_texel_xrgb8888_rev, + }, + { + MESA_FORMAT_RGB888, + fetch_texel_1d_f_rgb888, + fetch_texel_2d_f_rgb888, + fetch_texel_3d_f_rgb888, + store_texel_rgb888 + }, + { + MESA_FORMAT_BGR888, + fetch_texel_1d_f_bgr888, + fetch_texel_2d_f_bgr888, + fetch_texel_3d_f_bgr888, + store_texel_bgr888 + }, + { + MESA_FORMAT_RGB565, + fetch_texel_1d_f_rgb565, + fetch_texel_2d_f_rgb565, + fetch_texel_3d_f_rgb565, + store_texel_rgb565 + }, + { + MESA_FORMAT_RGB565_REV, + fetch_texel_1d_f_rgb565_rev, + fetch_texel_2d_f_rgb565_rev, + fetch_texel_3d_f_rgb565_rev, + store_texel_rgb565_rev + }, + { + MESA_FORMAT_ARGB4444, + fetch_texel_1d_f_argb4444, + fetch_texel_2d_f_argb4444, + fetch_texel_3d_f_argb4444, + store_texel_argb4444 + }, + { + MESA_FORMAT_ARGB4444_REV, + fetch_texel_1d_f_argb4444_rev, + fetch_texel_2d_f_argb4444_rev, + fetch_texel_3d_f_argb4444_rev, + store_texel_argb4444_rev + }, + { + MESA_FORMAT_RGBA5551, + fetch_texel_1d_f_rgba5551, + fetch_texel_2d_f_rgba5551, + fetch_texel_3d_f_rgba5551, + store_texel_rgba5551 + }, + { + MESA_FORMAT_ARGB1555, + fetch_texel_1d_f_argb1555, + fetch_texel_2d_f_argb1555, + fetch_texel_3d_f_argb1555, + store_texel_argb1555 + }, + { + MESA_FORMAT_ARGB1555_REV, + fetch_texel_1d_f_argb1555_rev, + fetch_texel_2d_f_argb1555_rev, + fetch_texel_3d_f_argb1555_rev, + store_texel_argb1555_rev + }, + { + MESA_FORMAT_AL44, + fetch_texel_1d_f_al44, + fetch_texel_2d_f_al44, + fetch_texel_3d_f_al44, + store_texel_al44 + }, + { + MESA_FORMAT_AL88, + fetch_texel_1d_f_al88, + fetch_texel_2d_f_al88, + fetch_texel_3d_f_al88, + store_texel_al88 + }, + { + MESA_FORMAT_AL88_REV, + fetch_texel_1d_f_al88_rev, + fetch_texel_2d_f_al88_rev, + fetch_texel_3d_f_al88_rev, + store_texel_al88_rev + }, + { + MESA_FORMAT_AL1616, + fetch_texel_1d_f_al1616, + fetch_texel_2d_f_al1616, + fetch_texel_3d_f_al1616, + store_texel_al1616 + }, + { + MESA_FORMAT_AL1616_REV, + fetch_texel_1d_f_al1616_rev, + fetch_texel_2d_f_al1616_rev, + fetch_texel_3d_f_al1616_rev, + store_texel_al1616_rev + }, + { + MESA_FORMAT_RGB332, + fetch_texel_1d_f_rgb332, + fetch_texel_2d_f_rgb332, + fetch_texel_3d_f_rgb332, + store_texel_rgb332 + }, + { + MESA_FORMAT_A8, + fetch_texel_1d_f_a8, + fetch_texel_2d_f_a8, + fetch_texel_3d_f_a8, + store_texel_a8 + }, + { + MESA_FORMAT_A16, + fetch_texel_1d_f_a16, + fetch_texel_2d_f_a16, + fetch_texel_3d_f_a16, + store_texel_a16 + }, + { + MESA_FORMAT_L8, + fetch_texel_1d_f_l8, + fetch_texel_2d_f_l8, + fetch_texel_3d_f_l8, + store_texel_l8 + }, + { + MESA_FORMAT_L16, + fetch_texel_1d_f_l16, + fetch_texel_2d_f_l16, + fetch_texel_3d_f_l16, + store_texel_l16 + }, + { + MESA_FORMAT_I8, + fetch_texel_1d_f_i8, + fetch_texel_2d_f_i8, + fetch_texel_3d_f_i8, + store_texel_i8 + }, + { + MESA_FORMAT_I16, + fetch_texel_1d_f_i16, + fetch_texel_2d_f_i16, + fetch_texel_3d_f_i16, + store_texel_i16 + }, + { + MESA_FORMAT_CI8, + fetch_texel_1d_f_ci8, + fetch_texel_2d_f_ci8, + fetch_texel_3d_f_ci8, + store_texel_ci8 + }, + { + MESA_FORMAT_YCBCR, + fetch_texel_1d_f_ycbcr, + fetch_texel_2d_f_ycbcr, + fetch_texel_3d_f_ycbcr, + store_texel_ycbcr + }, + { + MESA_FORMAT_YCBCR_REV, + fetch_texel_1d_f_ycbcr_rev, + fetch_texel_2d_f_ycbcr_rev, + fetch_texel_3d_f_ycbcr_rev, + store_texel_ycbcr_rev + }, + { + MESA_FORMAT_R8, + fetch_texel_1d_f_r8, + fetch_texel_2d_f_r8, + fetch_texel_3d_f_r8, + store_texel_r8, + }, + { + MESA_FORMAT_RG88, + fetch_texel_1d_f_rg88, + fetch_texel_2d_f_rg88, + fetch_texel_3d_f_rg88, + store_texel_rg88, + }, + { + MESA_FORMAT_RG88_REV, + fetch_texel_1d_f_rg88_rev, + fetch_texel_2d_f_rg88_rev, + fetch_texel_3d_f_rg88_rev, + store_texel_rg88_rev, + }, + { + MESA_FORMAT_R16, + fetch_texel_1d_f_r16, + fetch_texel_2d_f_r16, + fetch_texel_3d_f_r16, + store_texel_r16, + }, + { + MESA_FORMAT_RG1616, + fetch_texel_1d_f_rg1616, + fetch_texel_2d_f_rg1616, + fetch_texel_3d_f_rg1616, + store_texel_rg1616, + }, + { + MESA_FORMAT_RG1616_REV, + fetch_texel_1d_f_rg1616_rev, + fetch_texel_2d_f_rg1616_rev, + fetch_texel_3d_f_rg1616_rev, + store_texel_rg1616_rev, + }, + { + MESA_FORMAT_ARGB2101010, + fetch_texel_1d_f_argb2101010, + fetch_texel_2d_f_argb2101010, + fetch_texel_3d_f_argb2101010, + store_texel_argb2101010 + }, + { + MESA_FORMAT_Z24_S8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_S8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z16, + fetch_texel_1d_f_z16, + fetch_texel_2d_f_z16, + fetch_texel_3d_f_z16, + store_texel_z16 + }, + { + MESA_FORMAT_X8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z24_X8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_Z32, + fetch_texel_1d_f_z32, + fetch_texel_2d_f_z32, + fetch_texel_3d_f_z32, + store_texel_z32 + }, + { + MESA_FORMAT_S8, + NULL, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_SRGB8, + fetch_texel_1d_srgb8, + fetch_texel_2d_srgb8, + fetch_texel_3d_srgb8, + store_texel_srgb8 + }, + { + MESA_FORMAT_SRGBA8, + fetch_texel_1d_srgba8, + fetch_texel_2d_srgba8, + fetch_texel_3d_srgba8, + store_texel_srgba8 + }, + { + MESA_FORMAT_SARGB8, + fetch_texel_1d_sargb8, + fetch_texel_2d_sargb8, + fetch_texel_3d_sargb8, + store_texel_sargb8 + }, + { + MESA_FORMAT_SL8, + fetch_texel_1d_sl8, + fetch_texel_2d_sl8, + fetch_texel_3d_sl8, + store_texel_sl8 + }, + { + MESA_FORMAT_SLA8, + fetch_texel_1d_sla8, + fetch_texel_2d_sla8, + fetch_texel_3d_sla8, + store_texel_sla8 + }, + { + MESA_FORMAT_SRGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt5, + NULL, + NULL + }, + + { + MESA_FORMAT_RGB_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt5, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FLOAT32, + fetch_texel_1d_f_rgba_f32, + fetch_texel_2d_f_rgba_f32, + fetch_texel_3d_f_rgba_f32, + store_texel_rgba_f32 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + fetch_texel_1d_f_rgba_f16, + fetch_texel_2d_f_rgba_f16, + fetch_texel_3d_f_rgba_f16, + store_texel_rgba_f16 + }, + { + MESA_FORMAT_RGB_FLOAT32, + fetch_texel_1d_f_rgb_f32, + fetch_texel_2d_f_rgb_f32, + fetch_texel_3d_f_rgb_f32, + store_texel_rgb_f32 + }, + { + MESA_FORMAT_RGB_FLOAT16, + fetch_texel_1d_f_rgb_f16, + fetch_texel_2d_f_rgb_f16, + fetch_texel_3d_f_rgb_f16, + store_texel_rgb_f16 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + fetch_texel_1d_f_alpha_f32, + fetch_texel_2d_f_alpha_f32, + fetch_texel_3d_f_alpha_f32, + store_texel_alpha_f32 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + fetch_texel_1d_f_alpha_f16, + fetch_texel_2d_f_alpha_f16, + fetch_texel_3d_f_alpha_f16, + store_texel_alpha_f16 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + fetch_texel_1d_f_luminance_f32, + fetch_texel_2d_f_luminance_f32, + fetch_texel_3d_f_luminance_f32, + store_texel_luminance_f32 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + fetch_texel_1d_f_luminance_f16, + fetch_texel_2d_f_luminance_f16, + fetch_texel_3d_f_luminance_f16, + store_texel_luminance_f16 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + fetch_texel_1d_f_luminance_alpha_f32, + fetch_texel_2d_f_luminance_alpha_f32, + fetch_texel_3d_f_luminance_alpha_f32, + store_texel_luminance_alpha_f32 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + fetch_texel_1d_f_luminance_alpha_f16, + fetch_texel_2d_f_luminance_alpha_f16, + fetch_texel_3d_f_luminance_alpha_f16, + store_texel_luminance_alpha_f16 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + fetch_texel_1d_f_intensity_f32, + fetch_texel_2d_f_intensity_f32, + fetch_texel_3d_f_intensity_f32, + store_texel_intensity_f32 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + fetch_texel_1d_f_intensity_f16, + fetch_texel_2d_f_intensity_f16, + fetch_texel_3d_f_intensity_f16, + store_texel_intensity_f16 + }, + + /* non-normalized, signed int */ + { + MESA_FORMAT_RGBA_INT8, + fetch_texel_1d_rgba_int8, + fetch_texel_2d_rgba_int8, + fetch_texel_3d_rgba_int8, + store_texel_rgba_int8 + }, + { + MESA_FORMAT_RGBA_INT16, + fetch_texel_1d_rgba_int16, + fetch_texel_2d_rgba_int16, + fetch_texel_3d_rgba_int16, + store_texel_rgba_int16 + }, + { + MESA_FORMAT_RGBA_INT32, + fetch_texel_1d_rgba_int32, + fetch_texel_2d_rgba_int32, + fetch_texel_3d_rgba_int32, + store_texel_rgba_int32 + }, + + /* non-normalized, unsigned int */ + { + MESA_FORMAT_RGBA_UINT8, + fetch_texel_1d_rgba_uint8, + fetch_texel_2d_rgba_uint8, + fetch_texel_3d_rgba_uint8, + store_texel_rgba_uint8 + }, + { + MESA_FORMAT_RGBA_UINT16, + fetch_texel_1d_rgba_uint16, + fetch_texel_2d_rgba_uint16, + fetch_texel_3d_rgba_uint16, + store_texel_rgba_uint16 + }, + { + MESA_FORMAT_RGBA_UINT32, + fetch_texel_1d_rgba_uint32, + fetch_texel_2d_rgba_uint32, + fetch_texel_3d_rgba_uint32, + store_texel_rgba_uint32 + }, + + /* dudv */ + { + MESA_FORMAT_DUDV8, + fetch_texel_1d_dudv8, + fetch_texel_2d_dudv8, + fetch_texel_3d_dudv8, + NULL + }, + + /* signed, normalized */ + { + MESA_FORMAT_SIGNED_R8, + fetch_texel_1d_signed_r8, + fetch_texel_2d_signed_r8, + fetch_texel_3d_signed_r8, + store_texel_signed_r8 + }, + { + MESA_FORMAT_SIGNED_RG88, + fetch_texel_1d_signed_rg88, + fetch_texel_2d_signed_rg88, + fetch_texel_3d_signed_rg88, + store_texel_signed_rg88 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + fetch_texel_1d_signed_rgbx8888, + fetch_texel_2d_signed_rgbx8888, + fetch_texel_3d_signed_rgbx8888, + store_texel_signed_rgbx8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + fetch_texel_1d_signed_rgba8888, + fetch_texel_2d_signed_rgba8888, + fetch_texel_3d_signed_rgba8888, + store_texel_signed_rgba8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + fetch_texel_1d_signed_rgba8888_rev, + fetch_texel_2d_signed_rgba8888_rev, + fetch_texel_3d_signed_rgba8888_rev, + store_texel_signed_rgba8888_rev + }, + { + MESA_FORMAT_SIGNED_R_16, + fetch_texel_1d_signed_r_16, + fetch_texel_2d_signed_r_16, + fetch_texel_3d_signed_r_16, + store_texel_signed_r_16 + }, + { + MESA_FORMAT_SIGNED_RG_16, + fetch_texel_1d_signed_rg_16, + fetch_texel_2d_signed_rg_16, + fetch_texel_3d_signed_rg_16, + store_texel_signed_rg_16 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + fetch_texel_1d_signed_rgb_16, + fetch_texel_2d_signed_rgb_16, + fetch_texel_3d_signed_rgb_16, + store_texel_signed_rgb_16 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + fetch_texel_1d_signed_rgba_16, + fetch_texel_2d_signed_rgba_16, + fetch_texel_3d_signed_rgba_16, + store_texel_signed_rgba_16 + }, + { + MESA_FORMAT_RGBA_16, + fetch_texel_1d_rgba_16, + fetch_texel_2d_rgba_16, + fetch_texel_3d_rgba_16, + store_texel_rgba_16 + } +}; + + +static FetchTexelFuncF +_mesa_get_texel_fetch_func(gl_format format, GLuint dims) +{ +#ifdef DEBUG + /* check that the table entries are sorted by format name */ + gl_format fmt; + for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { + assert(texfetch_funcs[fmt].Name == fmt); + } +#endif + + assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + assert(format < MESA_FORMAT_COUNT); + + switch (dims) { + case 1: + return texfetch_funcs[format].Fetch1D; + case 2: + return texfetch_funcs[format].Fetch2D; + case 3: + return texfetch_funcs[format].Fetch3D; + default: + assert(0 && "bad dims in _mesa_get_texel_fetch_func"); + return NULL; + } +} + + +StoreTexelFunc +_mesa_get_texel_store_func(gl_format format) +{ + assert(format < MESA_FORMAT_COUNT); + return texfetch_funcs[format].StoreTexel; +} + + +/** + * Adaptor for fetching a GLchan texel from a float-valued texture. + */ +static void +fetch_texel_float_to_chan(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texelOut) +{ + GLfloat temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelf); + texImage->FetchTexelf(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + } + else { + /* four channels */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]); + } +} + + +#if 0 +/** + * Adaptor for fetching a float texel from a GLchan-valued texture. + */ +static void +fetch_texel_chan_to_float(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texelOut) +{ + GLchan temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelc); + texImage->FetchTexelc(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + } + else { + /* four channels */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + texelOut[1] = CHAN_TO_FLOAT(temp[1]); + texelOut[2] = CHAN_TO_FLOAT(temp[2]); + texelOut[3] = CHAN_TO_FLOAT(temp[3]); + } +} +#endif + + +/** + * Initialize the texture image's FetchTexelc and FetchTexelf methods. + */ +void +_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) +{ + ASSERT(dims == 1 || dims == 2 || dims == 3); + + texImage->FetchTexelf = + _mesa_get_texel_fetch_func(texImage->TexFormat, dims); + + texImage->FetchTexelc = fetch_texel_float_to_chan; + + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); +} diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/main/texfetch_tmp.h index f94355437..40f56209f 100644 --- a/mesalib/src/mesa/main/texfetch_tmp.h +++ b/mesalib/src/mesa/main/texfetch_tmp.h @@ -1,1768 +1,2040 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texfetch_tmp.h - * Texel fetch functions template. - * - * This template file is used by texfetch.c to generate texel fetch functions - * for 1-D, 2-D and 3-D texture images. - * - * It should be expanded by defining \p DIM as the number texture dimensions - * (1, 2 or 3). According to the value of \p DIM a series of macros is defined - * for the texel lookup in the gl_texture_image::Data. - * - * \author Gareth Hughes - * \author Brian Paul - */ - - -#if DIM == 1 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size))) - -#define FETCH(x) fetch_texel_1d_##x - -#elif DIM == 2 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((void) (k), \ - ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size))) - -#define FETCH(x) fetch_texel_2d_##x - -#elif DIM == 3 - -#define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((type *)(image)->Data + ((image)->ImageOffsets[k] \ - + (image)->RowStride * (j) + (i)) * (size)) - -#define FETCH(x) fetch_texel_3d_##x - -#else -#error illegal number of texture dimensions -#endif - - -/* MESA_FORMAT_Z32 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[0] = src[0] * (1.0F / 0xffffffff); -} - -#if DIM == 3 -static void store_texel_z32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLuint *depth = (const GLuint *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - dst[0] = *depth; -} -#endif - - -/* MESA_FORMAT_Z16 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[0] = src[0] * (1.0F / 65535.0F); -} - -#if DIM == 3 -static void store_texel_z16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *depth = (const GLushort *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - dst[0] = *depth; -} -#endif - - -/* MESA_FORMAT_RGBA_F32 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats. - */ -static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); - texel[RCOMP] = src[0]; - texel[GCOMP] = src[1]; - texel[BCOMP] = src[2]; - texel[ACOMP] = src[3]; -} - -#if DIM == 3 -static void store_texel_rgba_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *depth = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = depth[RCOMP]; - dst[1] = depth[GCOMP]; - dst[2] = depth[BCOMP]; - dst[3] = depth[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_F16 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); - texel[RCOMP] = _mesa_half_to_float(src[0]); - texel[GCOMP] = _mesa_half_to_float(src[1]); - texel[BCOMP] = _mesa_half_to_float(src[2]); - texel[ACOMP] = _mesa_half_to_float(src[3]); -} - -#if DIM == 3 -static void store_texel_rgba_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *depth = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(*depth); -} -#endif - -/* MESA_FORMAT_RGB_F32 *******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); - texel[RCOMP] = src[0]; - texel[GCOMP] = src[1]; - texel[BCOMP] = src[2]; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *depth = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = *depth; -} -#endif - - -/* MESA_FORMAT_RGB_F16 *******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); - texel[RCOMP] = _mesa_half_to_float(src[0]); - texel[GCOMP] = _mesa_half_to_float(src[1]); - texel[BCOMP] = _mesa_half_to_float(src[2]); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *depth = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(*depth); -} -#endif - - -/* MESA_FORMAT_ALPHA_F32 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = src[0]; -} - -#if DIM == 3 -static void store_texel_alpha_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_ALPHA_F32 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = _mesa_half_to_float(src[0]); -} - -#if DIM == 3 -static void store_texel_alpha_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_LUMINANCE_F32 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = src[0]; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_luminance_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_LUMINANCE_F16 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = _mesa_half_to_float(src[0]); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_luminance_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); -} -#endif - - -/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = src[0]; - texel[ACOMP] = src[1]; -} - -#if DIM == 3 -static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = _mesa_half_to_float(src[0]); - texel[ACOMP] = _mesa_half_to_float(src[1]); -} - -#if DIM == 3 -static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); - dst[1] = _mesa_float_to_half(rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_INTENSITY_F32 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = src[0]; -} - -#if DIM == 3 -static void store_texel_intensity_f32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_INTENSITY_F16 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = _mesa_half_to_float(src[0]); -} - -#if DIM == 3 -static void store_texel_intensity_f16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLfloat *rgba = (const GLfloat *) texel; - GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); - dst[0] = _mesa_float_to_half(rgba[RCOMP]); -} -#endif - - - - -/* - * Begin Hardware formats - */ - -/* MESA_FORMAT_RGBA8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ -static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); -} - - - -#if DIM == 3 -static void store_texel_rgba8888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_RGBA888_REV ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ -static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); -} - -#if DIM == 3 -static void store_texel_rgba8888_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_ARGB8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ -static void FETCH(f_argb8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); -} - -#if DIM == 3 -static void store_texel_argb8888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_ARGB8888_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); -} - -#if DIM == 3 -static void store_texel_argb8888_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_XRGB8888 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */ -static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); - texel[ACOMP] = 1.0f; -} - -#if DIM == 3 -static void store_texel_xrgb8888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_XRGB8888_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); - texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); - texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); - texel[ACOMP] = 1.0f; -} - -#if DIM == 3 -static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff); -} -#endif - - -/* MESA_FORMAT_RGB888 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ -static void FETCH(f_rgb888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[BCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_BGR888 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ -static void FETCH(f_bgr888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - texel[RCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_bgr888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; -} -#endif - - -/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) - instead of slow (g << 2) * 255 / 252 (always rounds down) */ - -/* MESA_FORMAT_RGB565 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ -static void FETCH(f_rgb565)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F); - texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb565(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_RGB565_REV ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ -static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ - texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); - texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); - texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb565_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); -} -#endif - - -/* MESA_FORMAT_ARGB4444 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ -static void FETCH(f_argb4444)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); - texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); - texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); -} - -#if DIM == 3 -static void store_texel_argb4444(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_ARGB4444_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ -static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); - texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); - texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); -} - -#if DIM == 3 -static void store_texel_argb4444_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); -} -#endif - -/* MESA_FORMAT_RGBA5551 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F); - texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = ((s ) & 0x01) * 1.0F; -} - -#if DIM == 3 -static void store_texel_rgba5551(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - -/* MESA_FORMAT_ARGB1555 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_argb1555)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = *src; - texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F); - texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F; -} - -#if DIM == 3 -static void store_texel_argb1555(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_ARGB1555_REV **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ -static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ - texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) ); - texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) ); - texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); - texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 ); -} - -#if DIM == 3 -static void store_texel_argb1555_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_AL88 **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ -static void FETCH(f_al88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); -} - -#if DIM == 3 -static void store_texel_al88(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]); -} -#endif - - -/* MESA_FORMAT_AL88_REV ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ -static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 ); - texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); -} - -#if DIM == 3 -static void store_texel_al88_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_AL1616 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */ -static void FETCH(f_al1616)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff ); - texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 ); -} - -#if DIM == 3 -static void store_texel_al1616(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]); -} -#endif - - -/* MESA_FORMAT_AL1616_REV ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */ -static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 ); - texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff ); -} - -#if DIM == 3 -static void store_texel_al1616_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]); -} -#endif - - -/* MESA_FORMAT_RGB332 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ -static void FETCH(f_rgb332)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - const GLubyte s = *src; - texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F); - texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F); - texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_rgb332(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - - -/* MESA_FORMAT_A8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ -static void FETCH(f_a8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); -} - -#if DIM == 3 -static void store_texel_a8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_L8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ -static void FETCH(f_l8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_l8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_I8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ -static void FETCH(f_i8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); -} - -#if DIM == 3 -static void store_texel_i8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_CI8 ***********************************************************/ - -/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a - * color table, and return 4 GLchans. - */ -static void FETCH(f_ci8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - const struct gl_color_table *palette; - GLuint index; - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Texture.SharedPalette) { - palette = &ctx->Texture.Palette; - } - else { - palette = &texImage->TexObject->Palette; - } - if (palette->Size == 0) - return; /* undefined results */ - - /* Mask the index against size of palette to avoid going out of bounds */ - index = (*src) & (palette->Size - 1); - - { - const GLfloat *table = palette->TableF; - switch (palette->_BaseFormat) { - case GL_ALPHA: - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = 0.0F; - texel[ACOMP] = table[index]; - break; - case GL_LUMINANCE: - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = table[index]; - texel[ACOMP] = 1.0F; - break; - case GL_INTENSITY: - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = - texel[ACOMP] = table[index]; - break; - case GL_LUMINANCE_ALPHA: - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = table[index * 2 + 0]; - texel[ACOMP] = table[index * 2 + 1]; - break; - case GL_RGB: - texel[RCOMP] = table[index * 3 + 0]; - texel[GCOMP] = table[index * 3 + 1]; - texel[BCOMP] = table[index * 3 + 2]; - texel[ACOMP] = 1.0F; - break; - case GL_RGBA: - texel[RCOMP] = table[index * 4 + 0]; - texel[GCOMP] = table[index * 4 + 1]; - texel[BCOMP] = table[index * 4 + 2]; - texel[ACOMP] = table[index * 4 + 3]; - break; - default: - _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8"); - return; - } - } -} - -#if DIM == 3 -static void store_texel_ci8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *index = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - *dst = *index; -} -#endif - - -/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */ -/* Note: component order is same as for MESA_FORMAT_RGB888 */ -static void FETCH(srgb8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - texel[RCOMP] = nonlinear_to_linear(src[2]); - texel[GCOMP] = nonlinear_to_linear(src[1]); - texel[BCOMP] = nonlinear_to_linear(src[0]); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_srgb8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); - dst[0] = rgba[BCOMP]; /* no conversion */ - dst[1] = rgba[GCOMP]; - dst[2] = rgba[RCOMP]; -} -#endif - -/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */ -static void FETCH(srgba8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = nonlinear_to_linear( (s >> 24) ); - texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff ); - texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */ -} - -#if DIM == 3 -static void store_texel_srgba8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - -/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */ -static void FETCH(sargb8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff ); - texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff ); - texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff ); - texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */ -} - -#if DIM == 3 -static void store_texel_sargb8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); -} -#endif - -/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ -static void FETCH(sl8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = nonlinear_to_linear(src[0]); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_sl8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - dst[0] = rgba[RCOMP]; -} -#endif - -/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */ -static void FETCH(sla8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); - texel[RCOMP] = - texel[GCOMP] = - texel[BCOMP] = nonlinear_to_linear(src[0]); - texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */ -} - -#if DIM == 3 -static void store_texel_sla8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_INT8 **************************************************/ - -static void -FETCH(rgba_int8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_int8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_INT16 **************************************************/ - -static void -FETCH(rgba_int16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_int16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_INT32 **************************************************/ - -static void -FETCH(rgba_int32)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_int32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLint *rgba = (const GLint *) texel; - GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_UINT8 **************************************************/ - -static void -FETCH(rgba_uint8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_uint8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_UINT16 **************************************************/ - -static void -FETCH(rgba_uint16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_uint16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_RGBA_UINT32 **************************************************/ - -static void -FETCH(rgba_uint32)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); - texel[RCOMP] = (GLfloat) src[0]; - texel[GCOMP] = (GLfloat) src[1]; - texel[BCOMP] = (GLfloat) src[2]; - texel[ACOMP] = (GLfloat) src[3]; -} - -#if DIM == 3 -static void -store_texel_rgba_uint32(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLuint *rgba = (const GLuint *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - -/* MESA_FORMAT_DUDV8 ********************************************************/ - -/* this format by definition produces 0,0,0,1 as rgba values, - however we'll return the dudv values as rg and fix up elsewhere */ -static void FETCH(dudv8)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2); - texel[RCOMP] = BYTE_TO_FLOAT(src[0]); - texel[GCOMP] = BYTE_TO_FLOAT(src[1]); - texel[BCOMP] = 0; - texel[ACOMP] = 0; -} - - -/* MESA_FORMAT_SIGNED_R8 ***********************************************/ - -static void FETCH(signed_r8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( s ); - texel[GCOMP] = 0.0F; - texel[BCOMP] = 0.0F; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_signed_r8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); - *dst = rgba[RCOMP]; -} -#endif - - -/* MESA_FORMAT_SIGNED_RG88 ***********************************************/ - -static void FETCH(signed_rg88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) ); - texel[BCOMP] = 0.0F; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_signed_rg88(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rg = (const GLbyte *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 2); - *dst = PACK_COLOR_88(rg[RCOMP], rg[GCOMP]); -} -#endif - - -/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/ - -static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); - texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); - texel[ACOMP] = 1.0f; -} - -#if DIM == 3 -static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255); -} -#endif - - -/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/ - -static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); - texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); - texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); -} - -#if DIM == 3 -static void store_texel_signed_rgba8888(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLbyte *rgba = (const GLbyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - -static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); - texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); - texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); - texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); -} - -#if DIM == 3 -static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLubyte *rgba = (const GLubyte *) texel; - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); -} -#endif - - - -/* MESA_FORMAT_SIGNED_R_16 ***********************************************/ - -static void -FETCH(signed_r_16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - texel[RCOMP] = SHORT_TO_FLOAT_TEX( s ); - texel[GCOMP] = 0.0F; - texel[BCOMP] = 0.0F; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void -store_texel_signed_r_16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); - *dst = rgba[0]; -} -#endif - - -/* MESA_FORMAT_SIGNED_RG_16 ***********************************************/ - -static void -FETCH(signed_rg_16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); - texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); - texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = 0.0F; - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void -store_texel_signed_rg_16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; -} -#endif - - -/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ - -static void -FETCH(signed_rgb_16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); - texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); - texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void -store_texel_signed_rgb_16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; -} -#endif - - -/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ - -static void -FETCH(signed_rgba_16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); - texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); - texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] ); -} - -#if DIM == 3 -static void -store_texel_signed_rgba_16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLshort *rgba = (const GLshort *) texel; - GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - - -/* MESA_FORMAT_RGBA_16 ***********************************************/ - -static void -FETCH(rgba_16)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); - texel[GCOMP] = USHORT_TO_FLOAT( s[1] ); - texel[BCOMP] = USHORT_TO_FLOAT( s[2] ); - texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); -} - -#if DIM == 3 -static void -store_texel_rgba_16(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - const GLushort *rgba = (const GLushort *) texel; - GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); - dst[0] = rgba[RCOMP]; - dst[1] = rgba[GCOMP]; - dst[2] = rgba[BCOMP]; - dst[3] = rgba[ACOMP]; -} -#endif - - - -/* MESA_FORMAT_YCBCR *********************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. - * We convert YCbCr to RGB here. - */ -static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ - const GLubyte cb = *src0 & 0xff; /* chroma U */ - const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ - const GLubyte cr = *src1 & 0xff; /* chroma V */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); - texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); - texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_ycbcr(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* XXX to do */ -} -#endif - - -/* MESA_FORMAT_YCBCR_REV *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats. - * We convert YCbCr to RGB here. - */ -static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ - const GLushort *src1 = src0 + 1; /* odd */ - const GLubyte y0 = *src0 & 0xff; /* luminance */ - const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ - const GLubyte y1 = *src1 & 0xff; /* luminance */ - const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ - const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); - GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); - GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); - r *= (1.0F / 255.0F); - g *= (1.0F / 255.0F); - b *= (1.0F / 255.0F); - texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); - texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); - texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); - texel[ACOMP] = 1.0F; -} - -#if DIM == 3 -static void store_texel_ycbcr_rev(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* XXX to do */ -} -#endif - - -/* MESA_TEXFORMAT_Z24_S8 ***************************************************/ - -static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* only return Z, not stencil data */ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - const GLfloat scale = 1.0F / (GLfloat) 0xffffff; - texel[0] = ((*src) >> 8) * scale; - ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8); - ASSERT(texel[0] >= 0.0F); - ASSERT(texel[0] <= 1.0F); -} - -#if DIM == 3 -static void store_texel_z24_s8(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - /* only store Z, not stencil */ - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLfloat depth = *((GLfloat *) texel); - GLuint zi = ((GLuint) (depth * 0xffffff)) << 8; - *dst = zi | (*dst & 0xff); -} -#endif - - -/* MESA_TEXFORMAT_S8_Z24 ***************************************************/ - -static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* only return Z, not stencil data */ - const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - const GLfloat scale = 1.0F / (GLfloat) 0xffffff; - texel[0] = ((*src) & 0x00ffffff) * scale; - ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24); - ASSERT(texel[0] >= 0.0F); - ASSERT(texel[0] <= 1.0F); -} - -#if DIM == 3 -static void store_texel_s8_z24(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - /* only store Z, not stencil */ - GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - GLfloat depth = *((GLfloat *) texel); - GLuint zi = (GLuint) (depth * 0xffffff); - *dst = zi | (*dst & 0xff000000); -} -#endif - - -#undef TEXEL_ADDR -#undef DIM -#undef FETCH +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texfetch_tmp.h + * Texel fetch functions template. + * + * This template file is used by texfetch.c to generate texel fetch functions + * for 1-D, 2-D and 3-D texture images. + * + * It should be expanded by defining \p DIM as the number texture dimensions + * (1, 2 or 3). According to the value of \p DIM a series of macros is defined + * for the texel lookup in the gl_texture_image::Data. + * + * \author Gareth Hughes + * \author Brian Paul + */ + + +#if DIM == 1 + +#define TEXEL_ADDR( type, image, i, j, k, size ) \ + ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size))) + +#define FETCH(x) fetch_texel_1d_##x + +#elif DIM == 2 + +#define TEXEL_ADDR( type, image, i, j, k, size ) \ + ((void) (k), \ + ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size))) + +#define FETCH(x) fetch_texel_2d_##x + +#elif DIM == 3 + +#define TEXEL_ADDR( type, image, i, j, k, size ) \ + ((type *)(image)->Data + ((image)->ImageOffsets[k] \ + + (image)->RowStride * (j) + (i)) * (size)) + +#define FETCH(x) fetch_texel_3d_##x + +#else +#error illegal number of texture dimensions +#endif + + +/* MESA_FORMAT_Z32 ***********************************************************/ + +/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, + * returning 1 GLfloat. + * Note: no GLchan version of this function. + */ +static void FETCH(f_z32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[0] = src[0] * (1.0F / 0xffffffff); +} + +#if DIM == 3 +static void store_texel_z32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLuint *depth = (const GLuint *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + dst[0] = *depth; +} +#endif + + +/* MESA_FORMAT_Z16 ***********************************************************/ + +/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, + * returning 1 GLfloat. + * Note: no GLchan version of this function. + */ +static void FETCH(f_z16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[0] = src[0] * (1.0F / 65535.0F); +} + +#if DIM == 3 +static void store_texel_z16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *depth = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + dst[0] = *depth; +} +#endif + + +/* MESA_FORMAT_RGBA_F32 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats. + */ +static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); + texel[RCOMP] = src[0]; + texel[GCOMP] = src[1]; + texel[BCOMP] = src[2]; + texel[ACOMP] = src[3]; +} + +#if DIM == 3 +static void store_texel_rgba_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *depth = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); + dst[0] = depth[RCOMP]; + dst[1] = depth[GCOMP]; + dst[2] = depth[BCOMP]; + dst[3] = depth[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_F16 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); + texel[RCOMP] = _mesa_half_to_float(src[0]); + texel[GCOMP] = _mesa_half_to_float(src[1]); + texel[BCOMP] = _mesa_half_to_float(src[2]); + texel[ACOMP] = _mesa_half_to_float(src[3]); +} + +#if DIM == 3 +static void store_texel_rgba_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *src = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); + dst[0] = _mesa_float_to_half(src[RCOMP]); + dst[1] = _mesa_float_to_half(src[GCOMP]); + dst[2] = _mesa_float_to_half(src[BCOMP]); + dst[3] = _mesa_float_to_half(src[ACOMP]); +} +#endif + +/* MESA_FORMAT_RGB_F32 *******************************************************/ + +/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); + texel[RCOMP] = src[0]; + texel[GCOMP] = src[1]; + texel[BCOMP] = src[2]; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *src = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); + dst[0] = src[RCOMP]; + dst[1] = src[GCOMP]; + dst[2] = src[BCOMP]; +} +#endif + + +/* MESA_FORMAT_RGB_F16 *******************************************************/ + +/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); + texel[RCOMP] = _mesa_half_to_float(src[0]); + texel[GCOMP] = _mesa_half_to_float(src[1]); + texel[BCOMP] = _mesa_half_to_float(src[2]); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *src = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); + dst[0] = _mesa_float_to_half(src[RCOMP]); + dst[1] = _mesa_float_to_half(src[GCOMP]); + dst[2] = _mesa_float_to_half(src[BCOMP]); +} +#endif + + +/* MESA_FORMAT_ALPHA_F32 *****************************************************/ + +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = src[0]; +} + +#if DIM == 3 +static void store_texel_alpha_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + dst[0] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_ALPHA_F32 *****************************************************/ + +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = _mesa_half_to_float(src[0]); +} + +#if DIM == 3 +static void store_texel_alpha_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + dst[0] = _mesa_float_to_half(rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_LUMINANCE_F32 *************************************************/ + +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = src[0]; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_luminance_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + dst[0] = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_LUMINANCE_F16 *************************************************/ + +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = _mesa_half_to_float(src[0]); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_luminance_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + dst[0] = _mesa_float_to_half(rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/ + +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = src[0]; + texel[ACOMP] = src[1]; +} + +#if DIM == 3 +static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/ + +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = _mesa_half_to_float(src[0]); + texel[ACOMP] = _mesa_half_to_float(src[1]); +} + +#if DIM == 3 +static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); + dst[0] = _mesa_float_to_half(rgba[RCOMP]); + dst[1] = _mesa_float_to_half(rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_INTENSITY_F32 *************************************************/ + +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = src[0]; +} + +#if DIM == 3 +static void store_texel_intensity_f32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLfloat *dst = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); + dst[0] = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_INTENSITY_F16 *************************************************/ + +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, + * returning 4 GLfloats. + */ +static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = _mesa_half_to_float(src[0]); +} + +#if DIM == 3 +static void store_texel_intensity_f16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLfloat *rgba = (const GLfloat *) texel; + GLhalfARB *dst = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); + dst[0] = _mesa_float_to_half(rgba[RCOMP]); +} +#endif + + + + +/* + * Begin Hardware formats + */ + +/* MESA_FORMAT_RGBA8888 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ +static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); +} + + + +#if DIM == 3 +static void store_texel_rgba8888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_RGBA888_REV ***************************************************/ + +/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ +static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); +} + +#if DIM == 3 +static void store_texel_rgba8888_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB8888 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ +static void FETCH(f_argb8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); +} + +#if DIM == 3 +static void store_texel_argb8888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB8888_REV **************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */ +static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); +} + +#if DIM == 3 +static void store_texel_argb8888_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_XRGB8888 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */ +static void FETCH(f_xrgb8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); + texel[ACOMP] = 1.0f; +} + +#if DIM == 3 +static void store_texel_xrgb8888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_XRGB8888_REV **************************************************/ + +/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */ +static void FETCH(f_xrgb8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[ACOMP] = 1.0f; +} + +#if DIM == 3 +static void store_texel_xrgb8888_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP], 0xff); +} +#endif + + +/* MESA_FORMAT_RGB888 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ +static void FETCH(f_rgb888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); + texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + dst[0] = rgba[BCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_BGR888 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ +static void FETCH(f_bgr888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + texel[RCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[BCOMP] = UBYTE_TO_FLOAT( src[2] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_bgr888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; +} +#endif + + +/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) + instead of slow (g << 2) * 255 / 252 (always rounds down) */ + +/* MESA_FORMAT_RGB565 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ +static void FETCH(f_rgb565)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = *src; + texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); + texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F); + texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb565(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_RGB565_REV ****************************************************/ + +/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ +static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb565_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB4444 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ +static void FETCH(f_argb4444)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = *src; + texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); + texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); + texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); + texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); +} + +#if DIM == 3 +static void store_texel_argb4444(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB4444_REV **************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ +static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); + texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); + texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); + texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); +} + +#if DIM == 3 +static void store_texel_argb4444_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]); +} +#endif + +/* MESA_FORMAT_RGBA5551 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ +static void FETCH(f_rgba5551)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = *src; + texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); + texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F); + texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F); + texel[ACOMP] = ((s ) & 0x01) * 1.0F; +} + +#if DIM == 3 +static void store_texel_rgba5551(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_5551(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + +/* MESA_FORMAT_ARGB1555 ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ +static void FETCH(f_argb1555)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = *src; + texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F); + texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F); + texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F); + texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F; +} + +#if DIM == 3 +static void store_texel_argb1555(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB1555_REV **************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ +static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) ); + texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 ); +} + +#if DIM == 3 +static void store_texel_argb1555_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_ARGB2101010 ***************************************************/ + +/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */ +static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + const GLuint s = *src; + texel[RCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F); + texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F); + texel[BCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F); + texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F); +} + +#if DIM == 3 +static void store_texel_argb2101010(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_2101010(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_RG88 **********************************************************/ + +/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */ +static void FETCH(f_rg88)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 ); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_rg88(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]); +} +#endif + + +/* MESA_FORMAT_RG88_REV ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */ +static void FETCH(f_rg88_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 ); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_rg88_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_88(rgba[GCOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_AL44 **********************************************************/ + +/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */ +static void FETCH(f_al44)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( (s & 0x0f) << 4 ); + texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xf0 ); +} + +#if DIM == 3 +static void store_texel_al44(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = PACK_COLOR_44(rgba[ACOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_AL88 **********************************************************/ + +/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ +static void FETCH(f_al88)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); +} + +#if DIM == 3 +static void store_texel_al88(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_R8 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */ +static void FETCH(f_r8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = UBYTE_TO_FLOAT(s); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_r8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_R16 ***********************************************************/ + +/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */ +static void FETCH(f_r16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = USHORT_TO_FLOAT(s); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_r16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_AL88_REV ******************************************************/ + +/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ +static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 ); + texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); +} + +#if DIM == 3 +static void store_texel_al88_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_RG1616 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */ +static void FETCH(f_rg1616)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = USHORT_TO_FLOAT( s & 0xffff ); + texel[GCOMP] = USHORT_TO_FLOAT( s >> 16 ); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_rg1616(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[GCOMP]); +} +#endif + + +/* MESA_FORMAT_RG1616_REV ****************************************************/ + +/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */ +static void FETCH(f_rg1616_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = USHORT_TO_FLOAT( s >> 16 ); + texel[GCOMP] = USHORT_TO_FLOAT( s & 0xffff ); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +#if DIM == 3 +static void store_texel_rg1616_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[GCOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_AL1616 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */ +static void FETCH(f_al1616)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff ); + texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 ); +} + +#if DIM == 3 +static void store_texel_al1616(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]); +} +#endif + + +/* MESA_FORMAT_AL1616_REV ****************************************************/ + +/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */ +static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 ); + texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff ); +} + +#if DIM == 3 +static void store_texel_al1616_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]); +} +#endif + + +/* MESA_FORMAT_RGB332 ********************************************************/ + +/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ +static void FETCH(f_rgb332)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + const GLubyte s = *src; + texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F); + texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F); + texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_rgb332(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + + +/* MESA_FORMAT_A8 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ +static void FETCH(f_a8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); +} + +#if DIM == 3 +static void store_texel_a8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_A16 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ +static void FETCH(f_a16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); +} + +#if DIM == 3 +static void store_texel_a16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_L8 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ +static void FETCH(f_l8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_l8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_L16 ***********************************************************/ + +/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */ +static void FETCH(f_l16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = USHORT_TO_FLOAT( src[0] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_l16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_I8 ************************************************************/ + +/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ +static void FETCH(f_i8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); +} + +#if DIM == 3 +static void store_texel_i8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_I16 ***********************************************************/ + +/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */ +static void FETCH(f_i16)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = USHORT_TO_FLOAT( src[0] ); +} + +#if DIM == 3 +static void store_texel_i16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_CI8 ***********************************************************/ + +/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a + * color table, and return 4 GLchans. + */ +static void FETCH(f_ci8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + const struct gl_color_table *palette; + GLuint index; + GET_CURRENT_CONTEXT(ctx); + + if (ctx->Texture.SharedPalette) { + palette = &ctx->Texture.Palette; + } + else { + palette = &texImage->TexObject->Palette; + } + if (palette->Size == 0) + return; /* undefined results */ + + /* Mask the index against size of palette to avoid going out of bounds */ + index = (*src) & (palette->Size - 1); + + { + const GLfloat *table = palette->TableF; + switch (palette->_BaseFormat) { + case GL_ALPHA: + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = 0.0F; + texel[ACOMP] = table[index]; + break; + case GL_LUMINANCE: + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = table[index]; + texel[ACOMP] = 1.0F; + break; + case GL_INTENSITY: + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = + texel[ACOMP] = table[index]; + break; + case GL_LUMINANCE_ALPHA: + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = table[index * 2 + 0]; + texel[ACOMP] = table[index * 2 + 1]; + break; + case GL_RGB: + texel[RCOMP] = table[index * 3 + 0]; + texel[GCOMP] = table[index * 3 + 1]; + texel[BCOMP] = table[index * 3 + 2]; + texel[ACOMP] = 1.0F; + break; + case GL_RGBA: + texel[RCOMP] = table[index * 4 + 0]; + texel[GCOMP] = table[index * 4 + 1]; + texel[BCOMP] = table[index * 4 + 2]; + texel[ACOMP] = table[index * 4 + 3]; + break; + default: + _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8"); + return; + } + } +} + +#if DIM == 3 +static void store_texel_ci8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *index = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + *dst = *index; +} +#endif + + +/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */ +/* Note: component order is same as for MESA_FORMAT_RGB888 */ +static void FETCH(srgb8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + texel[RCOMP] = nonlinear_to_linear(src[2]); + texel[GCOMP] = nonlinear_to_linear(src[1]); + texel[BCOMP] = nonlinear_to_linear(src[0]); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_srgb8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); + dst[0] = rgba[BCOMP]; /* no conversion */ + dst[1] = rgba[GCOMP]; + dst[2] = rgba[RCOMP]; +} +#endif + +/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */ +static void FETCH(srgba8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = nonlinear_to_linear( (s >> 24) ); + texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff ); + texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */ +} + +#if DIM == 3 +static void store_texel_srgba8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + +/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */ +static void FETCH(sargb8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff ); + texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff ); + texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */ +} + +#if DIM == 3 +static void store_texel_sargb8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); +} +#endif + +/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ +static void FETCH(sl8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = nonlinear_to_linear(src[0]); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_sl8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); + dst[0] = rgba[RCOMP]; +} +#endif + +/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */ +static void FETCH(sla8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = nonlinear_to_linear(src[0]); + texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */ +} + +#if DIM == 3 +static void store_texel_sla8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_INT8 **************************************************/ + +static void +FETCH(rgba_int8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_int8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLbyte *rgba = (const GLbyte *) texel; + GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_INT16 **************************************************/ + +static void +FETCH(rgba_int16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_int16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLshort *rgba = (const GLshort *) texel; + GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_INT32 **************************************************/ + +static void +FETCH(rgba_int32)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_int32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLint *rgba = (const GLint *) texel; + GLint *dst = TEXEL_ADDR(GLint, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_UINT8 **************************************************/ + +static void +FETCH(rgba_uint8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_uint8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_UINT16 **************************************************/ + +static void +FETCH(rgba_uint16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_uint16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_RGBA_UINT32 **************************************************/ + +static void +FETCH(rgba_uint32)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); + texel[RCOMP] = (GLfloat) src[0]; + texel[GCOMP] = (GLfloat) src[1]; + texel[BCOMP] = (GLfloat) src[2]; + texel[ACOMP] = (GLfloat) src[3]; +} + +#if DIM == 3 +static void +store_texel_rgba_uint32(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLuint *rgba = (const GLuint *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + +/* MESA_FORMAT_DUDV8 ********************************************************/ + +/* this format by definition produces 0,0,0,1 as rgba values, + however we'll return the dudv values as rg and fix up elsewhere */ +static void FETCH(dudv8)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2); + texel[RCOMP] = BYTE_TO_FLOAT(src[0]); + texel[GCOMP] = BYTE_TO_FLOAT(src[1]); + texel[BCOMP] = 0; + texel[ACOMP] = 0; +} + + +/* MESA_FORMAT_SIGNED_R8 ***********************************************/ + +static void FETCH(signed_r8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( s ); + texel[GCOMP] = 0.0F; + texel[BCOMP] = 0.0F; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_signed_r8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLbyte *rgba = (const GLbyte *) texel; + GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); + *dst = rgba[RCOMP]; +} +#endif + + +/* MESA_FORMAT_SIGNED_RG88 ***********************************************/ + +static void FETCH(signed_rg88)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) ); + texel[BCOMP] = 0.0F; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_signed_rg88(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLbyte *rg = (const GLbyte *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 2); + *dst = PACK_COLOR_88(rg[RCOMP], rg[GCOMP]); +} +#endif + + +/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/ + +static void FETCH(signed_rgbx8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[ACOMP] = 1.0f; +} + +#if DIM == 3 +static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLbyte *rgba = (const GLbyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255); +} +#endif + + +/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/ + +static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); +} + +#if DIM == 3 +static void store_texel_signed_rgba8888(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLbyte *rgba = (const GLbyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + +static void FETCH(signed_rgba8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); + texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) ); + texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); +} + +#if DIM == 3 +static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLubyte *rgba = (const GLubyte *) texel; + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]); +} +#endif + + + +/* MESA_FORMAT_SIGNED_R_16 ***********************************************/ + +static void +FETCH(signed_r_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); + texel[RCOMP] = SHORT_TO_FLOAT_TEX( s ); + texel[GCOMP] = 0.0F; + texel[BCOMP] = 0.0F; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void +store_texel_signed_r_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLshort *rgba = (const GLshort *) texel; + GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1); + *dst = rgba[0]; +} +#endif + + +/* MESA_FORMAT_SIGNED_RG_16 ***********************************************/ + +static void +FETCH(signed_rg_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); + texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); + texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); + texel[BCOMP] = 0.0F; + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void +store_texel_signed_rg_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLshort *rgba = (const GLshort *) texel; + GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; +} +#endif + + +/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ + +static void +FETCH(signed_rgb_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); + texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); + texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); + texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void +store_texel_signed_rgb_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLshort *rgba = (const GLshort *) texel; + GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; +} +#endif + + +/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ + +static void +FETCH(signed_rgba_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); + texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); + texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); + texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); + texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] ); +} + +#if DIM == 3 +static void +store_texel_signed_rgba_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLshort *rgba = (const GLshort *) texel; + GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + + +/* MESA_FORMAT_RGBA_16 ***********************************************/ + +static void +FETCH(rgba_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); + texel[GCOMP] = USHORT_TO_FLOAT( s[1] ); + texel[BCOMP] = USHORT_TO_FLOAT( s[2] ); + texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); +} + +#if DIM == 3 +static void +store_texel_rgba_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + + +/* MESA_FORMAT_YCBCR *********************************************************/ + +/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. + * We convert YCbCr to RGB here. + */ +static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ + const GLushort *src1 = src0 + 1; /* odd */ + const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ + const GLubyte cb = *src0 & 0xff; /* chroma U */ + const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ + const GLubyte cr = *src1 & 0xff; /* chroma V */ + const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ + GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); + GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); + GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); + r *= (1.0F / 255.0F); + g *= (1.0F / 255.0F); + b *= (1.0F / 255.0F); + texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); + texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); + texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_ycbcr(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; + /* XXX to do */ +} +#endif + + +/* MESA_FORMAT_YCBCR_REV *****************************************************/ + +/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats. + * We convert YCbCr to RGB here. + */ +static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ + const GLushort *src1 = src0 + 1; /* odd */ + const GLubyte y0 = *src0 & 0xff; /* luminance */ + const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ + const GLubyte y1 = *src1 & 0xff; /* luminance */ + const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ + const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ + GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); + GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); + GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); + r *= (1.0F / 255.0F); + g *= (1.0F / 255.0F); + b *= (1.0F / 255.0F); + texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); + texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); + texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); + texel[ACOMP] = 1.0F; +} + +#if DIM == 3 +static void store_texel_ycbcr_rev(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; + /* XXX to do */ +} +#endif + + +/* MESA_TEXFORMAT_Z24_S8 ***************************************************/ + +static void FETCH(f_z24_s8)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* only return Z, not stencil data */ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + const GLfloat scale = 1.0F / (GLfloat) 0xffffff; + texel[0] = ((*src) >> 8) * scale; + ASSERT(texImage->TexFormat == MESA_FORMAT_Z24_S8); + ASSERT(texel[0] >= 0.0F); + ASSERT(texel[0] <= 1.0F); +} + +#if DIM == 3 +static void store_texel_z24_s8(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + /* only store Z, not stencil */ + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + GLfloat depth = *((GLfloat *) texel); + GLuint zi = ((GLuint) (depth * 0xffffff)) << 8; + *dst = zi | (*dst & 0xff); +} +#endif + + +/* MESA_TEXFORMAT_S8_Z24 ***************************************************/ + +static void FETCH(f_s8_z24)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* only return Z, not stencil data */ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + const GLfloat scale = 1.0F / (GLfloat) 0xffffff; + texel[0] = ((*src) & 0x00ffffff) * scale; + ASSERT(texImage->TexFormat == MESA_FORMAT_S8_Z24); + ASSERT(texel[0] >= 0.0F); + ASSERT(texel[0] <= 1.0F); +} + +#if DIM == 3 +static void store_texel_s8_z24(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + /* only store Z, not stencil */ + GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + GLfloat depth = *((GLfloat *) texel); + GLuint zi = (GLuint) (depth * 0xffffff); + *dst = zi | (*dst & 0xff000000); +} +#endif + + +#undef TEXEL_ADDR +#undef DIM +#undef FETCH diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index b9271ef58..7b0b17b25 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -1,435 +1,468 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texformat.c - * Texture formats. - * - * \author Gareth Hughes - * \author Brian Paul - */ - - -#include "context.h" -#include "texcompress.h" -#include "texformat.h" - - -/** - * Choose an appropriate texture format given the format, type and - * internalFormat parameters passed to glTexImage(). - * - * \param ctx the GL context. - * \param internalFormat user's prefered internal texture format. - * \param format incoming image pixel format. - * \param type incoming image data type. - * - * \return a pointer to a gl_texture_format object which describes the - * choosen texture format, or NULL on failure. - * - * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers - * will typically override this function with a specialized version. - */ -gl_format -_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, - GLenum format, GLenum type ) -{ - (void) format; - (void) type; - - switch (internalFormat) { - /* shallow RGBA formats */ - case 4: - case GL_RGBA: - case GL_RGBA8: - return MESA_FORMAT_RGBA8888; - case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; - case GL_RGBA2: - return MESA_FORMAT_ARGB4444_REV; /* just to test another format*/ - case GL_RGBA4: - return MESA_FORMAT_ARGB4444; - - /* deep RGBA formats */ - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return MESA_FORMAT_RGBA_16; - - /* shallow RGB formats */ - case 3: - case GL_RGB: - case GL_RGB8: - return MESA_FORMAT_RGB888; - case GL_R3_G3_B2: - return MESA_FORMAT_RGB332; - case GL_RGB4: - return MESA_FORMAT_RGB565_REV; /* just to test another format */ - case GL_RGB5: - return MESA_FORMAT_RGB565; - - /* deep RGB formats */ - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return MESA_FORMAT_RGBA_16; - - /* Alpha formats */ - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_ALPHA8: - return MESA_FORMAT_A8; - - /* Luminance formats */ - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_LUMINANCE8: - return MESA_FORMAT_L8; - - /* Luminance/Alpha formats */ - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - return MESA_FORMAT_AL88; - - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return MESA_FORMAT_AL1616; - - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY12: - case GL_INTENSITY16: - case GL_INTENSITY8: - return MESA_FORMAT_I8; - - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - case GL_COLOR_INDEX8_EXT: - return MESA_FORMAT_CI8; - - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.ARB_depth_texture) { - switch (internalFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return MESA_FORMAT_Z32; - case GL_DEPTH_COMPONENT16: - return MESA_FORMAT_Z16; - default: - ; /* fallthrough */ - } - } - - switch (internalFormat) { - case GL_COMPRESSED_ALPHA_ARB: - return MESA_FORMAT_A8; - case GL_COMPRESSED_LUMINANCE_ARB: - return MESA_FORMAT_L8; - case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - return MESA_FORMAT_AL88; - case GL_COMPRESSED_INTENSITY_ARB: - return MESA_FORMAT_I8; - case GL_COMPRESSED_RGB_ARB: - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - return MESA_FORMAT_RGB_DXT1; - if (ctx->Extensions.TDFX_texture_compression_FXT1) - return MESA_FORMAT_RGB_FXT1; - return MESA_FORMAT_RGB888; - case GL_COMPRESSED_RGBA_ARB: - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - return MESA_FORMAT_RGBA_DXT3; /* Not rgba_dxt1, see spec */ - if (ctx->Extensions.TDFX_texture_compression_FXT1) - return MESA_FORMAT_RGBA_FXT1; - return MESA_FORMAT_RGBA8888; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.MESA_ycbcr_texture) { - if (internalFormat == GL_YCBCR_MESA) { - if (type == GL_UNSIGNED_SHORT_8_8_MESA) - return MESA_FORMAT_YCBCR; - else - return MESA_FORMAT_YCBCR_REV; - } - } - -#if FEATURE_texture_fxt1 - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - default: - ; /* fallthrough */ - } - } -#endif - -#if FEATURE_texture_s3tc - if (ctx->Extensions.EXT_texture_compression_s3tc) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.S3_s3tc) { - switch (internalFormat) { - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT3; - default: - ; /* fallthrough */ - } - } -#endif - - if (ctx->Extensions.ARB_texture_float) { - switch (internalFormat) { - case GL_ALPHA16F_ARB: - return MESA_FORMAT_ALPHA_FLOAT16; - case GL_ALPHA32F_ARB: - return MESA_FORMAT_ALPHA_FLOAT32; - case GL_LUMINANCE16F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT16; - case GL_LUMINANCE32F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT32; - case GL_LUMINANCE_ALPHA16F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; - case GL_LUMINANCE_ALPHA32F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; - case GL_INTENSITY16F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT16; - case GL_INTENSITY32F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT32; - case GL_RGB16F_ARB: - return MESA_FORMAT_RGB_FLOAT16; - case GL_RGB32F_ARB: - return MESA_FORMAT_RGB_FLOAT32; - case GL_RGBA16F_ARB: - return MESA_FORMAT_RGBA_FLOAT16; - case GL_RGBA32F_ARB: - return MESA_FORMAT_RGBA_FLOAT32; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_packed_depth_stencil) { - switch (internalFormat) { - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return MESA_FORMAT_Z24_S8; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ATI_envmap_bumpmap) { - switch (internalFormat) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return MESA_FORMAT_DUDV8; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.MESA_texture_signed_rgba) { - switch (internalFormat) { - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - return MESA_FORMAT_SIGNED_RGBA8888; - default: - ; /* fallthrough */ - } - } - - if (ctx->VersionMajor * 10 + ctx->VersionMinor >= 31) { - switch (internalFormat) { - case GL_RED_SNORM: - case GL_R8_SNORM: - return MESA_FORMAT_SIGNED_R8; - case GL_RG_SNORM: - case GL_RG8_SNORM: - return MESA_FORMAT_SIGNED_RG88; - case GL_RGB_SNORM: - case GL_RGB8_SNORM: - return MESA_FORMAT_SIGNED_RGBX8888; - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - return MESA_FORMAT_SIGNED_RGBA8888; - case GL_R16_SNORM: - return MESA_FORMAT_SIGNED_R_16; - case GL_RG16_SNORM: - return MESA_FORMAT_SIGNED_RG_16; - case GL_RGB16_SNORM: - return MESA_FORMAT_SIGNED_RGB_16; - case GL_RGBA16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; - default: - ; /* fall-through */ - } - } - -#if FEATURE_EXT_texture_sRGB - if (ctx->Extensions.EXT_texture_sRGB) { - switch (internalFormat) { - case GL_SRGB_EXT: - case GL_SRGB8_EXT: - return MESA_FORMAT_SRGB8; - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - return MESA_FORMAT_SRGBA8; - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: - return MESA_FORMAT_SL8; - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: - return MESA_FORMAT_SLA8; - case GL_COMPRESSED_SLUMINANCE_EXT: - return MESA_FORMAT_SL8; - case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - return MESA_FORMAT_SLA8; - case GL_COMPRESSED_SRGB_EXT: -#if FEATURE_texture_s3tc - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGB_DXT1; -#endif - return MESA_FORMAT_SRGB8; - case GL_COMPRESSED_SRGB_ALPHA_EXT: -#if FEATURE_texture_s3tc - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT3; /* Not srgba_dxt1, see spec */ -#endif - return MESA_FORMAT_SRGBA8; -#if FEATURE_texture_s3tc - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGB_DXT1; - break; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT1; - break; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT3; - break; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT5; - break; -#endif - default: - ; /* fallthrough */ - } - } -#endif /* FEATURE_EXT_texture_sRGB */ - - if (ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_RGBA32UI_EXT: - case GL_RGB32UI_EXT: - case GL_ALPHA32UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - return MESA_FORMAT_RGBA_UINT32; - case GL_RGBA16UI_EXT: - case GL_RGB16UI_EXT: - case GL_ALPHA16UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - return MESA_FORMAT_RGBA_UINT16; - case GL_RGBA8UI_EXT: - case GL_RGB8UI_EXT: - case GL_ALPHA8UI_EXT: - case GL_INTENSITY8UI_EXT: - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE_ALPHA8UI_EXT: - return MESA_FORMAT_RGBA_UINT8; - case GL_RGBA32I_EXT: - case GL_RGB32I_EXT: - case GL_ALPHA32I_EXT: - case GL_INTENSITY32I_EXT: - case GL_LUMINANCE32I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - return MESA_FORMAT_RGBA_INT32; - case GL_RGBA16I_EXT: - case GL_RGB16I_EXT: - case GL_ALPHA16I_EXT: - case GL_INTENSITY16I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - return MESA_FORMAT_RGBA_INT16; - case GL_RGBA8I_EXT: - case GL_RGB8I_EXT: - case GL_ALPHA8I_EXT: - case GL_INTENSITY8I_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - return MESA_FORMAT_RGBA_INT8; - } - } - - _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); - return MESA_FORMAT_NONE; -} - +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texformat.c + * Texture formats. + * + * \author Gareth Hughes + * \author Brian Paul + */ + + +#include "context.h" +#include "texcompress.h" +#include "texformat.h" + + +/** + * Choose an appropriate texture format given the format, type and + * internalFormat parameters passed to glTexImage(). + * + * \param ctx the GL context. + * \param internalFormat user's prefered internal texture format. + * \param format incoming image pixel format. + * \param type incoming image data type. + * + * \return a pointer to a gl_texture_format object which describes the + * choosen texture format, or NULL on failure. + * + * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers + * will typically override this function with a specialized version. + */ +gl_format +_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, + GLenum format, GLenum type ) +{ + (void) format; + (void) type; + + switch (internalFormat) { + /* shallow RGBA formats */ + case 4: + case GL_RGBA: + case GL_RGBA8: + return MESA_FORMAT_RGBA8888; + case GL_RGB5_A1: + return MESA_FORMAT_ARGB1555; + case GL_RGBA2: + return MESA_FORMAT_ARGB4444_REV; /* just to test another format*/ + case GL_RGBA4: + return MESA_FORMAT_ARGB4444; + + /* deep RGBA formats */ + case GL_RGB10_A2: + return MESA_FORMAT_ARGB2101010; + + case GL_RGBA12: + case GL_RGBA16: + return MESA_FORMAT_RGBA_16; + + /* shallow RGB formats */ + case 3: + case GL_RGB: + case GL_RGB8: + return MESA_FORMAT_RGB888; + case GL_R3_G3_B2: + return MESA_FORMAT_RGB332; + case GL_RGB4: + return MESA_FORMAT_RGB565_REV; /* just to test another format */ + case GL_RGB5: + return MESA_FORMAT_RGB565; + + /* deep RGB formats */ + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return MESA_FORMAT_RGBA_16; + + /* Alpha formats */ + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + return MESA_FORMAT_A8; + + case GL_ALPHA12: + case GL_ALPHA16: + return MESA_FORMAT_A16; + + /* Luminance formats */ + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + return MESA_FORMAT_L8; + + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return MESA_FORMAT_L16; + + /* Luminance/Alpha formats */ + case GL_LUMINANCE4_ALPHA4: + return MESA_FORMAT_AL44; + + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + return MESA_FORMAT_AL88; + + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return MESA_FORMAT_AL1616; + + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + return MESA_FORMAT_I8; + + case GL_INTENSITY12: + case GL_INTENSITY16: + return MESA_FORMAT_I16; + + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + case GL_COLOR_INDEX8_EXT: + return MESA_FORMAT_CI8; + + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.ARB_depth_texture) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return MESA_FORMAT_Z32; + case GL_DEPTH_COMPONENT16: + return MESA_FORMAT_Z16; + default: + ; /* fallthrough */ + } + } + + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + return MESA_FORMAT_A8; + case GL_COMPRESSED_LUMINANCE_ARB: + return MESA_FORMAT_L8; + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + return MESA_FORMAT_AL88; + case GL_COMPRESSED_INTENSITY_ARB: + return MESA_FORMAT_I8; + case GL_COMPRESSED_RGB_ARB: + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + return MESA_FORMAT_RGB_DXT1; + if (ctx->Extensions.TDFX_texture_compression_FXT1) + return MESA_FORMAT_RGB_FXT1; + return MESA_FORMAT_RGB888; + case GL_COMPRESSED_RGBA_ARB: + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + return MESA_FORMAT_RGBA_DXT3; /* Not rgba_dxt1, see spec */ + if (ctx->Extensions.TDFX_texture_compression_FXT1) + return MESA_FORMAT_RGBA_FXT1; + return MESA_FORMAT_RGBA8888; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.MESA_ycbcr_texture) { + if (internalFormat == GL_YCBCR_MESA) { + if (type == GL_UNSIGNED_SHORT_8_8_MESA) + return MESA_FORMAT_YCBCR; + else + return MESA_FORMAT_YCBCR_REV; + } + } + +#if FEATURE_texture_fxt1 + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return MESA_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return MESA_FORMAT_RGBA_FXT1; + default: + ; /* fallthrough */ + } + } +#endif + +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return MESA_FORMAT_RGB_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return MESA_FORMAT_RGBA_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return MESA_FORMAT_RGBA_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return MESA_FORMAT_RGBA_DXT5; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.S3_s3tc) { + switch (internalFormat) { + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + return MESA_FORMAT_RGB_DXT1; + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return MESA_FORMAT_RGBA_DXT3; + default: + ; /* fallthrough */ + } + } +#endif + + if (ctx->Extensions.ARB_texture_float) { + switch (internalFormat) { + case GL_ALPHA16F_ARB: + return MESA_FORMAT_ALPHA_FLOAT16; + case GL_ALPHA32F_ARB: + return MESA_FORMAT_ALPHA_FLOAT32; + case GL_LUMINANCE16F_ARB: + return MESA_FORMAT_LUMINANCE_FLOAT16; + case GL_LUMINANCE32F_ARB: + return MESA_FORMAT_LUMINANCE_FLOAT32; + case GL_LUMINANCE_ALPHA16F_ARB: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; + case GL_LUMINANCE_ALPHA32F_ARB: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; + case GL_INTENSITY16F_ARB: + return MESA_FORMAT_INTENSITY_FLOAT16; + case GL_INTENSITY32F_ARB: + return MESA_FORMAT_INTENSITY_FLOAT32; + case GL_RGB16F_ARB: + return MESA_FORMAT_RGB_FLOAT16; + case GL_RGB32F_ARB: + return MESA_FORMAT_RGB_FLOAT32; + case GL_RGBA16F_ARB: + return MESA_FORMAT_RGBA_FLOAT16; + case GL_RGBA32F_ARB: + return MESA_FORMAT_RGBA_FLOAT32; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_depth_stencil) { + switch (internalFormat) { + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return MESA_FORMAT_Z24_S8; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ATI_envmap_bumpmap) { + switch (internalFormat) { + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return MESA_FORMAT_DUDV8; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_texture_signed_rgba) { + switch (internalFormat) { + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + return MESA_FORMAT_SIGNED_RGBA8888; + default: + ; /* fallthrough */ + } + } + + if (ctx->VersionMajor * 10 + ctx->VersionMinor >= 31) { + switch (internalFormat) { + case GL_RED_SNORM: + case GL_R8_SNORM: + return MESA_FORMAT_SIGNED_R8; + case GL_RG_SNORM: + case GL_RG8_SNORM: + return MESA_FORMAT_SIGNED_RG88; + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + return MESA_FORMAT_SIGNED_RGBX8888; + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + return MESA_FORMAT_SIGNED_RGBA8888; + case GL_R16_SNORM: + return MESA_FORMAT_SIGNED_R_16; + case GL_RG16_SNORM: + return MESA_FORMAT_SIGNED_RG_16; + case GL_RGB16_SNORM: + return MESA_FORMAT_SIGNED_RGB_16; + case GL_RGBA16_SNORM: + return MESA_FORMAT_SIGNED_RGBA_16; + default: + ; /* fall-through */ + } + } + +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + switch (internalFormat) { + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + return MESA_FORMAT_SRGB8; + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + return MESA_FORMAT_SRGBA8; + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + return MESA_FORMAT_SL8; + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + return MESA_FORMAT_SLA8; + case GL_COMPRESSED_SLUMINANCE_EXT: + return MESA_FORMAT_SL8; + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + return MESA_FORMAT_SLA8; + case GL_COMPRESSED_SRGB_EXT: +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGB_DXT1; +#endif + return MESA_FORMAT_SRGB8; + case GL_COMPRESSED_SRGB_ALPHA_EXT: +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGBA_DXT3; /* Not srgba_dxt1, see spec */ +#endif + return MESA_FORMAT_SRGBA8; +#if FEATURE_texture_s3tc + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGB_DXT1; + break; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGBA_DXT1; + break; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGBA_DXT3; + break; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return MESA_FORMAT_SRGBA_DXT5; + break; +#endif + default: + ; /* fallthrough */ + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + + if (ctx->Extensions.EXT_texture_integer) { + switch (internalFormat) { + case GL_RGBA32UI_EXT: + case GL_RGB32UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + return MESA_FORMAT_RGBA_UINT32; + case GL_RGBA16UI_EXT: + case GL_RGB16UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + return MESA_FORMAT_RGBA_UINT16; + case GL_RGBA8UI_EXT: + case GL_RGB8UI_EXT: + case GL_ALPHA8UI_EXT: + case GL_INTENSITY8UI_EXT: + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE_ALPHA8UI_EXT: + return MESA_FORMAT_RGBA_UINT8; + case GL_RGBA32I_EXT: + case GL_RGB32I_EXT: + case GL_ALPHA32I_EXT: + case GL_INTENSITY32I_EXT: + case GL_LUMINANCE32I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + return MESA_FORMAT_RGBA_INT32; + case GL_RGBA16I_EXT: + case GL_RGB16I_EXT: + case GL_ALPHA16I_EXT: + case GL_INTENSITY16I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + return MESA_FORMAT_RGBA_INT16; + case GL_RGBA8I_EXT: + case GL_RGB8I_EXT: + case GL_ALPHA8I_EXT: + case GL_INTENSITY8I_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + return MESA_FORMAT_RGBA_INT8; + } + } + + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R8: + case GL_RED: + case GL_COMPRESSED_RED: + return MESA_FORMAT_R8; + + case GL_R16: + return MESA_FORMAT_R16; + + case GL_RG: + case GL_RG8: + case GL_COMPRESSED_RG: + return MESA_FORMAT_RG88; + + case GL_RG16: + return MESA_FORMAT_RG1616; + + default: + ; /* fallthrough */ + } + } + + _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); + return MESA_FORMAT_NONE; +} + diff --git a/mesalib/src/mesa/main/texformat.h b/mesalib/src/mesa/main/texformat.h index bda5fd6d8..b84117995 100644 --- a/mesalib/src/mesa/main/texformat.h +++ b/mesalib/src/mesa/main/texformat.h @@ -1,39 +1,39 @@ -/* - * Mesa 3-D graphics library - * Version: 7.75 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TEXFORMAT_H -#define TEXFORMAT_H - - -#include "mtypes.h" -#include "formats.h" - - -extern gl_format -_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, - GLenum format, GLenum type ); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.75 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef TEXFORMAT_H +#define TEXFORMAT_H + + +#include "formats.h" + +struct gl_context; + +extern gl_format +_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, + GLenum format, GLenum type ); + + +#endif diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 00134ea9f..227a670da 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -1,883 +1,915 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Code for glGetTexImage() and glGetCompressedTexImage(). - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "enums.h" -#include "context.h" -#include "formats.h" -#include "image.h" -#include "texgetimage.h" -#include "teximage.h" - - - -/** - * Can the given type represent negative values? - */ -static INLINE GLboolean -type_with_negative_values(GLenum type) -{ - switch (type) { - case GL_BYTE: - case GL_SHORT: - case GL_INT: - case GL_FLOAT: - case GL_HALF_FLOAT_ARB: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * glGetTexImage for color index pixels. - */ -static void -get_tex_color_index(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLuint indexBits = - _mesa_get_format_bits(texImage->TexFormat, GL_TEXTURE_INDEX_SIZE_EXT); - const GLbitfield transferOps = 0x0; - GLint img, row, col; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - GLuint indexRow[MAX_WIDTH] = { 0 }; - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - assert(dest); - - if (indexBits == 8) { - const GLubyte *src = (const GLubyte *) texImage->Data; - src += width * (img * texImage->Height + row); - for (col = 0; col < width; col++) { - indexRow[col] = src[col]; - } - } - else if (indexBits == 16) { - const GLushort *src = (const GLushort *) texImage->Data; - src += width * (img * texImage->Height + row); - for (col = 0; col < width; col++) { - indexRow[col] = src[col]; - } - } - else { - _mesa_problem(ctx, "Color index problem in _mesa_GetTexImage"); - } - _mesa_pack_index_span(ctx, width, type, dest, - indexRow, &ctx->Pack, transferOps); - } - } -} - - -/** - * glGetTexImage for depth/Z pixels. - */ -static void -get_tex_depth(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - GLint img, row, col; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - GLfloat depthRow[MAX_WIDTH]; - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - assert(dest); - - for (col = 0; col < width; col++) { - texImage->FetchTexelf(texImage, col, row, img, depthRow + col); - } - _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); - } - } -} - - -/** - * glGetTexImage for depth/stencil pixels. - */ -static void -get_tex_depth_stencil(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLuint *src = (const GLuint *) texImage->Data; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - memcpy(dest, src, width * sizeof(GLuint)); - if (ctx->Pack.SwapBytes) { - _mesa_swap4((GLuint *) dest, width); - } - - src += width * row + width * height * img; - } - } -} - - -/** - * glGetTexImage for YCbCr pixels. - */ -static void -get_tex_ycbcr(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLint rowstride = texImage->RowStride; - const GLushort *src = (const GLushort *) texImage->Data; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - memcpy(dest, src, width * sizeof(GLushort)); - - /* check for byte swapping */ - if ((texImage->TexFormat == MESA_FORMAT_YCBCR - && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) || - (texImage->TexFormat == MESA_FORMAT_YCBCR_REV - && type == GL_UNSIGNED_SHORT_8_8_MESA)) { - if (!ctx->Pack.SwapBytes) - _mesa_swap2((GLushort *) dest, width); - } - else if (ctx->Pack.SwapBytes) { - _mesa_swap2((GLushort *) dest, width); - } - - src += rowstride; - } - } -} - - -#if FEATURE_EXT_texture_sRGB - - -/** - * Convert a float value from linear space to a - * non-linear sRGB value in [0, 255]. - * Not terribly efficient. - */ -static INLINE GLfloat -linear_to_nonlinear(GLfloat cl) -{ - /* can't have values outside [0, 1] */ - GLfloat cs; - if (cl < 0.0031308f) { - cs = 12.92f * cl; - } - else { - cs = (GLfloat)(1.055 * pow(cl, 0.41666) - 0.055); - } - return cs; -} - - -/** - * glGetTexImagefor sRGB pixels; - */ -static void -get_tex_srgb(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLbitfield transferOps = 0x0; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - - GLfloat rgba[MAX_WIDTH][4]; - GLint col; - - /* convert row to RGBA format */ - for (col = 0; col < width; col++) { - texImage->FetchTexelf(texImage, col, row, img, rgba[col]); - if (texImage->_BaseFormat == GL_LUMINANCE) { - rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); - rgba[col][GCOMP] = 0.0; - rgba[col][BCOMP] = 0.0; - } - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { - rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); - rgba[col][GCOMP] = 0.0; - rgba[col][BCOMP] = 0.0; - } - else if (texImage->_BaseFormat == GL_RGB || - texImage->_BaseFormat == GL_RGBA) { - rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); - rgba[col][GCOMP] = linear_to_nonlinear(rgba[col][GCOMP]); - rgba[col][BCOMP] = linear_to_nonlinear(rgba[col][BCOMP]); - } - } - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, - format, type, dest, - &ctx->Pack, transferOps); - } - } -} - - -#else /* FEATURE_EXT_texture_sRGB */ - - -static INLINE void -get_tex_srgb(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - ASSERT_NO_FEATURE(); -} - - -#endif /* FEATURE_EXT_texture_sRGB */ - - -/** - * glGetTexImagefor RGBA, Luminance, etc. pixels. - * This is the slow way since we use texture sampling. - */ -static void -get_tex_rgba(GLcontext *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - /* Normally, no pixel transfer ops are performed during glGetTexImage. - * The only possible exception is component clamping to [0,1]. - */ - GLbitfield transferOps = 0x0; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - GLfloat rgba[MAX_WIDTH][4]; - GLint col; - GLenum dataType = _mesa_get_format_datatype(texImage->TexFormat); - - /* clamp does not apply to GetTexImage (final conversion)? - * Looks like we need clamp though when going from format - * containing negative values to unsigned format. - */ - if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { - transferOps |= IMAGE_CLAMP_BIT; - } - else if (!type_with_negative_values(type) && - (dataType == GL_FLOAT || - dataType == GL_SIGNED_NORMALIZED)) { - transferOps |= IMAGE_CLAMP_BIT; - } - - for (col = 0; col < width; col++) { - texImage->FetchTexelf(texImage, col, row, img, rgba[col]); - if (texImage->_BaseFormat == GL_ALPHA) { - rgba[col][RCOMP] = 0.0F; - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - else if (texImage->_BaseFormat == GL_LUMINANCE) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - else if (texImage->_BaseFormat == GL_INTENSITY) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - } - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, - format, type, dest, - &ctx->Pack, transferOps); - } - } -} - - -/** - * Try to do glGetTexImage() with simple memcpy(). - * \return GL_TRUE if done, GL_FALSE otherwise - */ -static GLboolean -get_tex_memcpy(GLcontext *ctx, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage) -{ - GLboolean memCopy = GL_FALSE; - - /* Texture image should have been mapped already */ - assert(texImage->Data); - - /* - * Check if the src/dst formats are compatible. - * Also note that GL's pixel transfer ops don't apply to glGetTexImage() - * so we don't have to worry about those. - * XXX more format combinations could be supported here. - */ - if ((texObj->Target == GL_TEXTURE_1D || - texObj->Target == GL_TEXTURE_2D || - texObj->Target == GL_TEXTURE_RECTANGLE || - (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { - if (texImage->TexFormat == MESA_FORMAT_ARGB8888 && - format == GL_BGRA && - type == GL_UNSIGNED_BYTE && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_AL88 && - format == GL_LUMINANCE_ALPHA && - type == GL_UNSIGNED_BYTE && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_L8 && - format == GL_LUMINANCE && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A8 && - format == GL_ALPHA && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - } - - if (memCopy) { - const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); - const GLuint bytesPerRow = texImage->Width * bpp; - GLubyte *dst = - _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, - texImage->Height, format, type, 0, 0); - const GLint dstRowStride = - _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); - const GLubyte *src = texImage->Data; - const GLint srcRowStride = texImage->RowStride * bpp; - GLuint row; - - if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { - memcpy(dst, src, bytesPerRow * texImage->Height); - } - else { - for (row = 0; row < texImage->Height; row++) { - memcpy(dst, src, bytesPerRow); - dst += dstRowStride; - src += srcRowStride; - } - } - } - - return memCopy; -} - - -/** - * This is the software fallback for Driver.GetTexImage(). - * All error checking will have been done before this routine is called. - * The texture image must be mapped. - */ -void -_mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint dimensions; - - /* If we get here, the texture image should be mapped */ - assert(texImage->Data); - - switch (target) { - case GL_TEXTURE_1D: - dimensions = 1; - break; - case GL_TEXTURE_3D: - dimensions = 3; - break; - default: - dimensions = 2; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Packing texture image into a PBO. - * Map the (potentially) VRAM-based buffer into our process space so - * we can write into it with the code below. - * A hardware driver might use a sophisticated blit to move the - * texture data to the PBO if the PBO is in VRAM along with the texture. - */ - GLubyte *buf = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); - if (!buf) { - /* out of memory or other unexpected error */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)"); - return; - } - /* was an offset into the PBO. - * Now make it a real, client-side pointer inside the mapped region. - */ - pixels = ADD_POINTERS(buf, pixels); - } - - if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) { - /* all done */ - } - else if (format == GL_COLOR_INDEX) { - get_tex_color_index(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_DEPTH_COMPONENT) { - get_tex_depth(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_DEPTH_STENCIL_EXT) { - get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_YCBCR_MESA) { - get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); - } - else if (_mesa_get_format_color_encoding(texImage->TexFormat) == GL_SRGB) { - get_tex_srgb(ctx, dimensions, format, type, pixels, texImage); - } - else { - get_tex_rgba(ctx, dimensions, format, type, pixels, texImage); - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } -} - - - -/** - * This is the software fallback for Driver.GetCompressedTexImage(). - * All error checking will have been done before this routine is called. - */ -void -_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, - texImage->Width); - const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat, - texImage->RowStride); - GLuint i; - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack texture image into a PBO */ - GLubyte *buf = (GLubyte *) - ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); - if (!buf) { - /* out of memory or other unexpected error */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glGetCompresssedTexImage(map PBO failed)"); - return; - } - img = ADD_POINTERS(buf, img); - } - - /* no pixelstore or pixel transfer, but respect stride */ - - if (row_stride == row_stride_stored) { - const GLuint size = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - memcpy(img, texImage->Data, size); - } - else { - GLuint bw, bh; - _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); - for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) { - memcpy((GLubyte *)img + i * row_stride, - (GLubyte *)texImage->Data + i * row_stride_stored, - row_stride); - } - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } -} - - - -/** - * Do error checking for a glGetTexImage() call. - * \return GL_TRUE if any error, GL_FALSE if no errors. - */ -static GLboolean -getteximage_error_check(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - GLenum baseFormat; - - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); - return GL_TRUE; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); - return GL_TRUE; - } - - if (_mesa_sizeof_packed_type(type) <= 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); - return GL_TRUE; - } - - if (_mesa_components_in_format(format) <= 0 || - format == GL_STENCIL_INDEX) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); - return GL_TRUE; - } - - if (!ctx->Extensions.EXT_paletted_texture && _mesa_is_index_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.ARB_depth_texture && _mesa_is_depth_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.EXT_packed_depth_stencil - && _mesa_is_depthstencil_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.ATI_envmap_bumpmap - && _mesa_is_dudv_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - if (!texObj || _mesa_is_proxy_texture(target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); - return GL_TRUE; - } - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - /* out of memory */ - return GL_TRUE; - } - - baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - /* Make sure the requested image format is compatible with the - * texture's format. Note that a color index texture can be converted - * to RGBA so that combo is allowed. - */ - if (_mesa_is_color_format(format) - && !_mesa_is_color_format(baseFormat) - && !_mesa_is_index_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_index_format(format) - && !_mesa_is_index_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_depth_format(format) - && !_mesa_is_depth_format(baseFormat) - && !_mesa_is_depthstencil_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_ycbcr_format(format) - && !_mesa_is_ycbcr_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_depthstencil_format(format) - && !_mesa_is_depthstencil_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_dudv_format(format) - && !_mesa_is_dudv_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* packing texture image into a PBO */ - const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; - if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, - texImage->Height, texImage->Depth, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexImage(out of bounds PBO write)"); - return GL_TRUE; - } - - /* PBO should not be mapped */ - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexImage(PBO is mapped)"); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - - -/** - * Get texture image. Called by glGetTexImage. - * - * \param target texture target. - * \param level image level. - * \param format pixel data format for returned image. - * \param type pixel data type for returned image. - * \param pixels returned pixel data. - */ -void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, GLenum format, - GLenum type, GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (getteximage_error_check(ctx, target, level, format, type, pixels)) { - return; - } - - if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) { - /* not an error, do nothing */ - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { - _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," - " dstFmt=0x%x, dstType=0x%x\n", - texObj->Name, - _mesa_get_format_name(texImage->TexFormat), - texImage->Width, texImage->Height, - format, type); - } - - _mesa_lock_texture(ctx, texObj); - { - ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, - texObj, texImage); - } - _mesa_unlock_texture(ctx, texObj); -} - - - -/** - * Do error checking for a glGetCompressedTexImage() call. - * \return GL_TRUE if any error, GL_FALSE if no errors. - */ -static GLboolean -getcompressedteximage_error_check(GLcontext *ctx, GLenum target, GLint level, - GLvoid *img) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)", - target); - return GL_TRUE; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetCompressedTexImageARB(bad level = %d)", level); - return GL_TRUE; - } - - if (_mesa_is_proxy_texture(target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetCompressedTexImageARB(bad target = %s)", - _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - if (!texObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); - return GL_TRUE; - } - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!texImage) { - /* probably invalid mipmap level */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetCompressedTexImageARB(level)"); - return GL_TRUE; - } - - if (!_mesa_is_format_compressed(texImage->TexFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImageARB(texture is not compressed)"); - return GL_TRUE; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - GLuint compressedSize; - - /* make sure PBO is not mapped */ - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(PBO is mapped)"); - return GL_TRUE; - } - - compressedSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - - /* do bounds checking on PBO write */ - if ((const GLubyte *) img + compressedSize > - (const GLubyte *) ctx->Pack.BufferObj->Size) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(out of bounds PBO write)"); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (getcompressedteximage_error_check(ctx, target, level, img)) { - return; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { - /* not an error, do nothing */ - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { - _mesa_debug(ctx, - "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n", - texObj->Name, - _mesa_get_format_name(texImage->TexFormat), - texImage->Width, texImage->Height); - } - - _mesa_lock_texture(ctx, texObj); - { - ctx->Driver.GetCompressedTexImage(ctx, target, level, img, - texObj, texImage); - } - _mesa_unlock_texture(ctx, texObj); -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * Code for glGetTexImage() and glGetCompressedTexImage(). + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "enums.h" +#include "context.h" +#include "formats.h" +#include "image.h" +#include "pack.h" +#include "texgetimage.h" +#include "teximage.h" + + + +/** + * Can the given type represent negative values? + */ +static INLINE GLboolean +type_with_negative_values(GLenum type) +{ + switch (type) { + case GL_BYTE: + case GL_SHORT: + case GL_INT: + case GL_FLOAT: + case GL_HALF_FLOAT_ARB: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * glGetTexImage for color index pixels. + */ +static void +get_tex_color_index(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLuint indexBits = + _mesa_get_format_bits(texImage->TexFormat, GL_TEXTURE_INDEX_SIZE_EXT); + const GLbitfield transferOps = 0x0; + GLint img, row, col; + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + GLuint indexRow[MAX_WIDTH] = { 0 }; + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + assert(dest); + + if (indexBits == 8) { + const GLubyte *src = (const GLubyte *) texImage->Data; + src += width * (img * texImage->Height + row); + for (col = 0; col < width; col++) { + indexRow[col] = src[col]; + } + } + else if (indexBits == 16) { + const GLushort *src = (const GLushort *) texImage->Data; + src += width * (img * texImage->Height + row); + for (col = 0; col < width; col++) { + indexRow[col] = src[col]; + } + } + else { + _mesa_problem(ctx, "Color index problem in _mesa_GetTexImage"); + } + _mesa_pack_index_span(ctx, width, type, dest, + indexRow, &ctx->Pack, transferOps); + } + } +} + + +/** + * glGetTexImage for depth/Z pixels. + */ +static void +get_tex_depth(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + GLint img, row, col; + GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); + + if (!depthRow) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + assert(dest); + + for (col = 0; col < width; col++) { + texImage->FetchTexelf(texImage, col, row, img, depthRow + col); + } + _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); + } + } + + free(depthRow); +} + + +/** + * glGetTexImage for depth/stencil pixels. + */ +static void +get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLuint *src = (const GLuint *) texImage->Data; + GLint img, row; + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + memcpy(dest, src, width * sizeof(GLuint)); + if (ctx->Pack.SwapBytes) { + _mesa_swap4((GLuint *) dest, width); + } + + src += width * row + width * height * img; + } + } +} + + +/** + * glGetTexImage for YCbCr pixels. + */ +static void +get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLint rowstride = texImage->RowStride; + const GLushort *src = (const GLushort *) texImage->Data; + GLint img, row; + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + memcpy(dest, src, width * sizeof(GLushort)); + + /* check for byte swapping */ + if ((texImage->TexFormat == MESA_FORMAT_YCBCR + && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) || + (texImage->TexFormat == MESA_FORMAT_YCBCR_REV + && type == GL_UNSIGNED_SHORT_8_8_MESA)) { + if (!ctx->Pack.SwapBytes) + _mesa_swap2((GLushort *) dest, width); + } + else if (ctx->Pack.SwapBytes) { + _mesa_swap2((GLushort *) dest, width); + } + + src += rowstride; + } + } +} + + +#if FEATURE_EXT_texture_sRGB + + +/** + * Convert a float value from linear space to a + * non-linear sRGB value in [0, 255]. + * Not terribly efficient. + */ +static INLINE GLfloat +linear_to_nonlinear(GLfloat cl) +{ + /* can't have values outside [0, 1] */ + GLfloat cs; + if (cl < 0.0031308f) { + cs = 12.92f * cl; + } + else { + cs = (GLfloat)(1.055 * pow(cl, 0.41666) - 0.055); + } + return cs; +} + + +/** + * glGetTexImagefor sRGB pixels; + */ +static void +get_tex_srgb(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLbitfield transferOps = 0x0; + GLint img, row; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + + GLint col; + + /* convert row to RGBA format */ + for (col = 0; col < width; col++) { + texImage->FetchTexelf(texImage, col, row, img, rgba[col]); + if (texImage->_BaseFormat == GL_LUMINANCE) { + rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + } + else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { + rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); + rgba[col][GCOMP] = 0.0; + rgba[col][BCOMP] = 0.0; + } + else if (texImage->_BaseFormat == GL_RGB || + texImage->_BaseFormat == GL_RGBA) { + rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]); + rgba[col][GCOMP] = linear_to_nonlinear(rgba[col][GCOMP]); + rgba[col][BCOMP] = linear_to_nonlinear(rgba[col][BCOMP]); + } + } + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, + format, type, dest, + &ctx->Pack, transferOps); + } + } + + free(rgba); +} + + +#else /* FEATURE_EXT_texture_sRGB */ + + +static INLINE void +get_tex_srgb(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + ASSERT_NO_FEATURE(); +} + + +#endif /* FEATURE_EXT_texture_sRGB */ + + +/** + * glGetTexImagefor RGBA, Luminance, etc. pixels. + * This is the slow way since we use texture sampling. + */ +static void +get_tex_rgba(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + /* Normally, no pixel transfer ops are performed during glGetTexImage. + * The only possible exception is component clamping to [0,1]. + */ + GLbitfield transferOps = 0x0; + GLint img, row; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + GLint col; + GLenum dataType = _mesa_get_format_datatype(texImage->TexFormat); + + /* clamp does not apply to GetTexImage (final conversion)? + * Looks like we need clamp though when going from format + * containing negative values to unsigned format. + */ + if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { + transferOps |= IMAGE_CLAMP_BIT; + } + else if (!type_with_negative_values(type) && + (dataType == GL_FLOAT || + dataType == GL_SIGNED_NORMALIZED)) { + transferOps |= IMAGE_CLAMP_BIT; + } + + for (col = 0; col < width; col++) { + texImage->FetchTexelf(texImage, col, row, img, rgba[col]); + if (texImage->_BaseFormat == GL_ALPHA) { + rgba[col][RCOMP] = 0.0F; + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + else if (texImage->_BaseFormat == GL_LUMINANCE) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + else if (texImage->_BaseFormat == GL_INTENSITY) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + } + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, + format, type, dest, + &ctx->Pack, transferOps); + } + } + + free(rgba); +} + + +/** + * Try to do glGetTexImage() with simple memcpy(). + * \return GL_TRUE if done, GL_FALSE otherwise + */ +static GLboolean +get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_object *texObj, + const struct gl_texture_image *texImage) +{ + GLboolean memCopy = GL_FALSE; + + /* Texture image should have been mapped already */ + assert(texImage->Data); + + /* + * Check if the src/dst formats are compatible. + * Also note that GL's pixel transfer ops don't apply to glGetTexImage() + * so we don't have to worry about those. + * XXX more format combinations could be supported here. + */ + if ((texObj->Target == GL_TEXTURE_1D || + texObj->Target == GL_TEXTURE_2D || + texObj->Target == GL_TEXTURE_RECTANGLE || + (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { + if (texImage->TexFormat == MESA_FORMAT_ARGB8888 && + format == GL_BGRA && + type == GL_UNSIGNED_BYTE && + !ctx->Pack.SwapBytes && + _mesa_little_endian()) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_AL88 && + format == GL_LUMINANCE_ALPHA && + type == GL_UNSIGNED_BYTE && + !ctx->Pack.SwapBytes && + _mesa_little_endian()) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_L8 && + format == GL_LUMINANCE && + type == GL_UNSIGNED_BYTE) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_L16 && + format == GL_LUMINANCE && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_A8 && + format == GL_ALPHA && + type == GL_UNSIGNED_BYTE) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_A16 && + format == GL_ALPHA && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } + } + + if (memCopy) { + const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); + const GLuint bytesPerRow = texImage->Width * bpp; + GLubyte *dst = + _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, + texImage->Height, format, type, 0, 0); + const GLint dstRowStride = + _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); + const GLubyte *src = texImage->Data; + const GLint srcRowStride = texImage->RowStride * bpp; + GLuint row; + + if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { + memcpy(dst, src, bytesPerRow * texImage->Height); + } + else { + for (row = 0; row < texImage->Height; row++) { + memcpy(dst, src, bytesPerRow); + dst += dstRowStride; + src += srcRowStride; + } + } + } + + return memCopy; +} + + +/** + * This is the software fallback for Driver.GetTexImage(). + * All error checking will have been done before this routine is called. + * The texture image must be mapped. + */ +void +_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint dimensions; + + /* If we get here, the texture image should be mapped */ + assert(texImage->Data); + + switch (target) { + case GL_TEXTURE_1D: + dimensions = 1; + break; + case GL_TEXTURE_3D: + dimensions = 3; + break; + default: + dimensions = 2; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* Packing texture image into a PBO. + * Map the (potentially) VRAM-based buffer into our process space so + * we can write into it with the code below. + * A hardware driver might use a sophisticated blit to move the + * texture data to the PBO if the PBO is in VRAM along with the texture. + */ + GLubyte *buf = (GLubyte *) + ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); + if (!buf) { + /* out of memory or other unexpected error */ + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)"); + return; + } + /* was an offset into the PBO. + * Now make it a real, client-side pointer inside the mapped region. + */ + pixels = ADD_POINTERS(buf, pixels); + } + + if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) { + /* all done */ + } + else if (format == GL_COLOR_INDEX) { + get_tex_color_index(ctx, dimensions, format, type, pixels, texImage); + } + else if (format == GL_DEPTH_COMPONENT) { + get_tex_depth(ctx, dimensions, format, type, pixels, texImage); + } + else if (format == GL_DEPTH_STENCIL_EXT) { + get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage); + } + else if (format == GL_YCBCR_MESA) { + get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); + } + else if (_mesa_get_format_color_encoding(texImage->TexFormat) == GL_SRGB) { + get_tex_srgb(ctx, dimensions, format, type, pixels, texImage); + } + else { + get_tex_rgba(ctx, dimensions, format, type, pixels, texImage); + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + ctx->Pack.BufferObj); + } +} + + + +/** + * This is the software fallback for Driver.GetCompressedTexImage(). + * All error checking will have been done before this routine is called. + */ +void +_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); + const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat, + texImage->RowStride); + GLuint i; + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* pack texture image into a PBO */ + GLubyte *buf = (GLubyte *) + ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); + if (!buf) { + /* out of memory or other unexpected error */ + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glGetCompresssedTexImage(map PBO failed)"); + return; + } + img = ADD_POINTERS(buf, img); + } + + /* no pixelstore or pixel transfer, but respect stride */ + + if (row_stride == row_stride_stored) { + const GLuint size = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); + memcpy(img, texImage->Data, size); + } + else { + GLuint bw, bh; + _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); + for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) { + memcpy((GLubyte *)img + i * row_stride, + (GLubyte *)texImage->Data + i * row_stride_stored, + row_stride); + } + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, + ctx->Pack.BufferObj); + } +} + + + +/** + * Do error checking for a glGetTexImage() call. + * \return GL_TRUE if any error, GL_FALSE if no errors. + */ +static GLboolean +getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLenum baseFormat; + + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); + return GL_TRUE; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); + return GL_TRUE; + } + + if (_mesa_sizeof_packed_type(type) <= 0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); + return GL_TRUE; + } + + if (_mesa_components_in_format(format) <= 0 || + format == GL_STENCIL_INDEX) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); + return GL_TRUE; + } + + if (!ctx->Extensions.EXT_paletted_texture && _mesa_is_index_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.ARB_depth_texture && _mesa_is_depth_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.EXT_packed_depth_stencil + && _mesa_is_depthstencil_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.ATI_envmap_bumpmap + && _mesa_is_dudv_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + if (!texObj || _mesa_is_proxy_texture(target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); + return GL_TRUE; + } + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + if (!texImage) { + /* out of memory */ + return GL_TRUE; + } + + baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + /* Make sure the requested image format is compatible with the + * texture's format. Note that a color index texture can be converted + * to RGBA so that combo is allowed. + */ + if (_mesa_is_color_format(format) + && !_mesa_is_color_format(baseFormat) + && !_mesa_is_index_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_index_format(format) + && !_mesa_is_index_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_depth_format(format) + && !_mesa_is_depth_format(baseFormat) + && !_mesa_is_depthstencil_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_ycbcr_format(format) + && !_mesa_is_ycbcr_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_depthstencil_format(format) + && !_mesa_is_depthstencil_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_dudv_format(format) + && !_mesa_is_dudv_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* packing texture image into a PBO */ + const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; + if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, + texImage->Height, texImage->Depth, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexImage(out of bounds PBO write)"); + return GL_TRUE; + } + + /* PBO should not be mapped */ + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexImage(PBO is mapped)"); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + + +/** + * Get texture image. Called by glGetTexImage. + * + * \param target texture target. + * \param level image level. + * \param format pixel data format for returned image. + * \param type pixel data type for returned image. + * \param pixels returned pixel data. + */ +void GLAPIENTRY +_mesa_GetTexImage( GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (getteximage_error_check(ctx, target, level, format, type, pixels)) { + return; + } + + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) { + /* not an error, do nothing */ + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { + _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," + " dstFmt=0x%x, dstType=0x%x\n", + texObj->Name, + _mesa_get_format_name(texImage->TexFormat), + texImage->Width, texImage->Height, + format, type); + } + + _mesa_lock_texture(ctx, texObj); + { + ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, + texObj, texImage); + } + _mesa_unlock_texture(ctx, texObj); +} + + + +/** + * Do error checking for a glGetCompressedTexImage() call. + * \return GL_TRUE if any error, GL_FALSE if no errors. + */ +static GLboolean +getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)", + target); + return GL_TRUE; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetCompressedTexImageARB(bad level = %d)", level); + return GL_TRUE; + } + + if (_mesa_is_proxy_texture(target)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetCompressedTexImageARB(bad target = %s)", + _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); + return GL_TRUE; + } + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (!texImage) { + /* probably invalid mipmap level */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetCompressedTexImageARB(level)"); + return GL_TRUE; + } + + if (!_mesa_is_format_compressed(texImage->TexFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImageARB(texture is not compressed)"); + return GL_TRUE; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + GLuint compressedSize; + + /* make sure PBO is not mapped */ + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(PBO is mapped)"); + return GL_TRUE; + } + + compressedSize = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); + + /* do bounds checking on PBO write */ + if ((const GLubyte *) img + compressedSize > + (const GLubyte *) ctx->Pack.BufferObj->Size) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(out of bounds PBO write)"); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (getcompressedteximage_error_check(ctx, target, level, img)) { + return; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { + /* not an error, do nothing */ + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { + _mesa_debug(ctx, + "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n", + texObj->Name, + _mesa_get_format_name(texImage->TexFormat), + texImage->Width, texImage->Height); + } + + _mesa_lock_texture(ctx, texObj); + { + ctx->Driver.GetCompressedTexImage(ctx, target, level, img, + texObj, texImage); + } + _mesa_unlock_texture(ctx, texObj); +} diff --git a/mesalib/src/mesa/main/texgetimage.h b/mesalib/src/mesa/main/texgetimage.h index 866ab7049..d5a1ffcf5 100644 --- a/mesalib/src/mesa/main/texgetimage.h +++ b/mesalib/src/mesa/main/texgetimage.h @@ -1,56 +1,60 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXGETIMAGE_H -#define TEXGETIMAGE_H - -#include "mtypes.h" - -extern void -_mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - - -extern void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); - - -#endif /* TEXGETIMAGE_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXGETIMAGE_H +#define TEXGETIMAGE_H + +#include "glheader.h" + +struct gl_context; +struct gl_texture_image; +struct gl_texture_object; + +extern void +_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + + +extern void GLAPIENTRY +_mesa_GetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); + + +#endif /* TEXGETIMAGE_H */ diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index ca1bd6096..f62074a1b 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1,3884 +1,3485 @@ -/* - * mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file teximage.c - * Texture image-related functions. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "context.h" -#include "convolve.h" -#include "enums.h" -#include "fbobject.h" -#include "framebuffer.h" -#include "hash.h" -#include "image.h" -#include "imports.h" -#include "macros.h" -#include "state.h" -#include "texcompress.h" -#include "texfetch.h" -#include "teximage.h" -#include "texstate.h" -#include "texpal.h" -#include "mtypes.h" - - -/** - * State changes which we care about for glCopyTex[Sub]Image() calls. - * In particular, we care about pixel transfer state and buffer state - * (such as glReadBuffer to make sure we read from the right renderbuffer). - */ -#define NEW_COPY_TEX_STATE (_MESA_NEW_TRANSFER_STATE | \ - _NEW_BUFFERS | \ - _NEW_PIXEL) - - - -/** - * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE - * elsewhere. - */ -void * -_mesa_alloc_texmemory(GLsizei bytes) -{ - return _mesa_align_malloc(bytes, 512); -} - - -/** - * Free texture memory allocated with _mesa_alloc_texmemory() - */ -void -_mesa_free_texmemory(void *m) -{ - _mesa_align_free(m); -} - - -/* - * Compute floor(log_base_2(n)). - * If n < 0 return -1. - */ -static int -logbase2( int n ) -{ - GLint i = 1; - GLint log2 = 0; - - if (n < 0) - return -1; - - if (n == 0) - return 0; - - while ( n > i ) { - i *= 2; - log2++; - } - if (i != n) { - return log2 - 1; - } - else { - return log2; - } -} - - - -/** - * Return the simple base format for a given internal texture format. - * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. - * - * \param ctx GL context. - * \param internalFormat the internal texture format token or 1, 2, 3, or 4. - * - * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, - * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. - * - * This is the format which is used during texture application (i.e. the - * texture format and env mode determine the arithmetic used. - * - * XXX this could be static - */ -GLint -_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) -{ - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.EXT_paletted_texture) { - switch (internalFormat) { - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - return GL_COLOR_INDEX; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_depth_texture) { - switch (internalFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_DEPTH_COMPONENT; - default: - ; /* fallthrough */ - } - } - - switch (internalFormat) { - case GL_COMPRESSED_ALPHA: - return GL_ALPHA; - case GL_COMPRESSED_LUMINANCE: - return GL_LUMINANCE; - case GL_COMPRESSED_LUMINANCE_ALPHA: - return GL_LUMINANCE_ALPHA; - case GL_COMPRESSED_INTENSITY: - return GL_INTENSITY; - case GL_COMPRESSED_RGB: - return GL_RGB; - case GL_COMPRESSED_RGBA: - return GL_RGBA; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return GL_RGB; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_compression_s3tc) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return GL_RGB; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.S3_s3tc) { - switch (internalFormat) { - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return GL_RGB; - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.MESA_ycbcr_texture) { - if (internalFormat == GL_YCBCR_MESA) - return GL_YCBCR_MESA; - } - - if (ctx->Extensions.ARB_texture_float) { - switch (internalFormat) { - case GL_ALPHA16F_ARB: - case GL_ALPHA32F_ARB: - return GL_ALPHA; - case GL_RGBA16F_ARB: - case GL_RGBA32F_ARB: - return GL_RGBA; - case GL_RGB16F_ARB: - case GL_RGB32F_ARB: - return GL_RGB; - case GL_INTENSITY16F_ARB: - case GL_INTENSITY32F_ARB: - return GL_INTENSITY; - case GL_LUMINANCE16F_ARB: - case GL_LUMINANCE32F_ARB: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA16F_ARB: - case GL_LUMINANCE_ALPHA32F_ARB: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ATI_envmap_bumpmap) { - switch (internalFormat) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return GL_DUDV_ATI; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.MESA_texture_signed_rgba) { - switch (internalFormat) { - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_packed_depth_stencil) { - switch (internalFormat) { - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return GL_DEPTH_STENCIL_EXT; - default: - ; /* fallthrough */ - } - } - -#if FEATURE_EXT_texture_sRGB - if (ctx->Extensions.EXT_texture_sRGB) { - switch (internalFormat) { - case GL_SRGB_EXT: - case GL_SRGB8_EXT: - case GL_COMPRESSED_SRGB_EXT: - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return GL_RGB; - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - case GL_COMPRESSED_SRGB_ALPHA_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return GL_RGBA; - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: - case GL_COMPRESSED_SLUMINANCE_EXT: - case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - return GL_LUMINANCE_ALPHA; - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: - return GL_LUMINANCE; - default: - ; /* fallthrough */ - } - } -#endif /* FEATURE_EXT_texture_sRGB */ - - if (ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_RGBA8UI_EXT: - case GL_RGBA16UI_EXT: - case GL_RGBA32UI_EXT: - case GL_RGBA8I_EXT: - case GL_RGBA16I_EXT: - case GL_RGBA32I_EXT: - return GL_RGBA; - case GL_RGB8UI_EXT: - case GL_RGB16UI_EXT: - case GL_RGB32UI_EXT: - case GL_RGB8I_EXT: - case GL_RGB16I_EXT: - case GL_RGB32I_EXT: - return GL_RGB; - case GL_ALPHA8UI_EXT: - case GL_ALPHA16UI_EXT: - case GL_ALPHA32UI_EXT: - case GL_ALPHA8I_EXT: - case GL_ALPHA16I_EXT: - case GL_ALPHA32I_EXT: - return GL_ALPHA; - case GL_INTENSITY8UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_INTENSITY8I_EXT: - case GL_INTENSITY16I_EXT: - case GL_INTENSITY32I_EXT: - return GL_INTENSITY; - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE32I_EXT: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA8UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_texture_rg) { - switch (internalFormat) { - case GL_R8: - case GL_R16: - case GL_R16F: - case GL_R32F: - case GL_R8I: - case GL_R8UI: - case GL_R16I: - case GL_R16UI: - case GL_R32I: - case GL_R32UI: - return GL_R; - case GL_RG: - case GL_RG_INTEGER: - case GL_RG8: - case GL_RG16: - case GL_RG16F: - case GL_RG32F: - case GL_RG8I: - case GL_RG8UI: - case GL_RG16I: - case GL_RG16UI: - case GL_RG32I: - case GL_RG32UI: - return GL_RG; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_shared_exponent) { - switch (internalFormat) { - case GL_RGB9_E5_EXT: - return GL_RGB; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_packed_float) { - switch (internalFormat) { - case GL_R11F_G11F_B10F_EXT: - return GL_RGB; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_depth_buffer_float) { - switch (internalFormat) { - case GL_DEPTH_COMPONENT32F: - return GL_DEPTH_COMPONENT; - case GL_DEPTH32F_STENCIL8: - return GL_DEPTH_STENCIL; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_compression_rgtc) { - switch (internalFormat) { - case GL_COMPRESSED_RED: - case GL_COMPRESSED_RED_RGTC1_EXT: - case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: - return GL_RED; - case GL_COMPRESSED_RG: - case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: - case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: - return GL_RG; - default: - ; /* fallthrough */ - } - } - - return -1; /* error */ -} - - -/** - * For cube map faces, return a face index in [0,5]. - * For other targets return 0; - */ -GLuint -_mesa_tex_target_to_face(GLenum target) -{ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) - return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; - else - return 0; -} - - - -/** - * Store a gl_texture_image pointer in a gl_texture_object structure - * according to the target and level parameters. - * - * \param tObj texture object. - * \param target texture target. - * \param level image level. - * \param texImage texture image. - * - * This was basically prompted by the introduction of cube maps. - */ -void -_mesa_set_tex_image(struct gl_texture_object *tObj, - GLenum target, GLint level, - struct gl_texture_image *texImage) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(tObj); - ASSERT(texImage); - ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0); - - tObj->Image[face][level] = texImage; - - /* Set the 'back' pointer */ - texImage->TexObject = tObj; -} - - -/** - * Allocate a texture image structure. - * - * Called via ctx->Driver.NewTextureImage() unless overriden by a device - * driver. - * - * \return a pointer to gl_texture_image struct with all fields initialized to - * zero. - */ -struct gl_texture_image * -_mesa_new_texture_image( GLcontext *ctx ) -{ - (void) ctx; - return CALLOC_STRUCT(gl_texture_image); -} - - -/** - * Free texture image data. - * This function is a fallback called via ctx->Driver.FreeTexImageData(). - * - * \param texImage texture image. - * - * Free the texture image data if it's not marked as client data. - */ -void -_mesa_free_texture_image_data(GLcontext *ctx, - struct gl_texture_image *texImage) -{ - (void) ctx; - - if (texImage->Data && !texImage->IsClientData) { - /* free the old texture data */ - _mesa_free_texmemory(texImage->Data); - } - - texImage->Data = NULL; -} - - -/** - * Free texture image. - * - * \param texImage texture image. - * - * Free the texture image structure and the associated image data. - */ -void -_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage ) -{ - /* Free texImage->Data and/or any other driver-specific texture - * image storage. - */ - ASSERT(ctx->Driver.FreeTexImageData); - ctx->Driver.FreeTexImageData( ctx, texImage ); - - ASSERT(texImage->Data == NULL); - if (texImage->ImageOffsets) - free(texImage->ImageOffsets); - free(texImage); -} - - -/** - * Test if a target is a proxy target. - * - * \param target texture target. - * - * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. - */ -GLboolean -_mesa_is_proxy_texture(GLenum target) -{ - /* NUM_TEXTURE_TARGETS should match number of terms below */ - assert(NUM_TEXTURE_TARGETS == 7); - - return (target == GL_PROXY_TEXTURE_1D || - target == GL_PROXY_TEXTURE_2D || - target == GL_PROXY_TEXTURE_3D || - target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || - target == GL_PROXY_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || - target == GL_PROXY_TEXTURE_2D_ARRAY_EXT); -} - - -/** - * Get the texture object that corresponds to the target of the given texture unit. - * - * \param ctx GL context. - * \param texUnit texture unit. - * \param target texture target. - * - * \return pointer to the texture object on success, or NULL on failure. - * - * \sa gl_texture_unit. - */ -struct gl_texture_object * -_mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, - GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; - case GL_PROXY_TEXTURE_1D: - return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; - case GL_PROXY_TEXTURE_2D: - return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; - case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; - case GL_PROXY_TEXTURE_3D: - return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; - case GL_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle - ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL; - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle - ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; - case GL_TEXTURE_1D_ARRAY_EXT: - return ctx->Extensions.MESA_texture_array - ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL; - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - return ctx->Extensions.MESA_texture_array - ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; - case GL_TEXTURE_2D_ARRAY_EXT: - return ctx->Extensions.MESA_texture_array - ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return ctx->Extensions.MESA_texture_array - ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; - default: - _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); - return NULL; - } -} - - -/** - * Return pointer to texture object for given target on current texture unit. - */ -struct gl_texture_object * -_mesa_get_current_tex_object(GLcontext *ctx, GLenum target) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - return _mesa_select_tex_object(ctx, texUnit, target); -} - - -/** - * Get a texture image pointer from a texture object, given a texture - * target and mipmap level. The target and level parameters should - * have already been error-checked. - * - * \param ctx GL context. - * \param texObj texture unit. - * \param target texture target. - * \param level image level. - * - * \return pointer to the texture image structure, or NULL on failure. - */ -struct gl_texture_image * -_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(texObj); - ASSERT(level >= 0); - ASSERT(level < MAX_TEXTURE_LEVELS); - - return texObj->Image[face][level]; -} - - -/** - * Like _mesa_select_tex_image() but if the image doesn't exist, allocate - * it and install it. Only return NULL if passed a bad parameter or run - * out of memory. - */ -struct gl_texture_image * -_mesa_get_tex_image(GLcontext *ctx, struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - - if (!texObj) - return NULL; - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); - return NULL; - } - - _mesa_set_tex_image(texObj, target, level, texImage); - } - - return texImage; -} - - -/** - * Return pointer to the specified proxy texture image. - * Note that proxy textures are per-context, not per-texture unit. - * \return pointer to texture image or NULL if invalid target, invalid - * level, or out of memory. - */ -struct gl_texture_image * -_mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - GLuint texIndex; - - if (level < 0 ) - return NULL; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_1D_INDEX; - break; - case GL_PROXY_TEXTURE_2D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_2D_INDEX; - break; - case GL_PROXY_TEXTURE_3D: - if (level >= ctx->Const.Max3DTextureLevels) - return NULL; - texIndex = TEXTURE_3D_INDEX; - break; - case GL_PROXY_TEXTURE_CUBE_MAP: - if (level >= ctx->Const.MaxCubeTextureLevels) - return NULL; - texIndex = TEXTURE_CUBE_INDEX; - break; - case GL_PROXY_TEXTURE_RECTANGLE_NV: - if (level > 0) - return NULL; - texIndex = TEXTURE_RECT_INDEX; - break; - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_1D_ARRAY_INDEX; - break; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_2D_ARRAY_INDEX; - break; - default: - return NULL; - } - - texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); - return NULL; - } - ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; - /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; - } - return texImage; -} - - -/** - * Get the maximum number of allowed mipmap levels. - * - * \param ctx GL context. - * \param target texture target. - * - * \return the maximum number of allowed mipmap levels for the given - * texture target, or zero if passed a bad target. - * - * \sa gl_constants. - */ -GLint -_mesa_max_texture_levels(GLcontext *ctx, GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return ctx->Const.MaxTextureLevels; - case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: - return ctx->Const.Max3DTextureLevels; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Const.MaxCubeTextureLevels : 0; - case GL_TEXTURE_RECTANGLE_NV: - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle ? 1 : 0; - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return ctx->Extensions.MESA_texture_array - ? ctx->Const.MaxTextureLevels : 0; - default: - return 0; /* bad target */ - } -} - - - -#if 000 /* not used anymore */ -/* - * glTexImage[123]D can accept a NULL image pointer. In this case we - * create a texture image with unspecified image contents per the OpenGL - * spec. - */ -static GLubyte * -make_null_texture(GLint width, GLint height, GLint depth, GLenum format) -{ - const GLint components = _mesa_components_in_format(format); - const GLint numPixels = width * height * depth; - GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); - -#ifdef DEBUG - /* - * Let's see if anyone finds this. If glTexImage2D() is called with - * a NULL image pointer then load the texture image with something - * interesting instead of leaving it indeterminate. - */ - if (data) { - static const char message[8][32] = { - " X X XXXXX XXX X ", - " XX XX X X X X X ", - " X X X X X X X ", - " X X XXXX XXX XXXXX ", - " X X X X X X ", - " X X X X X X X ", - " X X XXXXX XXX X X ", - " " - }; - - GLubyte *imgPtr = data; - GLint h, i, j, k; - for (h = 0; h < depth; h++) { - for (i = 0; i < height; i++) { - GLint srcRow = 7 - (i % 8); - for (j = 0; j < width; j++) { - GLint srcCol = j % 32; - GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; - for (k = 0; k < components; k++) { - *imgPtr++ = texel; - } - } - } - } - } -#endif - - return data; -} -#endif - - - -/** - * Reset the fields of a gl_texture_image struct to zero. - * - * \param img texture image structure. - * - * This is called when a proxy texture test fails, we set all the - * image members (except DriverData) to zero. - * It's also used in glTexImage[123]D as a safeguard to be sure all - * required fields get initialized properly by the Driver.TexImage[123]D - * functions. - */ -static void -clear_teximage_fields(struct gl_texture_image *img) -{ - ASSERT(img); - img->_BaseFormat = 0; - img->InternalFormat = 0; - img->Border = 0; - img->Width = 0; - img->Height = 0; - img->Depth = 0; - img->RowStride = 0; - if (img->ImageOffsets) { - free(img->ImageOffsets); - img->ImageOffsets = NULL; - } - img->Width2 = 0; - img->Height2 = 0; - img->Depth2 = 0; - img->WidthLog2 = 0; - img->HeightLog2 = 0; - img->DepthLog2 = 0; - img->Data = NULL; - img->TexFormat = MESA_FORMAT_NONE; - img->FetchTexelc = NULL; - img->FetchTexelf = NULL; -} - - -/** - * Initialize basic fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). - * \param img texture image structure to be initialized. - * \param width image width. - * \param height image height. - * \param depth image depth. - * \param border image border. - * \param internalFormat internal format. - * - * Fills in the fields of \p img with the given information. - * Note: width, height and depth include the border. - */ -void -_mesa_init_teximage_fields(GLcontext *ctx, GLenum target, - struct gl_texture_image *img, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum internalFormat) -{ - GLint i; - - ASSERT(img); - ASSERT(width >= 0); - ASSERT(height >= 0); - ASSERT(depth >= 0); - - img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); - ASSERT(img->_BaseFormat > 0); - img->InternalFormat = internalFormat; - img->Border = border; - img->Width = width; - img->Height = height; - img->Depth = depth; - - img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ - img->WidthLog2 = logbase2(img->Width2); - - if (height == 1) { /* 1-D texture */ - img->Height2 = 1; - img->HeightLog2 = 0; - } - else { - img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ - img->HeightLog2 = logbase2(img->Height2); - } - - if (depth == 1) { /* 2-D texture */ - img->Depth2 = 1; - img->DepthLog2 = 0; - } - else { - img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */ - img->DepthLog2 = logbase2(img->Depth2); - } - - img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); - - if ((width == 1 || _mesa_is_pow_two(img->Width2)) && - (height == 1 || _mesa_is_pow_two(img->Height2)) && - (depth == 1 || _mesa_is_pow_two(img->Depth2))) - img->_IsPowerOfTwo = GL_TRUE; - else - img->_IsPowerOfTwo = GL_FALSE; - - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ - img->RowStride = width; - /* Allocate the ImageOffsets array and initialize to typical values. - * We allocate the array for 1D/2D textures too in order to avoid special- - * case code in the texstore routines. - */ - if (img->ImageOffsets) - free(img->ImageOffsets); - img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); - for (i = 0; i < depth; i++) { - img->ImageOffsets[i] = i * width * height; - } - - /* Compute Width/Height/DepthScale for mipmap lod computation */ - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* scale = 1.0 since texture coords directly map to texels */ - img->WidthScale = 1.0; - img->HeightScale = 1.0; - img->DepthScale = 1.0; - } - else { - img->WidthScale = (GLfloat) img->Width; - img->HeightScale = (GLfloat) img->Height; - img->DepthScale = (GLfloat) img->Depth; - } - - img->FetchTexelc = NULL; - img->FetchTexelf = NULL; -} - - -/** - * Free and clear fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param texImage texture image structure to be cleared. - * - * After the call, \p texImage will have no data associated with it. Its - * fields are cleared so that its parent object will test incomplete. - */ -void -_mesa_clear_texture_image(GLcontext *ctx, struct gl_texture_image *texImage) -{ - ctx->Driver.FreeTexImageData(ctx, texImage); - clear_teximage_fields(texImage); -} - - -/** - * This is the fallback for Driver.TestProxyTexImage(). Test the texture - * level, width, height and depth against the ctx->Const limits for textures. - * - * A hardware driver might override this function if, for example, the - * max 3D texture size is 512x512x64 (i.e. not a cube). - * - * Note that width, height, depth == 0 is not an error. However, a - * texture with zero width/height/depth will be considered "incomplete" - * and texturing will effectively be disabled. - * - * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, - * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, - * GL_PROXY_TEXTURE_CUBE_MAP_ARB. - * \param level as passed to glTexImage - * \param internalFormat as passed to glTexImage - * \param format as passed to glTexImage - * \param type as passed to glTexImage - * \param width as passed to glTexImage - * \param height as passed to glTexImage - * \param depth as passed to glTexImage - * \param border as passed to glTexImage - * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. - */ -GLboolean -_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border) -{ - GLint maxSize; - - (void) internalFormat; - (void) format; - (void) type; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width >0 && !_mesa_is_pow_two(width - 2 * border)) || - level >= ctx->Const.MaxTextureLevels) { - /* bad width or level */ - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_2D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width > 0 && !_mesa_is_pow_two(width - 2 * border)) || - height < 2 * border || height > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - height > 0 && !_mesa_is_pow_two(height - 2 * border)) || - level >= ctx->Const.MaxTextureLevels) { - /* bad width or height or level */ - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_3D: - maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width > 0 && !_mesa_is_pow_two(width - 2 * border)) || - height < 2 * border || height > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - height > 0 && !_mesa_is_pow_two(height - 2 * border)) || - depth < 2 * border || depth > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) || - level >= ctx->Const.Max3DTextureLevels) { - /* bad width or height or depth or level */ - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_RECTANGLE_NV: - if (width < 0 || width > ctx->Const.MaxTextureRectSize || - height < 0 || height > ctx->Const.MaxTextureRectSize || - level != 0) { - /* bad width or height or level */ - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width > 0 && !_mesa_is_pow_two(width - 2 * border)) || - height < 2 * border || height > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - height > 0 && !_mesa_is_pow_two(height - 2 * border)) || - level >= ctx->Const.MaxCubeTextureLevels) { - /* bad width or height */ - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width > 0 && !_mesa_is_pow_two(width - 2 * border)) || - level >= ctx->Const.MaxTextureLevels) { - /* bad width or level */ - return GL_FALSE; - } - - if (height < 1 || height > ctx->Const.MaxArrayTextureLayers) { - return GL_FALSE; - } - return GL_TRUE; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - width > 0 && !_mesa_is_pow_two(width - 2 * border)) || - height < 2 * border || height > 2 + maxSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && - height > 0 && !_mesa_is_pow_two(height - 2 * border)) || - level >= ctx->Const.MaxTextureLevels) { - /* bad width or height or level */ - return GL_FALSE; - } - if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers) { - return GL_FALSE; - } - return GL_TRUE; - default: - _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); - return GL_FALSE; - } -} - - -/** - * Helper function to determine whether a target supports compressed textures - */ -static GLboolean -target_can_be_compressed(GLcontext *ctx, GLenum target) -{ - return (((target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D)) - || ((ctx->Extensions.ARB_texture_cube_map && - (target == GL_PROXY_TEXTURE_CUBE_MAP || - (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)))) - || ((ctx->Extensions.MESA_texture_array && - ((target == GL_PROXY_TEXTURE_2D_ARRAY_EXT) || - (target == GL_TEXTURE_2D_ARRAY_EXT))))); -} - - -/** - * Test the glTexImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * \param border image border given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __GLcontextRec::Const and the supported extensions, and according to the - * OpenGL specification. - */ -static GLboolean -texture_error_check( GLcontext *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLuint dimensions, - GLint width, GLint height, - GLint depth, GLint border ) -{ - const GLboolean isProxy = _mesa_is_proxy_texture(target); - GLboolean sizeOK = GL_TRUE; - GLboolean colorFormat, indexFormat; - GLenum proxy_target; - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d)", dimensions, level); - } - return GL_TRUE; - } - - /* Check border */ - if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(border=%d)", dimensions, border); - } - return GL_TRUE; - } - - if (width < 0 || height < 0 || depth < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(width, height or depth < 0)", dimensions); - } - return GL_TRUE; - } - - /* Check target and call ctx->Driver.TestProxyTexImage() to check the - * level, width, height and depth. - */ - if (dimensions == 1) { - if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) { - proxy_target = GL_PROXY_TEXTURE_1D; - height = 1; - depth = 1; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 2) { - depth = 1; - if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) { - proxy_target = GL_PROXY_TEXTURE_2D; - } - else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || - (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); - return GL_TRUE; - } - proxy_target = GL_PROXY_TEXTURE_CUBE_MAP_ARB; - sizeOK = (width == height); - } - else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV || - target == GL_TEXTURE_RECTANGLE_NV) { - if (!ctx->Extensions.NV_texture_rectangle) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); - return GL_TRUE; - } - proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV; - } - else if (target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || - target == GL_TEXTURE_1D_ARRAY_EXT) { - proxy_target = GL_PROXY_TEXTURE_1D_ARRAY_EXT; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)"); - return GL_TRUE; - } - } - else if (dimensions == 3) { - if (target == GL_PROXY_TEXTURE_3D || target == GL_TEXTURE_3D) { - proxy_target = GL_PROXY_TEXTURE_3D; - } - else if (target == GL_PROXY_TEXTURE_2D_ARRAY_EXT || - target == GL_TEXTURE_2D_ARRAY_EXT) { - proxy_target = GL_PROXY_TEXTURE_2D_ARRAY_EXT; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" ); - return GL_TRUE; - } - } - else { - _mesa_problem( ctx, "bad dims in texture_error_check" ); - return GL_TRUE; - } - - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxy_target, level, - internalFormat, format, - type, width, height, - depth, border); - if (!sizeOK) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", - dimensions, level, width, height, depth); - } - return GL_TRUE; - } - - /* Check internalFormat */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(internalFormat=%s)", - dimensions, _mesa_lookup_enum_by_nr(internalFormat)); - } - return GL_TRUE; - } - - /* Check incoming image format and type */ - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there - * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. - */ - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - } - return GL_TRUE; - } - - /* make sure internal format and format basically agree */ - colorFormat = _mesa_is_color_format(format); - indexFormat = _mesa_is_index_format(format); - if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || - (_mesa_is_index_format(internalFormat) && !indexFormat) || - (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || - (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || - (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || - (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", - dimensions, internalFormat, format); - return GL_TRUE; - } - - /* additional checks for ycbcr textures */ - if (internalFormat == GL_YCBCR_MESA) { - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - if (type != GL_UNSIGNED_SHORT_8_8_MESA && - type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format/type YCBCR mismatch", dimensions); - _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); - return GL_TRUE; /* error */ - } - if (target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - target != GL_TEXTURE_RECTANGLE_NV && - target != GL_PROXY_TEXTURE_RECTANGLE_NV) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); - return GL_TRUE; - } - if (border != 0) { - if (!isProxy) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); - } - return GL_TRUE; - } - } - - /* additional checks for depth textures */ - if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { - /* Only 1D, 2D and rectangular textures supported, not 3D or cubes */ - if (target != GL_TEXTURE_1D && - target != GL_PROXY_TEXTURE_1D && - target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - target != GL_TEXTURE_RECTANGLE_ARB && - target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage(target/internalFormat)"); - return GL_TRUE; - } - } - - /* additional checks for compressed textures */ - if (_mesa_is_compressed_format(ctx, internalFormat)) { - if (!target_can_be_compressed(ctx, target) && !isProxy) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage%dD(target)", dimensions); - return GL_TRUE; - } - if (border != 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(border!=0)", dimensions); - } - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glTexSubImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __GLcontextRec::Const and the supported extensions, and according to the - * OpenGL specification. - */ -static GLboolean -subtexture_error_check( GLcontext *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type ) -{ - /* Check target */ - if (dimensions == 1) { - if (target != GL_TEXTURE_1D) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 2) { - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target == GL_TEXTURE_RECTANGLE_NV) { - if (!ctx->Extensions.NV_texture_rectangle) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target == GL_TEXTURE_1D_ARRAY_EXT) { - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target != GL_TEXTURE_2D) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 3) { - if (target == GL_TEXTURE_2D_ARRAY_EXT) { - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" ); - return GL_TRUE; - } - } - else if (target != GL_TEXTURE_3D) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" ); - return GL_TRUE; - } - } - else { - _mesa_problem( ctx, "invalid dims in texture_error_check" ); - return GL_TRUE; - } - - /* Basic level check */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); - return GL_TRUE; - } - - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (height < 0 && dimensions > 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - if (depth < 0 && dimensions > 2) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(depth=%d)", dimensions, depth); - return GL_TRUE; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Do second part of glTexSubImage which depends on the destination texture. - * \return GL_TRUE if error recorded, GL_FALSE otherwise - */ -static GLboolean -subtexture_error_check2( GLcontext *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, - const struct gl_texture_image *destTex ) -{ - if (!destTex) { - /* undefined image level */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); - return GL_TRUE; - } - - if (xoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", - dimensions); - return GL_TRUE; - } - if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", - dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", - dimensions); - return GL_TRUE; - } - if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", - dimensions); - return GL_TRUE; - } - } - if (dimensions > 2) { - if (zoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); - return GL_TRUE; - } - if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); - return GL_TRUE; - } - } - - if (_mesa_is_format_compressed(destTex->TexFormat)) { - GLuint bw, bh; - - if (!target_can_be_compressed(ctx, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexSubImage%dD(target=%s)", dimensions, - _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* do tests which depend on compression block size */ - _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); - - /* offset must be multiple of block size */ - if ((xoffset % bw != 0) || (yoffset % bh != 0)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(xoffset = %d, yoffset = %d)", - dimensions, xoffset, yoffset); - return GL_TRUE; - } - /* size must be multiple of bw by bh or equal to whole texture size */ - if ((width % bw != 0) && (GLuint) width != destTex->Width) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(width = %d)", dimensions, width); - return GL_TRUE; - } - if ((height % bh != 0) && (GLuint) height != destTex->Height) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(height = %d)", dimensions, height); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -/** - * Test glCopyTexImage[12]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param border texture border. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __GLcontextRec::Const and the supported extensions, and according to the - * OpenGL specification. - */ -static GLboolean -copytexture_error_check( GLcontext *ctx, GLuint dimensions, - GLenum target, GLint level, GLint internalFormat, - GLint width, GLint height, GLint border ) -{ - GLenum type; - GLboolean sizeOK; - GLint format; - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - /* Check that the source buffer is complete */ - if (ctx->ReadBuffer->Name) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyTexImage%dD(invalid readbuffer)", dimensions); - return GL_TRUE; - } - } - - /* Check border */ - if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { - return GL_TRUE; - } - - format = _mesa_base_tex_format(ctx, internalFormat); - if (format < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(internalFormat)", dimensions); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(missing readbuffer)", dimensions); - return GL_TRUE; - } - - /* NOTE: the format and type aren't really significant for - * TestProxyTexImage(). Only the internalformat really matters. - */ - type = GL_FLOAT; - - /* Check target and call ctx->Driver.TestProxyTexImage() to check the - * level, width, height and depth. - */ - if (dimensions == 1) { - if (target == GL_TEXTURE_1D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_1D, - level, internalFormat, - format, type, - width, 1, 1, border); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 2) { - if (target == GL_TEXTURE_2D) { - sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_2D, - level, internalFormat, - format, type, - width, height, 1, border); - } - else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); - return GL_TRUE; - } - sizeOK = (width == height) && - ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_CUBE_MAP_ARB, - level, internalFormat, format, type, - width, height, 1, border); - } - else if (target == GL_TEXTURE_RECTANGLE_NV) { - if (!ctx->Extensions.NV_texture_rectangle) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); - return GL_TRUE; - } - sizeOK = ctx->Driver.TestProxyTexImage(ctx, - GL_PROXY_TEXTURE_RECTANGLE_NV, - level, internalFormat, - format, type, - width, height, 1, border); - } - else if (target == GL_TEXTURE_1D_ARRAY_EXT) { - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)"); - return GL_TRUE; - } - sizeOK = ctx->Driver.TestProxyTexImage(ctx, - GL_PROXY_TEXTURE_1D_ARRAY_EXT, - level, internalFormat, - format, type, - width, height, 1, border); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); - return GL_TRUE; - } - } - else { - _mesa_problem(ctx, "invalid dimensions in copytexture_error_check"); - return GL_TRUE; - } - - if (!sizeOK) { - if (dimensions == 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage1D(width=%d)", width); - } - else { - ASSERT(dimensions == 2); - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage2D(width=%d, height=%d)", width, height); - } - return GL_TRUE; - } - - if (_mesa_is_compressed_format(ctx, internalFormat)) { - if (!target_can_be_compressed(ctx, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexImage%dD(target)", dimensions); - return GL_TRUE; - } - if (border != 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(border!=0)", dimensions); - return GL_TRUE; - } - } - else if (_mesa_is_depth_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth)", dimensions); - return GL_TRUE; - } - } - else if (_mesa_is_depthstencil_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glCopyTexSubImage[12]D() parameters for errors. - * Note that this is the first part of error checking. - * See also copytexsubimage_error_check2() below for the second part. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - */ -static GLboolean -copytexsubimage_error_check1( GLcontext *ctx, GLuint dimensions, - GLenum target, GLint level) -{ - /* Check that the source buffer is complete */ - if (ctx->ReadBuffer->Name) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyTexImage%dD(invalid readbuffer)", dimensions); - return GL_TRUE; - } - } - - /* Check target */ - if (dimensions == 1) { - if (target != GL_TEXTURE_1D) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 2) { - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target == GL_TEXTURE_RECTANGLE_NV) { - if (!ctx->Extensions.NV_texture_rectangle) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target == GL_TEXTURE_1D_ARRAY_EXT) { - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (target != GL_TEXTURE_2D) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); - return GL_TRUE; - } - } - else if (dimensions == 3) { - if (((target != GL_TEXTURE_2D_ARRAY_EXT) || - (!ctx->Extensions.MESA_texture_array)) - && (target != GL_TEXTURE_3D)) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" ); - return GL_TRUE; - } - } - - /* Check level */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Second part of error checking for glCopyTexSubImage[12]D(). - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - */ -static GLboolean -copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, - const struct gl_texture_image *teximage ) -{ - /* check that dest tex image exists */ - if (!teximage) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(undefined texture level: %d)", - dimensions, level); - return GL_TRUE; - } - - /* Check size */ - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (dimensions > 1 && height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - - /* check x/y offsets */ - if (xoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); - return GL_TRUE; - } - if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset+width)", dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); - return GL_TRUE; - } - /* NOTE: we're adding the border here, not subtracting! */ - if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset+height)", dimensions); - return GL_TRUE; - } - } - - /* check z offset */ - if (dimensions > 2) { - if (zoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset)", dimensions); - return GL_TRUE; - } - if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset+depth)", dimensions); - return GL_TRUE; - } - } - - if (_mesa_is_format_compressed(teximage->TexFormat)) { - if (!target_can_be_compressed(ctx, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage%dD(target)", dimensions); - return GL_TRUE; - } - /* offset must be multiple of 4 */ - if ((xoffset & 3) || (yoffset & 3)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); - return GL_TRUE; - } - /* size must be multiple of 4 */ - if ((width & 3) != 0 && (GLuint) width != teximage->Width) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(width)", dimensions); - return GL_TRUE; - } - if ((height & 3) != 0 && (GLuint) height != teximage->Height) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(height)", dimensions); - return GL_TRUE; - } - } - - if (teximage->InternalFormat == GL_YCBCR_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", - dimensions, teximage->_BaseFormat); - return GL_TRUE; - } - - if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth buffer)", - dimensions); - return GL_TRUE; - } - } - else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth/stencil buffer)", - dimensions); - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** Callback info for walking over FBO hash table */ -struct cb_info -{ - GLcontext *ctx; - struct gl_texture_object *texObj; - GLuint level, face; -}; - - -/** - * Check render to texture callback. Called from _mesa_HashWalk(). - */ -static void -check_rtt_cb(GLuint key, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - const struct cb_info *info = (struct cb_info *) userData; - GLcontext *ctx = info->ctx; - const struct gl_texture_object *texObj = info->texObj; - const GLuint level = info->level, face = info->face; - - /* If this is a user-created FBO */ - if (fb->Name) { - GLuint i; - /* check if any of the FBO's attachments point to 'texObj' */ - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Type == GL_TEXTURE && - att->Texture == texObj && - att->TextureLevel == level && - att->CubeMapFace == face) { - ASSERT(att->Texture->Image[att->CubeMapFace][att->TextureLevel]); - /* Tell driver about the new renderbuffer texture */ - ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); - /* Mark fb status as indeterminate to force re-validation */ - fb->_Status = 0; - } - } - } -} - - -/** - * When a texture image is specified we have to check if it's bound to - * any framebuffer objects (render to texture) in order to detect changes - * in size or format since that effects FBO completeness. - * Any FBOs rendering into the texture must be re-validated. - */ -static void -update_fbo_texture(GLcontext *ctx, struct gl_texture_object *texObj, - GLuint face, GLuint level) -{ - /* Only check this texture if it's been marked as RenderToTexture */ - if (texObj->_RenderToTexture) { - struct cb_info info; - info.ctx = ctx; - info.texObj = texObj; - info.level = level; - info.face = face; - _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info); - } -} - - -/** - * If the texture object's GenerateMipmap flag is set and we've - * changed the texture base level image, regenerate the rest of the - * mipmap levels now. - */ -static INLINE void -check_gen_mipmap(GLcontext *ctx, GLenum target, - struct gl_texture_object *texObj, GLint level) -{ - ASSERT(target != GL_TEXTURE_CUBE_MAP); - if (texObj->GenerateMipmap && - level == texObj->BaseLevel && - level < texObj->MaxLevel) { - ASSERT(ctx->Driver.GenerateMipmap); - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/** Debug helper: override the user-requested internal format */ -static GLenum -override_internal_format(GLenum internalFormat, GLint width, GLint height) -{ -#if 0 - if (internalFormat == GL_RGBA16F_ARB || - internalFormat == GL_RGBA32F_ARB) { - printf("Convert rgba float tex to int %d x %d\n", width, height); - return GL_RGBA; - } - else if (internalFormat == GL_RGB16F_ARB || - internalFormat == GL_RGB32F_ARB) { - printf("Convert rgb float tex to int %d x %d\n", width, height); - return GL_RGB; - } - else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || - internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE_ALPHA; - } - else if (internalFormat == GL_LUMINANCE16F_ARB || - internalFormat == GL_LUMINANCE32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE; - } - else if (internalFormat == GL_ALPHA16F_ARB || - internalFormat == GL_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_ALPHA; - } - /* - else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { - internalFormat = GL_RGBA; - } - */ - else { - return internalFormat; - } -#else - return internalFormat; -#endif -} - - -/** - * Choose the actual hardware format for a texture image. - * Try to use the same format as the previous image level when possible. - * Otherwise, ask the driver for the best format. - * It's important to try to choose a consistant format for all levels - * for efficient texture memory layout/allocation. In particular, this - * comes up during automatic mipmap generation. - */ -void -_mesa_choose_texture_format(GLcontext *ctx, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type) -{ - /* see if we've already chosen a format for the previous level */ - if (level > 0) { - struct gl_texture_image *prevImage = - _mesa_select_tex_image(ctx, texObj, target, level - 1); - /* See if the prev level is defined and has an internal format which - * matches the new internal format. - */ - if (prevImage && - prevImage->Width > 0 && - prevImage->InternalFormat == internalFormat) { - /* use the same format */ - texImage->TexFormat = prevImage->TexFormat; - return; - } - } - - /* choose format from scratch */ - texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - format, type); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); -} - - - -/* - * Called from the API. Note that width includes the border. - */ -void GLAPIENTRY -_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid *pixels ) -{ - GLsizei postConvWidth = width; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage1D %s %d %s %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), width, border, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - internalFormat = override_internal_format(internalFormat, width, 1); - -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - - if (target == GL_TEXTURE_1D) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLuint face = _mesa_tex_target_to_face(target); - - if (texture_error_check(ctx, target, level, internalFormat, - format, type, 1, postConvWidth, 1, 1, border)) { - return; /* error was recorded */ - } - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - - ASSERT(texImage->Data == NULL); - - clear_teximage_fields(texImage); /* not really needed, but helpful */ - _mesa_init_teximage_fields(ctx, target, texImage, - postConvWidth, 1, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - - /* Give the texture to the driver. may be null. */ - ASSERT(ctx->Driver.TexImage1D); - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, format, type, pixels, - &ctx->Unpack, texObj, texImage); - - ASSERT(texImage->TexFormat); - - _mesa_set_fetch_functions(texImage, 1); - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_1D) { - /* Proxy texture: check for errors and update proxy state */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texture_error_check(ctx, target, level, internalFormat, - format, type, 1, postConvWidth, 1, 1, border)) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - ASSERT(texImage); - _mesa_init_teximage_fields(ctx, target, texImage, - postConvWidth, 1, 1, - border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GLsizei postConvWidth = width, postConvHeight = height; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage2D %s %d %s %d %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), width, height, - border, _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - internalFormat = override_internal_format(internalFormat, width, height); - -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - - if (target == GL_TEXTURE_2D || - (ctx->Extensions.ARB_texture_cube_map && - target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) || - (ctx->Extensions.NV_texture_rectangle && - target == GL_TEXTURE_RECTANGLE_NV) || - (ctx->Extensions.MESA_texture_array && - target == GL_TEXTURE_1D_ARRAY_EXT)) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLuint face = _mesa_tex_target_to_face(target); - - if (texture_error_check(ctx, target, level, internalFormat, - format, type, 2, postConvWidth, postConvHeight, - 1, border)) { - return; /* error was recorded */ - } - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - - ASSERT(texImage->Data == NULL); - clear_teximage_fields(texImage); /* not really needed, but helpful */ - _mesa_init_teximage_fields(ctx, target, texImage, - postConvWidth, postConvHeight, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - - /* Give the texture to the driver. may be null. */ - ASSERT(ctx->Driver.TexImage2D); - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, &ctx->Unpack, texObj, texImage); - - ASSERT(texImage->TexFormat); - - _mesa_set_fetch_functions(texImage, 2); - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_2D || - (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB && - ctx->Extensions.ARB_texture_cube_map) || - (target == GL_PROXY_TEXTURE_RECTANGLE_NV && - ctx->Extensions.NV_texture_rectangle) || - (ctx->Extensions.MESA_texture_array && - target == GL_PROXY_TEXTURE_1D_ARRAY_EXT)) { - /* Proxy texture: check for errors and update proxy state */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texture_error_check(ctx, target, level, internalFormat, - format, type, 2, postConvWidth, postConvHeight, - 1, border)) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - _mesa_init_teximage_fields(ctx, target, texImage, - postConvWidth, postConvHeight, 1, - border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); - return; - } -} - - -/* - * Called by the API or display list executor. - * Note that width and height include the border. - */ -void GLAPIENTRY -_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage3D %s %d %s %d %d %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), width, height, - depth, border, _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - internalFormat = override_internal_format(internalFormat, width, height); - - if (target == GL_TEXTURE_3D || - (ctx->Extensions.MESA_texture_array && - target == GL_TEXTURE_2D_ARRAY_EXT)) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLuint face = _mesa_tex_target_to_face(target); - - if (texture_error_check(ctx, target, level, (GLint) internalFormat, - format, type, 3, width, height, depth, border)) { - return; /* error was recorded */ - } - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - - ASSERT(texImage->Data == NULL); - clear_teximage_fields(texImage); /* not really needed, but helpful */ - _mesa_init_teximage_fields(ctx, target, texImage, - width, height, depth, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - - /* Give the texture to the driver. may be null. */ - ASSERT(ctx->Driver.TexImage3D); - ctx->Driver.TexImage3D(ctx, target, level, internalFormat, - width, height, depth, border, format, type, - pixels, &ctx->Unpack, texObj, texImage); - - ASSERT(texImage->TexFormat); - - _mesa_set_fetch_functions(texImage, 3); - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_3D || - (ctx->Extensions.MESA_texture_array && - target == GL_PROXY_TEXTURE_2D_ARRAY_EXT)) { - /* Proxy texture: check for errors and update proxy state */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texture_error_check(ctx, target, level, internalFormat, - format, type, 3, width, height, depth, border)) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - _mesa_init_teximage_fields(ctx, target, texImage, width, height, - depth, border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, format, type); - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) -{ - _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, - depth, border, format, type, pixels); -} - - -#if FEATURE_OES_EGL_image -void GLAPIENTRY -_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.OES_EGL_image) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetTexture2DOES(unsupported)"); - return; - } - - if (target != GL_TEXTURE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glEGLImageTargetTexture2D(target=%d)", target); - return; - } - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); - - texImage = _mesa_get_tex_image(ctx, texObj, target, 0); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); - } else { - if (texImage->Data) - ctx->Driver.FreeTexImageData( ctx, texImage ); - - ASSERT(texImage->Data == NULL); - ctx->Driver.EGLImageTargetTexture2D(ctx, target, - texObj, texImage, image); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - _mesa_unlock_texture(ctx, texObj); - -} -#endif - - -void GLAPIENTRY -_mesa_TexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GLsizei postConvWidth = width; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexSubImage1D %s %d %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - xoffset, width, _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - -#if FEATURE_convolve - /* XXX should test internal format */ - if (_mesa_is_color_format(format)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - - if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, - postConvWidth, 1, 1, format, type)) { - return; /* error was detected */ - } - - - texObj = _mesa_get_current_tex_object(ctx, target); - assert(texObj); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (subtexture_error_check2(ctx, 1, target, level, xoffset, 0, 0, - postConvWidth, 1, 1, - format, type, texImage)) { - /* error was recorded */ - } - else if (width > 0) { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - - ASSERT(ctx->Driver.TexSubImage1D); - ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width, - format, type, pixels, &ctx->Unpack, - texObj, texImage); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_TexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GLsizei postConvWidth = width, postConvHeight = height; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexSubImage2D %s %d %d %d %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - xoffset, yoffset, width, height, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - -#if FEATURE_convolve - /* XXX should test internal format */ - if (_mesa_is_color_format(format)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - - if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, - postConvWidth, postConvHeight, 1, format, type)) { - return; /* error was detected */ - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (subtexture_error_check2(ctx, 2, target, level, xoffset, yoffset, 0, - postConvWidth, postConvHeight, 1, - format, type, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height >= 0) { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - yoffset += texImage->Border; - - ASSERT(ctx->Driver.TexSubImage2D); - ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset, - width, height, format, type, pixels, - &ctx->Unpack, texObj, texImage); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_TexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexSubImage3D %s %d %d %d %d %d %d %d %s %s %p\n", - _mesa_lookup_enum_by_nr(target), level, - xoffset, yoffset, zoffset, width, height, depth, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - - if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type)) { - return; /* error was detected */ - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (subtexture_error_check2(ctx, 3, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height > 0 && height > 0) { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - yoffset += texImage->Border; - zoffset += texImage->Border; - - ASSERT(ctx->Driver.TexSubImage3D); - ctx->Driver.TexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage1D( GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLint border ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLsizei postConvWidth = width; - const GLuint face = _mesa_tex_target_to_face(target); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexImage1D %s %d %s %d %d %d %d\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - x, y, width, border); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - - if (copytexture_error_check(ctx, 1, target, level, internalFormat, - postConvWidth, 1, border)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - - ASSERT(texImage->Data == NULL); - - clear_teximage_fields(texImage); /* not really needed, but helpful */ - _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - - ASSERT(ctx->Driver.CopyTexImage1D); - ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat, - x, y, width, border); - - ASSERT(texImage->TexFormat); - - _mesa_set_fetch_functions(texImage, 1); - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLsizei postConvWidth = width, postConvHeight = height; - const GLuint face = _mesa_tex_target_to_face(target); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexImage2D %s %d %s %d %d %d %d %d\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - x, y, width, height, border); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - -#if FEATURE_convolve - if (_mesa_is_color_format(internalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, - &postConvHeight); - } -#endif - - if (copytexture_error_check(ctx, 2, target, level, internalFormat, - postConvWidth, postConvHeight, border)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - - ASSERT(texImage->Data == NULL); - - clear_teximage_fields(texImage); /* not really needed, but helpful */ - _mesa_init_teximage_fields(ctx, target, texImage, - postConvWidth, postConvHeight, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - - ASSERT(ctx->Driver.CopyTexImage2D); - ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat, - x, y, width, height, border); - - ASSERT(texImage->TexFormat); - - _mesa_set_fetch_functions(texImage, 2); - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_CopyTexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLsizei postConvWidth = width; - GLint yoffset = 0; - GLsizei height = 1; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexSubImage1D %s %d %d %d %d %d\n", - _mesa_lookup_enum_by_nr(target), - level, xoffset, x, y, width); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexsubimage_error_check1(ctx, 1, target, level)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); - } -#endif - - if (copytexsubimage_error_check2(ctx, 1, target, level, - xoffset, 0, 0, postConvWidth, 1, - texImage)) { - /* error was recorded */ - } - else { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - - if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, - &width, &height)) { - ASSERT(ctx->Driver.CopyTexSubImage1D); - ctx->Driver.CopyTexSubImage1D(ctx, target, level, - xoffset, x, y, width); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLsizei postConvWidth = width, postConvHeight = height; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexSubImage2D %s %d %d %d %d %d %d %d\n", - _mesa_lookup_enum_by_nr(target), - level, xoffset, yoffset, x, y, width, height); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexsubimage_error_check1(ctx, 2, target, level)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, - &postConvWidth, &postConvHeight); - } -#endif - - if (copytexsubimage_error_check2(ctx, 2, target, level, - xoffset, yoffset, 0, - postConvWidth, postConvHeight, - texImage)) { - /* error was recorded */ - } - else { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - yoffset += texImage->Border; - - if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, - &width, &height)) { - ASSERT(ctx->Driver.CopyTexSubImage2D); - ctx->Driver.CopyTexSubImage2D(ctx, target, level, xoffset, yoffset, - x, y, width, height); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLsizei postConvWidth = width, postConvHeight = height; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexSubImage3D %s %d %d %d %d %d %d %d %d\n", - _mesa_lookup_enum_by_nr(target), - level, xoffset, yoffset, zoffset, x, y, width, height); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexsubimage_error_check1(ctx, 3, target, level)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - -#if FEATURE_convolve - if (texImage && _mesa_is_color_format(texImage->InternalFormat)) { - _mesa_adjust_image_for_convolution(ctx, 2, - &postConvWidth, &postConvHeight); - } -#endif - - if (copytexsubimage_error_check2(ctx, 3, target, level, xoffset, yoffset, - zoffset, postConvWidth, postConvHeight, - texImage)) { - /* error was recored */ - } - else { - /* If we have a border, xoffset=-1 is legal. Bias by border width */ - xoffset += texImage->Border; - yoffset += texImage->Border; - zoffset += texImage->Border; - - if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, - &width, &height)) { - ASSERT(ctx->Driver.CopyTexSubImage3D); - ctx->Driver.CopyTexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - x, y, width, height); - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - - -/**********************************************************************/ -/****** Compressed Textures ******/ -/**********************************************************************/ - - -/** - * Return expected size of a compressed texture. - */ -static GLuint -compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, - GLenum glformat) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - return _mesa_format_image_size(mesaFormat, width, height, depth); -} - - -/* - * Return compressed texture block size, in pixels. - */ -static void -get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - _mesa_get_format_block_size(mesaFormat, bw, bh); -} - - -/** - * Error checking for glCompressedTexImage[123]D(). - * \return error code or GL_NO_ERROR. - */ -static GLenum -compressed_texture_error_check(GLcontext *ctx, GLint dimensions, - GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize) -{ - GLint expectedSize, maxLevels = 0, maxTextureSize; - - if (dimensions == 1) { - /* 1D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - else if (dimensions == 2) { - if (target == GL_PROXY_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else { - return GL_INVALID_ENUM; /*target*/ - } - } - else if (dimensions == 3) { - /* 3D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - else { - assert(0); - return GL_INVALID_ENUM; - } - - maxTextureSize = 1 << (maxLevels - 1); - - /* This will detect any invalid internalFormat value */ - if (!_mesa_is_compressed_format(ctx, internalFormat)) - return GL_INVALID_ENUM; - - /* This should really never fail */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) - return GL_INVALID_ENUM; - - if (border != 0) - return GL_INVALID_VALUE; - - /* - * XXX We should probably use the proxy texture error check function here. - */ - if (width < 1 || width > maxTextureSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(width))) - return GL_INVALID_VALUE; - - if ((height < 1 || height > maxTextureSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(height))) - && dimensions > 1) - return GL_INVALID_VALUE; - - if ((depth < 1 || depth > maxTextureSize || - (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(depth))) - && dimensions > 2) - return GL_INVALID_VALUE; - - /* For cube map, width must equal height */ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) - return GL_INVALID_VALUE; - - if (level < 0 || level >= maxLevels) - return GL_INVALID_VALUE; - - expectedSize = compressed_tex_size(width, height, depth, internalFormat); - if (expectedSize != imageSize) - return GL_INVALID_VALUE; - -#if FEATURE_EXT_texture_sRGB - if ((internalFormat == GL_COMPRESSED_SRGB_S3TC_DXT1_EXT || - internalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT || - internalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT || - internalFormat == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) - && border != 0) { - return GL_INVALID_OPERATION; - } -#endif - - return GL_NO_ERROR; -} - - -/** - * Error checking for glCompressedTexSubImage[123]D(). - * \warning There are some bad assumptions here about the size of compressed - * texture tiles (multiple of 4) used to test the validity of the - * offset and size parameters. - * \return error code or GL_NO_ERROR. - */ -static GLenum -compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize) -{ - GLint expectedSize, maxLevels = 0, maxTextureSize; - GLuint bw, bh; - (void) zoffset; - - if (dimensions == 1) { - /* 1D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - else if (dimensions == 2) { - if (target == GL_PROXY_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else { - return GL_INVALID_ENUM; /*target*/ - } - } - else if (dimensions == 3) { - /* 3D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - - maxTextureSize = 1 << (maxLevels - 1); - - /* this will catch any invalid compressed format token */ - if (!_mesa_is_compressed_format(ctx, format)) - return GL_INVALID_ENUM; - - if (width < 1 || width > maxTextureSize) - return GL_INVALID_VALUE; - - if ((height < 1 || height > maxTextureSize) - && dimensions > 1) - return GL_INVALID_VALUE; - - if (level < 0 || level >= maxLevels) - return GL_INVALID_VALUE; - - /* - * do checks which depend on compression block size - */ - get_compressed_block_size(format, &bw, &bh); - - if ((xoffset % bw != 0) || (yoffset % bh != 0)) - return GL_INVALID_VALUE; - - if ((width % bw != 0) && width != 2 && width != 1) - return GL_INVALID_VALUE; - - if ((height % bh != 0) && height != 2 && height != 1) - return GL_INVALID_VALUE; - - expectedSize = compressed_tex_size(width, height, depth, format); - if (expectedSize != imageSize) - return GL_INVALID_VALUE; - - return GL_NO_ERROR; -} - - -/** - * Do second part of glCompressedTexSubImage error checking. - * \return GL_TRUE if error found, GL_FALSE otherwise. - */ -static GLboolean -compressed_subtexture_error_check2(GLcontext *ctx, GLuint dims, - GLsizei width, GLsizei height, - GLsizei depth, GLenum format, - struct gl_texture_image *texImage) -{ - - if ((GLint) format != texImage->InternalFormat) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTexSubImage%uD(format=0x%x)", dims, format); - return GL_TRUE; - } - - if (((width == 1 || width == 2) && - width != (GLsizei) texImage->Width) || - (width > (GLsizei) texImage->Width)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(width=%d)", dims, width); - return GL_TRUE; - } - - if (dims >= 2) { - if (((height == 1 || height == 2) && - height != (GLsizei) texImage->Height) || - (height > (GLsizei) texImage->Height)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(height=%d)", dims, height); - return GL_TRUE; - } - } - - if (dims >= 3) { - if (((depth == 1 || depth == 2) && - depth != (GLsizei) texImage->Depth) || - (depth > (GLsizei) texImage->Depth)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(depth=%d)", dims, depth); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - - -void GLAPIENTRY -_mesa_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCompressedTexImage1DARB %s %d %s %d %d %d %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, border, imageSize, data); - - if (target == GL_TEXTURE_1D) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLenum error = compressed_texture_error_check(ctx, 1, target, level, - internalFormat, width, 1, 1, border, imageSize); - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage1D"); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - ASSERT(texImage->Data == NULL); - - _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - - ASSERT(ctx->Driver.CompressedTexImage1D); - ctx->Driver.CompressedTexImage1D(ctx, target, level, - internalFormat, width, border, - imageSize, data, - texObj, texImage); - - _mesa_set_fetch_functions(texImage, 1); - - check_gen_mipmap(ctx, target, texObj, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_1D) { - /* Proxy texture: check for errors and update proxy state */ - GLenum error = compressed_texture_error_check(ctx, 1, target, level, - internalFormat, width, 1, 1, border, imageSize); - if (!error) { - ASSERT(ctx->Driver.TestProxyTexImage); - error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, - internalFormat, GL_NONE, GL_NONE, - width, 1, 1, border); - } - if (error) { - /* if error, clear all proxy texture image parameters */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* store the teximage parameters */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1, - border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - } - _mesa_unlock_texture(ctx, texObj); - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1D(target)"); - return; - } -} - -void GLAPIENTRY -_mesa_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCompressedTexImage2DARB %s %d %s %d %d %d %d %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, border, imageSize, data); - -#if FEATURE_ES - switch (internalFormat) { - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - _mesa_cpal_compressed_teximage2d(target, level, internalFormat, - width, height, imageSize, data); - return; - } -#endif - - if (target == GL_TEXTURE_2D || - (ctx->Extensions.ARB_texture_cube_map && - target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - GLenum error = compressed_texture_error_check(ctx, 2, target, level, - internalFormat, width, height, 1, border, imageSize); - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage2D"); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - ASSERT(texImage->Data == NULL); - - _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, - border, internalFormat); - - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - - ASSERT(ctx->Driver.CompressedTexImage2D); - ctx->Driver.CompressedTexImage2D(ctx, target, level, - internalFormat, width, height, - border, imageSize, data, - texObj, texImage); - - _mesa_set_fetch_functions(texImage, 2); - - check_gen_mipmap(ctx, target, texObj, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_2D || - (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB && - ctx->Extensions.ARB_texture_cube_map)) { - /* Proxy texture: check for errors and update proxy state */ - GLenum error = compressed_texture_error_check(ctx, 2, target, level, - internalFormat, width, height, 1, border, imageSize); - if (!error) { - ASSERT(ctx->Driver.TestProxyTexImage); - error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, - internalFormat, GL_NONE, GL_NONE, - width, height, 1, border); - } - if (error) { - /* if error, clear all proxy texture image parameters */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* store the teximage parameters */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, - border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - } - _mesa_unlock_texture(ctx, texObj); - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(target)"); - return; - } -} - - -void GLAPIENTRY -_mesa_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCompressedTexImage3DARB %s %d %s %d %d %d %d %d %p\n", - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, imageSize, data); - - if (target == GL_TEXTURE_3D) { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLenum error = compressed_texture_error_check(ctx, 3, target, level, - internalFormat, width, height, depth, border, imageSize); - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage3D"); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3D"); - } - else { - if (texImage->Data) { - ctx->Driver.FreeTexImageData( ctx, texImage ); - } - ASSERT(texImage->Data == NULL); - - _mesa_init_teximage_fields(ctx, target, texImage, - width, height, depth, - border, internalFormat); - - /* Choose actual texture format */ - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - - ASSERT(ctx->Driver.CompressedTexImage3D); - ctx->Driver.CompressedTexImage3D(ctx, target, level, - internalFormat, - width, height, depth, - border, imageSize, data, - texObj, texImage); - - _mesa_set_fetch_functions(texImage, 3); - - check_gen_mipmap(ctx, target, texObj, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); - } - else if (target == GL_PROXY_TEXTURE_3D) { - /* Proxy texture: check for errors and update proxy state */ - GLenum error = compressed_texture_error_check(ctx, 3, target, level, - internalFormat, width, height, depth, border, imageSize); - if (!error) { - ASSERT(ctx->Driver.TestProxyTexImage); - error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, - internalFormat, GL_NONE, GL_NONE, - width, height, depth, border); - } - if (error) { - /* if error, clear all proxy texture image parameters */ - struct gl_texture_image *texImage; - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* store the teximage parameters */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - _mesa_init_teximage_fields(ctx, target, texImage, width, height, - depth, border, internalFormat); - _mesa_choose_texture_format(ctx, texObj, texImage, target, level, - internalFormat, GL_NONE, GL_NONE); - } - _mesa_unlock_texture(ctx, texObj); - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3D(target)"); - return; - } -} - - -/** - * Common helper for glCompressedTexSubImage1/2/3D(). - */ -static void -compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize, const GLvoid *data) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLenum error; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - error = compressed_subtexture_error_check(ctx, dims, target, level, - xoffset, 0, 0, /* pos */ - width, height, depth, /* size */ - format, imageSize); - if (error) { - _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - assert(texImage); - - if (compressed_subtexture_error_check2(ctx, dims, width, height, depth, - format, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height > 0 && depth > 0) { - switch (dims) { - case 1: - if (ctx->Driver.CompressedTexSubImage1D) { - ctx->Driver.CompressedTexSubImage1D(ctx, target, level, - xoffset, width, - format, imageSize, data, - texObj, texImage); - } - break; - case 2: - if (ctx->Driver.CompressedTexSubImage2D) { - ctx->Driver.CompressedTexSubImage2D(ctx, target, level, - xoffset, yoffset, - width, height, - format, imageSize, data, - texObj, texImage); - } - break; - case 3: - if (ctx->Driver.CompressedTexSubImage3D) { - ctx->Driver.CompressedTexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data, - texObj, texImage); - } - break; - default: - ; - } - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid *data) -{ - compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0, - width, height, 1, format, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, imageSize, data); -} - - +/* + * mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file teximage.c + * Texture image-related functions. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "framebuffer.h" +#include "hash.h" +#include "image.h" +#include "imports.h" +#include "macros.h" +#include "state.h" +#include "texcompress.h" +#include "texfetch.h" +#include "teximage.h" +#include "texstate.h" +#include "texpal.h" +#include "mtypes.h" + + +/** + * State changes which we care about for glCopyTex[Sub]Image() calls. + * In particular, we care about pixel transfer state and buffer state + * (such as glReadBuffer to make sure we read from the right renderbuffer). + */ +#define NEW_COPY_TEX_STATE (_MESA_NEW_TRANSFER_STATE | \ + _NEW_BUFFERS | \ + _NEW_PIXEL) + + + +/** + * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE + * elsewhere. + */ +void * +_mesa_alloc_texmemory(GLsizei bytes) +{ + return _mesa_align_malloc(bytes, 512); +} + + +/** + * Free texture memory allocated with _mesa_alloc_texmemory() + */ +void +_mesa_free_texmemory(void *m) +{ + _mesa_align_free(m); +} + + +/* + * Compute floor(log_base_2(n)). + * If n < 0 return -1. + */ +static int +logbase2( int n ) +{ + GLint i = 1; + GLint log2 = 0; + + if (n < 0) + return -1; + + if (n == 0) + return 0; + + while ( n > i ) { + i *= 2; + log2++; + } + if (i != n) { + return log2 - 1; + } + else { + return log2; + } +} + + + +/** + * Return the simple base format for a given internal texture format. + * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. + * + * \param ctx GL context. + * \param internalFormat the internal texture format token or 1, 2, 3, or 4. + * + * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, + * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. + * + * This is the format which is used during texture application (i.e. the + * texture format and env mode determine the arithmetic used. + * + * XXX this could be static + */ +GLint +_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) +{ + switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.EXT_paletted_texture) { + switch (internalFormat) { + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + return GL_COLOR_INDEX; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_texture) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + default: + ; /* fallthrough */ + } + } + + switch (internalFormat) { + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + case GL_COMPRESSED_RGB: + return GL_RGB; + case GL_COMPRESSED_RGBA: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return GL_RGB; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_s3tc) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.S3_s3tc) { + switch (internalFormat) { + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + return GL_RGB; + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_ycbcr_texture) { + if (internalFormat == GL_YCBCR_MESA) + return GL_YCBCR_MESA; + } + + if (ctx->Extensions.ARB_texture_float) { + switch (internalFormat) { + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + return GL_ALPHA; + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: + return GL_RGBA; + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + return GL_RGB; + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + return GL_INTENSITY; + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ATI_envmap_bumpmap) { + switch (internalFormat) { + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return GL_DUDV_ATI; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_texture_signed_rgba) { + switch (internalFormat) { + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_depth_stencil) { + switch (internalFormat) { + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return GL_DEPTH_STENCIL_EXT; + default: + ; /* fallthrough */ + } + } + +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + switch (internalFormat) { + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_RGBA; + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + return GL_LUMINANCE_ALPHA; + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + return GL_LUMINANCE; + default: + ; /* fallthrough */ + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + + if (ctx->Extensions.EXT_texture_integer) { + switch (internalFormat) { + case GL_RGBA8UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGBA32UI_EXT: + case GL_RGBA8I_EXT: + case GL_RGBA16I_EXT: + case GL_RGBA32I_EXT: + return GL_RGBA; + case GL_RGB8UI_EXT: + case GL_RGB16UI_EXT: + case GL_RGB32UI_EXT: + case GL_RGB8I_EXT: + case GL_RGB16I_EXT: + case GL_RGB32I_EXT: + return GL_RGB; + case GL_ALPHA8UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_ALPHA8I_EXT: + case GL_ALPHA16I_EXT: + case GL_ALPHA32I_EXT: + return GL_ALPHA; + case GL_INTENSITY8UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_INTENSITY8I_EXT: + case GL_INTENSITY16I_EXT: + case GL_INTENSITY32I_EXT: + return GL_INTENSITY; + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE32I_EXT: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R16F: + /* R16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_R32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RED; + case GL_R8I: + case GL_R8UI: + case GL_R16I: + case GL_R16UI: + case GL_R32I: + case GL_R32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_R8: + case GL_R16: + case GL_RED: + case GL_COMPRESSED_RED: + return GL_RED; + + case GL_RG16F: + /* RG16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_RG32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RG; + case GL_RG8I: + case GL_RG8UI: + case GL_RG16I: + case GL_RG16UI: + case GL_RG32I: + case GL_RG32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_RG: + case GL_RG8: + case GL_RG16: + case GL_COMPRESSED_RG: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_shared_exponent) { + switch (internalFormat) { + case GL_RGB9_E5_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_float) { + switch (internalFormat) { + case GL_R11F_G11F_B10F_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_buffer_float) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT32F: + return GL_DEPTH_COMPONENT; + case GL_DEPTH32F_STENCIL8: + return GL_DEPTH_STENCIL; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_RED; + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + return -1; /* error */ +} + + +/** + * For cube map faces, return a face index in [0,5]. + * For other targets return 0; + */ +GLuint +_mesa_tex_target_to_face(GLenum target) +{ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) + return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; + else + return 0; +} + + + +/** + * Store a gl_texture_image pointer in a gl_texture_object structure + * according to the target and level parameters. + * + * \param tObj texture object. + * \param target texture target. + * \param level image level. + * \param texImage texture image. + * + * This was basically prompted by the introduction of cube maps. + */ +void +_mesa_set_tex_image(struct gl_texture_object *tObj, + GLenum target, GLint level, + struct gl_texture_image *texImage) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(tObj); + ASSERT(texImage); + ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0); + + tObj->Image[face][level] = texImage; + + /* Set the 'back' pointer */ + texImage->TexObject = tObj; +} + + +/** + * Allocate a texture image structure. + * + * Called via ctx->Driver.NewTextureImage() unless overriden by a device + * driver. + * + * \return a pointer to gl_texture_image struct with all fields initialized to + * zero. + */ +struct gl_texture_image * +_mesa_new_texture_image( struct gl_context *ctx ) +{ + (void) ctx; + return CALLOC_STRUCT(gl_texture_image); +} + + +/** + * Free texture image data. + * This function is a fallback called via ctx->Driver.FreeTexImageData(). + * + * \param texImage texture image. + * + * Free the texture image data if it's not marked as client data. + */ +void +_mesa_free_texture_image_data(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + (void) ctx; + + if (texImage->Data && !texImage->IsClientData) { + /* free the old texture data */ + _mesa_free_texmemory(texImage->Data); + } + + texImage->Data = NULL; +} + + +/** + * Free texture image. + * + * \param texImage texture image. + * + * Free the texture image structure and the associated image data. + */ +void +_mesa_delete_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + /* Free texImage->Data and/or any other driver-specific texture + * image storage. + */ + ASSERT(ctx->Driver.FreeTexImageData); + ctx->Driver.FreeTexImageData( ctx, texImage ); + + ASSERT(texImage->Data == NULL); + if (texImage->ImageOffsets) + free(texImage->ImageOffsets); + free(texImage); +} + + +/** + * Test if a target is a proxy target. + * + * \param target texture target. + * + * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. + */ +GLboolean +_mesa_is_proxy_texture(GLenum target) +{ + /* NUM_TEXTURE_TARGETS should match number of terms below */ + assert(NUM_TEXTURE_TARGETS == 7); + + return (target == GL_PROXY_TEXTURE_1D || + target == GL_PROXY_TEXTURE_2D || + target == GL_PROXY_TEXTURE_3D || + target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || + target == GL_PROXY_TEXTURE_2D_ARRAY_EXT); +} + + +/** + * Return the proxy target which corresponds to the given texture target + */ +static GLenum +get_proxy_target(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_PROXY_TEXTURE_1D; + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_PROXY_TEXTURE_2D; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_PROXY_TEXTURE_3D; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return GL_PROXY_TEXTURE_CUBE_MAP_ARB; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return GL_PROXY_TEXTURE_RECTANGLE_NV; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return GL_PROXY_TEXTURE_1D_ARRAY_EXT; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return GL_PROXY_TEXTURE_2D_ARRAY_EXT; + default: + _mesa_problem(NULL, "unexpected target in get_proxy_target()"); + return 0; + } +} + + +/** + * Get the texture object that corresponds to the target of the given + * texture unit. + * + * \param ctx GL context. + * \param texUnit texture unit. + * \param target texture target. + * + * \return pointer to the texture object on success, or NULL on failure. + * + * \sa gl_texture_unit. + */ +struct gl_texture_object * +_mesa_select_tex_object(struct gl_context *ctx, + const struct gl_texture_unit *texUnit, + GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + case GL_PROXY_TEXTURE_1D: + return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; + case GL_TEXTURE_2D: + return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + case GL_PROXY_TEXTURE_2D: + return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; + case GL_TEXTURE_3D: + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + case GL_PROXY_TEXTURE_3D: + return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; + case GL_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + default: + _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); + return NULL; + } +} + + +/** + * Return pointer to texture object for given target on current texture unit. + */ +struct gl_texture_object * +_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + return _mesa_select_tex_object(ctx, texUnit, target); +} + + +/** + * Get a texture image pointer from a texture object, given a texture + * target and mipmap level. The target and level parameters should + * have already been error-checked. + * + * \param ctx GL context. + * \param texObj texture unit. + * \param target texture target. + * \param level image level. + * + * \return pointer to the texture image structure, or NULL on failure. + */ +struct gl_texture_image * +_mesa_select_tex_image(struct gl_context *ctx, + const struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(texObj); + ASSERT(level >= 0); + ASSERT(level < MAX_TEXTURE_LEVELS); + + return texObj->Image[face][level]; +} + + +/** + * Like _mesa_select_tex_image() but if the image doesn't exist, allocate + * it and install it. Only return NULL if passed a bad parameter or run + * out of memory. + */ +struct gl_texture_image * +_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + + if (!texObj) + return NULL; + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); + return NULL; + } + + _mesa_set_tex_image(texObj, target, level, texImage); + } + + return texImage; +} + + +/** + * Return pointer to the specified proxy texture image. + * Note that proxy textures are per-context, not per-texture unit. + * \return pointer to texture image or NULL if invalid target, invalid + * level, or out of memory. + */ +struct gl_texture_image * +_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + GLuint texIndex; + + if (level < 0 ) + return NULL; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_INDEX; + break; + case GL_PROXY_TEXTURE_2D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_INDEX; + break; + case GL_PROXY_TEXTURE_3D: + if (level >= ctx->Const.Max3DTextureLevels) + return NULL; + texIndex = TEXTURE_3D_INDEX; + break; + case GL_PROXY_TEXTURE_CUBE_MAP: + if (level >= ctx->Const.MaxCubeTextureLevels) + return NULL; + texIndex = TEXTURE_CUBE_INDEX; + break; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + if (level > 0) + return NULL; + texIndex = TEXTURE_RECT_INDEX; + break; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_ARRAY_INDEX; + break; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_ARRAY_INDEX; + break; + default: + return NULL; + } + + texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); + return NULL; + } + ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; + /* Set the 'back' pointer */ + texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; + } + return texImage; +} + + +/** + * Get the maximum number of allowed mipmap levels. + * + * \param ctx GL context. + * \param target texture target. + * + * \return the maximum number of allowed mipmap levels for the given + * texture target, or zero if passed a bad target. + * + * \sa gl_constants. + */ +GLint +_mesa_max_texture_levels(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return ctx->Const.MaxTextureLevels; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return ctx->Const.Max3DTextureLevels; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Const.MaxCubeTextureLevels : 0; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle ? 1 : 0; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array + ? ctx->Const.MaxTextureLevels : 0; + default: + return 0; /* bad target */ + } +} + + +/** + * Return number of dimensions per mipmap level for the given texture target. + */ +static GLint +get_texture_dimensions(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return 1; + case GL_TEXTURE_2D: + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_2D: + case GL_PROXY_TEXTURE_RECTANGLE: + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + case GL_TEXTURE_1D_ARRAY: + case GL_PROXY_TEXTURE_1D_ARRAY: + return 2; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + case GL_PROXY_TEXTURE_2D_ARRAY: + return 3; + default: + _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()", + target); + return 2; + } +} + + + + +#if 000 /* not used anymore */ +/* + * glTexImage[123]D can accept a NULL image pointer. In this case we + * create a texture image with unspecified image contents per the OpenGL + * spec. + */ +static GLubyte * +make_null_texture(GLint width, GLint height, GLint depth, GLenum format) +{ + const GLint components = _mesa_components_in_format(format); + const GLint numPixels = width * height * depth; + GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); + +#ifdef DEBUG + /* + * Let's see if anyone finds this. If glTexImage2D() is called with + * a NULL image pointer then load the texture image with something + * interesting instead of leaving it indeterminate. + */ + if (data) { + static const char message[8][32] = { + " X X XXXXX XXX X ", + " XX XX X X X X X ", + " X X X X X X X ", + " X X XXXX XXX XXXXX ", + " X X X X X X ", + " X X X X X X X ", + " X X XXXXX XXX X X ", + " " + }; + + GLubyte *imgPtr = data; + GLint h, i, j, k; + for (h = 0; h < depth; h++) { + for (i = 0; i < height; i++) { + GLint srcRow = 7 - (i % 8); + for (j = 0; j < width; j++) { + GLint srcCol = j % 32; + GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; + for (k = 0; k < components; k++) { + *imgPtr++ = texel; + } + } + } + } + } +#endif + + return data; +} +#endif + + + +/** + * Reset the fields of a gl_texture_image struct to zero. + * + * \param img texture image structure. + * + * This is called when a proxy texture test fails, we set all the + * image members (except DriverData) to zero. + * It's also used in glTexImage[123]D as a safeguard to be sure all + * required fields get initialized properly by the Driver.TexImage[123]D + * functions. + */ +static void +clear_teximage_fields(struct gl_texture_image *img) +{ + ASSERT(img); + img->_BaseFormat = 0; + img->InternalFormat = 0; + img->Border = 0; + img->Width = 0; + img->Height = 0; + img->Depth = 0; + img->RowStride = 0; + if (img->ImageOffsets) { + free(img->ImageOffsets); + img->ImageOffsets = NULL; + } + img->Width2 = 0; + img->Height2 = 0; + img->Depth2 = 0; + img->WidthLog2 = 0; + img->HeightLog2 = 0; + img->DepthLog2 = 0; + img->Data = NULL; + img->TexFormat = MESA_FORMAT_NONE; + img->FetchTexelc = NULL; + img->FetchTexelf = NULL; +} + + +/** + * Initialize basic fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). + * \param img texture image structure to be initialized. + * \param width image width. + * \param height image height. + * \param depth image depth. + * \param border image border. + * \param internalFormat internal format. + * \param format the actual hardware format (one of MESA_FORMAT_*) + * + * Fills in the fields of \p img with the given information. + * Note: width, height and depth include the border. + */ +void +_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, + struct gl_texture_image *img, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum internalFormat, + gl_format format) +{ + GLint i, dims; + + ASSERT(img); + ASSERT(width >= 0); + ASSERT(height >= 0); + ASSERT(depth >= 0); + + img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); + ASSERT(img->_BaseFormat > 0); + img->InternalFormat = internalFormat; + img->Border = border; + img->Width = width; + img->Height = height; + img->Depth = depth; + + img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ + img->WidthLog2 = logbase2(img->Width2); + + if (height == 1) { /* 1-D texture */ + img->Height2 = 1; + img->HeightLog2 = 0; + } + else { + img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ + img->HeightLog2 = logbase2(img->Height2); + } + + if (depth == 1) { /* 2-D texture */ + img->Depth2 = 1; + img->DepthLog2 = 0; + } + else { + img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */ + img->DepthLog2 = logbase2(img->Depth2); + } + + img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); + + if ((width == 1 || _mesa_is_pow_two(img->Width2)) && + (height == 1 || _mesa_is_pow_two(img->Height2)) && + (depth == 1 || _mesa_is_pow_two(img->Depth2))) + img->_IsPowerOfTwo = GL_TRUE; + else + img->_IsPowerOfTwo = GL_FALSE; + + /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ + img->RowStride = width; + /* Allocate the ImageOffsets array and initialize to typical values. + * We allocate the array for 1D/2D textures too in order to avoid special- + * case code in the texstore routines. + */ + if (img->ImageOffsets) + free(img->ImageOffsets); + img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); + for (i = 0; i < depth; i++) { + img->ImageOffsets[i] = i * width * height; + } + + /* Compute Width/Height/DepthScale for mipmap lod computation */ + if (target == GL_TEXTURE_RECTANGLE_NV) { + /* scale = 1.0 since texture coords directly map to texels */ + img->WidthScale = 1.0; + img->HeightScale = 1.0; + img->DepthScale = 1.0; + } + else { + img->WidthScale = (GLfloat) img->Width; + img->HeightScale = (GLfloat) img->Height; + img->DepthScale = (GLfloat) img->Depth; + } + + img->TexFormat = format; + + dims = get_texture_dimensions(target); + + _mesa_set_fetch_functions(img, dims); +} + + +/** + * Free and clear fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param texImage texture image structure to be cleared. + * + * After the call, \p texImage will have no data associated with it. Its + * fields are cleared so that its parent object will test incomplete. + */ +void +_mesa_clear_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + ctx->Driver.FreeTexImageData(ctx, texImage); + clear_teximage_fields(texImage); +} + + +/** + * This is the fallback for Driver.TestProxyTexImage(). Test the texture + * level, width, height and depth against the ctx->Const limits for textures. + * + * A hardware driver might override this function if, for example, the + * max 3D texture size is 512x512x64 (i.e. not a cube). + * + * Note that width, height, depth == 0 is not an error. However, a + * texture with zero width/height/depth will be considered "incomplete" + * and texturing will effectively be disabled. + * + * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, + * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, + * GL_PROXY_TEXTURE_CUBE_MAP_ARB. + * \param level as passed to glTexImage + * \param internalFormat as passed to glTexImage + * \param format as passed to glTexImage + * \param type as passed to glTexImage + * \param width as passed to glTexImage + * \param height as passed to glTexImage + * \param depth as passed to glTexImage + * \param border as passed to glTexImage + * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. + */ +GLboolean +_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, GLenum format, GLenum type, + GLint width, GLint height, GLint depth, GLint border) +{ + GLint maxSize; + + (void) internalFormat; + (void) format; + (void) type; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_3D: + maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 2 * border || depth > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.Max3DTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_RECTANGLE_NV: + maxSize = ctx->Const.MaxTextureRectSize; + if (width < 0 || width > maxSize) + return GL_FALSE; + if (height < 0 || height > maxSize) + return GL_FALSE; + if (level != 0) + return GL_FALSE; + return GL_TRUE; + + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxCubeTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 1 || height > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + default: + _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); + return GL_FALSE; + } +} + + +/** + * Check if the memory used by the texture would exceed the driver's limit. + * This lets us support a max 3D texture size of 8K (for example) but + * prevents allocating a full 8K x 8K x 8K texture. + * XXX this could be rolled into the proxy texture size test (above) but + * we don't have the actual texture internal format at that point. + */ +static GLboolean +legal_texture_size(struct gl_context *ctx, gl_format format, + GLint width, GLint height, GLint depth) +{ + uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); + uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ + return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; +} + + + +/** + * Helper function to determine whether a target and specific compression + * format are supported. + */ +static GLboolean +target_can_be_compressed(const struct gl_context *ctx, GLenum target, + GLenum intFormat) +{ + (void) intFormat; /* not used yet */ + + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; /* true for any compressed format so far */ + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexImage1/2/3D call. + */ +static GLboolean +legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_TRUE; + default: + return GL_FALSE; + } + case 2: + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims); + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexSubImage, glCopyTexSubImage or glCopyTexImage call. + * The difference compared to legal_teximage_target() above is that + * proxy targets are not supported. + */ +static GLboolean +legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + return target == GL_TEXTURE_1D; + case 2: + switch (target) { + case GL_TEXTURE_2D: + return GL_TRUE; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + return ctx->Extensions.MESA_texture_array; + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()", + dims); + return GL_FALSE; + } +} + + +/** + * Test the glTexImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * \param border image border given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +texture_error_check( struct gl_context *ctx, + GLuint dimensions, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLboolean isProxy = target == proxyTarget; + GLboolean sizeOK = GL_TRUE; + GLboolean colorFormat, indexFormat; + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d)", dimensions, level); + } + return GL_TRUE; + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(border=%d)", dimensions, border); + } + return GL_TRUE; + } + + if (width < 0 || height < 0 || depth < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(width, height or depth < 0)", dimensions); + } + return GL_TRUE; + } + + /* Do this simple check before calling the TestProxyTexImage() function */ + if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + sizeOK = (width == height); + } + + /* + * Use the proxy texture driver hook to see if the size/level/etc are + * legal. + */ + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + depth, border); + if (!sizeOK) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", + dimensions, level, width, height, depth); + } + return GL_TRUE; + } + + /* Check internalFormat */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(internalFormat=%s)", + dimensions, _mesa_lookup_enum_by_nr(internalFormat)); + } + return GL_TRUE; + } + + /* Check incoming image format and type */ + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* Normally, GL_INVALID_OPERATION is generated by a format/type + * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the + * GL_EXT_texture_integer extension, some combinations should generate + * GL_INVALID_ENUM instead (grr!). + */ + if (!isProxy) { + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_ENUM : GL_INVALID_OPERATION; + _mesa_error(ctx, error, + "glTexImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + } + return GL_TRUE; + } + + /* make sure internal format and format basically agree */ + colorFormat = _mesa_is_color_format(format); + indexFormat = _mesa_is_index_format(format); + if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || + (_mesa_is_index_format(internalFormat) && !indexFormat) || + (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || + (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || + (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || + (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", + dimensions, internalFormat, format); + return GL_TRUE; + } + + /* additional checks for ycbcr textures */ + if (internalFormat == GL_YCBCR_MESA) { + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + if (type != GL_UNSIGNED_SHORT_8_8_MESA && + type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format/type YCBCR mismatch", dimensions); + _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); + return GL_TRUE; /* error */ + } + if (target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_NV && + target != GL_PROXY_TEXTURE_RECTANGLE_NV) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); + } + return GL_TRUE; + } + } + + /* additional checks for depth textures */ + if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { + /* Only 1D, 2D and rectangular textures supported, not 3D or cubes */ + if (target != GL_TEXTURE_1D && + target != GL_PROXY_TEXTURE_1D && + target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_ARB && + target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage(target/internalFormat)"); + return GL_TRUE; + } + } + + /* additional checks for compressed textures */ + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(border!=0)", dimensions); + } + return GL_TRUE; + } + } + + /* additional checks for integer textures */ + if (ctx->Extensions.EXT_texture_integer && + (_mesa_is_integer_format(format) != + _mesa_is_integer_format(internalFormat))) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(integer/non-integer format mismatch)", + dimensions); + } + return GL_TRUE; + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glTexSubImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +subtexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type ) +{ + /* Basic level check */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); + return GL_TRUE; + } + + /* Check for negative sizes */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (height < 0 && dimensions > 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + if (depth < 0 && dimensions > 2) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(depth=%d)", dimensions, depth); + return GL_TRUE; + } + + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* As with the glTexImage2D check above, the error code here + * depends on texture integer. + */ + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_OPERATION : GL_INVALID_ENUM; + _mesa_error(ctx, error, + "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Do second part of glTexSubImage which depends on the destination texture. + * \return GL_TRUE if error recorded, GL_FALSE otherwise + */ +static GLboolean +subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, + const struct gl_texture_image *destTex ) +{ + if (!destTex) { + /* undefined image level */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); + return GL_TRUE; + } + + if (xoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", + dimensions); + return GL_TRUE; + } + if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", + dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", + dimensions); + return GL_TRUE; + } + if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", + dimensions); + return GL_TRUE; + } + } + if (dimensions > 2) { + if (zoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); + return GL_TRUE; + } + if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(destTex->TexFormat)) { + GLuint bw, bh; + + /* do tests which depend on compression block size */ + _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); + + /* offset must be multiple of block size */ + if ((xoffset % bw != 0) || (yoffset % bh != 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(xoffset = %d, yoffset = %d)", + dimensions, xoffset, yoffset); + return GL_TRUE; + } + /* size must be multiple of bw by bh or equal to whole texture size */ + if ((width % bw != 0) && (GLuint) width != destTex->Width) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(width = %d)", dimensions, width); + return GL_TRUE; + } + if ((height % bh != 0) && (GLuint) height != destTex->Height) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(height = %d)", dimensions, height); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Test glCopyTexImage[12]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param border texture border. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +copytexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, GLint internalFormat, + GLint width, GLint height, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLenum type = GL_FLOAT; + GLboolean sizeOK; + GLint format; + + /* check target */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + return GL_TRUE; + } + + format = _mesa_base_tex_format(ctx, internalFormat); + if (format < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(internalFormat)", dimensions); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(missing readbuffer)", dimensions); + return GL_TRUE; + } + + /* Do size, level checking */ + sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) + ? (width == height) : 1; + + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + 1, border); + + if (!sizeOK) { + if (dimensions == 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage1D(width=%d)", width); + } + else { + ASSERT(dimensions == 2); + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage2D(width=%d, height=%d)", width, height); + } + return GL_TRUE; + } + + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(border!=0)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depth_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depthstencil_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glCopyTexSubImage[12]D() parameters for errors. + * Note that this is the first part of error checking. + * See also copytexsubimage_error_check2() below for the second part. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + */ +static GLboolean +copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level) +{ + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Check level */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Second part of error checking for glCopyTexSubImage[12]D(). + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + */ +static GLboolean +copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, + const struct gl_texture_image *teximage ) +{ + /* check that dest tex image exists */ + if (!teximage) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(undefined texture level: %d)", + dimensions, level); + return GL_TRUE; + } + + /* Check size */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (dimensions > 1 && height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + + /* check x/y offsets */ + if (xoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); + return GL_TRUE; + } + if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset+width)", dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); + return GL_TRUE; + } + /* NOTE: we're adding the border here, not subtracting! */ + if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset+height)", dimensions); + return GL_TRUE; + } + } + + /* check z offset */ + if (dimensions > 2) { + if (zoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset)", dimensions); + return GL_TRUE; + } + if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset+depth)", dimensions); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(teximage->TexFormat)) { + /* offset must be multiple of 4 */ + if ((xoffset & 3) || (yoffset & 3)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); + return GL_TRUE; + } + /* size must be multiple of 4 */ + if ((width & 3) != 0 && (GLuint) width != teximage->Width) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width)", dimensions); + return GL_TRUE; + } + if ((height & 3) != 0 && (GLuint) height != teximage->Height) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height)", dimensions); + return GL_TRUE; + } + } + + if (teximage->InternalFormat == GL_YCBCR_MESA) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", + dimensions, teximage->_BaseFormat); + return GL_TRUE; + } + + if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth buffer)", + dimensions); + return GL_TRUE; + } + } + else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth/stencil buffer)", + dimensions); + return GL_TRUE; + } + } + + /* If copying into an integer texture, the source buffer must also be + * integer-valued. + */ + if (_mesa_is_format_integer_color(teximage->TexFormat)) { + struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + if (!_mesa_is_format_integer_color(rb->Format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(source buffer is not integer format)", + dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** Callback info for walking over FBO hash table */ +struct cb_info +{ + struct gl_context *ctx; + struct gl_texture_object *texObj; + GLuint level, face; +}; + + +/** + * Check render to texture callback. Called from _mesa_HashWalk(). + */ +static void +check_rtt_cb(GLuint key, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + const struct cb_info *info = (struct cb_info *) userData; + struct gl_context *ctx = info->ctx; + const struct gl_texture_object *texObj = info->texObj; + const GLuint level = info->level, face = info->face; + + /* If this is a user-created FBO */ + if (fb->Name) { + GLuint i; + /* check if any of the FBO's attachments point to 'texObj' */ + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Type == GL_TEXTURE && + att->Texture == texObj && + att->TextureLevel == level && + att->CubeMapFace == face) { + ASSERT(att->Texture->Image[att->CubeMapFace][att->TextureLevel]); + /* Tell driver about the new renderbuffer texture */ + ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); + /* Mark fb status as indeterminate to force re-validation */ + fb->_Status = 0; + } + } + } +} + + +/** + * When a texture image is specified we have to check if it's bound to + * any framebuffer objects (render to texture) in order to detect changes + * in size or format since that effects FBO completeness. + * Any FBOs rendering into the texture must be re-validated. + */ +static void +update_fbo_texture(struct gl_context *ctx, struct gl_texture_object *texObj, + GLuint face, GLuint level) +{ + /* Only check this texture if it's been marked as RenderToTexture */ + if (texObj->_RenderToTexture) { + struct cb_info info; + info.ctx = ctx; + info.texObj = texObj; + info.level = level; + info.face = face; + _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info); + } +} + + +/** + * If the texture object's GenerateMipmap flag is set and we've + * changed the texture base level image, regenerate the rest of the + * mipmap levels now. + */ +static INLINE void +check_gen_mipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, GLint level) +{ + ASSERT(target != GL_TEXTURE_CUBE_MAP); + if (texObj->GenerateMipmap && + level == texObj->BaseLevel && + level < texObj->MaxLevel) { + ASSERT(ctx->Driver.GenerateMipmap); + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } +} + + +/** Debug helper: override the user-requested internal format */ +static GLenum +override_internal_format(GLenum internalFormat, GLint width, GLint height) +{ +#if 0 + if (internalFormat == GL_RGBA16F_ARB || + internalFormat == GL_RGBA32F_ARB) { + printf("Convert rgba float tex to int %d x %d\n", width, height); + return GL_RGBA; + } + else if (internalFormat == GL_RGB16F_ARB || + internalFormat == GL_RGB32F_ARB) { + printf("Convert rgb float tex to int %d x %d\n", width, height); + return GL_RGB; + } + else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || + internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE_ALPHA; + } + else if (internalFormat == GL_LUMINANCE16F_ARB || + internalFormat == GL_LUMINANCE32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE; + } + else if (internalFormat == GL_ALPHA16F_ARB || + internalFormat == GL_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_ALPHA; + } + /* + else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { + internalFormat = GL_RGBA; + } + */ + else { + return internalFormat; + } +#else + return internalFormat; +#endif +} + + +/** + * Choose the actual hardware format for a texture image. + * Try to use the same format as the previous image level when possible. + * Otherwise, ask the driver for the best format. + * It's important to try to choose a consistant format for all levels + * for efficient texture memory layout/allocation. In particular, this + * comes up during automatic mipmap generation. + */ +gl_format +_mesa_choose_texture_format(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum target, GLint level, + GLenum internalFormat, GLenum format, GLenum type) +{ + gl_format f; + + /* see if we've already chosen a format for the previous level */ + if (level > 0) { + struct gl_texture_image *prevImage = + _mesa_select_tex_image(ctx, texObj, target, level - 1); + /* See if the prev level is defined and has an internal format which + * matches the new internal format. + */ + if (prevImage && + prevImage->Width > 0 && + prevImage->InternalFormat == internalFormat) { + /* use the same format */ + ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); + return prevImage->TexFormat; + } + } + + /* choose format from scratch */ + f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + ASSERT(f != MESA_FORMAT_NONE); + return f; +} + + +/** + * Common code to implement all the glTexImage1D/2D/3D functions. + */ +static void +teximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels) +{ + GLboolean error; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + internalFormat = override_internal_format(internalFormat, width, height); + + /* target error checking */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + /* general error checking */ + error = texture_error_check(ctx, dims, target, level, internalFormat, + format, type, width, height, depth, border); + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just clear or set state depending on error checking */ + struct gl_texture_image *texImage = + _mesa_get_proxy_tex_image(ctx, target, level); + + if (error) { + /* when error, clear all proxy texture image parameters */ + if (texImage) + clear_teximage_fields(texImage); + } + else { + /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, + target, level, + internalFormat, + format, type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + texFormat); + } + else if (texImage) { + clear_teximage_fields(texImage); + } + } + } + else { + /* non-proxy target */ + const GLuint face = _mesa_tex_target_to_face(target); + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + return; /* error was recorded */ + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + + ASSERT(texImage->Data == NULL); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, + type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + /* Give the texture to the driver. may be null. */ + ASSERT(ctx->Driver.TexImage3D); + switch (dims) { + case 1: + ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + width, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 2: + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 3: + ctx->Driver.TexImage3D(ctx, target, level, internalFormat, + width, height, depth, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + default: + _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); + } + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +/* + * Called from the API. Note that width includes the border. + */ +void GLAPIENTRY +_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 1, target, level, internalFormat, width, 1, 1, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 2, target, level, internalFormat, width, height, 1, + border, format, type, pixels); +} + + +/* + * Called by the API or display list executor. + * Note that width and height include the border. + */ +void GLAPIENTRY +_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 3, target, level, internalFormat, width, height, depth, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, + depth, border, format, type, pixels); +} + + +#if FEATURE_OES_EGL_image +void GLAPIENTRY +_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(unsupported)"); + return; + } + + if (target != GL_TEXTURE_2D) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glEGLImageTargetTexture2D(target=%d)", target); + return; + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + _mesa_lock_texture(ctx, texObj); + + texImage = _mesa_get_tex_image(ctx, texObj, target, 0); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); + } else { + if (texImage->Data) + ctx->Driver.FreeTexImageData( ctx, texImage ); + + ASSERT(texImage->Data == NULL); + ctx->Driver.EGLImageTargetTexture2D(ctx, target, + texObj, texImage, image); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + _mesa_unlock_texture(ctx, texObj); + +} +#endif + + + +/** + * Implement all the glTexSubImage1/2/3D() functions. + */ +static void +texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + xoffset, yoffset, zoffset, width, height, depth, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + if (ctx->NewState & _MESA_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + + if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type)) { + return; /* error was detected */ + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (subtexture_error_check2(ctx, dims, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && height > 0) { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + switch (dims) { + case 1: + ctx->Driver.TexSubImage1D(ctx, target, level, + xoffset, width, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 2: + ctx->Driver.TexSubImage2D(ctx, target, level, + xoffset, yoffset, width, height, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 3: + ctx->Driver.TexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + default: + _mesa_problem(ctx, "unexpected dims in subteximage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_TexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 1, target, level, + xoffset, 0, 0, + width, 1, 1, + format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 2, target, level, + xoffset, yoffset, 0, + width, height, 1, + format, type, pixels); +} + + + +void GLAPIENTRY +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 3, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels); +} + + + +/** + * Implement the glCopyTexImage1/2D() functions. + */ +static void +copyteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + x, y, width, height, border); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexture_error_check(ctx, dims, target, level, internalFormat, + width, height, border)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + + ASSERT(texImage->Data == NULL); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, + GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, 1)) { + _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, + border, internalFormat, texFormat); + + ASSERT(ctx->Driver.CopyTexImage2D); + if (dims == 1) + ctx->Driver.CopyTexImage1D(ctx, target, level, internalFormat, + x, y, width, border); + else + ctx->Driver.CopyTexImage2D(ctx, target, level, internalFormat, + x, y, width, height, border); + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage1D( GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 2, target, level, internalFormat, + x, y, width, height, border); +} + + + +/** + * Implementation for glCopyTexSubImage1/2/3D() functions. + */ +static void +copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), + level, xoffset, yoffset, zoffset, x, y, width, height); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexsubimage_error_check1(ctx, dims, target, level)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset, + zoffset, width, height, texImage)) { + /* error was recored */ + } + else { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, + &width, &height)) { + switch (dims) { + case 1: + ctx->Driver.CopyTexSubImage1D(ctx, target, level, + xoffset, x, y, width); + break; + case 2: + ctx->Driver.CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, + x, y, width, height); + break; + case 3: + ctx->Driver.CopyTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + x, y, width, height); + break; + default: + _mesa_problem(ctx, "bad dims in copytexsubimage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y, + width, height); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, + x, y, width, height); +} + + + + +/**********************************************************************/ +/****** Compressed Textures ******/ +/**********************************************************************/ + + +/** + * Return expected size of a compressed texture. + */ +static GLuint +compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, + GLenum glformat) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + return _mesa_format_image_size(mesaFormat, width, height, depth); +} + + +/* + * Return compressed texture block size, in pixels. + */ +static void +get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + _mesa_get_format_block_size(mesaFormat, bw, bh); +} + + +/** + * Error checking for glCompressedTexImage[123]D(). + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLint expectedSize; + + /* check level */ + if (level < 0 || level >= maxLevels) + return GL_INVALID_VALUE; + + if (!target_can_be_compressed(ctx, target, internalFormat)) { + return GL_INVALID_ENUM; + } + + /* This will detect any invalid internalFormat value */ + if (!_mesa_is_compressed_format(ctx, internalFormat)) + return GL_INVALID_ENUM; + + /* This should really never fail */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) + return GL_INVALID_ENUM; + + /* No compressed formats support borders at this time */ + if (border != 0) + return GL_INVALID_VALUE; + + /* For cube map, width must equal height */ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) + return GL_INVALID_VALUE; + + /* check image size against compression block size */ + { + gl_format texFormat = + ctx->Driver.ChooseTextureFormat(ctx, internalFormat, + GL_NONE, GL_NONE); + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + if ((width > bw && width % bw > 0) || + (height > bh && height % bh > 0)) { + /* + * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is + * generated [...] if any parameter combinations are not + * supported by the specific compressed internal format. + */ + return GL_INVALID_OPERATION; + } + } + + /* check image sizes */ + if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, GL_NONE, GL_NONE, + width, height, depth, border)) { + /* See error comment above */ + return GL_INVALID_OPERATION; + } + + /* check image size in bytes */ + expectedSize = compressed_tex_size(width, height, depth, internalFormat); + if (expectedSize != imageSize) { + /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] + * if is not consistent with the format, dimensions, and + * contents of the specified image. + */ + return GL_INVALID_VALUE; + } + + return GL_NO_ERROR; +} + + +/** + * Error checking for glCompressedTexSubImage[123]D(). + * \warning There are some bad assumptions here about the size of compressed + * texture tiles (multiple of 4) used to test the validity of the + * offset and size parameters. + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize) +{ + GLint expectedSize, maxLevels = 0, maxTextureSize; + GLuint bw, bh; + (void) zoffset; + + if (dimensions == 1) { + /* 1D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + else if (dimensions == 2) { + if (target == GL_PROXY_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else { + return GL_INVALID_ENUM; /*target*/ + } + } + else if (dimensions == 3) { + /* 3D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + + maxTextureSize = 1 << (maxLevels - 1); + + /* this will catch any invalid compressed format token */ + if (!_mesa_is_compressed_format(ctx, format)) + return GL_INVALID_ENUM; + + if (width < 1 || width > maxTextureSize) + return GL_INVALID_VALUE; + + if ((height < 1 || height > maxTextureSize) + && dimensions > 1) + return GL_INVALID_VALUE; + + if (level < 0 || level >= maxLevels) + return GL_INVALID_VALUE; + + /* + * do checks which depend on compression block size + */ + get_compressed_block_size(format, &bw, &bh); + + if ((xoffset % bw != 0) || (yoffset % bh != 0)) + return GL_INVALID_VALUE; + + if ((width % bw != 0) && width != 2 && width != 1) + return GL_INVALID_VALUE; + + if ((height % bh != 0) && height != 2 && height != 1) + return GL_INVALID_VALUE; + + expectedSize = compressed_tex_size(width, height, depth, format); + if (expectedSize != imageSize) + return GL_INVALID_VALUE; + + return GL_NO_ERROR; +} + + +/** + * Do second part of glCompressedTexSubImage error checking. + * \return GL_TRUE if error found, GL_FALSE otherwise. + */ +static GLboolean +compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, + GLsizei width, GLsizei height, + GLsizei depth, GLenum format, + struct gl_texture_image *texImage) +{ + + if ((GLint) format != texImage->InternalFormat) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTexSubImage%uD(format=0x%x)", dims, format); + return GL_TRUE; + } + + if (((width == 1 || width == 2) && + width != (GLsizei) texImage->Width) || + (width > (GLsizei) texImage->Width)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(width=%d)", dims, width); + return GL_TRUE; + } + + if (dims >= 2) { + if (((height == 1 || height == 2) && + height != (GLsizei) texImage->Height) || + (height > (GLsizei) texImage->Height)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(height=%d)", dims, height); + return GL_TRUE; + } + } + + if (dims >= 3) { + if (((depth == 1 || depth == 2) && + depth != (GLsizei) texImage->Depth) || + (depth > (GLsizei) texImage->Depth)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(depth=%d)", dims, depth); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Implementation of the glCompressedTexImage1/2/3D() functions. + */ +static void +compressedteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GLenum error; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, + "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, imageSize, data); + + /* check target */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + error = compressed_texture_error_check(ctx, dims, target, level, + internalFormat, width, height, depth, + border, imageSize); + +#if FEATURE_ES + /* XXX this is kind of a hack */ + if (error) { + _mesa_error(ctx, error, "glTexImage2D"); + return; + } + + if (dims == 2) { + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_teximage2d(target, level, internalFormat, + width, height, imageSize, data); + return; + } + } +#endif + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just check for errors and update proxy state */ + struct gl_texture_image *texImage; + + if (!error) { + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = + _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, GL_NONE); + if (!legal_texture_size(ctx, texFormat, width, height, depth)) { + error = GL_OUT_OF_MEMORY; + } + } + + texImage = _mesa_get_proxy_tex_image(ctx, target, level); + if (texImage) { + if (error) { + /* if error, clear all proxy texture image parameters */ + clear_teximage_fields(texImage); + } + else { + /* no error: store the teximage parameters */ + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + MESA_FORMAT_NONE); + } + } + } + else { + /* non-proxy target */ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + _mesa_error(ctx, error, "glCompressedTexImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + else { + gl_format texFormat; + + if (texImage->Data) { + ctx->Driver.FreeTexImageData( ctx, texImage ); + } + ASSERT(texImage->Data == NULL); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, + GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + switch (dims) { + case 1: + ASSERT(ctx->Driver.CompressedTexImage1D); + ctx->Driver.CompressedTexImage1D(ctx, target, level, + internalFormat, + width, + border, imageSize, data, + texObj, texImage); + break; + case 2: + ASSERT(ctx->Driver.CompressedTexImage2D); + ctx->Driver.CompressedTexImage2D(ctx, target, level, + internalFormat, + width, height, + border, imageSize, data, + texObj, texImage); + break; + case 3: + ASSERT(ctx->Driver.CompressedTexImage3D); + ctx->Driver.CompressedTexImage3D(ctx, target, level, + internalFormat, + width, height, depth, + border, imageSize, data, + texObj, texImage); + break; + default: + _mesa_problem(ctx, "bad dims in compressedteximage"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +void GLAPIENTRY +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 1, target, level, internalFormat, + width, 1, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 2, target, level, internalFormat, + width, height, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 3, target, level, internalFormat, + width, height, depth, border, imageSize, data); +} + + +/** + * Common helper for glCompressedTexSubImage1/2/3D(). + */ +static void +compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *data) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLenum error; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + error = compressed_subtexture_error_check(ctx, dims, target, level, + xoffset, 0, 0, /* pos */ + width, height, depth, /* size */ + format, imageSize); + if (error) { + _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + assert(texImage); + + if (compressed_subtexture_error_check2(ctx, dims, width, height, depth, + format, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && depth > 0) { + switch (dims) { + case 1: + if (ctx->Driver.CompressedTexSubImage1D) { + ctx->Driver.CompressedTexSubImage1D(ctx, target, level, + xoffset, width, + format, imageSize, data, + texObj, texImage); + } + break; + case 2: + if (ctx->Driver.CompressedTexSubImage2D) { + ctx->Driver.CompressedTexSubImage2D(ctx, target, level, + xoffset, yoffset, + width, height, + format, imageSize, data, + texObj, texImage); + } + break; + case 3: + if (ctx->Driver.CompressedTexSubImage3D) { + ctx->Driver.CompressedTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, data, + texObj, texImage); + } + break; + default: + ; + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1, + format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data) +{ + compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0, + width, height, 1, format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, imageSize, data); +} diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h index 0dcacab3c..e65f3cea4 100644 --- a/mesalib/src/mesa/main/teximage.h +++ b/mesalib/src/mesa/main/teximage.h @@ -1,273 +1,274 @@ -/** - * \file teximage.h - * Texture images manipulation functions. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXIMAGE_H -#define TEXIMAGE_H - - -#include "mtypes.h" - - -extern void * -_mesa_alloc_texmemory(GLsizei bytes); - -extern void -_mesa_free_texmemory(void *m); - - -/** \name Internal functions */ -/*@{*/ - -extern GLint -_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ); - - -extern GLboolean -_mesa_is_proxy_texture(GLenum target); - - -extern struct gl_texture_image * -_mesa_new_texture_image( GLcontext *ctx ); - - -extern void -_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *teximage ); - -extern void -_mesa_free_texture_image_data( GLcontext *ctx, - struct gl_texture_image *texImage ); - - -extern void -_mesa_init_teximage_fields(GLcontext *ctx, GLenum target, - struct gl_texture_image *img, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum internalFormat); - - -extern void -_mesa_choose_texture_format(GLcontext *ctx, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type); - - -extern void -_mesa_clear_texture_image(GLcontext *ctx, struct gl_texture_image *texImage); - - -extern void -_mesa_set_tex_image(struct gl_texture_object *tObj, - GLenum target, GLint level, - struct gl_texture_image *texImage); - - -extern struct gl_texture_object * -_mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, - GLenum target); - -extern struct gl_texture_object * -_mesa_get_current_tex_object(GLcontext *ctx, GLenum target); - - -extern struct gl_texture_image * -_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_object *texObj, - GLenum target, GLint level); - - -extern struct gl_texture_image * -_mesa_get_tex_image(GLcontext *ctx, struct gl_texture_object *texObj, - GLenum target, GLint level); - - -extern struct gl_texture_image * -_mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level); - - -extern GLint -_mesa_max_texture_levels(GLcontext *ctx, GLenum target); - - -extern GLboolean -_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border); - - -extern GLuint -_mesa_tex_target_to_face(GLenum target); - - -/** - * Lock a texture for updating. See also _mesa_lock_context_textures(). - */ -static INLINE void -_mesa_lock_texture(GLcontext *ctx, struct gl_texture_object *texObj) -{ - _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); - ctx->Shared->TextureStateStamp++; - (void) texObj; -} - -static INLINE void -_mesa_unlock_texture(GLcontext *ctx, struct gl_texture_object *texObj) -{ - _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); -} - -/*@}*/ - - -/** \name API entry point functions */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ); - -extern void GLAPIENTRY -_mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image ); - -extern void GLAPIENTRY -_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_TexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -extern void GLAPIENTRY -_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border ); - - -extern void GLAPIENTRY -_mesa_CopyTexImage2D( GLenum target, GLint level, - GLenum internalformat, GLint x, GLint y, - GLsizei width, GLsizei height, GLint border ); - - -extern void GLAPIENTRY -_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, - GLint x, GLint y, GLsizei width ); - - -extern void GLAPIENTRY -_mesa_CopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ); - - -extern void GLAPIENTRY -_mesa_CopyTexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height ); - - - -extern void GLAPIENTRY -_mesa_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalformat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid *data); - -extern void GLAPIENTRY -_mesa_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalformat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid *data); - -extern void GLAPIENTRY -_mesa_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalformat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid *data); - -#ifdef VMS -#define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR -#define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR -#define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR -#endif -extern void GLAPIENTRY -_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data); - -extern void GLAPIENTRY -_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid *data); - -extern void GLAPIENTRY -_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid *data); - -/*@}*/ - -#endif +/** + * \file teximage.h + * Texture images manipulation functions. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXIMAGE_H +#define TEXIMAGE_H + + +#include "mtypes.h" +#include "formats.h" + + +extern void * +_mesa_alloc_texmemory(GLsizei bytes); + +extern void +_mesa_free_texmemory(void *m); + + +/** \name Internal functions */ +/*@{*/ + +extern GLint +_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ); + + +extern GLboolean +_mesa_is_proxy_texture(GLenum target); + + +extern struct gl_texture_image * +_mesa_new_texture_image( struct gl_context *ctx ); + + +extern void +_mesa_delete_texture_image( struct gl_context *ctx, struct gl_texture_image *teximage ); + +extern void +_mesa_free_texture_image_data( struct gl_context *ctx, + struct gl_texture_image *texImage ); + + +extern void +_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, + struct gl_texture_image *img, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum internalFormat, + gl_format format); + + +extern gl_format +_mesa_choose_texture_format(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum target, GLint level, + GLenum internalFormat, GLenum format, GLenum type); + + +extern void +_mesa_clear_texture_image(struct gl_context *ctx, struct gl_texture_image *texImage); + + +extern void +_mesa_set_tex_image(struct gl_texture_object *tObj, + GLenum target, GLint level, + struct gl_texture_image *texImage); + + +extern struct gl_texture_object * +_mesa_select_tex_object(struct gl_context *ctx, const struct gl_texture_unit *texUnit, + GLenum target); + +extern struct gl_texture_object * +_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target); + + +extern struct gl_texture_image * +_mesa_select_tex_image(struct gl_context *ctx, const struct gl_texture_object *texObj, + GLenum target, GLint level); + + +extern struct gl_texture_image * +_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, + GLenum target, GLint level); + + +extern struct gl_texture_image * +_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level); + + +extern GLint +_mesa_max_texture_levels(struct gl_context *ctx, GLenum target); + + +extern GLboolean +_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, GLenum format, GLenum type, + GLint width, GLint height, GLint depth, GLint border); + + +extern GLuint +_mesa_tex_target_to_face(GLenum target); + + +/** + * Lock a texture for updating. See also _mesa_lock_context_textures(). + */ +static INLINE void +_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) +{ + _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); + ctx->Shared->TextureStateStamp++; + (void) texObj; +} + +static INLINE void +_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj) +{ + _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); +} + +/*@}*/ + + +/** \name API entry point functions */ +/*@{*/ + +extern void GLAPIENTRY +_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +extern void GLAPIENTRY +_mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image ); + +extern void GLAPIENTRY +_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset, + GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +extern void GLAPIENTRY +_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border ); + + +extern void GLAPIENTRY +_mesa_CopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ); + + +extern void GLAPIENTRY +_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, + GLint x, GLint y, GLsizei width ); + + +extern void GLAPIENTRY +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ); + + +extern void GLAPIENTRY +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ); + + + +extern void GLAPIENTRY +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data); + +extern void GLAPIENTRY +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data); + +extern void GLAPIENTRY +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data); + +#ifdef VMS +#define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR +#define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR +#define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR +#endif +extern void GLAPIENTRY +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data); + +extern void GLAPIENTRY +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data); + +extern void GLAPIENTRY +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data); + +/*@}*/ + +#endif diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 1df165cf6..6a038514b 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -1,1236 +1,1258 @@ -/** - * \file texobj.c - * Texture object management. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "mfeatures.h" -#include "colortab.h" -#include "context.h" -#include "enums.h" -#include "fbobject.h" -#include "formats.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" -#include "teximage.h" -#include "texobj.h" -#include "mtypes.h" -#include "program/prog_instruction.h" - - - -/**********************************************************************/ -/** \name Internal functions */ -/*@{*/ - - -/** - * Return the gl_texture_object for a given ID. - */ -struct gl_texture_object * -_mesa_lookup_texture(GLcontext *ctx, GLuint id) -{ - return (struct gl_texture_object *) - _mesa_HashLookup(ctx->Shared->TexObjects, id); -} - - - -/** - * Allocate and initialize a new texture object. But don't put it into the - * texture object hash table. - * - * Called via ctx->Driver.NewTextureObject, unless overridden by a device - * driver. - * - * \param shared the shared GL state structure to contain the texture object - * \param name integer name for the texture object - * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, - * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake - * of GenTextures() - * - * \return pointer to new texture object. - */ -struct gl_texture_object * -_mesa_new_texture_object( GLcontext *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - (void) ctx; - obj = MALLOC_STRUCT(gl_texture_object); - _mesa_initialize_texture_object(obj, name, target); - return obj; -} - - -/** - * Initialize a new texture object to default values. - * \param obj the texture object - * \param name the texture name - * \param target the texture target - */ -void -_mesa_initialize_texture_object( struct gl_texture_object *obj, - GLuint name, GLenum target ) -{ - ASSERT(target == 0 || - target == GL_TEXTURE_1D || - target == GL_TEXTURE_2D || - target == GL_TEXTURE_3D || - target == GL_TEXTURE_CUBE_MAP_ARB || - target == GL_TEXTURE_RECTANGLE_NV || - target == GL_TEXTURE_1D_ARRAY_EXT || - target == GL_TEXTURE_2D_ARRAY_EXT); - - memset(obj, 0, sizeof(*obj)); - /* init the non-zero fields */ - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - obj->Name = name; - obj->Target = target; - obj->Priority = 1.0F; - if (target == GL_TEXTURE_RECTANGLE_NV) { - obj->WrapS = GL_CLAMP_TO_EDGE; - obj->WrapT = GL_CLAMP_TO_EDGE; - obj->WrapR = GL_CLAMP_TO_EDGE; - obj->MinFilter = GL_LINEAR; - } - else { - obj->WrapS = GL_REPEAT; - obj->WrapT = GL_REPEAT; - obj->WrapR = GL_REPEAT; - obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR; - } - obj->MagFilter = GL_LINEAR; - obj->MinLod = -1000.0; - obj->MaxLod = 1000.0; - obj->LodBias = 0.0; - obj->BaseLevel = 0; - obj->MaxLevel = 1000; - obj->MaxAnisotropy = 1.0; - obj->CompareMode = GL_NONE; /* ARB_shadow */ - obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */ - obj->CompareFailValue = 0.0F; /* ARB_shadow_ambient */ - obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */ - obj->Swizzle[0] = GL_RED; - obj->Swizzle[1] = GL_GREEN; - obj->Swizzle[2] = GL_BLUE; - obj->Swizzle[3] = GL_ALPHA; - obj->_Swizzle = SWIZZLE_NOOP; -} - - -/** - * Some texture initialization can't be finished until we know which - * target it's getting bound to (GL_TEXTURE_1D/2D/etc). - */ -static void -finish_texture_init(GLcontext *ctx, GLenum target, - struct gl_texture_object *obj) -{ - assert(obj->Target == 0); - - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* have to init wrap and filter state here - kind of klunky */ - obj->WrapS = GL_CLAMP_TO_EDGE; - obj->WrapT = GL_CLAMP_TO_EDGE; - obj->WrapR = GL_CLAMP_TO_EDGE; - obj->MinFilter = GL_LINEAR; - if (ctx->Driver.TexParameter) { - static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE}; - static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR}; - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter); - } - } -} - - -/** - * Deallocate a texture object struct. It should have already been - * removed from the texture object pool. - * Called via ctx->Driver.DeleteTexture() if not overriden by a driver. - * - * \param shared the shared GL state to which the object belongs. - * \param texObj the texture object to delete. - */ -void -_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) -{ - GLuint i, face; - - (void) ctx; - - /* Set Target to an invalid value. With some assertions elsewhere - * we can try to detect possible use of deleted textures. - */ - texObj->Target = 0x99; - - _mesa_free_colortable_data(&texObj->Palette); - - /* free the texture images */ - for (face = 0; face < 6; face++) { - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - if (texObj->Image[face][i]) { - _mesa_delete_texture_image( ctx, texObj->Image[face][i] ); - } - } - } - - /* destroy the mutex -- it may have allocated memory (eg on bsd) */ - _glthread_DESTROY_MUTEX(texObj->Mutex); - - /* free this object */ - free(texObj); -} - - - - -/** - * Copy texture object state from one texture object to another. - * Use for glPush/PopAttrib. - * - * \param dest destination texture object. - * \param src source texture object. - */ -void -_mesa_copy_texture_object( struct gl_texture_object *dest, - const struct gl_texture_object *src ) -{ - dest->Target = src->Target; - dest->Name = src->Name; - dest->Priority = src->Priority; - dest->BorderColor.f[0] = src->BorderColor.f[0]; - dest->BorderColor.f[1] = src->BorderColor.f[1]; - dest->BorderColor.f[2] = src->BorderColor.f[2]; - dest->BorderColor.f[3] = src->BorderColor.f[3]; - dest->WrapS = src->WrapS; - dest->WrapT = src->WrapT; - dest->WrapR = src->WrapR; - dest->MinFilter = src->MinFilter; - dest->MagFilter = src->MagFilter; - dest->MinLod = src->MinLod; - dest->MaxLod = src->MaxLod; - dest->LodBias = src->LodBias; - dest->BaseLevel = src->BaseLevel; - dest->MaxLevel = src->MaxLevel; - dest->MaxAnisotropy = src->MaxAnisotropy; - dest->CompareMode = src->CompareMode; - dest->CompareFunc = src->CompareFunc; - dest->CompareFailValue = src->CompareFailValue; - dest->DepthMode = src->DepthMode; - dest->_MaxLevel = src->_MaxLevel; - dest->_MaxLambda = src->_MaxLambda; - dest->GenerateMipmap = src->GenerateMipmap; - dest->Palette = src->Palette; - dest->_Complete = src->_Complete; - COPY_4V(dest->Swizzle, src->Swizzle); - dest->_Swizzle = src->_Swizzle; -} - - -/** - * Clear all texture images of the given texture object. - * - * \param ctx GL context. - * \param t texture object. - * - * \sa _mesa_clear_texture_image(). - */ -void -_mesa_clear_texture_object(GLcontext *ctx, struct gl_texture_object *texObj) -{ - GLuint i, j; - - if (texObj->Target == 0) - return; - - for (i = 0; i < MAX_FACES; i++) { - for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { - struct gl_texture_image *texImage = texObj->Image[i][j]; - if (texImage) - _mesa_clear_texture_image(ctx, texImage); - } - } -} - - -/** - * Check if the given texture object is valid by examining its Target field. - * For debugging only. - */ -static GLboolean -valid_texture_object(const struct gl_texture_object *tex) -{ - switch (tex->Target) { - case 0: - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_TEXTURE_RECTANGLE_NV: - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - return GL_TRUE; - case 0x99: - _mesa_problem(NULL, "invalid reference to a deleted texture object"); - return GL_FALSE; - default: - _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", - tex->Target, tex->Name); - return GL_FALSE; - } -} - - -/** - * Reference (or unreference) a texture object. - * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). - * If 'tex' is non-null, increment its refcount. - */ -void -_mesa_reference_texobj(struct gl_texture_object **ptr, - struct gl_texture_object *tex) -{ - assert(ptr); - if (*ptr == tex) { - /* no change */ - return; - } - - if (*ptr) { - /* Unreference the old texture */ - GLboolean deleteFlag = GL_FALSE; - struct gl_texture_object *oldTex = *ptr; - - ASSERT(valid_texture_object(oldTex)); - - _glthread_LOCK_MUTEX(oldTex->Mutex); - ASSERT(oldTex->RefCount > 0); - oldTex->RefCount--; - - deleteFlag = (oldTex->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldTex->Mutex); - - if (deleteFlag) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) - ctx->Driver.DeleteTexture(ctx, oldTex); - else - _mesa_problem(NULL, "Unable to delete texture, no context"); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (tex) { - /* reference new texture */ - ASSERT(valid_texture_object(tex)); - _glthread_LOCK_MUTEX(tex->Mutex); - if (tex->RefCount == 0) { - /* this texture's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted texture object"); - *ptr = NULL; - } - else { - tex->RefCount++; - *ptr = tex; - } - _glthread_UNLOCK_MUTEX(tex->Mutex); - } -} - - - -/** - * Report why a texture object is incomplete. - * - * \param t texture object. - * \param why string describing why it's incomplete. - * - * \note For debug purposes only. - */ -#if 0 -static void -incomplete(const struct gl_texture_object *t, const char *why) -{ - printf("Texture Obj %d incomplete because: %s\n", t->Name, why); -} -#else -#define incomplete(t, why) -#endif - - -/** - * Examine a texture object to determine if it is complete. - * - * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE - * accordingly. - * - * \param ctx GL context. - * \param t texture object. - * - * According to the texture target, verifies that each of the mipmaps is - * present and has the expected size. - */ -void -_mesa_test_texobj_completeness( const GLcontext *ctx, - struct gl_texture_object *t ) -{ - const GLint baseLevel = t->BaseLevel; - GLint maxLog2 = 0, maxLevels = 0; - - t->_Complete = GL_TRUE; /* be optimistic */ - - /* Detect cases where the application set the base level to an invalid - * value. - */ - if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { - char s[100]; - _mesa_snprintf(s, sizeof(s), "base level = %d is invalid", baseLevel); - incomplete(t, s); - t->_Complete = GL_FALSE; - return; - } - - /* Always need the base level image */ - if (!t->Image[0][baseLevel]) { - char s[100]; - _mesa_snprintf(s, sizeof(s), "Image[baseLevel=%d] == NULL", baseLevel); - incomplete(t, s); - t->_Complete = GL_FALSE; - return; - } - - /* Check width/height/depth for zero */ - if (t->Image[0][baseLevel]->Width == 0 || - t->Image[0][baseLevel]->Height == 0 || - t->Image[0][baseLevel]->Depth == 0) { - incomplete(t, "texture width = 0"); - t->_Complete = GL_FALSE; - return; - } - - /* Compute _MaxLevel */ - if ((t->Target == GL_TEXTURE_1D) || - (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { - maxLog2 = t->Image[0][baseLevel]->WidthLog2; - maxLevels = ctx->Const.MaxTextureLevels; - } - else if ((t->Target == GL_TEXTURE_2D) || - (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (t->Target == GL_TEXTURE_3D) { - GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2)); - maxLevels = ctx->Const.Max3DTextureLevels; - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { - maxLog2 = 0; /* not applicable */ - maxLevels = 1; /* no mipmapping */ - } - else { - _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness"); - return; - } - - ASSERT(maxLevels > 0); - - t->_MaxLevel = baseLevel + maxLog2; - t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); - t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); - - /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */ - t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel); - - if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure that all six cube map level 0 images are the same size */ - const GLuint w = t->Image[0][baseLevel]->Width2; - const GLuint h = t->Image[0][baseLevel]->Height2; - GLuint face; - for (face = 1; face < 6; face++) { - if (t->Image[face][baseLevel] == NULL || - t->Image[face][baseLevel]->Width2 != w || - t->Image[face][baseLevel]->Height2 != h) { - t->_Complete = GL_FALSE; - incomplete(t, "Cube face missing or mismatched size"); - return; - } - } - } - - /* extra checking for mipmaps */ - if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) { - /* - * Mipmapping: determine if we have a complete set of mipmaps - */ - GLint i; - GLint minLevel = baseLevel; - GLint maxLevel = t->_MaxLevel; - - if (minLevel > maxLevel) { - t->_Complete = GL_FALSE; - incomplete(t, "minLevel > maxLevel"); - return; - } - - /* Test dimension-independent attributes */ - for (i = minLevel; i <= maxLevel; i++) { - if (t->Image[0][i]) { - if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) { - t->_Complete = GL_FALSE; - incomplete(t, "Format[i] != Format[baseLevel]"); - return; - } - if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) { - t->_Complete = GL_FALSE; - incomplete(t, "Border[i] != Border[baseLevel]"); - return; - } - } - } - - /* Test things which depend on number of texture image dimensions */ - if ((t->Target == GL_TEXTURE_1D) || - (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { - /* Test 1-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - t->_Complete = GL_FALSE; - incomplete(t, "1D Image[0][i] == NULL"); - return; - } - if (t->Image[0][i]->Width2 != width ) { - t->_Complete = GL_FALSE; - incomplete(t, "1D Image[0][i] bad width"); - return; - } - } - if (width == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if ((t->Target == GL_TEXTURE_2D) || - (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - /* Test 2-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - t->_Complete = GL_FALSE; - incomplete(t, "2D Image[0][i] == NULL"); - return; - } - if (t->Image[0][i]->Width2 != width) { - t->_Complete = GL_FALSE; - incomplete(t, "2D Image[0][i] bad width"); - return; - } - if (t->Image[0][i]->Height2 != height) { - t->_Complete = GL_FALSE; - incomplete(t, "2D Image[0][i] bad height"); - return; - } - if (width==1 && height==1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - } - else if (t->Target == GL_TEXTURE_3D) { - /* Test 3-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - GLuint depth = t->Image[0][baseLevel]->Depth2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (depth > 1) { - depth /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - incomplete(t, "3D Image[0][i] == NULL"); - t->_Complete = GL_FALSE; - return; - } - if (t->Image[0][i]->_BaseFormat == GL_DEPTH_COMPONENT) { - t->_Complete = GL_FALSE; - incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); - return; - } - if (t->Image[0][i]->Width2 != width) { - t->_Complete = GL_FALSE; - incomplete(t, "3D Image[0][i] bad width"); - return; - } - if (t->Image[0][i]->Height2 != height) { - t->_Complete = GL_FALSE; - incomplete(t, "3D Image[0][i] bad height"); - return; - } - if (t->Image[0][i]->Depth2 != depth) { - t->_Complete = GL_FALSE; - incomplete(t, "3D Image[0][i] bad depth"); - return; - } - } - if (width == 1 && height == 1 && depth == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure 6 cube faces are consistant */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - GLuint face; - for (face = 0; face < 6; face++) { - /* check that we have images defined */ - if (!t->Image[face][i]) { - t->_Complete = GL_FALSE; - incomplete(t, "CubeMap Image[n][i] == NULL"); - return; - } - /* Don't support GL_DEPTH_COMPONENT for cube maps */ - if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { - t->_Complete = GL_FALSE; - incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); - return; - } - /* check that all six images have same size */ - if (t->Image[face][i]->Width2!=width || - t->Image[face][i]->Height2!=height) { - t->_Complete = GL_FALSE; - incomplete(t, "CubeMap Image[n][i] bad size"); - return; - } - } - } - if (width == 1 && height == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { - /* XXX special checking? */ - } - else { - /* Target = ??? */ - _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n"); - } - } -} - - -/** - * Mark a texture object dirty. It forces the object to be incomplete - * and optionally forces the context to re-validate its state. - * - * \param ctx GL context. - * \param texObj texture object. - * \param invalidate_state also invalidate context state. - */ -void -_mesa_dirty_texobj(GLcontext *ctx, struct gl_texture_object *texObj, - GLboolean invalidate_state) -{ - texObj->_Complete = GL_FALSE; - if (invalidate_state) - ctx->NewState |= _NEW_TEXTURE; -} - - -/** - * Return pointer to a default/fallback texture. - * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). - * That's the value a sampler should get when sampling from an - * incomplete texture. - */ -struct gl_texture_object * -_mesa_get_fallback_texture(GLcontext *ctx) -{ - if (!ctx->Shared->FallbackTex) { - /* create fallback texture now */ - static GLubyte texels[8 * 8][4]; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLuint i; - - for (i = 0; i < 8 * 8; i++) { - texels[i][0] = - texels[i][1] = - texels[i][2] = 0x0; - texels[i][3] = 0xff; - } - - /* create texture object */ - texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); - assert(texObj->RefCount == 1); - texObj->MinFilter = GL_NEAREST; - texObj->MagFilter = GL_NEAREST; - - /* create level[0] texture image */ - texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); - - /* init the image fields */ - _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, - 8, 8, 1, 0, GL_RGBA); - - texImage->TexFormat = - ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); - - /* set image data */ - ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, - 8, 8, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texels, - &ctx->DefaultPacking, texObj, texImage); - - _mesa_test_texobj_completeness(ctx, texObj); - assert(texObj->_Complete); - - ctx->Shared->FallbackTex = texObj; - } - return ctx->Shared->FallbackTex; -} - - -/*@}*/ - - -/***********************************************************************/ -/** \name API functions */ -/*@{*/ - - -/** - * Generate texture names. - * - * \param n number of texture names to be generated. - * \param textures an array in which will hold the generated texture names. - * - * \sa glGenTextures(). - * - * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture - * IDs which are stored in \p textures. Corresponding empty texture - * objects are also generated. - */ -void GLAPIENTRY -_mesa_GenTextures( GLsizei n, GLuint *textures ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); - return; - } - - if (!textures) - return; - - /* - * This must be atomic (generation and allocation of texture IDs) - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); - - /* Allocate new, empty texture objects */ - for (i = 0; i < n; i++) { - struct gl_texture_object *texObj; - GLuint name = first + i; - GLenum target = 0; - texObj = (*ctx->Driver.NewTextureObject)( ctx, name, target); - if (!texObj) { - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures"); - return; - } - - /* insert into hash table */ - _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj); - - textures[i] = name; - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Check if the given texture object is bound to the current draw or - * read framebuffer. If so, Unbind it. - */ -static void -unbind_texobj_from_fbo(GLcontext *ctx, struct gl_texture_object *texObj) -{ - const GLuint n = (ctx->DrawBuffer == ctx->ReadBuffer) ? 1 : 2; - GLuint i; - - for (i = 0; i < n; i++) { - struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer; - if (fb->Name) { - GLuint j; - for (j = 0; j < BUFFER_COUNT; j++) { - if (fb->Attachment[j].Type == GL_TEXTURE && - fb->Attachment[j].Texture == texObj) { - _mesa_remove_attachment(ctx, fb->Attachment + j); - } - } - } - } -} - - -/** - * Check if the given texture object is bound to any texture image units and - * unbind it if so (revert to default textures). - */ -static void -unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) -{ - GLuint u, tex; - - for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { - struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { - _mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - ASSERT(unit->CurrentTex[tex]); - break; - } - } - } -} - - -/** - * Delete named textures. - * - * \param n number of textures to be deleted. - * \param textures array of texture IDs to be deleted. - * - * \sa glDeleteTextures(). - * - * If we're about to delete a texture that's currently bound to any - * texture unit, unbind the texture first. Decrement the reference - * count on the texture object and delete it if it's zero. - * Recall that texture objects can be shared among several rendering - * contexts. - */ -void GLAPIENTRY -_mesa_DeleteTextures( GLsizei n, const GLuint *textures) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ - - if (!textures) - return; - - for (i = 0; i < n; i++) { - if (textures[i] > 0) { - struct gl_texture_object *delObj - = _mesa_lookup_texture(ctx, textures[i]); - - if (delObj) { - _mesa_lock_texture(ctx, delObj); - - /* Check if texture is bound to any framebuffer objects. - * If so, unbind. - * See section 4.4.2.3 of GL_EXT_framebuffer_object. - */ - unbind_texobj_from_fbo(ctx, delObj); - - /* Check if this texture is currently bound to any texture units. - * If so, unbind it. - */ - unbind_texobj_from_texunits(ctx, delObj); - - _mesa_unlock_texture(ctx, delObj); - - ctx->NewState |= _NEW_TEXTURE; - - /* The texture _name_ is now free for re-use. - * Remove it from the hash table now. - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - /* Unreference the texobj. If refcount hits zero, the texture - * will be deleted. - */ - _mesa_reference_texobj(&delObj, NULL); - } - } - } -} - - -/** - * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D - * into the corresponding Mesa texture target index. - * Note that proxy targets are not valid here. - * \return TEXTURE_x_INDEX or -1 if target is invalid - */ -static GLint -target_enum_to_index(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - return TEXTURE_1D_INDEX; - case GL_TEXTURE_2D: - return TEXTURE_2D_INDEX; - case GL_TEXTURE_3D: - return TEXTURE_3D_INDEX; - case GL_TEXTURE_CUBE_MAP_ARB: - return TEXTURE_CUBE_INDEX; - case GL_TEXTURE_RECTANGLE_NV: - return TEXTURE_RECT_INDEX; - case GL_TEXTURE_1D_ARRAY_EXT: - return TEXTURE_1D_ARRAY_INDEX; - case GL_TEXTURE_2D_ARRAY_EXT: - return TEXTURE_2D_ARRAY_INDEX; - default: - return -1; - } -} - - -/** - * Bind a named texture to a texturing target. - * - * \param target texture target. - * \param texName texture name. - * - * \sa glBindTexture(). - * - * Determines the old texture object bound and returns immediately if rebinding - * the same texture. Get the current texture which is either a default texture - * if name is null, a named texture from the hash, or a new texture if the - * given texture name is new. Increments its reference count, binds it, and - * calls dd_function_table::BindTexture. Decrements the old texture reference - * count and deletes it if it reaches zero. - */ -void GLAPIENTRY -_mesa_BindTexture( GLenum target, GLuint texName ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL; - GLint targetIndex; - GLboolean early_out = GL_FALSE; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glBindTexture %s %d\n", - _mesa_lookup_enum_by_nr(target), (GLint) texName); - - targetIndex = target_enum_to_index(target); - if (targetIndex < 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); - return; - } - assert(targetIndex < NUM_TEXTURE_TARGETS); - defaultTexObj = ctx->Shared->DefaultTex[targetIndex]; - - /* - * Get pointer to new texture object (newTexObj) - */ - if (texName == 0) { - newTexObj = defaultTexObj; - } - else { - /* non-default texture object */ - newTexObj = _mesa_lookup_texture(ctx, texName); - if (newTexObj) { - /* error checking */ - if (newTexObj->Target != 0 && newTexObj->Target != target) { - /* the named texture object's target doesn't match the given target */ - _mesa_error( ctx, GL_INVALID_OPERATION, - "glBindTexture(target mismatch)" ); - return; - } - if (newTexObj->Target == 0) { - finish_texture_init(ctx, target, newTexObj); - } - } - else { - /* if this is a new texture id, allocate a texture object now */ - newTexObj = (*ctx->Driver.NewTextureObject)(ctx, texName, target); - if (!newTexObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); - return; - } - - /* and insert it into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } - newTexObj->Target = target; - } - - assert(valid_texture_object(newTexObj)); - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - if ((ctx->Shared->RefCount == 1) - && (newTexObj == texUnit->CurrentTex[targetIndex])) { - early_out = GL_TRUE; - } - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - if (early_out) { - return; - } - - /* flush before changing binding */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - /* Do the actual binding. The refcount on the previously bound - * texture object will be decremented. It'll be deleted if the - * count hits zero. - */ - _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); - ASSERT(texUnit->CurrentTex[targetIndex]); - - /* Pass BindTexture call to device driver */ - if (ctx->Driver.BindTexture) - (*ctx->Driver.BindTexture)( ctx, target, newTexObj ); -} - - -/** - * Set texture priorities. - * - * \param n number of textures. - * \param texName texture names. - * \param priorities corresponding texture priorities. - * - * \sa glPrioritizeTextures(). - * - * Looks up each texture in the hash, clamps the corresponding priority between - * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture. - */ -void GLAPIENTRY -_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, - const GLclampf *priorities ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" ); - return; - } - - if (!priorities) - return; - - for (i = 0; i < n; i++) { - if (texName[i] > 0) { - struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); - if (t) { - t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); - } - } - } - - ctx->NewState |= _NEW_TEXTURE; -} - -/** - * See if textures are loaded in texture memory. - * - * \param n number of textures to query. - * \param texName array with the texture names. - * \param residences array which will hold the residence status. - * - * \return GL_TRUE if all textures are resident and \p residences is left unchanged, - * - * \sa glAreTexturesResident(). - * - * Looks up each texture in the hash and calls - * dd_function_table::IsTextureResident. - */ -GLboolean GLAPIENTRY -_mesa_AreTexturesResident(GLsizei n, const GLuint *texName, - GLboolean *residences) -{ - GET_CURRENT_CONTEXT(ctx); - GLboolean allResident = GL_TRUE; - GLint i, j; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)"); - return GL_FALSE; - } - - if (!texName || !residences) - return GL_FALSE; - - for (i = 0; i < n; i++) { - struct gl_texture_object *t; - if (texName[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - t = _mesa_lookup_texture(ctx, texName[i]); - if (!t) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - if (!ctx->Driver.IsTextureResident || - ctx->Driver.IsTextureResident(ctx, t)) { - /* The texture is resident */ - if (!allResident) - residences[i] = GL_TRUE; - } - else { - /* The texture is not resident */ - if (allResident) { - allResident = GL_FALSE; - for (j = 0; j < i; j++) - residences[j] = GL_TRUE; - } - residences[i] = GL_FALSE; - } - } - - return allResident; -} - -/** - * See if a name corresponds to a texture. - * - * \param texture texture name. - * - * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE - * otherwise. - * - * \sa glIsTexture(). - * - * Calls _mesa_HashLookup(). - */ -GLboolean GLAPIENTRY -_mesa_IsTexture( GLuint texture ) -{ - struct gl_texture_object *t; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (!texture) - return GL_FALSE; - - t = _mesa_lookup_texture(ctx, texture); - - /* IsTexture is true only after object has been bound once. */ - return t && t->Target; -} - - -/** - * Simplest implementation of texture locking: grab the shared tex - * mutex. Examine the shared context state timestamp and if there has - * been a change, set the appropriate bits in ctx->NewState. - * - * This is used to deal with synchronizing things when a texture object - * is used/modified by different contexts (or threads) which are sharing - * the texture. - * - * See also _mesa_lock/unlock_texture() in teximage.h - */ -void -_mesa_lock_context_textures( GLcontext *ctx ) -{ - _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); - - if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { - ctx->NewState |= _NEW_TEXTURE; - ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; - } -} - - -void -_mesa_unlock_context_textures( GLcontext *ctx ) -{ - assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp); - _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); -} - -/*@}*/ - - +/** + * \file texobj.c + * Texture object management. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "mfeatures.h" +#include "colortab.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "formats.h" +#include "hash.h" +#include "imports.h" +#include "macros.h" +#include "teximage.h" +#include "texobj.h" +#include "mtypes.h" +#include "program/prog_instruction.h" + + + +/**********************************************************************/ +/** \name Internal functions */ +/*@{*/ + + +/** + * Return the gl_texture_object for a given ID. + */ +struct gl_texture_object * +_mesa_lookup_texture(struct gl_context *ctx, GLuint id) +{ + return (struct gl_texture_object *) + _mesa_HashLookup(ctx->Shared->TexObjects, id); +} + + + +/** + * Allocate and initialize a new texture object. But don't put it into the + * texture object hash table. + * + * Called via ctx->Driver.NewTextureObject, unless overridden by a device + * driver. + * + * \param shared the shared GL state structure to contain the texture object + * \param name integer name for the texture object + * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, + * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake + * of GenTextures() + * + * \return pointer to new texture object. + */ +struct gl_texture_object * +_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ) +{ + struct gl_texture_object *obj; + (void) ctx; + obj = MALLOC_STRUCT(gl_texture_object); + _mesa_initialize_texture_object(obj, name, target); + return obj; +} + + +/** + * Initialize a new texture object to default values. + * \param obj the texture object + * \param name the texture name + * \param target the texture target + */ +void +_mesa_initialize_texture_object( struct gl_texture_object *obj, + GLuint name, GLenum target ) +{ + ASSERT(target == 0 || + target == GL_TEXTURE_1D || + target == GL_TEXTURE_2D || + target == GL_TEXTURE_3D || + target == GL_TEXTURE_CUBE_MAP_ARB || + target == GL_TEXTURE_RECTANGLE_NV || + target == GL_TEXTURE_1D_ARRAY_EXT || + target == GL_TEXTURE_2D_ARRAY_EXT); + + memset(obj, 0, sizeof(*obj)); + /* init the non-zero fields */ + _glthread_INIT_MUTEX(obj->Mutex); + obj->RefCount = 1; + obj->Name = name; + obj->Target = target; + obj->Priority = 1.0F; + if (target == GL_TEXTURE_RECTANGLE_NV) { + obj->WrapS = GL_CLAMP_TO_EDGE; + obj->WrapT = GL_CLAMP_TO_EDGE; + obj->WrapR = GL_CLAMP_TO_EDGE; + obj->MinFilter = GL_LINEAR; + } + else { + obj->WrapS = GL_REPEAT; + obj->WrapT = GL_REPEAT; + obj->WrapR = GL_REPEAT; + obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR; + } + obj->MagFilter = GL_LINEAR; + obj->MinLod = -1000.0; + obj->MaxLod = 1000.0; + obj->LodBias = 0.0; + obj->BaseLevel = 0; + obj->MaxLevel = 1000; + obj->MaxAnisotropy = 1.0; + obj->CompareMode = GL_NONE; /* ARB_shadow */ + obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */ + obj->CompareFailValue = 0.0F; /* ARB_shadow_ambient */ + obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */ + obj->Swizzle[0] = GL_RED; + obj->Swizzle[1] = GL_GREEN; + obj->Swizzle[2] = GL_BLUE; + obj->Swizzle[3] = GL_ALPHA; + obj->_Swizzle = SWIZZLE_NOOP; +} + + +/** + * Some texture initialization can't be finished until we know which + * target it's getting bound to (GL_TEXTURE_1D/2D/etc). + */ +static void +finish_texture_init(struct gl_context *ctx, GLenum target, + struct gl_texture_object *obj) +{ + assert(obj->Target == 0); + + if (target == GL_TEXTURE_RECTANGLE_NV) { + /* have to init wrap and filter state here - kind of klunky */ + obj->WrapS = GL_CLAMP_TO_EDGE; + obj->WrapT = GL_CLAMP_TO_EDGE; + obj->WrapR = GL_CLAMP_TO_EDGE; + obj->MinFilter = GL_LINEAR; + if (ctx->Driver.TexParameter) { + static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE}; + static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR}; + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter); + } + } +} + + +/** + * Deallocate a texture object struct. It should have already been + * removed from the texture object pool. + * Called via ctx->Driver.DeleteTexture() if not overriden by a driver. + * + * \param shared the shared GL state to which the object belongs. + * \param texObj the texture object to delete. + */ +void +_mesa_delete_texture_object(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint i, face; + + /* Set Target to an invalid value. With some assertions elsewhere + * we can try to detect possible use of deleted textures. + */ + texObj->Target = 0x99; + + _mesa_free_colortable_data(&texObj->Palette); + + /* free the texture images */ + for (face = 0; face < 6; face++) { + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + if (texObj->Image[face][i]) { + _mesa_delete_texture_image( ctx, texObj->Image[face][i] ); + } + } + } + + /* destroy the mutex -- it may have allocated memory (eg on bsd) */ + _glthread_DESTROY_MUTEX(texObj->Mutex); + + /* free this object */ + free(texObj); +} + + + +/** + * Copy texture object state from one texture object to another. + * Use for glPush/PopAttrib. + * + * \param dest destination texture object. + * \param src source texture object. + */ +void +_mesa_copy_texture_object( struct gl_texture_object *dest, + const struct gl_texture_object *src ) +{ + dest->Target = src->Target; + dest->Name = src->Name; + dest->Priority = src->Priority; + dest->BorderColor.f[0] = src->BorderColor.f[0]; + dest->BorderColor.f[1] = src->BorderColor.f[1]; + dest->BorderColor.f[2] = src->BorderColor.f[2]; + dest->BorderColor.f[3] = src->BorderColor.f[3]; + dest->WrapS = src->WrapS; + dest->WrapT = src->WrapT; + dest->WrapR = src->WrapR; + dest->MinFilter = src->MinFilter; + dest->MagFilter = src->MagFilter; + dest->MinLod = src->MinLod; + dest->MaxLod = src->MaxLod; + dest->LodBias = src->LodBias; + dest->BaseLevel = src->BaseLevel; + dest->MaxLevel = src->MaxLevel; + dest->MaxAnisotropy = src->MaxAnisotropy; + dest->CompareMode = src->CompareMode; + dest->CompareFunc = src->CompareFunc; + dest->CompareFailValue = src->CompareFailValue; + dest->DepthMode = src->DepthMode; + dest->_MaxLevel = src->_MaxLevel; + dest->_MaxLambda = src->_MaxLambda; + dest->GenerateMipmap = src->GenerateMipmap; + dest->Palette = src->Palette; + dest->_Complete = src->_Complete; + COPY_4V(dest->Swizzle, src->Swizzle); + dest->_Swizzle = src->_Swizzle; +} + + +/** + * Free all texture images of the given texture object. + * + * \param ctx GL context. + * \param t texture object. + * + * \sa _mesa_clear_texture_image(). + */ +void +_mesa_clear_texture_object(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint i, j; + + if (texObj->Target == 0) + return; + + for (i = 0; i < MAX_FACES; i++) { + for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { + struct gl_texture_image *texImage = texObj->Image[i][j]; + if (texImage) + _mesa_clear_texture_image(ctx, texImage); + } + } +} + + +/** + * Check if the given texture object is valid by examining its Target field. + * For debugging only. + */ +static GLboolean +valid_texture_object(const struct gl_texture_object *tex) +{ + switch (tex->Target) { + case 0: + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + return GL_TRUE; + case 0x99: + _mesa_problem(NULL, "invalid reference to a deleted texture object"); + return GL_FALSE; + default: + _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", + tex->Target, tex->Name); + return GL_FALSE; + } +} + + +/** + * Reference (or unreference) a texture object. + * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). + * If 'tex' is non-null, increment its refcount. + */ +void +_mesa_reference_texobj(struct gl_texture_object **ptr, + struct gl_texture_object *tex) +{ + assert(ptr); + if (*ptr == tex) { + /* no change */ + return; + } + + if (*ptr) { + /* Unreference the old texture */ + GLboolean deleteFlag = GL_FALSE; + struct gl_texture_object *oldTex = *ptr; + + ASSERT(valid_texture_object(oldTex)); + (void) valid_texture_object; /* silence warning in release builds */ + + _glthread_LOCK_MUTEX(oldTex->Mutex); + ASSERT(oldTex->RefCount > 0); + oldTex->RefCount--; + + deleteFlag = (oldTex->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldTex->Mutex); + + if (deleteFlag) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) + ctx->Driver.DeleteTexture(ctx, oldTex); + else + _mesa_problem(NULL, "Unable to delete texture, no context"); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (tex) { + /* reference new texture */ + ASSERT(valid_texture_object(tex)); + _glthread_LOCK_MUTEX(tex->Mutex); + if (tex->RefCount == 0) { + /* this texture's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted texture object"); + *ptr = NULL; + } + else { + tex->RefCount++; + *ptr = tex; + } + _glthread_UNLOCK_MUTEX(tex->Mutex); + } +} + + + +/** + * Mark a texture object as incomplete. + * \param t texture object + * \param fmt... string describing why it's incomplete (for debugging). + */ +static void +incomplete(struct gl_texture_object *t, const char *fmt, ...) +{ +#if 0 + va_list args; + char s[100]; + + va_start(args, fmt); + vsnprintf(s, sizeof(s), fmt, args); + va_end(args); + + printf("Texture Obj %d incomplete because: %s\n", t->Name, s); +#endif + t->_Complete = GL_FALSE; +} + + +/** + * Examine a texture object to determine if it is complete. + * + * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE + * accordingly. + * + * \param ctx GL context. + * \param t texture object. + * + * According to the texture target, verifies that each of the mipmaps is + * present and has the expected size. + */ +void +_mesa_test_texobj_completeness( const struct gl_context *ctx, + struct gl_texture_object *t ) +{ + const GLint baseLevel = t->BaseLevel; + GLint maxLog2 = 0, maxLevels = 0; + + t->_Complete = GL_TRUE; /* be optimistic */ + + /* Detect cases where the application set the base level to an invalid + * value. + */ + if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { + incomplete(t, "base level = %d is invalid", baseLevel); + return; + } + + /* Always need the base level image */ + if (!t->Image[0][baseLevel]) { + incomplete(t, "Image[baseLevel=%d] == NULL", baseLevel); + return; + } + + /* Check width/height/depth for zero */ + if (t->Image[0][baseLevel]->Width == 0 || + t->Image[0][baseLevel]->Height == 0 || + t->Image[0][baseLevel]->Depth == 0) { + incomplete(t, "texture width = 0"); + return; + } + + /* Compute _MaxLevel */ + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { + maxLog2 = t->Image[0][baseLevel]->WidthLog2; + maxLevels = ctx->Const.MaxTextureLevels; + } + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (t->Target == GL_TEXTURE_3D) { + GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2)); + maxLevels = ctx->Const.Max3DTextureLevels; + } + else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { + maxLog2 = 0; /* not applicable */ + maxLevels = 1; /* no mipmapping */ + } + else { + _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness"); + return; + } + + ASSERT(maxLevels > 0); + + t->_MaxLevel = baseLevel + maxLog2; + t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); + t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); + + /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */ + t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel); + + if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + /* make sure that all six cube map level 0 images are the same size */ + const GLuint w = t->Image[0][baseLevel]->Width2; + const GLuint h = t->Image[0][baseLevel]->Height2; + GLuint face; + for (face = 1; face < 6; face++) { + if (t->Image[face][baseLevel] == NULL || + t->Image[face][baseLevel]->Width2 != w || + t->Image[face][baseLevel]->Height2 != h) { + incomplete(t, "Cube face missing or mismatched size"); + return; + } + } + } + + /* extra checking for mipmaps */ + if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) { + /* + * Mipmapping: determine if we have a complete set of mipmaps + */ + GLint i; + GLint minLevel = baseLevel; + GLint maxLevel = t->_MaxLevel; + + if (minLevel > maxLevel) { + incomplete(t, "minLevel > maxLevel"); + return; + } + + /* Test dimension-independent attributes */ + for (i = minLevel; i <= maxLevel; i++) { + if (t->Image[0][i]) { + if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) { + incomplete(t, "Format[i] != Format[baseLevel]"); + return; + } + if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) { + incomplete(t, "Border[i] != Border[baseLevel]"); + return; + } + } + } + + /* Test things which depend on number of texture image dimensions */ + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { + /* Test 1-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "1D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->Width2 != width ) { + incomplete(t, "1D Image[0][i] bad width"); + return; + } + } + if (width == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + /* Test 2-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "2D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->Width2 != width) { + incomplete(t, "2D Image[0][i] bad width"); + return; + } + if (t->Image[0][i]->Height2 != height) { + incomplete(t, "2D Image[0][i] bad height"); + return; + } + if (width==1 && height==1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + } + else if (t->Target == GL_TEXTURE_3D) { + /* Test 3-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + GLuint depth = t->Image[0][baseLevel]->Depth2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (depth > 1) { + depth /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "3D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->_BaseFormat == GL_DEPTH_COMPONENT) { + incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); + return; + } + if (t->Image[0][i]->Width2 != width) { + incomplete(t, "3D Image[0][i] bad width"); + return; + } + if (t->Image[0][i]->Height2 != height) { + incomplete(t, "3D Image[0][i] bad height"); + return; + } + if (t->Image[0][i]->Depth2 != depth) { + incomplete(t, "3D Image[0][i] bad depth"); + return; + } + } + if (width == 1 && height == 1 && depth == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + /* make sure 6 cube faces are consistant */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (i >= minLevel && i <= maxLevel) { + GLuint face; + for (face = 0; face < 6; face++) { + /* check that we have images defined */ + if (!t->Image[face][i]) { + incomplete(t, "CubeMap Image[n][i] == NULL"); + return; + } + /* Don't support GL_DEPTH_COMPONENT for cube maps */ + if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { + incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); + return; + } + /* check that all six images have same size */ + if (t->Image[face][i]->Width2 != width || + t->Image[face][i]->Height2 != height) { + incomplete(t, "CubeMap Image[n][i] bad size"); + return; + } + } + } + if (width == 1 && height == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { + /* XXX special checking? */ + } + else { + /* Target = ??? */ + _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n"); + } + } +} + + +/** + * Check if the given cube map texture is "cube complete" as defined in + * the OpenGL specification. + */ +GLboolean +_mesa_cube_complete(const struct gl_texture_object *texObj) +{ + const GLint baseLevel = texObj->BaseLevel; + const struct gl_texture_image *img0, *img; + GLuint face; + + if (texObj->Target != GL_TEXTURE_CUBE_MAP) + return GL_FALSE; + + if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) + return GL_FALSE; + + /* check first face */ + img0 = texObj->Image[0][baseLevel]; + if (!img0 || + img0->Width < 1 || + img0->Width != img0->Height) + return GL_FALSE; + + /* check remaining faces vs. first face */ + for (face = 1; face < 6; face++) { + img = texObj->Image[face][baseLevel]; + if (!img || + img->Width != img0->Width || + img->Height != img0->Height || + img->TexFormat != img0->TexFormat) + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Mark a texture object dirty. It forces the object to be incomplete + * and optionally forces the context to re-validate its state. + * + * \param ctx GL context. + * \param texObj texture object. + * \param invalidate_state also invalidate context state. + */ +void +_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, + GLboolean invalidate_state) +{ + texObj->_Complete = GL_FALSE; + if (invalidate_state) + ctx->NewState |= _NEW_TEXTURE; +} + + +/** + * Return pointer to a default/fallback texture. + * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). + * That's the value a sampler should get when sampling from an + * incomplete texture. + */ +struct gl_texture_object * +_mesa_get_fallback_texture(struct gl_context *ctx) +{ + if (!ctx->Shared->FallbackTex) { + /* create fallback texture now */ + static GLubyte texels[8 * 8][4]; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + gl_format texFormat; + GLuint i; + + for (i = 0; i < 8 * 8; i++) { + texels[i][0] = + texels[i][1] = + texels[i][2] = 0x0; + texels[i][3] = 0xff; + } + + /* create texture object */ + texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); + assert(texObj->RefCount == 1); + texObj->MinFilter = GL_NEAREST; + texObj->MagFilter = GL_NEAREST; + + /* create level[0] texture image */ + texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); + + texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, + GL_UNSIGNED_BYTE); + + /* init the image fields */ + _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, + 8, 8, 1, 0, GL_RGBA, texFormat); + + ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + + /* set image data */ + ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, + 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texels, + &ctx->DefaultPacking, texObj, texImage); + + _mesa_test_texobj_completeness(ctx, texObj); + assert(texObj->_Complete); + + ctx->Shared->FallbackTex = texObj; + } + return ctx->Shared->FallbackTex; +} + + +/*@}*/ + + +/***********************************************************************/ +/** \name API functions */ +/*@{*/ + + +/** + * Generate texture names. + * + * \param n number of texture names to be generated. + * \param textures an array in which will hold the generated texture names. + * + * \sa glGenTextures(). + * + * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture + * IDs which are stored in \p textures. Corresponding empty texture + * objects are also generated. + */ +void GLAPIENTRY +_mesa_GenTextures( GLsizei n, GLuint *textures ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); + return; + } + + if (!textures) + return; + + /* + * This must be atomic (generation and allocation of texture IDs) + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); + + /* Allocate new, empty texture objects */ + for (i = 0; i < n; i++) { + struct gl_texture_object *texObj; + GLuint name = first + i; + GLenum target = 0; + texObj = (*ctx->Driver.NewTextureObject)( ctx, name, target); + if (!texObj) { + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures"); + return; + } + + /* insert into hash table */ + _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj); + + textures[i] = name; + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +/** + * Check if the given texture object is bound to the current draw or + * read framebuffer. If so, Unbind it. + */ +static void +unbind_texobj_from_fbo(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + const GLuint n = (ctx->DrawBuffer == ctx->ReadBuffer) ? 1 : 2; + GLuint i; + + for (i = 0; i < n; i++) { + struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer; + if (fb->Name) { + GLuint j; + for (j = 0; j < BUFFER_COUNT; j++) { + if (fb->Attachment[j].Type == GL_TEXTURE && + fb->Attachment[j].Texture == texObj) { + _mesa_remove_attachment(ctx, fb->Attachment + j); + } + } + } + } +} + + +/** + * Check if the given texture object is bound to any texture image units and + * unbind it if so (revert to default textures). + */ +static void +unbind_texobj_from_texunits(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint u, tex; + + for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { + struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + if (texObj == unit->CurrentTex[tex]) { + _mesa_reference_texobj(&unit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + ASSERT(unit->CurrentTex[tex]); + break; + } + } + } +} + + +/** + * Delete named textures. + * + * \param n number of textures to be deleted. + * \param textures array of texture IDs to be deleted. + * + * \sa glDeleteTextures(). + * + * If we're about to delete a texture that's currently bound to any + * texture unit, unbind the texture first. Decrement the reference + * count on the texture object and delete it if it's zero. + * Recall that texture objects can be shared among several rendering + * contexts. + */ +void GLAPIENTRY +_mesa_DeleteTextures( GLsizei n, const GLuint *textures) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ + + if (!textures) + return; + + for (i = 0; i < n; i++) { + if (textures[i] > 0) { + struct gl_texture_object *delObj + = _mesa_lookup_texture(ctx, textures[i]); + + if (delObj) { + _mesa_lock_texture(ctx, delObj); + + /* Check if texture is bound to any framebuffer objects. + * If so, unbind. + * See section 4.4.2.3 of GL_EXT_framebuffer_object. + */ + unbind_texobj_from_fbo(ctx, delObj); + + /* Check if this texture is currently bound to any texture units. + * If so, unbind it. + */ + unbind_texobj_from_texunits(ctx, delObj); + + _mesa_unlock_texture(ctx, delObj); + + ctx->NewState |= _NEW_TEXTURE; + + /* The texture _name_ is now free for re-use. + * Remove it from the hash table now. + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + /* Unreference the texobj. If refcount hits zero, the texture + * will be deleted. + */ + _mesa_reference_texobj(&delObj, NULL); + } + } + } +} + + +/** + * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D + * into the corresponding Mesa texture target index. + * Note that proxy targets are not valid here. + * \return TEXTURE_x_INDEX or -1 if target is invalid + */ +static GLint +target_enum_to_index(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return TEXTURE_1D_INDEX; + case GL_TEXTURE_2D: + return TEXTURE_2D_INDEX; + case GL_TEXTURE_3D: + return TEXTURE_3D_INDEX; + case GL_TEXTURE_CUBE_MAP_ARB: + return TEXTURE_CUBE_INDEX; + case GL_TEXTURE_RECTANGLE_NV: + return TEXTURE_RECT_INDEX; + case GL_TEXTURE_1D_ARRAY_EXT: + return TEXTURE_1D_ARRAY_INDEX; + case GL_TEXTURE_2D_ARRAY_EXT: + return TEXTURE_2D_ARRAY_INDEX; + default: + return -1; + } +} + + +/** + * Bind a named texture to a texturing target. + * + * \param target texture target. + * \param texName texture name. + * + * \sa glBindTexture(). + * + * Determines the old texture object bound and returns immediately if rebinding + * the same texture. Get the current texture which is either a default texture + * if name is null, a named texture from the hash, or a new texture if the + * given texture name is new. Increments its reference count, binds it, and + * calls dd_function_table::BindTexture. Decrements the old texture reference + * count and deletes it if it reaches zero. + */ +void GLAPIENTRY +_mesa_BindTexture( GLenum target, GLuint texName ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint unit = ctx->Texture.CurrentUnit; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL; + GLint targetIndex; + GLboolean early_out = GL_FALSE; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glBindTexture %s %d\n", + _mesa_lookup_enum_by_nr(target), (GLint) texName); + + targetIndex = target_enum_to_index(target); + if (targetIndex < 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); + return; + } + assert(targetIndex < NUM_TEXTURE_TARGETS); + defaultTexObj = ctx->Shared->DefaultTex[targetIndex]; + + /* + * Get pointer to new texture object (newTexObj) + */ + if (texName == 0) { + newTexObj = defaultTexObj; + } + else { + /* non-default texture object */ + newTexObj = _mesa_lookup_texture(ctx, texName); + if (newTexObj) { + /* error checking */ + if (newTexObj->Target != 0 && newTexObj->Target != target) { + /* the named texture object's target doesn't match the given target */ + _mesa_error( ctx, GL_INVALID_OPERATION, + "glBindTexture(target mismatch)" ); + return; + } + if (newTexObj->Target == 0) { + finish_texture_init(ctx, target, newTexObj); + } + } + else { + /* if this is a new texture id, allocate a texture object now */ + newTexObj = (*ctx->Driver.NewTextureObject)(ctx, texName, target); + if (!newTexObj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); + return; + } + + /* and insert it into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } + newTexObj->Target = target; + } + + assert(valid_texture_object(newTexObj)); + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + if ((ctx->Shared->RefCount == 1) + && (newTexObj == texUnit->CurrentTex[targetIndex])) { + early_out = GL_TRUE; + } + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + if (early_out) { + return; + } + + /* flush before changing binding */ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + /* Do the actual binding. The refcount on the previously bound + * texture object will be decremented. It'll be deleted if the + * count hits zero. + */ + _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); + ASSERT(texUnit->CurrentTex[targetIndex]); + + /* Pass BindTexture call to device driver */ + if (ctx->Driver.BindTexture) + (*ctx->Driver.BindTexture)( ctx, target, newTexObj ); +} + + +/** + * Set texture priorities. + * + * \param n number of textures. + * \param texName texture names. + * \param priorities corresponding texture priorities. + * + * \sa glPrioritizeTextures(). + * + * Looks up each texture in the hash, clamps the corresponding priority between + * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture. + */ +void GLAPIENTRY +_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, + const GLclampf *priorities ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (n < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" ); + return; + } + + if (!priorities) + return; + + for (i = 0; i < n; i++) { + if (texName[i] > 0) { + struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); + if (t) { + t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); + } + } + } + + ctx->NewState |= _NEW_TEXTURE; +} + + + +/** + * See if textures are loaded in texture memory. + * + * \param n number of textures to query. + * \param texName array with the texture names. + * \param residences array which will hold the residence status. + * + * \return GL_TRUE if all textures are resident and \p residences is left unchanged, + * + * \sa glAreTexturesResident(). + * + * Looks up each texture in the hash and calls + * dd_function_table::IsTextureResident. + */ +GLboolean GLAPIENTRY +_mesa_AreTexturesResident(GLsizei n, const GLuint *texName, + GLboolean *residences) +{ + GET_CURRENT_CONTEXT(ctx); + GLboolean allResident = GL_TRUE; + GLint i, j; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)"); + return GL_FALSE; + } + + if (!texName || !residences) + return GL_FALSE; + + for (i = 0; i < n; i++) { + struct gl_texture_object *t; + if (texName[i] == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); + return GL_FALSE; + } + t = _mesa_lookup_texture(ctx, texName[i]); + if (!t) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); + return GL_FALSE; + } + if (!ctx->Driver.IsTextureResident || + ctx->Driver.IsTextureResident(ctx, t)) { + /* The texture is resident */ + if (!allResident) + residences[i] = GL_TRUE; + } + else { + /* The texture is not resident */ + if (allResident) { + allResident = GL_FALSE; + for (j = 0; j < i; j++) + residences[j] = GL_TRUE; + } + residences[i] = GL_FALSE; + } + } + + return allResident; +} + + +/** + * See if a name corresponds to a texture. + * + * \param texture texture name. + * + * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE + * otherwise. + * + * \sa glIsTexture(). + * + * Calls _mesa_HashLookup(). + */ +GLboolean GLAPIENTRY +_mesa_IsTexture( GLuint texture ) +{ + struct gl_texture_object *t; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (!texture) + return GL_FALSE; + + t = _mesa_lookup_texture(ctx, texture); + + /* IsTexture is true only after object has been bound once. */ + return t && t->Target; +} + + +/** + * Simplest implementation of texture locking: grab the shared tex + * mutex. Examine the shared context state timestamp and if there has + * been a change, set the appropriate bits in ctx->NewState. + * + * This is used to deal with synchronizing things when a texture object + * is used/modified by different contexts (or threads) which are sharing + * the texture. + * + * See also _mesa_lock/unlock_texture() in teximage.h + */ +void +_mesa_lock_context_textures( struct gl_context *ctx ) +{ + _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); + + if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { + ctx->NewState |= _NEW_TEXTURE; + ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; + } +} + + +void +_mesa_unlock_context_textures( struct gl_context *ctx ) +{ + assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp); + _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h index 9bfebd45c..09c738fda 100644 --- a/mesalib/src/mesa/main/texobj.h +++ b/mesalib/src/mesa/main/texobj.h @@ -1,118 +1,122 @@ -/** - * \file texobj.h - * Texture object management. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXTOBJ_H -#define TEXTOBJ_H - - -#include "mtypes.h" - - -/** - * \name Internal functions - */ -/*@{*/ - -extern struct gl_texture_object * -_mesa_lookup_texture(GLcontext *ctx, GLuint id); - -extern struct gl_texture_object * -_mesa_new_texture_object( GLcontext *ctx, GLuint name, GLenum target ); - -extern void -_mesa_initialize_texture_object( struct gl_texture_object *obj, - GLuint name, GLenum target ); - -extern void -_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *obj ); - -extern void -_mesa_copy_texture_object( struct gl_texture_object *dest, - const struct gl_texture_object *src ); - -extern void -_mesa_clear_texture_object(GLcontext *ctx, struct gl_texture_object *obj); - -extern void -_mesa_reference_texobj(struct gl_texture_object **ptr, - struct gl_texture_object *tex); - -extern void -_mesa_test_texobj_completeness( const GLcontext *ctx, - struct gl_texture_object *obj ); - -extern void -_mesa_dirty_texobj(GLcontext *ctx, struct gl_texture_object *texObj, - GLboolean invalidate_state); - -extern struct gl_texture_object * -_mesa_get_fallback_texture(GLcontext *ctx); - -extern void -_mesa_unlock_context_textures( GLcontext *ctx ); - -extern void -_mesa_lock_context_textures( GLcontext *ctx ); - -/*@}*/ - -/** - * \name API functions - */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_GenTextures( GLsizei n, GLuint *textures ); - - -extern void GLAPIENTRY -_mesa_DeleteTextures( GLsizei n, const GLuint *textures ); - - -extern void GLAPIENTRY -_mesa_BindTexture( GLenum target, GLuint texture ); - - -extern void GLAPIENTRY -_mesa_PrioritizeTextures( GLsizei n, const GLuint *textures, - const GLclampf *priorities ); - - -extern GLboolean GLAPIENTRY -_mesa_AreTexturesResident( GLsizei n, const GLuint *textures, - GLboolean *residences ); - -extern GLboolean GLAPIENTRY -_mesa_IsTexture( GLuint texture ); - -/*@}*/ - - -#endif +/** + * \file texobj.h + * Texture object management. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXTOBJ_H +#define TEXTOBJ_H + + +#include "glheader.h" + +struct gl_context; + +/** + * \name Internal functions + */ +/*@{*/ + +extern struct gl_texture_object * +_mesa_lookup_texture(struct gl_context *ctx, GLuint id); + +extern struct gl_texture_object * +_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ); + +extern void +_mesa_initialize_texture_object( struct gl_texture_object *obj, + GLuint name, GLenum target ); + +extern void +_mesa_delete_texture_object( struct gl_context *ctx, struct gl_texture_object *obj ); + +extern void +_mesa_copy_texture_object( struct gl_texture_object *dest, + const struct gl_texture_object *src ); + +extern void +_mesa_clear_texture_object(struct gl_context *ctx, struct gl_texture_object *obj); + +extern void +_mesa_reference_texobj(struct gl_texture_object **ptr, + struct gl_texture_object *tex); + +extern void +_mesa_test_texobj_completeness( const struct gl_context *ctx, + struct gl_texture_object *obj ); + +extern GLboolean +_mesa_cube_complete(const struct gl_texture_object *texObj); + +extern void +_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, + GLboolean invalidate_state); + +extern struct gl_texture_object * +_mesa_get_fallback_texture(struct gl_context *ctx); + +extern void +_mesa_unlock_context_textures( struct gl_context *ctx ); + +extern void +_mesa_lock_context_textures( struct gl_context *ctx ); + +/*@}*/ + +/** + * \name API functions + */ +/*@{*/ + +extern void GLAPIENTRY +_mesa_GenTextures( GLsizei n, GLuint *textures ); + + +extern void GLAPIENTRY +_mesa_DeleteTextures( GLsizei n, const GLuint *textures ); + + +extern void GLAPIENTRY +_mesa_BindTexture( GLenum target, GLuint texture ); + + +extern void GLAPIENTRY +_mesa_PrioritizeTextures( GLsizei n, const GLuint *textures, + const GLclampf *priorities ); + + +extern GLboolean GLAPIENTRY +_mesa_AreTexturesResident( GLsizei n, const GLuint *textures, + GLboolean *residences ); + +extern GLboolean GLAPIENTRY +_mesa_IsTexture( GLuint texture ); + +/*@}*/ + + +#endif diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 745a0aeec..996218b16 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -1,1422 +1,1417 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texparam.c - * - * glTexParameter-related functions - */ - - -#include "main/glheader.h" -#include "main/colormac.h" -#include "main/context.h" -#include "main/formats.h" -#include "main/macros.h" -#include "main/texcompress.h" -#include "main/texparam.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "program/prog_instruction.h" - - -/** - * Check if a coordinate wrap mode is supported for the texture target. - * \return GL_TRUE if legal, GL_FALSE otherwise - */ -static GLboolean -validate_texture_wrap_mode(GLcontext * ctx, GLenum target, GLenum wrap) -{ - const struct gl_extensions * const e = & ctx->Extensions; - - if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE || - (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) { - /* any texture target */ - return GL_TRUE; - } - else if (target != GL_TEXTURE_RECTANGLE_NV && - (wrap == GL_REPEAT || - (wrap == GL_MIRRORED_REPEAT && - e->ARB_texture_mirrored_repeat) || - (wrap == GL_MIRROR_CLAMP_EXT && - (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || - (wrap == GL_MIRROR_CLAMP_TO_EDGE_EXT && - (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || - (wrap == GL_MIRROR_CLAMP_TO_BORDER_EXT && - (e->EXT_texture_mirror_clamp)))) { - /* non-rectangle texture */ - return GL_TRUE; - } - - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); - return GL_FALSE; -} - - -/** - * Get current texture object for given target. - * Return NULL if any error (and record the error). - * Note that this is different from _mesa_select_tex_object() in that proxy - * targets are not accepted. - * Only the glGetTexLevelParameter() functions accept proxy targets. - */ -static struct gl_texture_object * -get_texobj(GLcontext *ctx, GLenum target, GLboolean get) -{ - struct gl_texture_unit *texUnit; - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sTexParameter(current unit)", get ? "Get" : ""); - return NULL; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - switch (target) { - case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; - case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; - case GL_TEXTURE_CUBE_MAP: - if (ctx->Extensions.ARB_texture_cube_map) { - return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; - } - break; - case GL_TEXTURE_RECTANGLE_NV: - if (ctx->Extensions.NV_texture_rectangle) { - return texUnit->CurrentTex[TEXTURE_RECT_INDEX]; - } - break; - case GL_TEXTURE_1D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array) { - return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX]; - } - break; - case GL_TEXTURE_2D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array) { - return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX]; - } - break; - default: - ; - } - - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sTexParameter(target)", get ? "Get" : ""); - return NULL; -} - - -/** - * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE. - * \return -1 if error. - */ -static GLint -comp_to_swizzle(GLenum comp) -{ - switch (comp) { - case GL_RED: - return SWIZZLE_X; - case GL_GREEN: - return SWIZZLE_Y; - case GL_BLUE: - return SWIZZLE_Z; - case GL_ALPHA: - return SWIZZLE_W; - case GL_ZERO: - return SWIZZLE_ZERO; - case GL_ONE: - return SWIZZLE_ONE; - default: - return -1; - } -} - - -static void -set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) -{ - ASSERT(comp < 4); - ASSERT(swz <= SWIZZLE_NIL); - { - GLuint mask = 0x7 << (3 * comp); - GLuint s = (*swizzle & ~mask) | (swz << (3 * comp)); - *swizzle = s; - } -} - - -/** - * This is called just prior to changing any texture object state. - * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE - * state flag and then mark the texture object as 'incomplete' so that any - * per-texture derived state gets recomputed. - */ -static INLINE void -flush(GLcontext *ctx, struct gl_texture_object *texObj) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->_Complete = GL_FALSE; -} - - -/** - * Set an integer-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameteri(GLcontext *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLint *params) -{ - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - if (texObj->MinFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - flush(ctx, texObj); - texObj->MinFilter = params[0]; - return GL_TRUE; - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) { - flush(ctx, texObj); - texObj->MinFilter = params[0]; - return GL_TRUE; - } - /* fall-through */ - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", - params[0] ); - } - return GL_FALSE; - - case GL_TEXTURE_MAG_FILTER: - if (texObj->MagFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - flush(ctx, texObj); - texObj->MagFilter = params[0]; - return GL_TRUE; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", - params[0]); - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_S: - if (texObj->WrapS == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx, texObj); - texObj->WrapS = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_T: - if (texObj->WrapT == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx, texObj); - texObj->WrapT = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_R: - if (texObj->WrapR == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx, texObj); - texObj->WrapR = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_BASE_LEVEL: - if (texObj->BaseLevel == params[0]) - return GL_FALSE; - if (params[0] < 0 || - (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexParameter(param=%d)", params[0]); - return GL_FALSE; - } - flush(ctx, texObj); - texObj->BaseLevel = params[0]; - return GL_TRUE; - - case GL_TEXTURE_MAX_LEVEL: - if (texObj->MaxLevel == params[0]) - return GL_FALSE; - if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(param=%d)", params[0]); - return GL_FALSE; - } - flush(ctx, texObj); - texObj->MaxLevel = params[0]; - return GL_TRUE; - - case GL_GENERATE_MIPMAP_SGIS: - if (ctx->Extensions.SGIS_generate_mipmap) { - if (texObj->GenerateMipmap != params[0]) { - flush(ctx, texObj); - texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE; - return GL_TRUE; - } - return GL_FALSE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)"); - } - return GL_FALSE; - - case GL_TEXTURE_COMPARE_MODE_ARB: - if (ctx->Extensions.ARB_shadow && - (params[0] == GL_NONE || - params[0] == GL_COMPARE_R_TO_TEXTURE_ARB)) { - if (texObj->CompareMode != params[0]) { - flush(ctx, texObj); - texObj->CompareMode = params[0]; - return GL_TRUE; - } - return GL_FALSE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(GL_TEXTURE_COMPARE_MODE_ARB)"); - } - return GL_FALSE; - - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (ctx->Extensions.ARB_shadow) { - if (texObj->CompareFunc == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_LEQUAL: - case GL_GEQUAL: - flush(ctx, texObj); - texObj->CompareFunc = params[0]; - return GL_TRUE; - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_LESS: - case GL_GREATER: - case GL_ALWAYS: - case GL_NEVER: - if (ctx->Extensions.EXT_shadow_funcs) { - flush(ctx, texObj); - texObj->CompareFunc = params[0]; - return GL_TRUE; - } - /* fall-through */ - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(GL_TEXTURE_COMPARE_FUNC_ARB)"); - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - } - return GL_FALSE; - - case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->Extensions.ARB_depth_texture && - (params[0] == GL_LUMINANCE || - params[0] == GL_INTENSITY || - params[0] == GL_ALPHA)) { - if (texObj->DepthMode != params[0]) { - flush(ctx, texObj); - texObj->DepthMode = params[0]; - return GL_TRUE; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(GL_DEPTH_TEXTURE_MODE_ARB)"); - } - return GL_FALSE; - -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - texObj->CropRect[0] = params[0]; - texObj->CropRect[1] = params[1]; - texObj->CropRect[2] = params[2]; - texObj->CropRect[3] = params[3]; - return GL_TRUE; -#endif - - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; - const GLint swz = comp_to_swizzle(params[0]); - if (swz < 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(swizzle 0x%x)", params[0]); - return GL_FALSE; - } - ASSERT(comp < 4); - if (swz >= 0) { - flush(ctx, texObj); - texObj->Swizzle[comp] = params[0]; - set_swizzle_component(&texObj->_Swizzle, comp, swz); - return GL_TRUE; - } - } - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - return GL_FALSE; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - GLuint comp; - flush(ctx, texObj); - for (comp = 0; comp < 4; comp++) { - const GLint swz = comp_to_swizzle(params[comp]); - if (swz >= 0) { - texObj->Swizzle[comp] = params[comp]; - set_swizzle_component(&texObj->_Swizzle, comp, swz); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(swizzle 0x%x)", params[comp]); - return GL_FALSE; - } - } - return GL_TRUE; - } - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - return GL_FALSE; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - } - return GL_FALSE; -} - - -/** - * Set a float-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameterf(GLcontext *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params) -{ - switch (pname) { - case GL_TEXTURE_MIN_LOD: - if (texObj->MinLod == params[0]) - return GL_FALSE; - flush(ctx, texObj); - texObj->MinLod = params[0]; - return GL_TRUE; - - case GL_TEXTURE_MAX_LOD: - if (texObj->MaxLod == params[0]) - return GL_FALSE; - flush(ctx, texObj); - texObj->MaxLod = params[0]; - return GL_TRUE; - - case GL_TEXTURE_PRIORITY: - flush(ctx, texObj); - texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - if (texObj->MaxAnisotropy == params[0]) - return GL_FALSE; - if (params[0] < 1.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); - return GL_FALSE; - } - flush(ctx, texObj); - /* clamp to max, that's what NVIDIA does */ - texObj->MaxAnisotropy = MIN2(params[0], - ctx->Const.MaxTextureMaxAnisotropy); - return GL_TRUE; - } - else { - static GLuint count = 0; - if (count++ < 10) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); - } - return GL_FALSE; - - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (ctx->Extensions.ARB_shadow_ambient) { - if (texObj->CompareFailValue != params[0]) { - flush(ctx, texObj); - texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); - } - return GL_FALSE; - - case GL_TEXTURE_LOD_BIAS: - /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ - if (ctx->Extensions.EXT_texture_lod_bias) { - if (texObj->LodBias != params[0]) { - flush(ctx, texObj); - texObj->LodBias = params[0]; - return GL_TRUE; - } - return GL_FALSE; - } - break; - - case GL_TEXTURE_BORDER_COLOR: - flush(ctx, texObj); - texObj->BorderColor.f[RCOMP] = params[0]; - texObj->BorderColor.f[GCOMP] = params[1]; - texObj->BorderColor.f[BCOMP] = params[2]; - texObj->BorderColor.f[ACOMP] = params[3]; - return GL_TRUE; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - } - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_GENERATE_MIPMAP_SGIS: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) param; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - default: - { - /* this will generate an error if pname is illegal */ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, p); - } - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m); - } -} - - -void GLAPIENTRY -_mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_GENERATE_MIPMAP_SGIS: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) params[0]; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - { - /* convert float params to int */ - GLint iparams[4]; - iparams[0] = (GLint) params[0]; - iparams[1] = (GLint) params[1]; - iparams[2] = (GLint) params[2]; - iparams[3] = (GLint) params[3]; - need_update = set_tex_parameteri(ctx, texObj, pname, iparams); - } - break; -#endif - - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameterf(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, params); - } -} - - -void GLAPIENTRY -_mesa_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - /* convert int param to float */ - need_update = set_tex_parameterf(ctx, texObj, pname, fparam); - } - break; - default: - /* this will generate an error if pname is illegal */ - { - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, iparam); - } - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparam = (GLfloat) param; - ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam); - } -} - - -void GLAPIENTRY -_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - { - /* convert int params to float */ - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - /* convert int param to float */ - GLfloat fparams[4]; - fparams[0] = (GLfloat) params[0]; - fparams[1] = fparams[2] = fparams[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameteri(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - if (pname == GL_TEXTURE_BORDER_COLOR || - pname == GL_TEXTURE_CROP_RECT_OES) { - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - } - ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams); - } -} - - -/** - * Set tex parameter to integer value(s). Primarily intended to set - * integer-valued texture border color (for integer-valued textures). - * New in GL 3.0. - */ -void GLAPIENTRY -_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the integer-valued border color */ - COPY_4V(texObj->BorderColor.i, params); - break; - default: - _mesa_TexParameteriv(target, pname, params); - break; - } - /* XXX no driver hook for TexParameterIiv() yet */ -} - - -/** - * Set tex parameter to unsigned integer value(s). Primarily intended to set - * uint-valued texture border color (for integer-valued textures). - * New in GL 3.0 - */ -void GLAPIENTRY -_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the unsigned integer-valued border color */ - COPY_4V(texObj->BorderColor.ui, params); - break; - default: - _mesa_TexParameteriv(target, pname, (const GLint *) params); - break; - } - /* XXX no driver hook for TexParameterIuiv() yet */ -} - - - - -void GLAPIENTRY -_mesa_GetTexLevelParameterfv( GLenum target, GLint level, - GLenum pname, GLfloat *params ) -{ - GLint iparam; - _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); - *params = (GLfloat) iparam; -} - - -void GLAPIENTRY -_mesa_GetTexLevelParameteriv( GLenum target, GLint level, - GLenum pname, GLint *params ) -{ - const struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - const struct gl_texture_image *img = NULL; - GLboolean isProxy; - GLint maxLevels; - gl_format texFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameteriv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - /* this will catch bad target values */ - maxLevels = _mesa_max_texture_levels(ctx, target); - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(target=0x%x)", target); - return; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); - return; - } - - texObj = _mesa_select_tex_object(ctx, texUnit, target); - _mesa_lock_texture(ctx, texObj); - - img = _mesa_select_tex_image(ctx, texObj, target, level); - if (!img || !img->TexFormat) { - /* undefined texture image */ - if (pname == GL_TEXTURE_COMPONENTS) - *params = 1; - else - *params = 0; - goto out; - } - - texFormat = img->TexFormat; - - isProxy = _mesa_is_proxy_texture(target); - - switch (pname) { - case GL_TEXTURE_WIDTH: - *params = img->Width; - break; - case GL_TEXTURE_HEIGHT: - *params = img->Height; - break; - case GL_TEXTURE_DEPTH: - *params = img->Depth; - break; - case GL_TEXTURE_INTERNAL_FORMAT: - if (_mesa_is_format_compressed(img->TexFormat)) { - /* need to return the actual compressed format */ - *params = _mesa_compressed_format_to_glenum(ctx, img->TexFormat); - } - else { - /* return the user's requested internal format */ - *params = img->InternalFormat; - } - break; - case GL_TEXTURE_BORDER: - *params = img->Border; - break; - case GL_TEXTURE_RED_SIZE: - case GL_TEXTURE_GREEN_SIZE: - case GL_TEXTURE_BLUE_SIZE: - if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_ALPHA_SIZE: - if (img->_BaseFormat == GL_ALPHA || - img->_BaseFormat == GL_LUMINANCE_ALPHA || - img->_BaseFormat == GL_RGBA) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_INTENSITY_SIZE: - if (img->_BaseFormat != GL_INTENSITY) - *params = 0; - else { - *params = _mesa_get_format_bits(texFormat, pname); - if (*params == 0) { - /* intensity probably stored as rgb texture */ - *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), - _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); - } - } - break; - case GL_TEXTURE_LUMINANCE_SIZE: - if (img->_BaseFormat != GL_LUMINANCE && - img->_BaseFormat != GL_LUMINANCE_ALPHA) - *params = 0; - else { - *params = _mesa_get_format_bits(texFormat, pname); - if (*params == 0) { - /* luminance probably stored as rgb texture */ - *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), - _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); - } - } - break; - case GL_TEXTURE_INDEX_SIZE_EXT: - if (img->_BaseFormat == GL_COLOR_INDEX) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_DEPTH_SIZE_ARB: - if (ctx->Extensions.ARB_depth_texture) - *params = _mesa_get_format_bits(texFormat, pname); - else - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - break; - case GL_TEXTURE_STENCIL_SIZE_EXT: - if (ctx->Extensions.EXT_packed_depth_stencil || - ctx->Extensions.ARB_framebuffer_object) { - *params = _mesa_get_format_bits(texFormat, pname); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_SHARED_SIZE: - if (ctx->VersionMajor >= 3) { - /* XXX return number of exponent bits for shared exponent texture - * formats, like GL_RGB9_E5. - */ - *params = 0; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - - /* GL_ARB_texture_compression */ - case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: - if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) { - *params = _mesa_format_image_size(texFormat, img->Width, - img->Height, img->Depth); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_COMPRESSED: - *params = (GLint) _mesa_is_format_compressed(img->TexFormat); - break; - - /* GL_ARB_texture_float */ - case GL_TEXTURE_RED_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_GREEN_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_BLUE_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_ALPHA_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_LUMINANCE_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_INTENSITY_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_DEPTH_TYPE_ARB: - if (ctx->Extensions.ARB_texture_float) { - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)"); - } - - out: - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) -{ - struct gl_texture_object *obj; - GLboolean error = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = ENUM_TO_FLOAT(obj->MagFilter); - break; - case GL_TEXTURE_MIN_FILTER: - *params = ENUM_TO_FLOAT(obj->MinFilter); - break; - case GL_TEXTURE_WRAP_S: - *params = ENUM_TO_FLOAT(obj->WrapS); - break; - case GL_TEXTURE_WRAP_T: - *params = ENUM_TO_FLOAT(obj->WrapT); - break; - case GL_TEXTURE_WRAP_R: - *params = ENUM_TO_FLOAT(obj->WrapR); - break; - case GL_TEXTURE_BORDER_COLOR: - params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F); - params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F); - params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F); - params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F); - break; - case GL_TEXTURE_RESIDENT: - { - GLboolean resident; - if (ctx->Driver.IsTextureResident) - resident = ctx->Driver.IsTextureResident(ctx, obj); - else - resident = GL_TRUE; - *params = ENUM_TO_FLOAT(resident); - } - break; - case GL_TEXTURE_PRIORITY: - *params = obj->Priority; - break; - case GL_TEXTURE_MIN_LOD: - *params = obj->MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = obj->MaxLod; - break; - case GL_TEXTURE_BASE_LEVEL: - *params = (GLfloat) obj->BaseLevel; - break; - case GL_TEXTURE_MAX_LEVEL: - *params = (GLfloat) obj->MaxLevel; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - *params = obj->MaxAnisotropy; - } - else - error = GL_TRUE; - break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (ctx->Extensions.ARB_shadow_ambient) { - *params = obj->CompareFailValue; - } - else - error = GL_TRUE; - break; - case GL_GENERATE_MIPMAP_SGIS: - if (ctx->Extensions.SGIS_generate_mipmap) { - *params = (GLfloat) obj->GenerateMipmap; - } - else - error = GL_TRUE; - break; - case GL_TEXTURE_COMPARE_MODE_ARB: - if (ctx->Extensions.ARB_shadow) { - *params = (GLfloat) obj->CompareMode; - } - else - error = GL_TRUE; - break; - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (ctx->Extensions.ARB_shadow) { - *params = (GLfloat) obj->CompareFunc; - } - else - error = GL_TRUE; - break; - case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->Extensions.ARB_depth_texture) { - *params = (GLfloat) obj->DepthMode; - } - else - error = GL_TRUE; - break; - case GL_TEXTURE_LOD_BIAS: - if (ctx->Extensions.EXT_texture_lod_bias) { - *params = obj->LodBias; - } - else - error = GL_TRUE; - break; -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - params[0] = obj->CropRect[0]; - params[1] = obj->CropRect[1]; - params[2] = obj->CropRect[2]; - params[3] = obj->CropRect[3]; - break; -#endif - - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; - *params = (GLfloat) obj->Swizzle[comp]; - } - else { - error = GL_TRUE; - } - break; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - GLuint comp; - for (comp = 0; comp < 4; comp++) { - params[comp] = (GLfloat) obj->Swizzle[comp]; - } - } - else { - error = GL_TRUE; - } - break; - - default: - error = GL_TRUE; - break; - } - - if (error) - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", - pname); - - _mesa_unlock_texture(ctx, obj); -} - - -void GLAPIENTRY -_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) -{ - struct gl_texture_object *obj; - GLboolean error = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = (GLint) obj->MagFilter; - break;; - case GL_TEXTURE_MIN_FILTER: - *params = (GLint) obj->MinFilter; - break;; - case GL_TEXTURE_WRAP_S: - *params = (GLint) obj->WrapS; - break;; - case GL_TEXTURE_WRAP_T: - *params = (GLint) obj->WrapT; - break;; - case GL_TEXTURE_WRAP_R: - *params = (GLint) obj->WrapR; - break;; - case GL_TEXTURE_BORDER_COLOR: - { - GLfloat b[4]; - b[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F); - b[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F); - b[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F); - b[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F); - params[0] = FLOAT_TO_INT(b[0]); - params[1] = FLOAT_TO_INT(b[1]); - params[2] = FLOAT_TO_INT(b[2]); - params[3] = FLOAT_TO_INT(b[3]); - } - break;; - case GL_TEXTURE_RESIDENT: - { - GLboolean resident; - if (ctx->Driver.IsTextureResident) - resident = ctx->Driver.IsTextureResident(ctx, obj); - else - resident = GL_TRUE; - *params = (GLint) resident; - } - break;; - case GL_TEXTURE_PRIORITY: - *params = FLOAT_TO_INT(obj->Priority); - break;; - case GL_TEXTURE_MIN_LOD: - *params = (GLint) obj->MinLod; - break;; - case GL_TEXTURE_MAX_LOD: - *params = (GLint) obj->MaxLod; - break;; - case GL_TEXTURE_BASE_LEVEL: - *params = obj->BaseLevel; - break;; - case GL_TEXTURE_MAX_LEVEL: - *params = obj->MaxLevel; - break;; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - *params = (GLint) obj->MaxAnisotropy; - } - else { - error = GL_TRUE; - } - break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (ctx->Extensions.ARB_shadow_ambient) { - *params = (GLint) FLOAT_TO_INT(obj->CompareFailValue); - } - else { - error = GL_TRUE; - } - break; - case GL_GENERATE_MIPMAP_SGIS: - if (ctx->Extensions.SGIS_generate_mipmap) { - *params = (GLint) obj->GenerateMipmap; - } - else { - error = GL_TRUE; - } - break; - case GL_TEXTURE_COMPARE_MODE_ARB: - if (ctx->Extensions.ARB_shadow) { - *params = (GLint) obj->CompareMode; - } - else { - error = GL_TRUE; - } - break; - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (ctx->Extensions.ARB_shadow) { - *params = (GLint) obj->CompareFunc; - } - else { - error = GL_TRUE; - } - break; - case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->Extensions.ARB_depth_texture) { - *params = (GLint) obj->DepthMode; - } - else { - error = GL_TRUE; - } - break; - case GL_TEXTURE_LOD_BIAS: - if (ctx->Extensions.EXT_texture_lod_bias) { - *params = (GLint) obj->LodBias; - } - else { - error = GL_TRUE; - } - break; -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - params[0] = obj->CropRect[0]; - params[1] = obj->CropRect[1]; - params[2] = obj->CropRect[2]; - params[3] = obj->CropRect[3]; - break; -#endif - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; - *params = obj->Swizzle[comp]; - } - else { - error = GL_TRUE; - } - break; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - COPY_4V(params, obj->Swizzle); - } - else { - error = GL_TRUE; - } - break; - - default: - ; /* silence warnings */ - } - - if (error) - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", - pname); - - _mesa_unlock_texture(ctx, obj); -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->BorderColor.i); - break; - default: - _mesa_GetTexParameteriv(target, pname, params); - } -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->BorderColor.i); - break; - default: - { - GLint ip[4]; - _mesa_GetTexParameteriv(target, pname, ip); - params[0] = ip[0]; - if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || - pname == GL_TEXTURE_CROP_RECT_OES) { - params[1] = ip[1]; - params[2] = ip[2]; - params[3] = ip[3]; - } - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file texparam.c + * + * glTexParameter-related functions + */ + + +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/formats.h" +#include "main/macros.h" +#include "main/texcompress.h" +#include "main/texparam.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "program/prog_instruction.h" + + +/** + * Check if a coordinate wrap mode is supported for the texture target. + * \return GL_TRUE if legal, GL_FALSE otherwise + */ +static GLboolean +validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) +{ + const struct gl_extensions * const e = & ctx->Extensions; + + if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE || + (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) { + /* any texture target */ + return GL_TRUE; + } + else if (target != GL_TEXTURE_RECTANGLE_NV && + (wrap == GL_REPEAT || + (wrap == GL_MIRRORED_REPEAT && + e->ARB_texture_mirrored_repeat) || + (wrap == GL_MIRROR_CLAMP_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (wrap == GL_MIRROR_CLAMP_TO_EDGE_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (wrap == GL_MIRROR_CLAMP_TO_BORDER_EXT && + (e->EXT_texture_mirror_clamp)))) { + /* non-rectangle texture */ + return GL_TRUE; + } + + _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); + return GL_FALSE; +} + + +/** + * Get current texture object for given target. + * Return NULL if any error (and record the error). + * Note that this is different from _mesa_select_tex_object() in that proxy + * targets are not accepted. + * Only the glGetTexLevelParameter() functions accept proxy targets. + */ +static struct gl_texture_object * +get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) +{ + struct gl_texture_unit *texUnit; + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sTexParameter(current unit)", get ? "Get" : ""); + return NULL; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + case GL_TEXTURE_2D: + return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + case GL_TEXTURE_3D: + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + case GL_TEXTURE_CUBE_MAP: + if (ctx->Extensions.ARB_texture_cube_map) { + return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; + } + break; + case GL_TEXTURE_RECTANGLE_NV: + if (ctx->Extensions.NV_texture_rectangle) { + return texUnit->CurrentTex[TEXTURE_RECT_INDEX]; + } + break; + case GL_TEXTURE_1D_ARRAY_EXT: + if (ctx->Extensions.MESA_texture_array) { + return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX]; + } + break; + case GL_TEXTURE_2D_ARRAY_EXT: + if (ctx->Extensions.MESA_texture_array) { + return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX]; + } + break; + default: + ; + } + + _mesa_error(ctx, GL_INVALID_ENUM, + "gl%sTexParameter(target)", get ? "Get" : ""); + return NULL; +} + + +/** + * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE. + * \return -1 if error. + */ +static GLint +comp_to_swizzle(GLenum comp) +{ + switch (comp) { + case GL_RED: + return SWIZZLE_X; + case GL_GREEN: + return SWIZZLE_Y; + case GL_BLUE: + return SWIZZLE_Z; + case GL_ALPHA: + return SWIZZLE_W; + case GL_ZERO: + return SWIZZLE_ZERO; + case GL_ONE: + return SWIZZLE_ONE; + default: + return -1; + } +} + + +static void +set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) +{ + ASSERT(comp < 4); + ASSERT(swz <= SWIZZLE_NIL); + { + GLuint mask = 0x7 << (3 * comp); + GLuint s = (*swizzle & ~mask) | (swz << (3 * comp)); + *swizzle = s; + } +} + + +/** + * This is called just prior to changing any texture object state. + * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE + * state flag and then mark the texture object as 'incomplete' so that any + * per-texture derived state gets recomputed. + */ +static INLINE void +flush(struct gl_context *ctx, struct gl_texture_object *texObj) +{ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texObj->_Complete = GL_FALSE; +} + + +/** + * Set an integer-valued texture parameter + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise + */ +static GLboolean +set_tex_parameteri(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum pname, const GLint *params) +{ + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + if (texObj->MinFilter == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_NEAREST: + case GL_LINEAR: + flush(ctx, texObj); + texObj->MinFilter = params[0]; + return GL_TRUE; + case GL_NEAREST_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + case GL_LINEAR_MIPMAP_LINEAR: + if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) { + flush(ctx, texObj); + texObj->MinFilter = params[0]; + return GL_TRUE; + } + /* fall-through */ + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", + params[0] ); + } + return GL_FALSE; + + case GL_TEXTURE_MAG_FILTER: + if (texObj->MagFilter == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_NEAREST: + case GL_LINEAR: + flush(ctx, texObj); + texObj->MagFilter = params[0]; + return GL_TRUE; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", + params[0]); + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_S: + if (texObj->WrapS == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx, texObj); + texObj->WrapS = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_T: + if (texObj->WrapT == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx, texObj); + texObj->WrapT = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_R: + if (texObj->WrapR == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx, texObj); + texObj->WrapR = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_BASE_LEVEL: + if (texObj->BaseLevel == params[0]) + return GL_FALSE; + if (params[0] < 0 || + (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexParameter(param=%d)", params[0]); + return GL_FALSE; + } + flush(ctx, texObj); + texObj->BaseLevel = params[0]; + return GL_TRUE; + + case GL_TEXTURE_MAX_LEVEL: + if (texObj->MaxLevel == params[0]) + return GL_FALSE; + if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(param=%d)", params[0]); + return GL_FALSE; + } + flush(ctx, texObj); + texObj->MaxLevel = params[0]; + return GL_TRUE; + + case GL_GENERATE_MIPMAP_SGIS: + if (texObj->GenerateMipmap != params[0]) { + flush(ctx, texObj); + texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_COMPARE_MODE_ARB: + if (ctx->Extensions.ARB_shadow && + (params[0] == GL_NONE || + params[0] == GL_COMPARE_R_TO_TEXTURE_ARB)) { + if (texObj->CompareMode != params[0]) { + flush(ctx, texObj); + texObj->CompareMode = params[0]; + return GL_TRUE; + } + return GL_FALSE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(GL_TEXTURE_COMPARE_MODE_ARB)"); + } + return GL_FALSE; + + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (ctx->Extensions.ARB_shadow) { + if (texObj->CompareFunc == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_LEQUAL: + case GL_GEQUAL: + flush(ctx, texObj); + texObj->CompareFunc = params[0]; + return GL_TRUE; + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_LESS: + case GL_GREATER: + case GL_ALWAYS: + case GL_NEVER: + if (ctx->Extensions.EXT_shadow_funcs) { + flush(ctx, texObj); + texObj->CompareFunc = params[0]; + return GL_TRUE; + } + /* fall-through */ + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(GL_TEXTURE_COMPARE_FUNC_ARB)"); + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + } + return GL_FALSE; + + case GL_DEPTH_TEXTURE_MODE_ARB: + if (ctx->Extensions.ARB_depth_texture && + (params[0] == GL_LUMINANCE || + params[0] == GL_INTENSITY || + params[0] == GL_ALPHA || + (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED))) { + if (texObj->DepthMode != params[0]) { + flush(ctx, texObj); + texObj->DepthMode = params[0]; + return GL_TRUE; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(GL_DEPTH_TEXTURE_MODE_ARB)"); + } + return GL_FALSE; + +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + texObj->CropRect[0] = params[0]; + texObj->CropRect[1] = params[1]; + texObj->CropRect[2] = params[2]; + texObj->CropRect[3] = params[3]; + return GL_TRUE; +#endif + + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; + const GLint swz = comp_to_swizzle(params[0]); + if (swz < 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(swizzle 0x%x)", params[0]); + return GL_FALSE; + } + ASSERT(comp < 4); + if (swz >= 0) { + flush(ctx, texObj); + texObj->Swizzle[comp] = params[0]; + set_swizzle_component(&texObj->_Swizzle, comp, swz); + return GL_TRUE; + } + } + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + return GL_FALSE; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + GLuint comp; + flush(ctx, texObj); + for (comp = 0; comp < 4; comp++) { + const GLint swz = comp_to_swizzle(params[comp]); + if (swz >= 0) { + texObj->Swizzle[comp] = params[comp]; + set_swizzle_component(&texObj->_Swizzle, comp, swz); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(swizzle 0x%x)", params[comp]); + return GL_FALSE; + } + } + return GL_TRUE; + } + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + return GL_FALSE; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + } + return GL_FALSE; +} + + +/** + * Set a float-valued texture parameter + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise + */ +static GLboolean +set_tex_parameterf(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params) +{ + switch (pname) { + case GL_TEXTURE_MIN_LOD: + if (texObj->MinLod == params[0]) + return GL_FALSE; + flush(ctx, texObj); + texObj->MinLod = params[0]; + return GL_TRUE; + + case GL_TEXTURE_MAX_LOD: + if (texObj->MaxLod == params[0]) + return GL_FALSE; + flush(ctx, texObj); + texObj->MaxLod = params[0]; + return GL_TRUE; + + case GL_TEXTURE_PRIORITY: + flush(ctx, texObj); + texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); + return GL_TRUE; + + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + if (texObj->MaxAnisotropy == params[0]) + return GL_FALSE; + if (params[0] < 1.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return GL_FALSE; + } + flush(ctx, texObj); + /* clamp to max, that's what NVIDIA does */ + texObj->MaxAnisotropy = MIN2(params[0], + ctx->Const.MaxTextureMaxAnisotropy); + return GL_TRUE; + } + else { + static GLuint count = 0; + if (count++ < 10) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); + } + return GL_FALSE; + + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + if (texObj->CompareFailValue != params[0]) { + flush(ctx, texObj); + texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); + return GL_TRUE; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); + } + return GL_FALSE; + + case GL_TEXTURE_LOD_BIAS: + /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ + if (ctx->Extensions.EXT_texture_lod_bias) { + if (texObj->LodBias != params[0]) { + flush(ctx, texObj); + texObj->LodBias = params[0]; + return GL_TRUE; + } + return GL_FALSE; + } + break; + + case GL_TEXTURE_BORDER_COLOR: + flush(ctx, texObj); + texObj->BorderColor.f[RCOMP] = params[0]; + texObj->BorderColor.f[GCOMP] = params[1]; + texObj->BorderColor.f[BCOMP] = params[2]; + texObj->BorderColor.f[ACOMP] = params[3]; + return GL_TRUE; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + } + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_GENERATE_MIPMAP_SGIS: + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + case GL_DEPTH_TEXTURE_MODE_ARB: + { + /* convert float param to int */ + GLint p[4]; + p[0] = (GLint) param; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); + } + break; + default: + { + /* this will generate an error if pname is illegal */ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, p); + } + } + + if (ctx->Driver.TexParameter && need_update) { + ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m); + } +} + + +void GLAPIENTRY +_mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_GENERATE_MIPMAP_SGIS: + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + case GL_DEPTH_TEXTURE_MODE_ARB: + { + /* convert float param to int */ + GLint p[4]; + p[0] = (GLint) params[0]; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); + } + break; + +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + { + /* convert float params to int */ + GLint iparams[4]; + iparams[0] = (GLint) params[0]; + iparams[1] = (GLint) params[1]; + iparams[2] = (GLint) params[2]; + iparams[3] = (GLint) params[3]; + need_update = set_tex_parameteri(ctx, texObj, pname, iparams); + } + break; +#endif + + default: + /* this will generate an error if pname is illegal */ + need_update = set_tex_parameterf(ctx, texObj, pname, params); + } + + if (ctx->Driver.TexParameter && need_update) { + ctx->Driver.TexParameter(ctx, target, texObj, pname, params); + } +} + + +void GLAPIENTRY +_mesa_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + case GL_TEXTURE_LOD_BIAS: + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + { + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + /* convert int param to float */ + need_update = set_tex_parameterf(ctx, texObj, pname, fparam); + } + break; + default: + /* this will generate an error if pname is illegal */ + { + GLint iparam[4]; + iparam[0] = param; + iparam[1] = iparam[2] = iparam[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, iparam); + } + } + + if (ctx->Driver.TexParameter && need_update) { + GLfloat fparam = (GLfloat) param; + ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam); + } +} + + +void GLAPIENTRY +_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + { + /* convert int params to float */ + GLfloat fparams[4]; + fparams[0] = INT_TO_FLOAT(params[0]); + fparams[1] = INT_TO_FLOAT(params[1]); + fparams[2] = INT_TO_FLOAT(params[2]); + fparams[3] = INT_TO_FLOAT(params[3]); + need_update = set_tex_parameterf(ctx, texObj, pname, fparams); + } + break; + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + case GL_TEXTURE_LOD_BIAS: + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + { + /* convert int param to float */ + GLfloat fparams[4]; + fparams[0] = (GLfloat) params[0]; + fparams[1] = fparams[2] = fparams[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, fparams); + } + break; + default: + /* this will generate an error if pname is illegal */ + need_update = set_tex_parameteri(ctx, texObj, pname, params); + } + + if (ctx->Driver.TexParameter && need_update) { + GLfloat fparams[4]; + fparams[0] = INT_TO_FLOAT(params[0]); + if (pname == GL_TEXTURE_BORDER_COLOR || + pname == GL_TEXTURE_CROP_RECT_OES) { + fparams[1] = INT_TO_FLOAT(params[1]); + fparams[2] = INT_TO_FLOAT(params[2]); + fparams[3] = INT_TO_FLOAT(params[3]); + } + ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams); + } +} + + +/** + * Set tex parameter to integer value(s). Primarily intended to set + * integer-valued texture border color (for integer-valued textures). + * New in GL 3.0. + */ +void GLAPIENTRY +_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + /* set the integer-valued border color */ + COPY_4V(texObj->BorderColor.i, params); + break; + default: + _mesa_TexParameteriv(target, pname, params); + break; + } + /* XXX no driver hook for TexParameterIiv() yet */ +} + + +/** + * Set tex parameter to unsigned integer value(s). Primarily intended to set + * uint-valued texture border color (for integer-valued textures). + * New in GL 3.0 + */ +void GLAPIENTRY +_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + /* set the unsigned integer-valued border color */ + COPY_4V(texObj->BorderColor.ui, params); + break; + default: + _mesa_TexParameteriv(target, pname, (const GLint *) params); + break; + } + /* XXX no driver hook for TexParameterIuiv() yet */ +} + + + + +void GLAPIENTRY +_mesa_GetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ) +{ + GLint iparam; + _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); + *params = (GLfloat) iparam; +} + + +void GLAPIENTRY +_mesa_GetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ) +{ + const struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + const struct gl_texture_image *img = NULL; + GLboolean isProxy; + GLint maxLevels; + gl_format texFormat; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexLevelParameteriv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + /* this will catch bad target values */ + maxLevels = _mesa_max_texture_levels(ctx, target); + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(target=0x%x)", target); + return; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); + return; + } + + texObj = _mesa_select_tex_object(ctx, texUnit, target); + _mesa_lock_texture(ctx, texObj); + + img = _mesa_select_tex_image(ctx, texObj, target, level); + if (!img || !img->TexFormat) { + /* undefined texture image */ + if (pname == GL_TEXTURE_COMPONENTS) + *params = 1; + else + *params = 0; + goto out; + } + + texFormat = img->TexFormat; + + isProxy = _mesa_is_proxy_texture(target); + + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = img->Width; + break; + case GL_TEXTURE_HEIGHT: + *params = img->Height; + break; + case GL_TEXTURE_DEPTH: + *params = img->Depth; + break; + case GL_TEXTURE_INTERNAL_FORMAT: + if (_mesa_is_format_compressed(img->TexFormat)) { + /* need to return the actual compressed format */ + *params = _mesa_compressed_format_to_glenum(ctx, img->TexFormat); + } + else { + /* return the user's requested internal format */ + *params = img->InternalFormat; + } + break; + case GL_TEXTURE_BORDER: + *params = img->Border; + break; + case GL_TEXTURE_RED_SIZE: + if (img->_BaseFormat == GL_RED) { + *params = _mesa_get_format_bits(texFormat, pname); + break; + } + /* FALLTHROUGH */ + case GL_TEXTURE_GREEN_SIZE: + if (img->_BaseFormat == GL_RG) { + *params = _mesa_get_format_bits(texFormat, pname); + break; + } + /* FALLTHROUGH */ + case GL_TEXTURE_BLUE_SIZE: + if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) + *params = _mesa_get_format_bits(texFormat, pname); + else + *params = 0; + break; + case GL_TEXTURE_ALPHA_SIZE: + if (img->_BaseFormat == GL_ALPHA || + img->_BaseFormat == GL_LUMINANCE_ALPHA || + img->_BaseFormat == GL_RGBA) + *params = _mesa_get_format_bits(texFormat, pname); + else + *params = 0; + break; + case GL_TEXTURE_INTENSITY_SIZE: + if (img->_BaseFormat != GL_INTENSITY) + *params = 0; + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* intensity probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } + break; + case GL_TEXTURE_LUMINANCE_SIZE: + if (img->_BaseFormat != GL_LUMINANCE && + img->_BaseFormat != GL_LUMINANCE_ALPHA) + *params = 0; + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* luminance probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } + break; + case GL_TEXTURE_INDEX_SIZE_EXT: + if (img->_BaseFormat == GL_COLOR_INDEX) + *params = _mesa_get_format_bits(texFormat, pname); + else + *params = 0; + break; + case GL_TEXTURE_DEPTH_SIZE_ARB: + if (ctx->Extensions.ARB_depth_texture) + *params = _mesa_get_format_bits(texFormat, pname); + else + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + break; + case GL_TEXTURE_STENCIL_SIZE_EXT: + if (ctx->Extensions.EXT_packed_depth_stencil || + ctx->Extensions.ARB_framebuffer_object) { + *params = _mesa_get_format_bits(texFormat, pname); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_SHARED_SIZE: + if (ctx->VersionMajor >= 3) { + /* XXX return number of exponent bits for shared exponent texture + * formats, like GL_RGB9_E5. + */ + *params = 0; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: + if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) { + *params = _mesa_format_image_size(texFormat, img->Width, + img->Height, img->Depth); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_COMPRESSED: + *params = (GLint) _mesa_is_format_compressed(img->TexFormat); + break; + + /* GL_ARB_texture_float */ + case GL_TEXTURE_RED_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_GREEN_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_BLUE_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_ALPHA_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_LUMINANCE_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_INTENSITY_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_DEPTH_TYPE_ARB: + if (ctx->Extensions.ARB_texture_float) { + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname)"); + } + + out: + _mesa_unlock_texture(ctx, texObj); +} + + + +void GLAPIENTRY +_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) +{ + struct gl_texture_object *obj; + GLboolean error = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + obj = get_texobj(ctx, target, GL_TRUE); + if (!obj) + return; + + _mesa_lock_texture(ctx, obj); + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = ENUM_TO_FLOAT(obj->MagFilter); + break; + case GL_TEXTURE_MIN_FILTER: + *params = ENUM_TO_FLOAT(obj->MinFilter); + break; + case GL_TEXTURE_WRAP_S: + *params = ENUM_TO_FLOAT(obj->WrapS); + break; + case GL_TEXTURE_WRAP_T: + *params = ENUM_TO_FLOAT(obj->WrapT); + break; + case GL_TEXTURE_WRAP_R: + *params = ENUM_TO_FLOAT(obj->WrapR); + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F); + params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F); + params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F); + params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F); + break; + case GL_TEXTURE_RESIDENT: + { + GLboolean resident; + if (ctx->Driver.IsTextureResident) + resident = ctx->Driver.IsTextureResident(ctx, obj); + else + resident = GL_TRUE; + *params = ENUM_TO_FLOAT(resident); + } + break; + case GL_TEXTURE_PRIORITY: + *params = obj->Priority; + break; + case GL_TEXTURE_MIN_LOD: + *params = obj->MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = obj->MaxLod; + break; + case GL_TEXTURE_BASE_LEVEL: + *params = (GLfloat) obj->BaseLevel; + break; + case GL_TEXTURE_MAX_LEVEL: + *params = (GLfloat) obj->MaxLevel; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + *params = obj->MaxAnisotropy; + } + else + error = GL_TRUE; + break; + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + *params = obj->CompareFailValue; + } + else + error = GL_TRUE; + break; + case GL_GENERATE_MIPMAP_SGIS: + *params = (GLfloat) obj->GenerateMipmap; + break; + case GL_TEXTURE_COMPARE_MODE_ARB: + if (ctx->Extensions.ARB_shadow) { + *params = (GLfloat) obj->CompareMode; + } + else + error = GL_TRUE; + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (ctx->Extensions.ARB_shadow) { + *params = (GLfloat) obj->CompareFunc; + } + else + error = GL_TRUE; + break; + case GL_DEPTH_TEXTURE_MODE_ARB: + if (ctx->Extensions.ARB_depth_texture) { + *params = (GLfloat) obj->DepthMode; + } + else + error = GL_TRUE; + break; + case GL_TEXTURE_LOD_BIAS: + if (ctx->Extensions.EXT_texture_lod_bias) { + *params = obj->LodBias; + } + else + error = GL_TRUE; + break; +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + params[0] = obj->CropRect[0]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; + break; +#endif + + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; + *params = (GLfloat) obj->Swizzle[comp]; + } + else { + error = GL_TRUE; + } + break; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + GLuint comp; + for (comp = 0; comp < 4; comp++) { + params[comp] = (GLfloat) obj->Swizzle[comp]; + } + } + else { + error = GL_TRUE; + } + break; + + default: + error = GL_TRUE; + break; + } + + if (error) + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", + pname); + + _mesa_unlock_texture(ctx, obj); +} + + +void GLAPIENTRY +_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + struct gl_texture_object *obj; + GLboolean error = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + obj = get_texobj(ctx, target, GL_TRUE); + if (!obj) + return; + + _mesa_lock_texture(ctx, obj); + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = (GLint) obj->MagFilter; + break;; + case GL_TEXTURE_MIN_FILTER: + *params = (GLint) obj->MinFilter; + break;; + case GL_TEXTURE_WRAP_S: + *params = (GLint) obj->WrapS; + break;; + case GL_TEXTURE_WRAP_T: + *params = (GLint) obj->WrapT; + break;; + case GL_TEXTURE_WRAP_R: + *params = (GLint) obj->WrapR; + break;; + case GL_TEXTURE_BORDER_COLOR: + { + GLfloat b[4]; + b[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F); + b[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F); + b[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F); + b[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F); + params[0] = FLOAT_TO_INT(b[0]); + params[1] = FLOAT_TO_INT(b[1]); + params[2] = FLOAT_TO_INT(b[2]); + params[3] = FLOAT_TO_INT(b[3]); + } + break;; + case GL_TEXTURE_RESIDENT: + { + GLboolean resident; + if (ctx->Driver.IsTextureResident) + resident = ctx->Driver.IsTextureResident(ctx, obj); + else + resident = GL_TRUE; + *params = (GLint) resident; + } + break;; + case GL_TEXTURE_PRIORITY: + *params = FLOAT_TO_INT(obj->Priority); + break;; + case GL_TEXTURE_MIN_LOD: + *params = (GLint) obj->MinLod; + break;; + case GL_TEXTURE_MAX_LOD: + *params = (GLint) obj->MaxLod; + break;; + case GL_TEXTURE_BASE_LEVEL: + *params = obj->BaseLevel; + break;; + case GL_TEXTURE_MAX_LEVEL: + *params = obj->MaxLevel; + break;; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + *params = (GLint) obj->MaxAnisotropy; + } + else { + error = GL_TRUE; + } + break; + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + *params = (GLint) FLOAT_TO_INT(obj->CompareFailValue); + } + else { + error = GL_TRUE; + } + break; + case GL_GENERATE_MIPMAP_SGIS: + *params = (GLint) obj->GenerateMipmap; + break; + case GL_TEXTURE_COMPARE_MODE_ARB: + if (ctx->Extensions.ARB_shadow) { + *params = (GLint) obj->CompareMode; + } + else { + error = GL_TRUE; + } + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (ctx->Extensions.ARB_shadow) { + *params = (GLint) obj->CompareFunc; + } + else { + error = GL_TRUE; + } + break; + case GL_DEPTH_TEXTURE_MODE_ARB: + if (ctx->Extensions.ARB_depth_texture) { + *params = (GLint) obj->DepthMode; + } + else { + error = GL_TRUE; + } + break; + case GL_TEXTURE_LOD_BIAS: + if (ctx->Extensions.EXT_texture_lod_bias) { + *params = (GLint) obj->LodBias; + } + else { + error = GL_TRUE; + } + break; +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + params[0] = obj->CropRect[0]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; + break; +#endif + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; + *params = obj->Swizzle[comp]; + } + else { + error = GL_TRUE; + } + break; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + COPY_4V(params, obj->Swizzle); + } + else { + error = GL_TRUE; + } + break; + + default: + ; /* silence warnings */ + } + + if (error) + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", + pname); + + _mesa_unlock_texture(ctx, obj); +} + + +/** New in GL 3.0 */ +void GLAPIENTRY +_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_TRUE); + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + COPY_4V(params, texObj->BorderColor.i); + break; + default: + _mesa_GetTexParameteriv(target, pname, params); + } +} + + +/** New in GL 3.0 */ +void GLAPIENTRY +_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_TRUE); + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + COPY_4V(params, texObj->BorderColor.i); + break; + default: + { + GLint ip[4]; + _mesa_GetTexParameteriv(target, pname, ip); + params[0] = ip[0]; + if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || + pname == GL_TEXTURE_CROP_RECT_OES) { + params[1] = ip[1]; + params[2] = ip[2]; + params[3] = ip[3]; + } + } + } +} diff --git a/mesalib/src/mesa/main/texrender.c b/mesalib/src/mesa/main/texrender.c index c68105b39..6d5531f18 100644 --- a/mesalib/src/mesa/main/texrender.c +++ b/mesalib/src/mesa/main/texrender.c @@ -1,635 +1,635 @@ - -#include "context.h" -#include "colormac.h" -#include "macros.h" -#include "texfetch.h" -#include "texrender.h" -#include "renderbuffer.h" - - -/* - * Render-to-texture code for GL_EXT_framebuffer_object - */ - - -/** - * Derived from gl_renderbuffer class - */ -struct texture_renderbuffer -{ - struct gl_renderbuffer Base; /**< Base class object */ - struct gl_texture_image *TexImage; - StoreTexelFunc Store; - GLint Yoffset; /**< Layer for 1D array textures. */ - GLint Zoffset; /**< Layer for 2D array textures, or slice - * for 3D textures - */ -}; - - -/** - * Get row of values from the renderbuffer that wraps a texture image. - */ -static void -texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - ASSERT(trb->TexImage->Width == rb->Width); - ASSERT(trb->TexImage->Height == rb->Height); - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - GLchan *rgbaOut = (GLchan *) values; - for (i = 0; i < count; i++) { - GLfloat rgba[4]; - trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, rgba); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); - zValues[i] = (GLushort) (flt * 0xffff); - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) values; - /* - const GLdouble scale = (GLdouble) 0xffffffff; - */ - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); -#if 0 - /* this should work, but doesn't (overflow due to low precision) */ - zValues[i] = (GLuint) (flt * scale); -#else - /* temporary hack */ - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; -#endif - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); - zValues[i] = (GLuint) (flt * 0xffffff); - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_get_row"); - } -} - - -static void -texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - if (rb->DataType == CHAN_TYPE) { - GLchan *rgbaOut = (GLchan *) values; - for (i = 0; i < count; i++) { - GLfloat rgba[4]; - trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, rgba); - UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = (GLushort) (flt * 0xffff); - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); -#if 0 - zValues[i] = (GLuint) (flt * 0xffffffff); -#else - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; -#endif - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - GLuint *zValues = (GLuint *) values; - for (i = 0; i < count; i++) { - GLfloat flt; - trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, - z, &flt); - zValues[i] = (GLuint) (flt * 0xffffff); - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_get_values"); - } -} - - -/** - * Put row of values into a renderbuffer that wraps a texture image. - */ -static void -texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, rgba); - } - rgba += 4; - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort *zValues = (const GLushort *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_row"); - } -} - -/** - * Put row of RGB values into a renderbuffer that wraps a texture image. - */ -static void -texture_put_row_rgb(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgb = (const GLchan *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, rgb); - } - rgb += 3; - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort *zValues = (const GLushort *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_row"); - } -} - - -static void -texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - y += trb->Yoffset; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) value; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, rgba); - } - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort zValue = *((const GLushort *) value); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, &zValue); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint zValue = *((const GLuint *) value); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, &zValue); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint zValue = *((const GLuint *) value); - const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff)); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint zValue = *((const GLuint *) value); - const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff)); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x + i, y, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_row"); - } -} - - -static void -texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba); - } - rgba += 4; - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort *zValues = (const GLushort *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint *zValues = (const GLuint *) values; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_values"); - } -} - - -static void -texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const struct texture_renderbuffer *trb - = (const struct texture_renderbuffer *) rb; - const GLint z = trb->Zoffset; - GLuint i; - - if (rb->DataType == CHAN_TYPE) { - const GLchan *rgba = (const GLchan *) value; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT) { - const GLuint zValue = *((const GLuint *) value); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue); - } - } - } - else if (rb->DataType == GL_UNSIGNED_SHORT) { - const GLushort zValue = *((const GLushort *) value); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { - const GLuint zValue = *((const GLuint *) value); - const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff)); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { - const GLuint zValue = *((const GLuint *) value); - const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff)); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); - } - } - } - else { - _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_values"); - } -} - - -static void -store_nop(struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel) -{ -} - - -static void -delete_texture_wrapper(struct gl_renderbuffer *rb) -{ - ASSERT(rb->RefCount == 0); - free(rb); -} - - -/** - * This function creates a renderbuffer object which wraps a texture image. - * The new renderbuffer is plugged into the given attachment point. - * This allows rendering into the texture as if it were a renderbuffer. - */ -static void -wrap_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att) -{ - struct texture_renderbuffer *trb; - const GLuint name = 0; - - ASSERT(att->Type == GL_TEXTURE); - ASSERT(att->Renderbuffer == NULL); - - trb = CALLOC_STRUCT(texture_renderbuffer); - if (!trb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture"); - return; - } - - /* init base gl_renderbuffer fields */ - _mesa_init_renderbuffer(&trb->Base, name); - /* plug in our texture_renderbuffer-specific functions */ - trb->Base.Delete = delete_texture_wrapper; - trb->Base.AllocStorage = NULL; /* illegal! */ - trb->Base.GetRow = texture_get_row; - trb->Base.GetValues = texture_get_values; - trb->Base.PutRow = texture_put_row; - trb->Base.PutRowRGB = texture_put_row_rgb; - trb->Base.PutMonoRow = texture_put_mono_row; - trb->Base.PutValues = texture_put_values; - trb->Base.PutMonoValues = texture_put_mono_values; - - /* update attachment point */ - _mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base)); -} - - - -/** - * Update the renderbuffer wrapper for rendering to a texture. - * For example, update the width, height of the RB based on the texture size, - * update the internal format info, etc. - */ -static void -update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att) -{ - struct texture_renderbuffer *trb - = (struct texture_renderbuffer *) att->Renderbuffer; - - (void) ctx; - ASSERT(trb); - - trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; - ASSERT(trb->TexImage); - - trb->Store = _mesa_get_texel_store_func(trb->TexImage->TexFormat); - if (!trb->Store) { - /* we'll never draw into some textures (compressed formats) */ - trb->Store = store_nop; - } - - if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) { - trb->Yoffset = att->Zoffset; - trb->Zoffset = 0; - } - else { - trb->Yoffset = 0; - trb->Zoffset = att->Zoffset; - } - - trb->Base.Width = trb->TexImage->Width; - trb->Base.Height = trb->TexImage->Height; - trb->Base.InternalFormat = trb->TexImage->InternalFormat; - trb->Base.Format = trb->TexImage->TexFormat; - - /* XXX may need more special cases here */ - switch (trb->TexImage->TexFormat) { - case MESA_FORMAT_Z24_S8: - trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - trb->Base._BaseFormat = GL_DEPTH_STENCIL; - break; - case MESA_FORMAT_S8_Z24: - trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; - trb->Base._BaseFormat = GL_DEPTH_STENCIL; - break; - case MESA_FORMAT_Z24_X8: - trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_X8_Z24: - trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_Z16: - trb->Base.DataType = GL_UNSIGNED_SHORT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - case MESA_FORMAT_Z32: - trb->Base.DataType = GL_UNSIGNED_INT; - trb->Base._BaseFormat = GL_DEPTH_COMPONENT; - break; - default: - trb->Base.DataType = CHAN_TYPE; - trb->Base._BaseFormat = GL_RGBA; - } - trb->Base.Data = trb->TexImage->Data; -} - - - -/** - * Called when rendering to a texture image begins, or when changing - * the dest mipmap level, cube face, etc. - * This is a fallback routine for software render-to-texture. - * - * Called via the glRenderbufferTexture1D/2D/3D() functions - * and elsewhere (such as glTexImage2D). - * - * The image we're rendering into is - * att->Texture->Image[att->CubeMapFace][att->TextureLevel]; - * It'll never be NULL. - * - * \param fb the framebuffer object the texture is being bound to - * \param att the fb attachment point of the texture - * - * \sa _mesa_framebuffer_renderbuffer - */ -void -_mesa_render_texture(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att) -{ - (void) fb; - - if (!att->Renderbuffer) { - wrap_texture(ctx, att); - } - update_wrapper(ctx, att); -} - - -void -_mesa_finish_render_texture(GLcontext *ctx, - struct gl_renderbuffer_attachment *att) -{ - /* do nothing */ - /* The renderbuffer texture wrapper will get deleted by the - * normal mechanism for deleting renderbuffers. - */ - (void) ctx; - (void) att; -} + +#include "context.h" +#include "colormac.h" +#include "macros.h" +#include "texfetch.h" +#include "texrender.h" +#include "renderbuffer.h" + + +/* + * Render-to-texture code for GL_EXT_framebuffer_object + */ + + +/** + * Derived from gl_renderbuffer class + */ +struct texture_renderbuffer +{ + struct gl_renderbuffer Base; /**< Base class object */ + struct gl_texture_image *TexImage; + StoreTexelFunc Store; + GLint Yoffset; /**< Layer for 1D array textures. */ + GLint Zoffset; /**< Layer for 2D array textures, or slice + * for 3D textures + */ +}; + + +/** + * Get row of values from the renderbuffer that wraps a texture image. + */ +static void +texture_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + ASSERT(trb->TexImage->Width == rb->Width); + ASSERT(trb->TexImage->Height == rb->Height); + + y += trb->Yoffset; + + if (rb->DataType == CHAN_TYPE) { + GLchan *rgbaOut = (GLchan *) values; + for (i = 0; i < count; i++) { + GLfloat rgba[4]; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, rgba); + UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); + zValues[i] = (GLushort) (flt * 0xffff); + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + GLuint *zValues = (GLuint *) values; + /* + const GLdouble scale = (GLdouble) 0xffffffff; + */ + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); +#if 0 + /* this should work, but doesn't (overflow due to low precision) */ + zValues[i] = (GLuint) (flt * scale); +#else + /* temporary hack */ + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; +#endif + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x + i, y, z, &flt); + zValues[i] = (GLuint) (flt * 0xffffff); + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_get_row"); + } +} + + +static void +texture_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + if (rb->DataType == CHAN_TYPE) { + GLchan *rgbaOut = (GLchan *) values; + for (i = 0; i < count; i++) { + GLfloat rgba[4]; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, rgba); + UNCLAMPED_FLOAT_TO_RGBA_CHAN(rgbaOut + 4 * i, rgba); + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, &flt); + zValues[i] = (GLushort) (flt * 0xffff); + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, &flt); +#if 0 + zValues[i] = (GLuint) (flt * 0xffffffff); +#else + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; +#endif + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, &flt); + zValues[i] = ((GLuint) (flt * 0xffffff)) << 8; + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + GLuint *zValues = (GLuint *) values; + for (i = 0; i < count; i++) { + GLfloat flt; + trb->TexImage->FetchTexelf(trb->TexImage, x[i], y[i] + trb->Yoffset, + z, &flt); + zValues[i] = (GLuint) (flt * 0xffffff); + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_get_values"); + } +} + + +/** + * Put row of values into a renderbuffer that wraps a texture image. + */ +static void +texture_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + y += trb->Yoffset; + + if (rb->DataType == CHAN_TYPE) { + const GLchan *rgba = (const GLchan *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, rgba); + } + rgba += 4; + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort *zValues = (const GLushort *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_put_row"); + } +} + +/** + * Put row of RGB values into a renderbuffer that wraps a texture image. + */ +static void +texture_put_row_rgb(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + y += trb->Yoffset; + + if (rb->DataType == CHAN_TYPE) { + const GLchan *rgb = (const GLchan *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, rgb); + } + rgb += 3; + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort *zValues = (const GLushort *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_put_row"); + } +} + + +static void +texture_put_mono_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + y += trb->Yoffset; + + if (rb->DataType == CHAN_TYPE) { + const GLchan *rgba = (const GLchan *) value; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, rgba); + } + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort zValue = *((const GLushort *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, &zValue); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint zValue = *((const GLuint *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, &zValue); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + const GLuint zValue = *((const GLuint *) value); + const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff)); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + const GLuint zValue = *((const GLuint *) value); + const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff)); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x + i, y, z, &flt); + } + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_row"); + } +} + + +static void +texture_put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + if (rb->DataType == CHAN_TYPE) { + const GLchan *rgba = (const GLchan *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba); + } + rgba += 4; + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort *zValues = (const GLushort *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, zValues + i); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] >> 8) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + const GLuint *zValues = (const GLuint *) values; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat flt = (GLfloat) ((zValues[i] & 0xffffff) * (1.0 / 0xffffff)); + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); + } + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_put_values"); + } +} + + +static void +texture_put_mono_values(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const struct texture_renderbuffer *trb + = (const struct texture_renderbuffer *) rb; + const GLint z = trb->Zoffset; + GLuint i; + + if (rb->DataType == CHAN_TYPE) { + const GLchan *rgba = (const GLchan *) value; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT) { + const GLuint zValue = *((const GLuint *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue); + } + } + } + else if (rb->DataType == GL_UNSIGNED_SHORT) { + const GLushort zValue = *((const GLushort *) value); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) { + const GLuint zValue = *((const GLuint *) value); + const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff)); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); + } + } + } + else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) { + const GLuint zValue = *((const GLuint *) value); + const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff)); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt); + } + } + } + else { + _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_values"); + } +} + + +static void +store_nop(struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + const void *texel) +{ +} + + +static void +delete_texture_wrapper(struct gl_renderbuffer *rb) +{ + ASSERT(rb->RefCount == 0); + free(rb); +} + + +/** + * This function creates a renderbuffer object which wraps a texture image. + * The new renderbuffer is plugged into the given attachment point. + * This allows rendering into the texture as if it were a renderbuffer. + */ +static void +wrap_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) +{ + struct texture_renderbuffer *trb; + const GLuint name = 0; + + ASSERT(att->Type == GL_TEXTURE); + ASSERT(att->Renderbuffer == NULL); + + trb = CALLOC_STRUCT(texture_renderbuffer); + if (!trb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture"); + return; + } + + /* init base gl_renderbuffer fields */ + _mesa_init_renderbuffer(&trb->Base, name); + /* plug in our texture_renderbuffer-specific functions */ + trb->Base.Delete = delete_texture_wrapper; + trb->Base.AllocStorage = NULL; /* illegal! */ + trb->Base.GetRow = texture_get_row; + trb->Base.GetValues = texture_get_values; + trb->Base.PutRow = texture_put_row; + trb->Base.PutRowRGB = texture_put_row_rgb; + trb->Base.PutMonoRow = texture_put_mono_row; + trb->Base.PutValues = texture_put_values; + trb->Base.PutMonoValues = texture_put_mono_values; + + /* update attachment point */ + _mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base)); +} + + + +/** + * Update the renderbuffer wrapper for rendering to a texture. + * For example, update the width, height of the RB based on the texture size, + * update the internal format info, etc. + */ +static void +update_wrapper(struct gl_context *ctx, const struct gl_renderbuffer_attachment *att) +{ + struct texture_renderbuffer *trb + = (struct texture_renderbuffer *) att->Renderbuffer; + + (void) ctx; + ASSERT(trb); + + trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + ASSERT(trb->TexImage); + + trb->Store = _mesa_get_texel_store_func(trb->TexImage->TexFormat); + if (!trb->Store) { + /* we'll never draw into some textures (compressed formats) */ + trb->Store = store_nop; + } + + if (att->Texture->Target == GL_TEXTURE_1D_ARRAY_EXT) { + trb->Yoffset = att->Zoffset; + trb->Zoffset = 0; + } + else { + trb->Yoffset = 0; + trb->Zoffset = att->Zoffset; + } + + trb->Base.Width = trb->TexImage->Width; + trb->Base.Height = trb->TexImage->Height; + trb->Base.InternalFormat = trb->TexImage->InternalFormat; + trb->Base.Format = trb->TexImage->TexFormat; + + /* XXX may need more special cases here */ + switch (trb->TexImage->TexFormat) { + case MESA_FORMAT_Z24_S8: + trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; + trb->Base._BaseFormat = GL_DEPTH_STENCIL; + break; + case MESA_FORMAT_S8_Z24: + trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; + trb->Base._BaseFormat = GL_DEPTH_STENCIL; + break; + case MESA_FORMAT_Z24_X8: + trb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; + trb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + case MESA_FORMAT_X8_Z24: + trb->Base.DataType = GL_UNSIGNED_INT_8_24_REV_MESA; + trb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + case MESA_FORMAT_Z16: + trb->Base.DataType = GL_UNSIGNED_SHORT; + trb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + case MESA_FORMAT_Z32: + trb->Base.DataType = GL_UNSIGNED_INT; + trb->Base._BaseFormat = GL_DEPTH_COMPONENT; + break; + default: + trb->Base.DataType = CHAN_TYPE; + trb->Base._BaseFormat = GL_RGBA; + } + trb->Base.Data = trb->TexImage->Data; +} + + + +/** + * Called when rendering to a texture image begins, or when changing + * the dest mipmap level, cube face, etc. + * This is a fallback routine for software render-to-texture. + * + * Called via the glRenderbufferTexture1D/2D/3D() functions + * and elsewhere (such as glTexImage2D). + * + * The image we're rendering into is + * att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + * It'll never be NULL. + * + * \param fb the framebuffer object the texture is being bound to + * \param att the fb attachment point of the texture + * + * \sa _mesa_framebuffer_renderbuffer + */ +void +_mesa_render_texture(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att) +{ + (void) fb; + + if (!att->Renderbuffer) { + wrap_texture(ctx, att); + } + update_wrapper(ctx, att); +} + + +void +_mesa_finish_render_texture(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att) +{ + /* do nothing */ + /* The renderbuffer texture wrapper will get deleted by the + * normal mechanism for deleting renderbuffers. + */ + (void) ctx; + (void) att; +} diff --git a/mesalib/src/mesa/main/texrender.h b/mesalib/src/mesa/main/texrender.h index 1e87d594a..d6e4784ca 100644 --- a/mesalib/src/mesa/main/texrender.h +++ b/mesalib/src/mesa/main/texrender.h @@ -1,16 +1,18 @@ -#ifndef TEXRENDER_H -#define TEXRENDER_H - -#include "mtypes.h" - -extern void -_mesa_render_texture(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att); - -extern void -_mesa_finish_render_texture(GLcontext *ctx, - struct gl_renderbuffer_attachment *att); - - -#endif /* TEXRENDER_H */ +#ifndef TEXRENDER_H +#define TEXRENDER_H + +struct gl_context; +struct gl_framebuffer; +struct gl_renderbuffer_attachment; + +extern void +_mesa_render_texture(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att); + +extern void +_mesa_finish_render_texture(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + + +#endif /* TEXRENDER_H */ diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c index dae173d1b..d86a5a5ec 100644 --- a/mesalib/src/mesa/main/texstate.c +++ b/mesalib/src/mesa/main/texstate.c @@ -1,833 +1,844 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file texstate.c - * - * Texture state handling. - */ - -#include "glheader.h" -#include "mfeatures.h" -#include "colormac.h" -#include "colortab.h" -#include "context.h" -#include "enums.h" -#include "macros.h" -#include "texobj.h" -#include "teximage.h" -#include "texstate.h" -#include "mtypes.h" - - - -/** - * Default texture combine environment state. This is used to initialize - * a context's texture units and as the basis for converting "classic" - * texture environmnets to ARB_texture_env_combine style values. - */ -static const struct gl_tex_env_combine_state default_combine_state = { - GL_MODULATE, GL_MODULATE, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_ALPHA }, - { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, - 0, 0, - 2, 2 -}; - - - -/** - * Used by glXCopyContext to copy texture state from one context to another. - */ -void -_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) -{ - GLuint u, tex; - - ASSERT(src); - ASSERT(dst); - - dst->Texture.CurrentUnit = src->Texture.CurrentUnit; - dst->Texture._GenFlags = src->Texture._GenFlags; - dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; - dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; - dst->Texture.SharedPalette = src->Texture.SharedPalette; - - /* per-unit state */ - for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) { - dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; - dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; - COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); - dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; - dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; - dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; - dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; - dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; - dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; - - /* GL_EXT_texture_env_combine */ - dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; - - /* GL_ATI_envmap_bumpmap - need this? */ - dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; - COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); - - /* - * XXX strictly speaking, we should compare texture names/ids and - * bind textures in the dest context according to id. For now, only - * copy bindings if the contexts share the same pool of textures to - * avoid refcounting bugs. - */ - if (dst->Shared == src->Shared) { - /* copy texture object bindings, not contents of texture objects */ - _mesa_lock_context_textures(dst); - - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], - src->Texture.Unit[u].CurrentTex[tex]); - } - _mesa_unlock_context_textures(dst); - } - } -} - - -/* - * For debugging - */ -void -_mesa_print_texunit_state( GLcontext *ctx, GLuint unit ) -{ - const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; - printf("Texture Unit %d\n", unit); - printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); - printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); - printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); - printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); - printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); - printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); - printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); - printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); - printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); - printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); - printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); - printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); - printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); - printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); - printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); -} - - - -/**********************************************************************/ -/* Texture Environment */ -/**********************************************************************/ - -/** - * Convert "classic" texture environment to ARB_texture_env_combine style - * environments. - * - * \param state texture_env_combine state vector to be filled-in. - * \param mode Classic texture environment mode (i.e., \c GL_REPLACE, - * \c GL_BLEND, \c GL_DECAL, etc.). - * \param texBaseFormat Base format of the texture associated with the - * texture unit. - */ -static void -calculate_derived_texenv( struct gl_tex_env_combine_state *state, - GLenum mode, GLenum texBaseFormat ) -{ - GLenum mode_rgb; - GLenum mode_a; - - *state = default_combine_state; - - switch (texBaseFormat) { - case GL_ALPHA: - state->SourceRGB[0] = GL_PREVIOUS; - break; - - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - break; - - case GL_LUMINANCE: - case GL_RGB: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - state->SourceA[0] = GL_PREVIOUS; - break; - - default: - _mesa_problem(NULL, - "Invalid texBaseFormat 0x%x in calculate_derived_texenv", - texBaseFormat); - return; - } - - if (mode == GL_REPLACE_EXT) - mode = GL_REPLACE; - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode; - mode_a = mode; - break; - - case GL_DECAL: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_REPLACE; - - state->SourceA[0] = GL_PREVIOUS; - - /* Having alpha / luminance / intensity textures replace using the - * incoming fragment color matches the definition in NV_texture_shader. - * The 1.5 spec simply marks these as "undefined". - */ - switch (texBaseFormat) { - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - state->SourceRGB[0] = GL_PREVIOUS; - break; - case GL_RGB: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - mode_rgb = GL_REPLACE; - break; - case GL_RGBA: - state->SourceRGB[2] = GL_TEXTURE; - break; - } - break; - - case GL_BLEND: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_MODULATE; - - switch (texBaseFormat) { - case GL_ALPHA: - mode_rgb = GL_REPLACE; - break; - case GL_INTENSITY: - mode_a = GL_INTERPOLATE; - state->SourceA[0] = GL_CONSTANT; - state->OperandA[2] = GL_SRC_ALPHA; - /* FALLTHROUGH */ - case GL_LUMINANCE: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - state->SourceRGB[2] = GL_TEXTURE; - state->SourceA[2] = GL_TEXTURE; - state->SourceRGB[0] = GL_CONSTANT; - state->OperandRGB[2] = GL_SRC_COLOR; - break; - } - break; - - case GL_ADD: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD; - mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE; - break; - - default: - _mesa_problem(NULL, - "Invalid texture env mode 0x%x in calculate_derived_texenv", - mode); - return; - } - - state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS) - ? mode_rgb : GL_REPLACE; - state->ModeA = (state->SourceA[0] != GL_PREVIOUS) - ? mode_a : GL_REPLACE; -} - - - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ActiveTextureARB(GLenum texture) -{ - const GLuint texUnit = texture - GL_TEXTURE0; - GLuint k; - GET_CURRENT_CONTEXT(ctx); - - /* See OpenGL spec for glActiveTexture: */ - k = MAX2(ctx->Const.MaxCombinedTextureImageUnits, - ctx->Const.MaxTextureCoordUnits); - - ASSERT(k <= Elements(ctx->Texture.Unit)); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= k) { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", - _mesa_lookup_enum_by_nr(texture)); - return; - } - - if (ctx->Texture.CurrentUnit == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - ctx->Texture.CurrentUnit = texUnit; - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - /* update current stack pointer */ - ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; - } -} - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ClientActiveTextureARB(GLenum texture) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint texUnit = texture - GL_TEXTURE0; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glClientActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)"); - return; - } - - if (ctx->Array.ActiveTexture == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ActiveTexture = texUnit; -} - - - -/**********************************************************************/ -/***** State management *****/ -/**********************************************************************/ - - -/** - * \note This routine refers to derived texture attribute values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT - * flags are updated by _mesa_update_textures(), below. - * - * \param ctx GL context. - */ -static void -update_texture_matrices( GLcontext *ctx ) -{ - GLuint u; - - ctx->Texture._TexMatEnabled = 0x0; - - for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - ASSERT(u < Elements(ctx->TextureMatrixStack)); - if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { - _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); - - if (ctx->Texture.Unit[u]._ReallyEnabled && - ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); - } - } -} - - -/** - * Examine texture unit's combine/env state to update derived state. - */ -static void -update_tex_combine(GLcontext *ctx, struct gl_texture_unit *texUnit) -{ - struct gl_tex_env_combine_state *combine; - - /* Set the texUnit->_CurrentCombine field to point to the user's combiner - * state, or the combiner state which is derived from traditional texenv - * mode. - */ - if (texUnit->EnvMode == GL_COMBINE || - texUnit->EnvMode == GL_COMBINE4_NV) { - texUnit->_CurrentCombine = & texUnit->Combine; - } - else { - const struct gl_texture_object *texObj = texUnit->_Current; - GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; - if (format == GL_COLOR_INDEX) { - format = GL_RGBA; /* a bit of a hack */ - } - else if (format == GL_DEPTH_COMPONENT || - format == GL_DEPTH_STENCIL_EXT) { - format = texObj->DepthMode; - } - calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format); - texUnit->_CurrentCombine = & texUnit->_EnvMode; - } - - combine = texUnit->_CurrentCombine; - - /* Determine number of source RGB terms in the combiner function */ - switch (combine->ModeRGB) { - case GL_REPLACE: - combine->_NumArgsRGB = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsRGB = 4; - else - combine->_NumArgsRGB = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - combine->_NumArgsRGB = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsRGB = 3; - break; - case GL_BUMP_ENVMAP_ATI: - /* no real arguments for this case */ - combine->_NumArgsRGB = 0; - break; - default: - combine->_NumArgsRGB = 0; - _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); - return; - } - - /* Determine number of source Alpha terms in the combiner function */ - switch (combine->ModeA) { - case GL_REPLACE: - combine->_NumArgsA = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsA = 4; - else - combine->_NumArgsA = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - combine->_NumArgsA = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsA = 3; - break; - default: - combine->_NumArgsA = 0; - _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state"); - break; - } -} - - -/** - * \note This routine refers to derived texture matrix values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT - * flags are updated by _mesa_update_texture_matrices, above. - * - * \param ctx GL context. - */ -static void -update_texture_state( GLcontext *ctx ) -{ - GLuint unit; - struct gl_fragment_program *fprog = NULL; - struct gl_vertex_program *vprog = NULL; - GLbitfield enabledFragUnits = 0x0; - - if (ctx->Shader.CurrentProgram && - ctx->Shader.CurrentProgram->LinkStatus) { - fprog = ctx->Shader.CurrentProgram->FragmentProgram; - vprog = ctx->Shader.CurrentProgram->VertexProgram; - } - else { - if (ctx->FragmentProgram._Enabled) { - fprog = ctx->FragmentProgram.Current; - } - if (ctx->VertexProgram._Enabled) { - /* XXX enable this if/when non-shader vertex programs get - * texture fetches: - vprog = ctx->VertexProgram.Current; - */ - } - } - - /* TODO: only set this if there are actual changes */ - ctx->NewState |= _NEW_TEXTURE; - - ctx->Texture._EnabledUnits = 0x0; - ctx->Texture._GenFlags = 0x0; - ctx->Texture._TexMatEnabled = 0x0; - ctx->Texture._TexGenEnabled = 0x0; - - /* - * Update texture unit state. - */ - for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLbitfield enabledVertTargets = 0x0; - GLbitfield enabledFragTargets = 0x0; - GLbitfield enabledTargets = 0x0; - GLuint texIndex; - - /* Get the bitmask of texture target enables. - * enableBits will be a mask of the TEXTURE_*_BIT flags indicating - * which texture targets are enabled (fixed function) or referenced - * by a fragment program/program. When multiple flags are set, we'll - * settle on the one with highest priority (see below). - */ - if (vprog) { - enabledVertTargets |= vprog->Base.TexturesUsed[unit]; - } - - if (fprog) { - enabledFragTargets |= fprog->Base.TexturesUsed[unit]; - } - else { - /* fixed-function fragment program */ - enabledFragTargets |= texUnit->Enabled; - } - - enabledTargets = enabledVertTargets | enabledFragTargets; - - texUnit->_ReallyEnabled = 0x0; - - if (enabledTargets == 0x0) { - /* neither vertex nor fragment processing uses this unit */ - continue; - } - - /* Look for the highest priority texture target that's enabled (or used - * by the vert/frag shaders) and "complete". That's the one we'll use - * for texturing. If we're using vert/frag program we're guaranteed - * that bitcount(enabledBits) <= 1. - * Note that the TEXTURE_x_INDEX values are in high to low priority. - */ - for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - if (enabledTargets & (1 << texIndex)) { - struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; - if (!texObj->_Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->_Complete) { - texUnit->_ReallyEnabled = 1 << texIndex; - _mesa_reference_texobj(&texUnit->_Current, texObj); - break; - } - } - } - - if (!texUnit->_ReallyEnabled) { - if (fprog) { - /* If we get here it means the shader is expecting a texture - * object, but there isn't one (or it's incomplete). Use the - * fallback texture. - */ - struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); - texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; - _mesa_reference_texobj(&texUnit->_Current, texObj); - } - else { - /* fixed-function: texture unit is really disabled */ - continue; - } - } - - /* if we get here, we know this texture unit is enabled */ - - ctx->Texture._EnabledUnits |= (1 << unit); - - if (enabledFragTargets) - enabledFragUnits |= (1 << unit); - - update_tex_combine(ctx, texUnit); - } - - - /* Determine which texture coordinate sets are actually needed */ - if (fprog) { - const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; - ctx->Texture._EnabledCoordUnits - = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; - } - else { - ctx->Texture._EnabledCoordUnits = enabledFragUnits; - } - - /* Setup texgen for those texture coordinate sets that are in use */ - for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - - texUnit->_GenFlags = 0x0; - - if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) - continue; - - if (texUnit->TexGenEnabled) { - if (texUnit->TexGenEnabled & S_BIT) { - texUnit->_GenFlags |= texUnit->GenS._ModeBit; - } - if (texUnit->TexGenEnabled & T_BIT) { - texUnit->_GenFlags |= texUnit->GenT._ModeBit; - } - if (texUnit->TexGenEnabled & R_BIT) { - texUnit->_GenFlags |= texUnit->GenR._ModeBit; - } - if (texUnit->TexGenEnabled & Q_BIT) { - texUnit->_GenFlags |= texUnit->GenQ._ModeBit; - } - - ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); - ctx->Texture._GenFlags |= texUnit->_GenFlags; - } - - ASSERT(unit < Elements(ctx->TextureMatrixStack)); - if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); - } -} - - -/** - * Update texture-related derived state. - */ -void -_mesa_update_texture( GLcontext *ctx, GLuint new_state ) -{ - if (new_state & _NEW_TEXTURE_MATRIX) - update_texture_matrices( ctx ); - - if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) - update_texture_state( ctx ); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Allocate the proxy textures for the given context. - * - * \param ctx the context to allocate proxies for. - * - * \return GL_TRUE on success, or GL_FALSE on failure - * - * If run out of memory part way through the allocations, clean up and return - * GL_FALSE. - */ -static GLboolean -alloc_proxy_textures( GLcontext *ctx ) -{ - static const GLenum targets[] = { - GL_TEXTURE_1D, - GL_TEXTURE_2D, - GL_TEXTURE_3D, - GL_TEXTURE_CUBE_MAP_ARB, - GL_TEXTURE_RECTANGLE_NV, - GL_TEXTURE_1D_ARRAY_EXT, - GL_TEXTURE_2D_ARRAY_EXT - }; - GLint tgt; - - ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - if (!(ctx->Texture.ProxyTex[tgt] - = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { - /* out of memory, free what we did allocate */ - while (--tgt >= 0) { - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - } - return GL_FALSE; - } - } - - assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ - return GL_TRUE; -} - - -/** - * Initialize a texture unit. - * - * \param ctx GL context. - * \param unit texture unit number to be initialized. - */ -static void -init_texture_unit( GLcontext *ctx, GLuint unit ) -{ - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint tex; - - texUnit->EnvMode = GL_MODULATE; - ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); - - texUnit->Combine = default_combine_state; - texUnit->_EnvMode = default_combine_state; - texUnit->_CurrentCombine = & texUnit->_EnvMode; - texUnit->BumpTarget = GL_TEXTURE0; - - texUnit->TexGenEnabled = 0x0; - texUnit->GenS.Mode = GL_EYE_LINEAR; - texUnit->GenT.Mode = GL_EYE_LINEAR; - texUnit->GenR.Mode = GL_EYE_LINEAR; - texUnit->GenQ.Mode = GL_EYE_LINEAR; - texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; - - /* Yes, these plane coefficients are correct! */ - ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - - /* no mention of this in spec, but maybe id matrix expected? */ - ASSIGN_4V( texUnit->RotMatrix, 1.0, 0.0, 0.0, 1.0 ); - - /* initialize current texture object ptrs to the shared default objects */ - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } -} - - -/** - * Initialize texture state for the given context. - */ -GLboolean -_mesa_init_texture(GLcontext *ctx) -{ - GLuint u; - - /* Texture group */ - ctx->Texture.CurrentUnit = 0; /* multitexture */ - ctx->Texture._EnabledUnits = 0x0; - ctx->Texture.SharedPalette = GL_FALSE; - _mesa_init_colortable(&ctx->Texture.Palette); - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) - init_texture_unit(ctx, u); - - /* After we're done initializing the context's texture state the default - * texture objects' refcounts should be at least - * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. - */ - assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount - >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); - - /* Allocate proxy textures */ - if (!alloc_proxy_textures( ctx )) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Free dynamically-allocted texture data attached to the given context. - */ -void -_mesa_free_texture_data(GLcontext *ctx) -{ - GLuint u, tgt; - - /* unreference current textures */ - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - /* The _Current texture could account for another reference */ - _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); - } - } - - /* Free proxy texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) - _mesa_free_colortable_data(&ctx->Texture.Unit[u].ColorTable); -} - - -/** - * Update the default texture objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_texture(GLcontext *ctx) -{ - GLuint u, tex; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file texstate.c + * + * Texture state handling. + */ + +#include "glheader.h" +#include "mfeatures.h" +#include "colormac.h" +#include "colortab.h" +#include "context.h" +#include "enums.h" +#include "macros.h" +#include "texobj.h" +#include "teximage.h" +#include "texstate.h" +#include "mtypes.h" + + + +/** + * Default texture combine environment state. This is used to initialize + * a context's texture units and as the basis for converting "classic" + * texture environmnets to ARB_texture_env_combine style values. + */ +static const struct gl_tex_env_combine_state default_combine_state = { + GL_MODULATE, GL_MODULATE, + { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, + { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, + { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_ALPHA }, + { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, + 0, 0, + 2, 2 +}; + + + +/** + * Used by glXCopyContext to copy texture state from one context to another. + */ +void +_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) +{ + GLuint u, tex; + + ASSERT(src); + ASSERT(dst); + + dst->Texture.CurrentUnit = src->Texture.CurrentUnit; + dst->Texture._GenFlags = src->Texture._GenFlags; + dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; + dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; + dst->Texture.SharedPalette = src->Texture.SharedPalette; + + /* per-unit state */ + for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) { + dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; + dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; + COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); + dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; + dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; + dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; + dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; + dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; + dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; + + /* GL_EXT_texture_env_combine */ + dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; + + /* GL_ATI_envmap_bumpmap - need this? */ + dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; + COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); + + /* + * XXX strictly speaking, we should compare texture names/ids and + * bind textures in the dest context according to id. For now, only + * copy bindings if the contexts share the same pool of textures to + * avoid refcounting bugs. + */ + if (dst->Shared == src->Shared) { + /* copy texture object bindings, not contents of texture objects */ + _mesa_lock_context_textures(dst); + + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], + src->Texture.Unit[u].CurrentTex[tex]); + } + _mesa_unlock_context_textures(dst); + } + } +} + + +/* + * For debugging + */ +void +_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ) +{ + const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; + printf("Texture Unit %d\n", unit); + printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); + printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); + printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); + printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); + printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); + printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); + printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); + printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); + printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); + printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); + printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); + printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); + printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); + printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); + printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); + printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); + printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); + printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); +} + + + +/**********************************************************************/ +/* Texture Environment */ +/**********************************************************************/ + +/** + * Convert "classic" texture environment to ARB_texture_env_combine style + * environments. + * + * \param state texture_env_combine state vector to be filled-in. + * \param mode Classic texture environment mode (i.e., \c GL_REPLACE, + * \c GL_BLEND, \c GL_DECAL, etc.). + * \param texBaseFormat Base format of the texture associated with the + * texture unit. + */ +static void +calculate_derived_texenv( struct gl_tex_env_combine_state *state, + GLenum mode, GLenum texBaseFormat ) +{ + GLenum mode_rgb; + GLenum mode_a; + + *state = default_combine_state; + + switch (texBaseFormat) { + case GL_ALPHA: + state->SourceRGB[0] = GL_PREVIOUS; + break; + + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGBA: + break; + + case GL_LUMINANCE: + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + state->SourceA[0] = GL_PREVIOUS; + break; + + default: + _mesa_problem(NULL, + "Invalid texBaseFormat 0x%x in calculate_derived_texenv", + texBaseFormat); + return; + } + + if (mode == GL_REPLACE_EXT) + mode = GL_REPLACE; + + switch (mode) { + case GL_REPLACE: + case GL_MODULATE: + mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode; + mode_a = mode; + break; + + case GL_DECAL: + mode_rgb = GL_INTERPOLATE; + mode_a = GL_REPLACE; + + state->SourceA[0] = GL_PREVIOUS; + + /* Having alpha / luminance / intensity textures replace using the + * incoming fragment color matches the definition in NV_texture_shader. + * The 1.5 spec simply marks these as "undefined". + */ + switch (texBaseFormat) { + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + state->SourceRGB[0] = GL_PREVIOUS; + break; + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + mode_rgb = GL_REPLACE; + break; + case GL_RGBA: + state->SourceRGB[2] = GL_TEXTURE; + break; + } + break; + + case GL_BLEND: + mode_rgb = GL_INTERPOLATE; + mode_a = GL_MODULATE; + + switch (texBaseFormat) { + case GL_ALPHA: + mode_rgb = GL_REPLACE; + break; + case GL_INTENSITY: + mode_a = GL_INTERPOLATE; + state->SourceA[0] = GL_CONSTANT; + state->OperandA[2] = GL_SRC_ALPHA; + /* FALLTHROUGH */ + case GL_LUMINANCE: + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + state->SourceRGB[2] = GL_TEXTURE; + state->SourceA[2] = GL_TEXTURE; + state->SourceRGB[0] = GL_CONSTANT; + state->OperandRGB[2] = GL_SRC_COLOR; + break; + } + break; + + case GL_ADD: + mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD; + mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE; + break; + + default: + _mesa_problem(NULL, + "Invalid texture env mode 0x%x in calculate_derived_texenv", + mode); + return; + } + + state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS) + ? mode_rgb : GL_REPLACE; + state->ModeA = (state->SourceA[0] != GL_PREVIOUS) + ? mode_a : GL_REPLACE; +} + + + + +/* GL_ARB_multitexture */ +void GLAPIENTRY +_mesa_ActiveTextureARB(GLenum texture) +{ + const GLuint texUnit = texture - GL_TEXTURE0; + GLuint k; + GET_CURRENT_CONTEXT(ctx); + + /* See OpenGL spec for glActiveTexture: */ + k = MAX2(ctx->Const.MaxCombinedTextureImageUnits, + ctx->Const.MaxTextureCoordUnits); + + ASSERT(k <= Elements(ctx->Texture.Unit)); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glActiveTexture %s\n", + _mesa_lookup_enum_by_nr(texture)); + + if (texUnit >= k) { + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", + _mesa_lookup_enum_by_nr(texture)); + return; + } + + if (ctx->Texture.CurrentUnit == texUnit) + return; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + ctx->Texture.CurrentUnit = texUnit; + if (ctx->Transform.MatrixMode == GL_TEXTURE) { + /* update current stack pointer */ + ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; + } +} + + +/* GL_ARB_multitexture */ +void GLAPIENTRY +_mesa_ClientActiveTextureARB(GLenum texture) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint texUnit = texture - GL_TEXTURE0; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glClientActiveTexture %s\n", + _mesa_lookup_enum_by_nr(texture)); + + if (texUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)"); + return; + } + + if (ctx->Array.ActiveTexture == texUnit) + return; + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.ActiveTexture = texUnit; +} + + + +/**********************************************************************/ +/***** State management *****/ +/**********************************************************************/ + + +/** + * \note This routine refers to derived texture attribute values to + * compute the ENABLE_TEXMAT flags, but is only called on + * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT + * flags are updated by _mesa_update_textures(), below. + * + * \param ctx GL context. + */ +static void +update_texture_matrices( struct gl_context *ctx ) +{ + GLuint u; + + ctx->Texture._TexMatEnabled = 0x0; + + for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { + ASSERT(u < Elements(ctx->TextureMatrixStack)); + if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { + _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); + + if (ctx->Texture.Unit[u]._ReallyEnabled && + ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); + } + } +} + + +/** + * Examine texture unit's combine/env state to update derived state. + */ +static void +update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) +{ + struct gl_tex_env_combine_state *combine; + + /* Set the texUnit->_CurrentCombine field to point to the user's combiner + * state, or the combiner state which is derived from traditional texenv + * mode. + */ + if (texUnit->EnvMode == GL_COMBINE || + texUnit->EnvMode == GL_COMBINE4_NV) { + texUnit->_CurrentCombine = & texUnit->Combine; + } + else { + const struct gl_texture_object *texObj = texUnit->_Current; + GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; + if (format == GL_COLOR_INDEX) { + format = GL_RGBA; /* a bit of a hack */ + } + else if (format == GL_DEPTH_COMPONENT || + format == GL_DEPTH_STENCIL_EXT) { + format = texObj->DepthMode; + } + calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format); + texUnit->_CurrentCombine = & texUnit->_EnvMode; + } + + combine = texUnit->_CurrentCombine; + + /* Determine number of source RGB terms in the combiner function */ + switch (combine->ModeRGB) { + case GL_REPLACE: + combine->_NumArgsRGB = 1; + break; + case GL_ADD: + case GL_ADD_SIGNED: + if (texUnit->EnvMode == GL_COMBINE4_NV) + combine->_NumArgsRGB = 4; + else + combine->_NumArgsRGB = 2; + break; + case GL_MODULATE: + case GL_SUBTRACT: + case GL_DOT3_RGB: + case GL_DOT3_RGBA: + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + combine->_NumArgsRGB = 2; + break; + case GL_INTERPOLATE: + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + combine->_NumArgsRGB = 3; + break; + case GL_BUMP_ENVMAP_ATI: + /* no real arguments for this case */ + combine->_NumArgsRGB = 0; + break; + default: + combine->_NumArgsRGB = 0; + _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); + return; + } + + /* Determine number of source Alpha terms in the combiner function */ + switch (combine->ModeA) { + case GL_REPLACE: + combine->_NumArgsA = 1; + break; + case GL_ADD: + case GL_ADD_SIGNED: + if (texUnit->EnvMode == GL_COMBINE4_NV) + combine->_NumArgsA = 4; + else + combine->_NumArgsA = 2; + break; + case GL_MODULATE: + case GL_SUBTRACT: + combine->_NumArgsA = 2; + break; + case GL_INTERPOLATE: + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + combine->_NumArgsA = 3; + break; + default: + combine->_NumArgsA = 0; + _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state"); + break; + } +} + + +/** + * \note This routine refers to derived texture matrix values to + * compute the ENABLE_TEXMAT flags, but is only called on + * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT + * flags are updated by _mesa_update_texture_matrices, above. + * + * \param ctx GL context. + */ +static void +update_texture_state( struct gl_context *ctx ) +{ + GLuint unit; + struct gl_fragment_program *fprog = NULL; + struct gl_vertex_program *vprog = NULL; + GLbitfield enabledFragUnits = 0x0; + + if (ctx->Shader.CurrentVertexProgram && + ctx->Shader.CurrentVertexProgram->LinkStatus) { + vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + } else if (ctx->VertexProgram._Enabled) { + /* XXX enable this if/when non-shader vertex programs get + * texture fetches: + vprog = ctx->VertexProgram.Current; + */ + } + + if (ctx->Shader.CurrentFragmentProgram && + ctx->Shader.CurrentFragmentProgram->LinkStatus) { + fprog = ctx->Shader.CurrentFragmentProgram->FragmentProgram; + } + else if (ctx->FragmentProgram._Enabled) { + fprog = ctx->FragmentProgram.Current; + } + + /* FINISHME: Geometry shader texture accesses should also be considered + * FINISHME: here. + */ + + /* TODO: only set this if there are actual changes */ + ctx->NewState |= _NEW_TEXTURE; + + ctx->Texture._EnabledUnits = 0x0; + ctx->Texture._GenFlags = 0x0; + ctx->Texture._TexMatEnabled = 0x0; + ctx->Texture._TexGenEnabled = 0x0; + + /* + * Update texture unit state. + */ + for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + GLbitfield enabledVertTargets = 0x0; + GLbitfield enabledFragTargets = 0x0; + GLbitfield enabledTargets = 0x0; + GLuint texIndex; + + /* Get the bitmask of texture target enables. + * enableBits will be a mask of the TEXTURE_*_BIT flags indicating + * which texture targets are enabled (fixed function) or referenced + * by a fragment program/program. When multiple flags are set, we'll + * settle on the one with highest priority (see below). + */ + if (vprog) { + enabledVertTargets |= vprog->Base.TexturesUsed[unit]; + } + + if (fprog) { + enabledFragTargets |= fprog->Base.TexturesUsed[unit]; + } + else { + /* fixed-function fragment program */ + enabledFragTargets |= texUnit->Enabled; + } + + enabledTargets = enabledVertTargets | enabledFragTargets; + + texUnit->_ReallyEnabled = 0x0; + + if (enabledTargets == 0x0) { + /* neither vertex nor fragment processing uses this unit */ + continue; + } + + /* Look for the highest priority texture target that's enabled (or used + * by the vert/frag shaders) and "complete". That's the one we'll use + * for texturing. If we're using vert/frag program we're guaranteed + * that bitcount(enabledBits) <= 1. + * Note that the TEXTURE_x_INDEX values are in high to low priority. + */ + for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { + if (enabledTargets & (1 << texIndex)) { + struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; + if (!texObj->_Complete) { + _mesa_test_texobj_completeness(ctx, texObj); + } + if (texObj->_Complete) { + texUnit->_ReallyEnabled = 1 << texIndex; + _mesa_reference_texobj(&texUnit->_Current, texObj); + break; + } + } + } + + if (!texUnit->_ReallyEnabled) { + if (fprog) { + /* If we get here it means the shader is expecting a texture + * object, but there isn't one (or it's incomplete). Use the + * fallback texture. + */ + struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); + texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; + _mesa_reference_texobj(&texUnit->_Current, texObj); + } + else { + /* fixed-function: texture unit is really disabled */ + continue; + } + } + + /* if we get here, we know this texture unit is enabled */ + + ctx->Texture._EnabledUnits |= (1 << unit); + + if (enabledFragTargets) + enabledFragUnits |= (1 << unit); + + update_tex_combine(ctx, texUnit); + } + + + /* Determine which texture coordinate sets are actually needed */ + if (fprog) { + const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; + ctx->Texture._EnabledCoordUnits + = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; + } + else { + ctx->Texture._EnabledCoordUnits = enabledFragUnits; + } + + /* Setup texgen for those texture coordinate sets that are in use */ + for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + + texUnit->_GenFlags = 0x0; + + if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) + continue; + + if (texUnit->TexGenEnabled) { + if (texUnit->TexGenEnabled & S_BIT) { + texUnit->_GenFlags |= texUnit->GenS._ModeBit; + } + if (texUnit->TexGenEnabled & T_BIT) { + texUnit->_GenFlags |= texUnit->GenT._ModeBit; + } + if (texUnit->TexGenEnabled & R_BIT) { + texUnit->_GenFlags |= texUnit->GenR._ModeBit; + } + if (texUnit->TexGenEnabled & Q_BIT) { + texUnit->_GenFlags |= texUnit->GenQ._ModeBit; + } + + ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); + ctx->Texture._GenFlags |= texUnit->_GenFlags; + } + + ASSERT(unit < Elements(ctx->TextureMatrixStack)); + if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); + } +} + + +/** + * Update texture-related derived state. + */ +void +_mesa_update_texture( struct gl_context *ctx, GLuint new_state ) +{ + if (new_state & _NEW_TEXTURE_MATRIX) + update_texture_matrices( ctx ); + + if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) + update_texture_state( ctx ); +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +/** + * Allocate the proxy textures for the given context. + * + * \param ctx the context to allocate proxies for. + * + * \return GL_TRUE on success, or GL_FALSE on failure + * + * If run out of memory part way through the allocations, clean up and return + * GL_FALSE. + */ +static GLboolean +alloc_proxy_textures( struct gl_context *ctx ) +{ + static const GLenum targets[] = { + GL_TEXTURE_1D, + GL_TEXTURE_2D, + GL_TEXTURE_3D, + GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_1D_ARRAY_EXT, + GL_TEXTURE_2D_ARRAY_EXT + }; + GLint tgt; + + ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + if (!(ctx->Texture.ProxyTex[tgt] + = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { + /* out of memory, free what we did allocate */ + while (--tgt >= 0) { + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); + } + return GL_FALSE; + } + } + + assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ + return GL_TRUE; +} + + +/** + * Initialize a texture unit. + * + * \param ctx GL context. + * \param unit texture unit number to be initialized. + */ +static void +init_texture_unit( struct gl_context *ctx, GLuint unit ) +{ + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + GLuint tex; + + texUnit->EnvMode = GL_MODULATE; + ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); + + texUnit->Combine = default_combine_state; + texUnit->_EnvMode = default_combine_state; + texUnit->_CurrentCombine = & texUnit->_EnvMode; + texUnit->BumpTarget = GL_TEXTURE0; + + texUnit->TexGenEnabled = 0x0; + texUnit->GenS.Mode = GL_EYE_LINEAR; + texUnit->GenT.Mode = GL_EYE_LINEAR; + texUnit->GenR.Mode = GL_EYE_LINEAR; + texUnit->GenQ.Mode = GL_EYE_LINEAR; + texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; + + /* Yes, these plane coefficients are correct! */ + ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); + + /* no mention of this in spec, but maybe id matrix expected? */ + ASSIGN_4V( texUnit->RotMatrix, 1.0, 0.0, 0.0, 1.0 ); + + /* initialize current texture object ptrs to the shared default objects */ + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texUnit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + } +} + + +/** + * Initialize texture state for the given context. + */ +GLboolean +_mesa_init_texture(struct gl_context *ctx) +{ + GLuint u; + + /* Texture group */ + ctx->Texture.CurrentUnit = 0; /* multitexture */ + ctx->Texture._EnabledUnits = 0x0; + ctx->Texture.SharedPalette = GL_FALSE; + _mesa_init_colortable(&ctx->Texture.Palette); + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) + init_texture_unit(ctx, u); + + /* After we're done initializing the context's texture state the default + * texture objects' refcounts should be at least + * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. + */ + assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount + >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); + + /* Allocate proxy textures */ + if (!alloc_proxy_textures( ctx )) + return GL_FALSE; + + return GL_TRUE; +} + + +/** + * Free dynamically-allocted texture data attached to the given context. + */ +void +_mesa_free_texture_data(struct gl_context *ctx) +{ + GLuint u, tgt; + + /* unreference current textures */ + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + /* The _Current texture could account for another reference */ + _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); + + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); + } + } + + /* Free proxy texture objects */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) + _mesa_free_colortable_data(&ctx->Texture.Unit[u].ColorTable); +} + + +/** + * Update the default texture objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_texture(struct gl_context *ctx) +{ + GLuint u, tex; + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texUnit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + } + } +} diff --git a/mesalib/src/mesa/main/texstate.h b/mesalib/src/mesa/main/texstate.h index 912cb6779..1258a0705 100644 --- a/mesalib/src/mesa/main/texstate.h +++ b/mesalib/src/mesa/main/texstate.h @@ -1,92 +1,92 @@ -/** - * \file texstate.h - * Texture state management. - */ - -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef TEXSTATE_H -#define TEXSTATE_H - - -#include "compiler.h" -#include "mtypes.h" - - -/** - * Return pointer to current texture unit. - * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). - */ -static INLINE struct gl_texture_unit * -_mesa_get_current_tex_unit(GLcontext *ctx) -{ - ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->Texture.Unit)); - return &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]); -} - - -extern void -_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ); - -extern void -_mesa_print_texunit_state( GLcontext *ctx, GLuint unit ); - - - -/** - * \name Called from API - */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_ActiveTextureARB( GLenum target ); - -extern void GLAPIENTRY -_mesa_ClientActiveTextureARB( GLenum target ); - -/*@}*/ - - -/** - * \name Initialization, state maintenance - */ -/*@{*/ - -extern void -_mesa_update_texture( GLcontext *ctx, GLuint new_state ); - -extern GLboolean -_mesa_init_texture( GLcontext *ctx ); - -extern void -_mesa_free_texture_data( GLcontext *ctx ); - -extern void -_mesa_update_default_objects_texture(GLcontext *ctx); - -/*@}*/ - -#endif +/** + * \file texstate.h + * Texture state management. + */ + +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef TEXSTATE_H +#define TEXSTATE_H + + +#include "compiler.h" +#include "mtypes.h" + + +/** + * Return pointer to current texture unit. + * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). + */ +static INLINE struct gl_texture_unit * +_mesa_get_current_tex_unit(struct gl_context *ctx) +{ + ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->Texture.Unit)); + return &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]); +} + + +extern void +_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ); + +extern void +_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ); + + + +/** + * \name Called from API + */ +/*@{*/ + +extern void GLAPIENTRY +_mesa_ActiveTextureARB( GLenum target ); + +extern void GLAPIENTRY +_mesa_ClientActiveTextureARB( GLenum target ); + +/*@}*/ + + +/** + * \name Initialization, state maintenance + */ +/*@{*/ + +extern void +_mesa_update_texture( struct gl_context *ctx, GLuint new_state ); + +extern GLboolean +_mesa_init_texture( struct gl_context *ctx ); + +extern void +_mesa_free_texture_data( struct gl_context *ctx ); + +extern void +_mesa_update_default_objects_texture(struct gl_context *ctx); + +/*@}*/ + +#endif diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 2989fdb72..8759c33ae 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -1,4536 +1,4775 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - -/** - * The GL texture image functions in teximage.c basically just do - * error checking and data structure allocation. They in turn call - * device driver functions which actually copy/convert/store the user's - * texture image data. - * - * However, most device drivers will be able to use the fallback functions - * in this file. That is, most drivers will have the following bit of - * code: - * ctx->Driver.TexImage1D = _mesa_store_teximage1d; - * ctx->Driver.TexImage2D = _mesa_store_teximage2d; - * ctx->Driver.TexImage3D = _mesa_store_teximage3d; - * etc... - * - * Texture image processing is actually kind of complicated. We have to do: - * Format/type conversions - * pixel unpacking - * pixel transfer (scale, bais, lookup, convolution!, etc) - * - * These functions can handle most everything, including processing full - * images and sub-images. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "convolve.h" -#include "image.h" -#include "macros.h" -#include "mipmap.h" -#include "imports.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_s3tc.h" -#include "teximage.h" -#include "texstore.h" -#include "enums.h" - - -enum { - ZERO = 4, - ONE = 5 -}; - - -/** - * Texture image storage function. - */ -typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); - - -/** - * Return GL_TRUE if the given image format is one that be converted - * to another format by swizzling. - */ -static GLboolean -can_swizzle(GLenum logicalBaseFormat) -{ - switch (logicalBaseFormat) { - case GL_RGBA: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_BGR: - case GL_BGRA: - case GL_ABGR_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - - -enum { - IDX_LUMINANCE = 0, - IDX_ALPHA, - IDX_INTENSITY, - IDX_LUMINANCE_ALPHA, - IDX_RGB, - IDX_RGBA, - IDX_RED, - IDX_GREEN, - IDX_BLUE, - IDX_BGR, - IDX_BGRA, - IDX_ABGR, - MAX_IDX -}; - -#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) -#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) -#define MAP3(x,y,z) MAP4(x, y, z, ZERO) -#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } - - -static const struct { - GLubyte format_idx; - GLubyte to_rgba[6]; - GLubyte from_rgba[6]; -} mappings[MAX_IDX] = -{ - { - IDX_LUMINANCE, - MAP4(0,0,0,ONE), - MAP1(0) - }, - - { - IDX_ALPHA, - MAP4(ZERO, ZERO, ZERO, 0), - MAP1(3) - }, - - { - IDX_INTENSITY, - MAP4(0, 0, 0, 0), - MAP1(0), - }, - - { - IDX_LUMINANCE_ALPHA, - MAP4(0,0,0,1), - MAP2(0,3) - }, - - { - IDX_RGB, - MAP4(0,1,2,ONE), - MAP3(0,1,2) - }, - - { - IDX_RGBA, - MAP4(0,1,2,3), - MAP4(0,1,2,3), - }, - - - { - IDX_RED, - MAP4(0, ZERO, ZERO, ONE), - MAP1(0), - }, - - { - IDX_GREEN, - MAP4(ZERO, 0, ZERO, ONE), - MAP1(1), - }, - - { - IDX_BLUE, - MAP4(ZERO, ZERO, 0, ONE), - MAP1(2), - }, - - { - IDX_BGR, - MAP4(2,1,0,ONE), - MAP3(2,1,0) - }, - - { - IDX_BGRA, - MAP4(2,1,0,3), - MAP4(2,1,0,3) - }, - - { - IDX_ABGR, - MAP4(3,2,1,0), - MAP4(3,2,1,0) - }, -}; - - - -/** - * Convert a GL image format enum to an IDX_* value (see above). - */ -static int -get_map_idx(GLenum value) -{ - switch (value) { - case GL_LUMINANCE: return IDX_LUMINANCE; - case GL_ALPHA: return IDX_ALPHA; - case GL_INTENSITY: return IDX_INTENSITY; - case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; - case GL_RGB: return IDX_RGB; - case GL_RGBA: return IDX_RGBA; - case GL_RED: return IDX_RED; - case GL_GREEN: return IDX_GREEN; - case GL_BLUE: return IDX_BLUE; - case GL_BGR: return IDX_BGR; - case GL_BGRA: return IDX_BGRA; - case GL_ABGR_EXT: return IDX_ABGR; - default: - _mesa_problem(NULL, "Unexpected inFormat"); - return 0; - } -} - - -/** - * When promoting texture formats (see below) we need to compute the - * mapping of dest components back to source components. - * This function does that. - * \param inFormat the incoming format of the texture - * \param outFormat the final texture format - * \return map[6] a full 6-component map - */ -static void -compute_component_mapping(GLenum inFormat, GLenum outFormat, - GLubyte *map) -{ - const int inFmt = get_map_idx(inFormat); - const int outFmt = get_map_idx(outFormat); - const GLubyte *in2rgba = mappings[inFmt].to_rgba; - const GLubyte *rgba2out = mappings[outFmt].from_rgba; - int i; - - for (i = 0; i < 4; i++) - map[i] = in2rgba[rgba2out[i]]; - - map[ZERO] = ZERO; - map[ONE] = ONE; - -#if 0 - printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", - inFormat, _mesa_lookup_enum_by_nr(inFormat), - outFormat, _mesa_lookup_enum_by_nr(outFormat), - map[0], - map[1], - map[2], - map[3], - map[4], - map[5]); -#endif -} - - -/** - * Make a temporary (color) texture image with GLfloat components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLfloat. - */ -static GLfloat * -make_temp_float_image(GLcontext *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint transferOps = ctx->_ImageTransferState; - GLfloat *tempImage; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY || - logicalBaseFormat == GL_COLOR_INDEX || - logicalBaseFormat == GL_DEPTH_COMPONENT); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY || - textureBaseFormat == GL_COLOR_INDEX || - textureBaseFormat == GL_DEPTH_COMPONENT); - - /* conventional color image */ - - if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) || - (dims >= 2 && ctx->Pixel.Convolution2DEnabled) || - (dims >= 2 && ctx->Pixel.Separable2DEnabled)) { - /* need image convolution */ - const GLuint preConvTransferOps - = (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT; - const GLuint postConvTransferOps - = (transferOps & IMAGE_POST_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT; - GLint img, row; - GLint convWidth = srcWidth, convHeight = srcHeight; - GLfloat *convImage; - - /* pre-convolution image buffer (3D) */ - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * 4 * sizeof(GLfloat)); - if (!tempImage) - return NULL; - - /* post-convolution image buffer (2D) */ - convImage = (GLfloat *) malloc(srcWidth * srcHeight - * 4 * sizeof(GLfloat)); - if (!convImage) { - free(tempImage); - return NULL; - } - - /* loop over 3D image slices */ - for (img = 0; img < srcDepth; img++) { - GLfloat *dst = tempImage + img * (srcWidth * srcHeight * 4); - - /* unpack and do transfer ops up to convolution */ - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, - srcFormat, srcType, img, row, 0); - _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst, - srcFormat, srcType, src, - srcPacking, - preConvTransferOps); - dst += srcWidth * 4; - } - - /* size after optional convolution */ - convWidth = srcWidth; - convHeight = srcHeight; - -#if FEATURE_convolve - /* do convolution */ - { - GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4); - if (dims == 1) { - ASSERT(ctx->Pixel.Convolution1DEnabled); - _mesa_convolve_1d_image(ctx, &convWidth, src, convImage); - } - else { - if (ctx->Pixel.Convolution2DEnabled) { - _mesa_convolve_2d_image(ctx, &convWidth, &convHeight, - src, convImage); - } - else { - ASSERT(ctx->Pixel.Separable2DEnabled); - _mesa_convolve_sep_image(ctx, &convWidth, &convHeight, - src, convImage); - } - } - } -#endif - /* do post-convolution transfer and pack into tempImage */ - { - const GLint logComponents - = _mesa_components_in_format(logicalBaseFormat); - const GLfloat *src = convImage; - GLfloat *dst = tempImage + img * (convWidth * convHeight * 4); - for (row = 0; row < convHeight; row++) { - _mesa_pack_rgba_span_float(ctx, convWidth, - (GLfloat (*)[4]) src, - logicalBaseFormat, GL_FLOAT, - dst, &ctx->DefaultPacking, - postConvTransferOps); - src += convWidth * 4; - dst += convWidth * logComponents; - } - } - } /* loop over 3D image slices */ - - free(convImage); - - /* might need these below */ - srcWidth = convWidth; - srcHeight = convHeight; - } - else { - /* no convolution */ - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLfloat *dst; - GLint img, row; - - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLfloat)); - if (!tempImage) - return NULL; - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking, transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* more work */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLfloat *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLfloat)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0.0F; - else if (j == ONE) - newImage[i * texComponents + k] = 1.0F; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Make a temporary (color) texture image with GLchan components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLchan. - */ -GLchan * -_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint transferOps = ctx->_ImageTransferState; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - GLboolean freeSrcImage = GL_FALSE; - GLint img, row; - GLchan *tempImage, *dst; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY); - -#if FEATURE_convolve - if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) || - (dims >= 2 && ctx->Pixel.Convolution2DEnabled) || - (dims >= 2 && ctx->Pixel.Separable2DEnabled)) { - /* get convolved image */ - GLfloat *convImage = make_temp_float_image(ctx, dims, - logicalBaseFormat, - logicalBaseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - if (!convImage) - return NULL; - /* the convolved image is our new source image */ - srcAddr = convImage; - srcFormat = logicalBaseFormat; - srcType = GL_FLOAT; - srcPacking = &ctx->DefaultPacking; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - transferOps = 0; - freeSrcImage = GL_TRUE; - } -#endif - - /* unpack and transfer the source image */ - tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLchan)); - if (!tempImage) { - if (freeSrcImage) { - free((void *) srcAddr); - } - return NULL; - } - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = - (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, - srcFormat, srcType, src, srcPacking, - transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - - /* If we made a temporary image for convolution, free it here */ - if (freeSrcImage) { - free((void *) srcAddr); - } - - if (logicalBaseFormat != textureBaseFormat) { - /* one more conversion step */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLchan *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLchan)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0; - else if (j == ONE) - newImage[i * texComponents + k] = CHAN_MAX; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Copy GLubyte pixels from to with swizzling. - * \param dst destination pixels - * \param dstComponents number of color components in destination pixels - * \param src source pixels - * \param srcComponents number of color components in source pixels - * \param map the swizzle mapping. map[X] says where to find the X component - * in the source image's pixels. For example, if the source image - * is GL_BGRA and X = red, map[0] yields 2. - * \param count number of pixels to copy/swizzle. - */ -static void -swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, - GLuint srcComponents, const GLubyte *map, GLuint count) -{ -#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ - do { \ - GLuint i; \ - for (i = 0; i < count; i++) { \ - GLuint j; \ - if (srcComps == 4) { \ - COPY_4UBV(tmp, src); \ - } \ - else { \ - for (j = 0; j < srcComps; j++) { \ - tmp[j] = src[j]; \ - } \ - } \ - src += srcComps; \ - for (j = 0; j < dstComps; j++) { \ - dst[j] = tmp[map[j]]; \ - } \ - dst += dstComps; \ - } \ - } while (0) - - GLubyte tmp[6]; - - tmp[ZERO] = 0x0; - tmp[ONE] = 0xff; - - ASSERT(srcComponents <= 4); - ASSERT(dstComponents <= 4); - - switch (dstComponents) { - case 4: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 4, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 4, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 4, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 4, 1); - break; - default: - ; - } - break; - case 3: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 3, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 3, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 3, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 3, 1); - break; - default: - ; - } - break; - case 2: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 2, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 2, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 2, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 2, 1); - break; - default: - ; - } - break; - case 1: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 1, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 1, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 1, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 1, 1); - break; - default: - ; - } - break; - default: - ; - } -#undef SWZ_CPY -} - - - -static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; -static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; - -/* Deal with the _REV input types: - */ -static const GLubyte * -type_mapping( GLenum srcType ) -{ - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - return _mesa_little_endian() ? map_3210 : map_identity; - case GL_UNSIGNED_INT_8_8_8_8_REV: - return _mesa_little_endian() ? map_identity : map_3210; - default: - return NULL; - } -} - -/* Mapping required if input type is - */ -static const GLubyte * -byteswap_mapping( GLboolean swapBytes, - GLenum srcType ) -{ - if (!swapBytes) - return map_identity; - - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - return map_3210; - default: - return NULL; - } -} - - - -/** - * Transfer a GLubyte texture image with component swizzling. - */ -static void -_mesa_swizzle_ubyte_image(GLcontext *ctx, - GLuint dimensions, - GLenum srcFormat, - GLenum srcType, - - GLenum baseInternalFormat, - - const GLubyte *rgba2dst, - GLuint dstComponents, - - GLvoid *dstAddr, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, - const GLuint *dstImageOffsets, - - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLint srcComponents = _mesa_components_in_format(srcFormat); - const GLubyte *srctype2ubyte, *swap; - GLubyte map[4], src2base[6], base2rgba[6]; - GLint i; - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, GL_UNSIGNED_BYTE); - const GLint srcImageStride - = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE); - const GLubyte *srcImage - = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE, 0, 0, 0); - - (void) ctx; - - /* Translate from src->baseInternal->GL_RGBA->dst. This will - * correctly deal with RGBA->RGB->RGBA conversions where the final - * A value must be 0xff regardless of the incoming alpha values. - */ - compute_component_mapping(srcFormat, baseInternalFormat, src2base); - compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); - swap = byteswap_mapping(srcPacking->SwapBytes, srcType); - srctype2ubyte = type_mapping(srcType); - - - for (i = 0; i < 4; i++) - map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; - -/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ - - if (srcComponents == dstComponents && - srcRowStride == dstRowStride && - srcRowStride == srcWidth * srcComponents && - dimensions < 3) { - /* 1 and 2D images only */ - GLubyte *dstImage = (GLubyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; - swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, - srcWidth * srcHeight); - } - else { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * dstComponents - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; - for (row = 0; row < srcHeight; row++) { - swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } - } -} - - -/** - * Teximage storage routine for when a simple memcpy will do. - * No pixel transfer operations or special texel encodings allowed. - * 1D, 2D and 3D images supported. - */ -static void -memcpy_texture(GLcontext *ctx, - GLuint dimensions, - gl_format dstFormat, - GLvoid *dstAddr, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, - const GLuint *dstImageOffsets, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - const GLint srcImageStride = _mesa_image_image_stride(srcPacking, - srcWidth, srcHeight, srcFormat, srcType); - const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, - srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLint bytesPerRow = srcWidth * texelBytes; - -#if 0 - /* XXX update/re-enable for dstImageOffsets array */ - const GLint bytesPerImage = srcHeight * bytesPerRow; - const GLint bytesPerTexture = srcDepth * bytesPerImage; - GLubyte *dstImage = (GLubyte *) dstAddr - + dstZoffset * dstImageStride - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - - if (dstRowStride == srcRowStride && - dstRowStride == bytesPerRow && - ((dstImageStride == srcImageStride && - dstImageStride == bytesPerImage) || - (srcDepth == 1))) { - /* one big memcpy */ - ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture); - } - else - { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstImage; - for (row = 0; row < srcHeight; row++) { - ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - dstImage += dstImageStride; - } - } -#endif - - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } -} - - - -/** - * Store a 32-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z32(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z32); - ASSERT(texelBytes == sizeof(GLuint)); - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_UNSIGNED_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, (GLuint *) dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_x8_z24(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_X8_Z24); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, (GLuint *) dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z24_x8(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z24_X8); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLuint *dst = (GLuint *) dstRow; - GLint i; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, dst, - depthScale, srcType, src, srcPacking); - for (i = 0; i < srcWidth; i++) - dst[i] <<= 8; - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 16-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z16(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z16); - ASSERT(texelBytes == sizeof(GLushort)); - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLushort *dst16 = (GLushort *) dstRow; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_SHORT, dst16, depthScale, - srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store an rgb565 or rgb565_rev texture image. - */ -static GLboolean -_mesa_texstore_rgb565(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB565 || - dstFormat == MESA_FORMAT_RGB565_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGB565 && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_SHORT_5_6_5) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - dims == 2) { - /* do optimized tex store */ - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = (const GLubyte *) - _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - GLubyte *dst = (GLubyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - GLint row, col; - for (row = 0; row < srcHeight; row++) { - const GLubyte *srcUB = (const GLubyte *) src; - GLushort *dstUS = (GLushort *) dst; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - dst += dstRowStride; - src += srcRowStride; - } - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. - */ -static GLboolean -_mesa_texstore_rgba8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBA8888_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA8888 && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA8888_REV && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) || - (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) { - dstmap[3] = 0; - dstmap[2] = 1; - dstmap[1] = 2; - dstmap[0] = 3; - } - else { - dstmap[3] = 3; - dstmap[2] = 2; - dstmap[1] = 1; - dstmap[0] = 0; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_RGBA8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = GL_RGBA; - - ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888 || - dstFormat == MESA_FORMAT_XRGB8888_REV ); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { - /* simple memcpy path (little endian) */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888_REV) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8)) { - /* simple memcpy path (big endian) */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - srcFormat == GL_RGB && - (baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB) && - srcType == GL_UNSIGNED_BYTE) { - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(0xff, - srcRow[col * 3 + RCOMP], - srcRow[col * 3 + GCOMP], - srcRow[col * 3 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB8888 && - srcFormat == GL_RGBA && - baseInternalFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* same as above case, but src data has alpha too */ - GLint img, row, col; - /* For some reason, streaming copies to write-combined regions - * are extremely sensitive to the characteristics of how the - * source data is retrieved. By reordering the source reads to - * be in-order, the speed of this operation increases by half. - * Strangely the same isn't required for the RGB path, above. - */ - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], - srcRow[col * 4 + RCOMP], - srcRow[col * 4 + GCOMP], - srcRow[col * 4 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { - dstmap[3] = 3; /* alpha */ - dstmap[2] = 0; /* red */ - dstmap[1] = 1; /* green */ - dstmap[0] = 2; /* blue */ - } - else { - assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); - dstmap[3] = 2; - dstmap[2] = 1; - dstmap[1] = 0; - dstmap[0] = 3; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else if (dstFormat == MESA_FORMAT_XRGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( 0xff, - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB888); - ASSERT(texelBytes == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_BGR && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract RGB from RGBA */ - GLint img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 2; - dstmap[1] = 1; - dstmap[2] = 0; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = (const GLchan *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { -#if 0 - if (littleEndian) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcUB[BCOMP]; - dstRow[col * 3 + 1] = srcUB[GCOMP]; - dstRow[col * 3 + 2] = srcUB[RCOMP]; - srcUB += 3; - } - } -#else - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]); - src += 3; - } -#endif - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_bgr888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_BGR888); - ASSERT(texelBytes == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract BGR from RGBA */ - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 0; - dstmap[1] = 1; - dstmap[2] = 2; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = (const GLchan *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb4444(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || - dstFormat == MESA_FORMAT_ARGB4444_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB4444 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB4444) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_rgba5551(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA5551); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA5551 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT_5_5_5_1) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_argb1555(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || - dstFormat == MESA_FORMAT_ARGB1555_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB1555 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB1555) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_al88(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL88 || - dstFormat == MESA_FORMAT_AL88_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_AL88 && - baseInternalFormat == GL_LUMINANCE_ALPHA && - srcFormat == GL_LUMINANCE_ALPHA && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - littleEndian && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || - (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 2, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_AL88) { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]), - CHAN_TO_UBYTE(src[0]) ); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]), - CHAN_TO_UBYTE(src[0]) ); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_al1616(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL1616 || - dstFormat == MESA_FORMAT_AL1616_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_AL1616 && - baseInternalFormat == GL_LUMINANCE_ALPHA && - srcFormat == GL_LUMINANCE_ALPHA && - srcType == GL_UNSIGNED_SHORT && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_AL1616) { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616(a, l); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616_REV(a, l); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgba_16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_16); - ASSERT(texelBytes == 8); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r, g, b, a; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); - UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); - dstUS[col*4+0] = r; - dstUS[col*4+1] = g; - dstUS[col*4+2] = b; - dstUS[col*4+3] = a; - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || - dstFormat == MESA_FORMAT_SIGNED_RG_16 || - dstFormat == MESA_FORMAT_SIGNED_RGB_16 || - dstFormat == MESA_FORMAT_SIGNED_RGBA_16); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && - srcFormat == GL_RGBA && - srcType == GL_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; - GLint img, row, col; - - if (!tempImage) - return GL_FALSE; - - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - - /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, - * 3 or 4 components/pixel here. - */ - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLshort *dstRowS = (GLshort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLuint c; - for (c = 0; c < comps; c++) { - GLshort p; - UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); - dstRowS[col * comps + c] = p; - } - } - dstRow += dstRowStride; - src += 4 * srcWidth; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb332(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB332); - ASSERT(texelBytes == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. - */ -static GLboolean -_mesa_texstore_a8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_A8 || - dstFormat == MESA_FORMAT_L8 || - dstFormat == MESA_FORMAT_I8); - ASSERT(texelBytes == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (dstFormat == MESA_FORMAT_A8) { - dstmap[0] = 3; - } - else { - dstmap[0] = 0; - } - dstmap[1] = ZERO; /* ? */ - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 1, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = CHAN_TO_UBYTE(src[col]); - } - dstRow += dstRowStride; - src += srcWidth; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - - -static GLboolean -_mesa_texstore_ci8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - (void) dims; (void) baseInternalFormat; - ASSERT(dstFormat == MESA_FORMAT_CI8); - ASSERT(texelBytes == 1); - ASSERT(baseInternalFormat == GL_COLOR_INDEX); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_COLOR_INDEX && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, - srcType, src, srcPacking, - ctx->_ImageTransferState); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. - */ -static GLboolean -_mesa_texstore_ycbcr(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - (void) ctx; (void) dims; (void) baseInternalFormat; - - ASSERT((dstFormat == MESA_FORMAT_YCBCR) || - (dstFormat == MESA_FORMAT_YCBCR_REV)); - ASSERT(texelBytes == 2); - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - ASSERT(srcFormat == GL_YCBCR_MESA); - ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); - ASSERT(baseInternalFormat == GL_YCBCR_MESA); - - /* always just memcpy since no pixel transfer ops apply */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - - /* Check if we need byte swapping */ - /* XXX the logic here _might_ be wrong */ - if (srcPacking->SwapBytes ^ - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ - (dstFormat == MESA_FORMAT_YCBCR_REV) ^ - !littleEndian) { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - _mesa_swap2((GLushort *) dstRow, srcWidth); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_dudv8(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_DUDV8); - ASSERT(texelBytes == 2); - ASSERT(ctx->Extensions.ATI_envmap_bumpmap); - ASSERT((srcFormat == GL_DU8DV8_ATI) || - (srcFormat == GL_DUDV_ATI)); - ASSERT(baseInternalFormat == GL_DUDV_ATI); - - if (!srcPacking->SwapBytes && srcType == GL_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (srcType == GL_BYTE) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (littleEndian) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - GL_LUMINANCE_ALPHA, /* hack */ - GL_UNSIGNED_BYTE, /* hack */ - GL_LUMINANCE_ALPHA, /* hack */ - dstmap, 2, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path - note this is defined for 2d textures only */ - const GLint components = _mesa_components_in_format(baseInternalFormat); - const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - GLbyte *tempImage, *dst, *src; - GLint row; - - tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLbyte)); - if (!tempImage) - return GL_FALSE; - - src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - 0, 0, 0); - - dst = tempImage; - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, - dst, srcFormat, srcType, src, - srcPacking, 0); - dst += srcWidth * components; - src += srcStride; - } - - src = tempImage; - dst = (GLbyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - memcpy(dst, src, srcWidth * texelBytes); - dst += dstRowStride; - src += srcWidth * texelBytes; - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_R8 format. - */ -static GLboolean -_mesa_texstore_signed_r8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8); - ASSERT(texelBytes == 1); - - /* XXX look at adding optimized paths */ - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstB = (GLubyte *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RG88 format. - */ -static GLboolean -_mesa_texstore_signed_rg88(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88); - ASSERT(texelBytes == 1); - - /* XXX look at adding optimized paths */ - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP])); - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. - */ -static GLboolean -_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); - ASSERT(texelBytes == 4); - - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - 0xff ); - srcRow += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or MESA_FORMAT_SIGNED_RGBA8888_REV - */ -static GLboolean -_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || - dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_SIGNED_RGBA8888 && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - (srcType == GL_BYTE) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) || - (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) { - dstmap[3] = 0; - dstmap[2] = 1; - dstmap[1] = 2; - dstmap[0] = 3; - } - else { - dstmap[3] = 3; - dstmap[2] = 2; - dstmap[1] = 1; - dstmap[0] = 0; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); - srcRow += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); - srcRow += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a combined depth/stencil texture image. - */ -static GLboolean -_mesa_texstore_z24_s8(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - ASSERT(dstFormat == MESA_FORMAT_Z24_S8); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); - - /* In case we only upload depth we need to preserve the stencil */ - if (srcFormat == GL_DEPTH_COMPONENT) { - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLint i; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, /* dst type */ - depth, /* dst addr */ - depthScale, - srcType, src, srcPacking); - - for (i = 0; i < srcWidth; i++) - dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - } - else if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes) { - /* simple path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLubyte stencil[MAX_WIDTH]; - GLint i; - /* the 24 depth bits will be in the high position: */ - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT_24_8_EXT, /* dst type */ - dstRow, /* dst addr */ - depthScale, - srcType, src, srcPacking); - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - /* merge stencil values into depth values */ - for (i = 0; i < srcWidth; i++) - dstRow[i] |= stencil[i]; - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - } - return GL_TRUE; -} - - -/** - * Store a combined depth/stencil texture image. - */ -static GLboolean -_mesa_texstore_s8_z24(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - ASSERT(dstFormat == MESA_FORMAT_S8_Z24); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); - - /* In case we only upload depth we need to preserve the stencil */ - if (srcFormat == GL_DEPTH_COMPONENT) { - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLint i; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, /* dst type */ - depth, /* dst addr */ - depthScale, - srcType, src, srcPacking); - - for (i = 0; i < srcWidth; i++) - dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - } - else { - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLubyte stencil[MAX_WIDTH]; - GLint i; - /* the 24 depth bits will be in the low position: */ - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, /* dst type */ - dstRow, /* dst addr */ - depthScale, - srcType, src, srcPacking); - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - /* merge stencil values into depth values */ - for (i = 0; i < srcWidth; i++) - dstRow[i] |= stencil[i] << 24; - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - } - return GL_TRUE; -} - -/** - * Store an image in any of the formats: - * _mesa_texformat_rgba_float32 - * _mesa_texformat_rgb_float32 - * _mesa_texformat_alpha_float32 - * _mesa_texformat_luminance_float32 - * _mesa_texformat_luminance_alpha_float32 - * _mesa_texformat_intensity_float32 - */ -static GLboolean -_mesa_texstore_rgba_float32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || - dstFormat == MESA_FORMAT_RGB_FLOAT32 || - dstFormat == MESA_FORMAT_ALPHA_FLOAT32 || - dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || - dstFormat == MESA_FORMAT_INTENSITY_FLOAT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLfloat)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_FLOAT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *srcRow = tempImage; - GLint bytesPerRow; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - bytesPerRow = srcWidth * components * sizeof(GLfloat); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - memcpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * As above, but store 16-bit floats. - */ -static GLboolean -_mesa_texstore_rgba_float16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || - dstFormat == MESA_FORMAT_RGB_FLOAT16 || - dstFormat == MESA_FORMAT_ALPHA_FLOAT16 || - dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || - dstFormat == MESA_FORMAT_INTENSITY_FLOAT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLhalfARB)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_HALF_FLOAT_ARB) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLhalfARB *dstTexel = (GLhalfARB *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = _mesa_float_to_half(src[i]); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int8 */ -static GLboolean -_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLbyte)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLbyte *dstTexel = (GLbyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLbyte) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int16 */ -static GLboolean -_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLshort)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLshort *dstTexel = (GLshort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int32 */ -static GLboolean -_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLint)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLint *dstTexel = (GLint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int8 */ -static GLboolean -_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLubyte)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstTexel = (GLubyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLubyte) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int16 */ -static GLboolean -_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLushort)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstTexel = (GLushort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLushort) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int32 */ -static GLboolean -_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLuint)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstTexel = (GLuint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLuint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - - - -#if FEATURE_EXT_texture_sRGB -static GLboolean -_mesa_texstore_srgb8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SRGB8); - - /* reuse normal rgb texstore code */ - newDstFormat = MESA_FORMAT_RGB888; - - k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_srgba8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SRGBA8); - - /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_RGBA8888; - k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sargb8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SARGB8); - - /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_ARGB8888; - - k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sl8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SL8); - - newDstFormat = MESA_FORMAT_L8; - - /* _mesa_textore_a8 handles luminance8 too */ - k = _mesa_texstore_a8(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sla8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SLA8); - - /* reuse normal luminance/alpha texstore code */ - newDstFormat = MESA_FORMAT_AL88; - - k = _mesa_texstore_al88(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - -#else - -/* these are used only in texstore_funcs[] below */ -#define _mesa_texstore_srgb8 NULL -#define _mesa_texstore_srgba8 NULL -#define _mesa_texstore_sargb8 NULL -#define _mesa_texstore_sl8 NULL -#define _mesa_texstore_sla8 NULL - -#endif /* FEATURE_EXT_texture_sRGB */ - - - - -/** - * Table mapping MESA_FORMAT_8 to _mesa_texstore_*() - * XXX this is somewhat temporary. - */ -static const struct { - gl_format Name; - StoreTexImageFunc Store; -} -texstore_funcs[MESA_FORMAT_COUNT] = -{ - { MESA_FORMAT_NONE, NULL }, - { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 }, - { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 }, - { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, - { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, - { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, - { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, - { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, - { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, - { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, - { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 }, - { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 }, - { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 }, - { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, - { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, - { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, - { MESA_FORMAT_AL88, _mesa_texstore_al88 }, - { MESA_FORMAT_AL88_REV, _mesa_texstore_al88 }, - { MESA_FORMAT_AL1616, _mesa_texstore_al1616 }, - { MESA_FORMAT_AL1616_REV, _mesa_texstore_al1616 }, - { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, - { MESA_FORMAT_A8, _mesa_texstore_a8 }, - { MESA_FORMAT_L8, _mesa_texstore_a8 }, - { MESA_FORMAT_I8, _mesa_texstore_a8 }, - { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, - { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, - { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr }, - { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 }, - { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 }, - { MESA_FORMAT_Z16, _mesa_texstore_z16 }, - { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 }, - { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 }, - { MESA_FORMAT_Z32, _mesa_texstore_z32 }, - { MESA_FORMAT_S8, NULL/*_mesa_texstore_s8*/ }, - { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 }, - { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 }, - { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 }, - { MESA_FORMAT_SL8, _mesa_texstore_sl8 }, - { MESA_FORMAT_SLA8, _mesa_texstore_sla8 }, - { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 }, - { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 }, - { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 }, - { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 }, - { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 }, - { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 }, - { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 }, - { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 }, - { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 }, - { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 }, - { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 }, - - { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 }, - { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 }, - { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 }, - { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 }, - { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 }, - { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 }, - - { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 }, - - { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 }, - { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 }, - { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 }, - - { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, - { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, - - { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 } -}; - - -static GLboolean -_mesa_texstore_null(TEXSTORE_PARAMS) -{ - (void) ctx; (void) dims; - (void) baseInternalFormat; - (void) dstFormat; - (void) dstAddr; - (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; - (void) dstRowStride; (void) dstImageOffsets; - (void) srcWidth; (void) srcHeight; (void) srcDepth; - (void) srcFormat; (void) srcType; - (void) srcAddr; - (void) srcPacking; - - /* should never happen */ - _mesa_problem(NULL, "_mesa_texstore_null() is called"); - return GL_FALSE; -} - - -/** - * Return the StoreTexImageFunc pointer to store an image in the given format. - */ -static StoreTexImageFunc -_mesa_get_texstore_func(gl_format format) -{ -#ifdef DEBUG - GLuint i; - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - ASSERT(texstore_funcs[i].Name == i); - } -#endif - ASSERT(texstore_funcs[format].Name == format); - - if (texstore_funcs[format].Store) - return texstore_funcs[format].Store; - else - return _mesa_texstore_null; -} - - -/** - * Store user data into texture memory. - * Called via glTex[Sub]Image1/2/3D() - */ -GLboolean -_mesa_texstore(TEXSTORE_PARAMS) -{ - StoreTexImageFunc storeImage; - GLboolean success; - - storeImage = _mesa_get_texstore_func(dstFormat); - - success = storeImage(ctx, dims, baseInternalFormat, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - return success; -} - - -/** - * Check if an unpack PBO is active prior to fetching a texture image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - return pixels; - } - if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access"); - return NULL; - } - - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * Check if an unpack PBO is active prior to fetching a compressed texture - * image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_compressed_teximage(GLcontext *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(packing->BufferObj)) { - /* not using a PBO - return pointer unchanged */ - return pixels; - } - if ((const GLubyte *) pixels + imageSize > - ((const GLubyte *) 0) + packing->BufferObj->Size) { - /* out of bounds read! */ - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access"); - return NULL; - } - - buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, packing->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * This function must be called after either of the validate_pbo_*_teximage() - * functions. It unmaps the PBO buffer if it was mapped earlier. - */ -void -_mesa_unmap_teximage_pbo(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack) -{ - if (_mesa_is_bufferobj(unpack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } -} - - -/** Return texture size in bytes */ -static GLuint -texture_size(const struct gl_texture_image *texImage) -{ - GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width, - texImage->Height, texImage->Depth); - return sz; -} - - -/** Return row stride in bytes */ -static GLuint -texture_row_stride(const struct gl_texture_image *texImage) -{ - GLuint stride = _mesa_format_row_stride(texImage->TexFormat, - texImage->Width); - return stride; -} - - - -/** - * This is the software fallback for Driver.TexImage1D() - * and Driver.CopyTexImage1D(). - * \sa _mesa_store_teximage2d() - * Note that the width may not be the actual texture width since it may - * be changed by convolution w/ GL_REDUCE. The texImage->Width field will - * have the actual texture size. - */ -void -_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, - pixels, packing, "glTexImage1D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - const GLint dstRowStride = 0; - GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, 1, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/** - * This is the software fallback for Driver.TexImage2D() - * and Driver.CopyTexImage2D(). - * - * This function is oriented toward storing images in main memory, rather - * than VRAM. Device driver's can easily plug in their own replacement. - * - * Note: width and height may be pre-convolved dimensions, but - * texImage->Width and texImage->Height will be post-convolved dimensions. - */ -void -_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, - pixels, packing, "glTexImage2D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - -/** - * This is the software fallback for Driver.TexImage3D() - * and Driver.CopyTexImage3D(). - * \sa _mesa_store_teximage2d() - */ -void -_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, - type, pixels, packing, "glTexImage3D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - - -/* - * This is the software fallback for Driver.TexSubImage1D() - * and Driver.CopyTexSubImage1D(). - */ -void -_mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, - pixels, packing, "glTexSubImage1D"); - if (!pixels) - return; - - { - const GLint dstRowStride = 0; - GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, 0, 0, /* offsets */ - dstRowStride, - texImage->ImageOffsets, - width, 1, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - -/** - * This is the software fallback for Driver.TexSubImage2D() - * and Driver.CopyTexSubImage2D(). - */ -void -_mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, - pixels, packing, "glTexSubImage2D"); - if (!pixels) - return; - - { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, yoffset, 0, - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/* - * This is the software fallback for Driver.TexSubImage3D(). - * and Driver.CopyTexSubImage3D(). - */ -void -_mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, - type, pixels, packing, - "glTexSubImage3D"); - if (!pixels) - return; - - { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, yoffset, zoffset, - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/* - * Fallback for Driver.CompressedTexImage1D() - */ -void -_mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* this space intentionally left blank */ - (void) ctx; - (void) target; (void) level; - (void) internalFormat; - (void) width; (void) border; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - - -/** - * Fallback for Driver.CompressedTexImage2D() - */ -void -_mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - (void) width; (void) height; (void) border; - - /* This is pretty simple, basically just do a memcpy without worrying - * about the usual image unpacking or image transfer operations. - */ - ASSERT(texObj); - ASSERT(texImage); - ASSERT(texImage->Width > 0); - ASSERT(texImage->Height > 0); - ASSERT(texImage->Depth == 1); - ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */ - - /* allocate storage */ - texImage->Data = _mesa_alloc_texmemory(imageSize); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - - data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, - &ctx->Unpack, - "glCompressedTexImage2D"); - if (!data) - return; - - /* copy the data */ - memcpy(texImage->Data, data, imageSize); - - _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); -} - - - -/* - * Fallback for Driver.CompressedTexImage3D() - */ -void -_mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* this space intentionally left blank */ - (void) ctx; - (void) target; (void) level; - (void) internalFormat; - (void) width; (void) height; (void) depth; - (void) border; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - - -/** - * Fallback for Driver.CompressedTexSubImage1D() - */ -void -_mesa_store_compressed_texsubimage1d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* there are no compressed 1D texture formats yet */ - (void) ctx; - (void) target; (void) level; - (void) xoffset; (void) width; - (void) format; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - -/** - * Fallback for Driver.CompressedTexSubImage2D() - */ -void -_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLint bytesPerRow, destRowStride, srcRowStride; - GLint i, rows; - GLubyte *dest; - const GLubyte *src; - const gl_format texFormat = texImage->TexFormat; - const GLint destWidth = texImage->Width; - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - - (void) level; - (void) format; - - /* these should have been caught sooner */ - ASSERT((width % bw) == 0 || width == 2 || width == 1); - ASSERT((height % bh) == 0 || height == 2 || height == 1); - ASSERT((xoffset % bw) == 0); - ASSERT((yoffset % bh) == 0); - - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, - &ctx->Unpack, - "glCompressedTexSubImage2D"); - if (!data) - return; - - srcRowStride = _mesa_format_row_stride(texFormat, width); - src = (const GLubyte *) data; - - destRowStride = _mesa_format_row_stride(texFormat, destWidth); - dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - texFormat, destWidth, - (GLubyte *) texImage->Data); - - bytesPerRow = srcRowStride; /* bytes per row of blocks */ - rows = height / bh; /* rows in blocks */ - - /* copy rows of blocks */ - for (i = 0; i < rows; i++) { - memcpy(dest, src, bytesPerRow); - dest += destRowStride; - src += srcRowStride; - } - - _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); -} - - -/** - * Fallback for Driver.CompressedTexSubImage3D() - */ -void -_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* there are no compressed 3D texture formats yet */ - (void) ctx; - (void) target; (void) level; - (void) xoffset; (void) yoffset; (void) zoffset; - (void) width; (void) height; (void) depth; - (void) format; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + +/** + * The GL texture image functions in teximage.c basically just do + * error checking and data structure allocation. They in turn call + * device driver functions which actually copy/convert/store the user's + * texture image data. + * + * However, most device drivers will be able to use the fallback functions + * in this file. That is, most drivers will have the following bit of + * code: + * ctx->Driver.TexImage1D = _mesa_store_teximage1d; + * ctx->Driver.TexImage2D = _mesa_store_teximage2d; + * ctx->Driver.TexImage3D = _mesa_store_teximage3d; + * etc... + * + * Texture image processing is actually kind of complicated. We have to do: + * Format/type conversions + * pixel unpacking + * pixel transfer (scale, bais, lookup, etc) + * + * These functions can handle most everything, including processing full + * images and sub-images. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mipmap.h" +#include "pack.h" +#include "imports.h" +#include "pack.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_s3tc.h" +#include "teximage.h" +#include "texstore.h" +#include "enums.h" + + +enum { + ZERO = 4, + ONE = 5 +}; + + +/** + * Texture image storage function. + */ +typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); + + +/** + * Return GL_TRUE if the given image format is one that be converted + * to another format by swizzling. + */ +static GLboolean +can_swizzle(GLenum logicalBaseFormat) +{ + switch (logicalBaseFormat) { + case GL_RGBA: + case GL_RGB: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_BGR: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RG: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + +enum { + IDX_LUMINANCE = 0, + IDX_ALPHA, + IDX_INTENSITY, + IDX_LUMINANCE_ALPHA, + IDX_RGB, + IDX_RGBA, + IDX_RED, + IDX_GREEN, + IDX_BLUE, + IDX_BGR, + IDX_BGRA, + IDX_ABGR, + IDX_RG, + MAX_IDX +}; + +#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) +#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) +#define MAP3(x,y,z) MAP4(x, y, z, ZERO) +#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } + + +static const struct { + GLubyte format_idx; + GLubyte to_rgba[6]; + GLubyte from_rgba[6]; +} mappings[MAX_IDX] = +{ + { + IDX_LUMINANCE, + MAP4(0,0,0,ONE), + MAP1(0) + }, + + { + IDX_ALPHA, + MAP4(ZERO, ZERO, ZERO, 0), + MAP1(3) + }, + + { + IDX_INTENSITY, + MAP4(0, 0, 0, 0), + MAP1(0), + }, + + { + IDX_LUMINANCE_ALPHA, + MAP4(0,0,0,1), + MAP2(0,3) + }, + + { + IDX_RGB, + MAP4(0,1,2,ONE), + MAP3(0,1,2) + }, + + { + IDX_RGBA, + MAP4(0,1,2,3), + MAP4(0,1,2,3), + }, + + { + IDX_RED, + MAP4(0, ZERO, ZERO, ONE), + MAP1(0), + }, + + { + IDX_GREEN, + MAP4(ZERO, 0, ZERO, ONE), + MAP1(1), + }, + + { + IDX_BLUE, + MAP4(ZERO, ZERO, 0, ONE), + MAP1(2), + }, + + { + IDX_BGR, + MAP4(2,1,0,ONE), + MAP3(2,1,0) + }, + + { + IDX_BGRA, + MAP4(2,1,0,3), + MAP4(2,1,0,3) + }, + + { + IDX_ABGR, + MAP4(3,2,1,0), + MAP4(3,2,1,0) + }, + + { + IDX_RG, + MAP4(0, 1, ZERO, ONE), + MAP2(0, 1) + }, +}; + + + +/** + * Convert a GL image format enum to an IDX_* value (see above). + */ +static int +get_map_idx(GLenum value) +{ + switch (value) { + case GL_LUMINANCE: return IDX_LUMINANCE; + case GL_ALPHA: return IDX_ALPHA; + case GL_INTENSITY: return IDX_INTENSITY; + case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; + case GL_RGB: return IDX_RGB; + case GL_RGBA: return IDX_RGBA; + case GL_RED: return IDX_RED; + case GL_GREEN: return IDX_GREEN; + case GL_BLUE: return IDX_BLUE; + case GL_BGR: return IDX_BGR; + case GL_BGRA: return IDX_BGRA; + case GL_ABGR_EXT: return IDX_ABGR; + case GL_RG: return IDX_RG; + default: + _mesa_problem(NULL, "Unexpected inFormat"); + return 0; + } +} + + +/** + * When promoting texture formats (see below) we need to compute the + * mapping of dest components back to source components. + * This function does that. + * \param inFormat the incoming format of the texture + * \param outFormat the final texture format + * \return map[6] a full 6-component map + */ +static void +compute_component_mapping(GLenum inFormat, GLenum outFormat, + GLubyte *map) +{ + const int inFmt = get_map_idx(inFormat); + const int outFmt = get_map_idx(outFormat); + const GLubyte *in2rgba = mappings[inFmt].to_rgba; + const GLubyte *rgba2out = mappings[outFmt].from_rgba; + int i; + + for (i = 0; i < 4; i++) + map[i] = in2rgba[rgba2out[i]]; + + map[ZERO] = ZERO; + map[ONE] = ONE; + +#if 0 + printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", + inFormat, _mesa_lookup_enum_by_nr(inFormat), + outFormat, _mesa_lookup_enum_by_nr(outFormat), + map[0], + map[1], + map[2], + map[3], + map[4], + map[5]); +#endif +} + + +/** + * Make a temporary (color) texture image with GLfloat components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLfloat. + */ +static GLfloat * +make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps) +{ + GLfloat *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLfloat *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_COLOR_INDEX || + logicalBaseFormat == GL_DEPTH_COMPONENT); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY || + textureBaseFormat == GL_COLOR_INDEX || + textureBaseFormat == GL_DEPTH_COMPONENT); + + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLfloat)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking, transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLfloat *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLfloat)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Make temporary image with uint pixel values. Used for unsigned + * integer-valued textures. + */ +static GLuint * +make_temp_uint_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLuint *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_ALPHA); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA); + + tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLuint)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLuint *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLuint)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + + +/** + * Make a temporary (color) texture image with GLchan components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLchan. + */ +GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint transferOps = ctx->_ImageTransferState; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + GLint img, row; + GLchan *tempImage, *dst; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY); + + /* unpack and transfer the source image */ + tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLchan)); + if (!tempImage) { + return NULL; + } + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = + (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, + srcFormat, srcType, src, srcPacking, + transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* one more conversion step */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLchan *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLchan)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0; + else if (j == ONE) + newImage[i * texComponents + k] = CHAN_MAX; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Copy GLubyte pixels from to with swizzling. + * \param dst destination pixels + * \param dstComponents number of color components in destination pixels + * \param src source pixels + * \param srcComponents number of color components in source pixels + * \param map the swizzle mapping. map[X] says where to find the X component + * in the source image's pixels. For example, if the source image + * is GL_BGRA and X = red, map[0] yields 2. + * \param count number of pixels to copy/swizzle. + */ +static void +swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, + GLuint srcComponents, const GLubyte *map, GLuint count) +{ +#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ + do { \ + GLuint i; \ + for (i = 0; i < count; i++) { \ + GLuint j; \ + if (srcComps == 4) { \ + COPY_4UBV(tmp, src); \ + } \ + else { \ + for (j = 0; j < srcComps; j++) { \ + tmp[j] = src[j]; \ + } \ + } \ + src += srcComps; \ + for (j = 0; j < dstComps; j++) { \ + dst[j] = tmp[map[j]]; \ + } \ + dst += dstComps; \ + } \ + } while (0) + + GLubyte tmp[6]; + + tmp[ZERO] = 0x0; + tmp[ONE] = 0xff; + + ASSERT(srcComponents <= 4); + ASSERT(dstComponents <= 4); + + switch (dstComponents) { + case 4: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 4, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 4, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 4, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 4, 1); + break; + default: + ; + } + break; + case 3: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 3, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 3, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 3, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 3, 1); + break; + default: + ; + } + break; + case 2: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 2, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 2, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 2, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 2, 1); + break; + default: + ; + } + break; + case 1: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 1, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 1, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 1, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 1, 1); + break; + default: + ; + } + break; + default: + ; + } +#undef SWZ_CPY +} + + + +static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; +static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on endianness. + */ +static const GLubyte * +type_mapping( GLenum srcType ) +{ + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + return _mesa_little_endian() ? map_3210 : map_identity; + case GL_UNSIGNED_INT_8_8_8_8_REV: + return _mesa_little_endian() ? map_identity : map_3210; + default: + return NULL; + } +} + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on pixelstore byte swapping state. + */ +static const GLubyte * +byteswap_mapping( GLboolean swapBytes, + GLenum srcType ) +{ + if (!swapBytes) + return map_identity; + + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + return map_3210; + default: + return NULL; + } +} + + + +/** + * Transfer a GLubyte texture image with component swizzling. + */ +static void +_mesa_swizzle_ubyte_image(struct gl_context *ctx, + GLuint dimensions, + GLenum srcFormat, + GLenum srcType, + + GLenum baseInternalFormat, + + const GLubyte *rgba2dst, + GLuint dstComponents, + + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking ) +{ + GLint srcComponents = _mesa_components_in_format(srcFormat); + const GLubyte *srctype2ubyte, *swap; + GLubyte map[4], src2base[6], base2rgba[6]; + GLint i; + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, GL_UNSIGNED_BYTE); + const GLint srcImageStride + = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE); + const GLubyte *srcImage + = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, + srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE, 0, 0, 0); + + (void) ctx; + + /* Translate from src->baseInternal->GL_RGBA->dst. This will + * correctly deal with RGBA->RGB->RGBA conversions where the final + * A value must be 0xff regardless of the incoming alpha values. + */ + compute_component_mapping(srcFormat, baseInternalFormat, src2base); + compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); + swap = byteswap_mapping(srcPacking->SwapBytes, srcType); + srctype2ubyte = type_mapping(srcType); + + + for (i = 0; i < 4; i++) + map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; + +/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ + + if (srcComponents == dstComponents && + srcRowStride == dstRowStride && + srcRowStride == srcWidth * srcComponents && + dimensions < 3) { + /* 1 and 2D images only */ + GLubyte *dstImage = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, + srcWidth * srcHeight); + } + else { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * dstComponents + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + for (row = 0; row < srcHeight; row++) { + swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } + } +} + + +/** + * Teximage storage routine for when a simple memcpy will do. + * No pixel transfer operations or special texel encodings allowed. + * 1D, 2D and 3D images supported. + */ +static void +memcpy_texture(struct gl_context *ctx, + GLuint dimensions, + gl_format dstFormat, + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + const GLint srcImageStride = _mesa_image_image_stride(srcPacking, + srcWidth, srcHeight, srcFormat, srcType); + const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, + srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLint bytesPerRow = srcWidth * texelBytes; + +#if 0 + /* XXX update/re-enable for dstImageOffsets array */ + const GLint bytesPerImage = srcHeight * bytesPerRow; + const GLint bytesPerTexture = srcDepth * bytesPerImage; + GLubyte *dstImage = (GLubyte *) dstAddr + + dstZoffset * dstImageStride + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + + if (dstRowStride == srcRowStride && + dstRowStride == bytesPerRow && + ((dstImageStride == srcImageStride && + dstImageStride == bytesPerImage) || + (srcDepth == 1))) { + /* one big memcpy */ + ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture); + } + else + { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = dstImage; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + dstImage += dstImageStride; + } + } +#endif + + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } +} + + + +/** + * Store a 32-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z32(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z32); + ASSERT(texelBytes == sizeof(GLuint)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_x8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_X8_Z24); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z24_x8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z24_X8); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLuint *dst = (GLuint *) dstRow; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, dst, + depthScale, srcType, src, srcPacking); + for (i = 0; i < srcWidth; i++) + dst[i] <<= 8; + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 16-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z16(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z16); + ASSERT(texelBytes == sizeof(GLushort)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLushort *dst16 = (GLushort *) dstRow; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_SHORT, dst16, depthScale, + srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store an rgb565 or rgb565_rev texture image. + */ +static GLboolean +_mesa_texstore_rgb565(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB565 || + dstFormat == MESA_FORMAT_RGB565_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGB565 && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_SHORT_5_6_5) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + dims == 2) { + /* do optimized tex store */ + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = (const GLubyte *) + _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, + srcFormat, srcType, 0, 0, 0); + GLubyte *dst = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + GLint row, col; + for (row = 0; row < srcHeight; row++) { + const GLubyte *srcUB = (const GLubyte *) src; + GLushort *dstUS = (GLushort *) dst; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + dst += dstRowStride; + src += srcRowStride; + } + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. + */ +static GLboolean +_mesa_texstore_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || + dstFormat == MESA_FORMAT_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = GL_RGBA; + + ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888 || + dstFormat == MESA_FORMAT_XRGB8888_REV ); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { + /* simple memcpy path (little endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888_REV) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8)) { + /* simple memcpy path (big endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + srcFormat == GL_RGB && + (baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB) && + srcType == GL_UNSIGNED_BYTE) { + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(0xff, + srcRow[col * 3 + RCOMP], + srcRow[col * 3 + GCOMP], + srcRow[col * 3 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB8888 && + srcFormat == GL_RGBA && + baseInternalFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* same as above case, but src data has alpha too */ + GLint img, row, col; + /* For some reason, streaming copies to write-combined regions + * are extremely sensitive to the characteristics of how the + * source data is retrieved. By reordering the source reads to + * be in-order, the speed of this operation increases by half. + * Strangely the same isn't required for the RGB path, above. + */ + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], + srcRow[col * 4 + RCOMP], + srcRow[col * 4 + GCOMP], + srcRow[col * 4 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { + dstmap[3] = 3; /* alpha */ + dstmap[2] = 0; /* red */ + dstmap[1] = 1; /* green */ + dstmap[0] = 2; /* blue */ + } + else { + assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); + dstmap[3] = 2; + dstmap[2] = 1; + dstmap[1] = 0; + dstmap[0] = 3; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else if (dstFormat == MESA_FORMAT_XRGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( 0xff, + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_BGR && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract RGB from RGBA */ + GLint img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 2; + dstmap[1] = 1; + dstmap[2] = 0; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { +#if 0 + if (littleEndian) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcUB[BCOMP]; + dstRow[col * 3 + 1] = srcUB[GCOMP]; + dstRow[col * 3 + 2] = srcUB[RCOMP]; + srcUB += 3; + } + } +#else + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]); + src += 3; + } +#endif + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_bgr888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_BGR888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract BGR from RGBA */ + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 0; + dstmap[1] = 1; + dstmap[2] = 2; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb4444(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || + dstFormat == MESA_FORMAT_ARGB4444_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB4444 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB4444) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_rgba5551(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA5551); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA5551 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT_5_5_5_1) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_argb1555(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || + dstFormat == MESA_FORMAT_ARGB1555_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB1555 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB1555) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb2101010(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB2101010 && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_INT_2_10_10_10_REV && + baseInternalFormat == GL_RGBA) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + if (baseInternalFormat == GL_RGBA) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUS = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_2101010( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + dstRow += dstRowStride; + } + } else if (baseInternalFormat == GL_RGB) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUS = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_2101010( 0xff, + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + dstRow += dstRowStride; + } + } else { + ASSERT(0); + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm44(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL44); + ASSERT(texelBytes == 1); + + { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstUS = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm88(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_AL88_REV || + dstFormat == MESA_FORMAT_RG88 || + dstFormat == MESA_FORMAT_RG88_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_RG88) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + littleEndian && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) { + if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || + (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + } + else { + if ((littleEndian && dstFormat == MESA_FORMAT_RG88) || + (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) { + dstmap[0] = 0; + dstmap[1] = 1; + } + else { + dstmap[0] = 1; + dstmap[1] = 0; + } + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_RG88) { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm1616(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_AL1616_REV || + dstFormat == MESA_FORMAT_RG1616 || + dstFormat == MESA_FORMAT_RG1616_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_RG1616) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_RG1616) { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616(a, l); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616_REV(a, l); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* Texstore for R16, A16, L16, I16. */ +static GLboolean +_mesa_texstore_unorm16(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_R16 || + dstFormat == MESA_FORMAT_A16 || + dstFormat == MESA_FORMAT_L16 || + dstFormat == MESA_FORMAT_I16); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + dstUS[col] = r; + src += 1; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(texelBytes == 8); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r, g, b, a; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); + dstUS[col*4+0] = r; + dstUS[col*4+1] = g; + dstUS[col*4+2] = b; + dstUS[col*4+3] = a; + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || + dstFormat == MESA_FORMAT_SIGNED_RG_16 || + dstFormat == MESA_FORMAT_SIGNED_RGB_16 || + dstFormat == MESA_FORMAT_SIGNED_RGBA_16); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && + srcFormat == GL_RGBA && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; + GLint img, row, col; + + if (!tempImage) + return GL_FALSE; + + /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, + * 3 or 4 components/pixel here. + */ + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstRowS = (GLshort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLuint c; + for (c = 0; c < comps; c++) { + GLshort p; + UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); + dstRowS[col * comps + c] = p; + } + } + dstRow += dstRowStride; + src += 4 * srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb332(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB332); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. + */ +static GLboolean +_mesa_texstore_a8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_A8 || + dstFormat == MESA_FORMAT_L8 || + dstFormat == MESA_FORMAT_I8 || + dstFormat == MESA_FORMAT_R8); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_A8) { + dstmap[0] = 3; + } + else { + dstmap[0] = 0; + } + dstmap[1] = ZERO; /* ? */ + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 1, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = CHAN_TO_UBYTE(src[col]); + } + dstRow += dstRowStride; + src += srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +static GLboolean +_mesa_texstore_ci8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) dims; (void) baseInternalFormat; + ASSERT(dstFormat == MESA_FORMAT_CI8); + ASSERT(texelBytes == 1); + ASSERT(baseInternalFormat == GL_COLOR_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_COLOR_INDEX && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, + srcType, src, srcPacking, + ctx->_ImageTransferState); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. + */ +static GLboolean +_mesa_texstore_ycbcr(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) ctx; (void) dims; (void) baseInternalFormat; + + ASSERT((dstFormat == MESA_FORMAT_YCBCR) || + (dstFormat == MESA_FORMAT_YCBCR_REV)); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + ASSERT(srcFormat == GL_YCBCR_MESA); + ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); + ASSERT(baseInternalFormat == GL_YCBCR_MESA); + + /* always just memcpy since no pixel transfer ops apply */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + + /* Check if we need byte swapping */ + /* XXX the logic here _might_ be wrong */ + if (srcPacking->SwapBytes ^ + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ + (dstFormat == MESA_FORMAT_YCBCR_REV) ^ + !littleEndian) { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + _mesa_swap2((GLushort *) dstRow, srcWidth); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_dudv8(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_DUDV8); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.ATI_envmap_bumpmap); + ASSERT((srcFormat == GL_DU8DV8_ATI) || + (srcFormat == GL_DUDV_ATI)); + ASSERT(baseInternalFormat == GL_DUDV_ATI); + + if (!srcPacking->SwapBytes && srcType == GL_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcType == GL_BYTE) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (littleEndian) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + GL_LUMINANCE_ALPHA, /* hack */ + GL_UNSIGNED_BYTE, /* hack */ + GL_LUMINANCE_ALPHA, /* hack */ + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path - note this is defined for 2d textures only */ + const GLint components = _mesa_components_in_format(baseInternalFormat); + const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + GLbyte *tempImage, *dst, *src; + GLint row; + + tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLbyte)); + if (!tempImage) + return GL_FALSE; + + src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + 0, 0, 0); + + dst = tempImage; + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, + dst, srcFormat, srcType, src, + srcPacking, 0); + dst += srcWidth * components; + src += srcStride; + } + + src = tempImage; + dst = (GLbyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dst, src, srcWidth * texelBytes); + dst += dstRowStride; + src += srcWidth * texelBytes; + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_R8 format. + */ +static GLboolean +_mesa_texstore_signed_r8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstB = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RG88 format. + */ +static GLboolean +_mesa_texstore_signed_rg88(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP])); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. + */ +static GLboolean +_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); + ASSERT(texelBytes == 4); + + { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + 0xff ); + srcRow += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or + * MESA_FORMAT_SIGNED_RGBA8888_REV + */ +static GLboolean +_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_BYTE) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_z24_s8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_Z24_S8); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); + + if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes) { + /* simple path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcFormat == GL_DEPTH_COMPONENT) { + /* In case we only upload depth we need to preserve the stencil */ + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF00) | (stencil[i] & 0xFF); + } + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_s8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_S8_Z24); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || + srcFormat == GL_DEPTH_COMPONENT || + srcFormat == GL_STENCIL_INDEX); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || + srcType == GL_UNSIGNED_INT_24_8_EXT); + + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24); + + } + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + return GL_TRUE; +} + + +/** + * Store simple 8-bit/value stencil texture data. + */ +static GLboolean +_mesa_texstore_s8(TEXSTORE_PARAMS) +{ + ASSERT(dstFormat == MESA_FORMAT_S8); + ASSERT(srcFormat == GL_STENCIL_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLubyte stencil[MAX_WIDTH]; + GLint i; + + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) + dstRow[i] = stencil[i]; + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLubyte); + } + } + + } + + return GL_TRUE; +} + + +/** + * Store an image in any of the formats: + * _mesa_texformat_rgba_float32 + * _mesa_texformat_rgb_float32 + * _mesa_texformat_alpha_float32 + * _mesa_texformat_luminance_float32 + * _mesa_texformat_luminance_alpha_float32 + * _mesa_texformat_intensity_float32 + */ +static GLboolean +_mesa_texstore_rgba_float32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || + dstFormat == MESA_FORMAT_RGB_FLOAT32 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLfloat)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_FLOAT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint bytesPerRow; + GLint img, row; + if (!tempImage) + return GL_FALSE; + bytesPerRow = srcWidth * components * sizeof(GLfloat); + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * As above, but store 16-bit floats. + */ +static GLboolean +_mesa_texstore_rgba_float16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || + dstFormat == MESA_FORMAT_RGB_FLOAT16 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLhalfARB)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_HALF_FLOAT_ARB) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLhalfARB *dstTexel = (GLhalfARB *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = _mesa_float_to_half(src[i]); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int8 */ +static GLboolean +_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLbyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLbyte *dstTexel = (GLbyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLbyte) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int16 */ +static GLboolean +_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLshort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstTexel = (GLshort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int32 */ +static GLboolean +_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLint *dstTexel = (GLint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int8 */ +static GLboolean +_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLubyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstTexel = (GLubyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int16 */ +static GLboolean +_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLushort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstTexel = (GLushort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int32 */ +static GLboolean +_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLuint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstTexel = (GLuint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + + +#if FEATURE_EXT_texture_sRGB +static GLboolean +_mesa_texstore_srgb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGB8); + + /* reuse normal rgb texstore code */ + newDstFormat = MESA_FORMAT_RGB888; + + k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_srgba8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGBA8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_RGBA8888; + k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sargb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SARGB8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_ARGB8888; + + k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sl8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SL8); + + newDstFormat = MESA_FORMAT_L8; + + /* _mesa_textore_a8 handles luminance8 too */ + k = _mesa_texstore_a8(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sla8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SLA8); + + /* reuse normal luminance/alpha texstore code */ + newDstFormat = MESA_FORMAT_AL88; + + k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + +#else + +/* these are used only in texstore_funcs[] below */ +#define _mesa_texstore_srgb8 NULL +#define _mesa_texstore_srgba8 NULL +#define _mesa_texstore_sargb8 NULL +#define _mesa_texstore_sl8 NULL +#define _mesa_texstore_sla8 NULL + +#endif /* FEATURE_EXT_texture_sRGB */ + + + + +/** + * Table mapping MESA_FORMAT_* to _mesa_texstore_*() + * XXX this is somewhat temporary. + */ +static const struct { + gl_format Name; + StoreTexImageFunc Store; +} +texstore_funcs[MESA_FORMAT_COUNT] = +{ + { MESA_FORMAT_NONE, NULL }, + { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, + { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, + { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, + { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 }, + { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 }, + { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 }, + { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, + { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, + { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, + { MESA_FORMAT_AL44, _mesa_texstore_unorm44 }, + { MESA_FORMAT_AL88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, + { MESA_FORMAT_A8, _mesa_texstore_a8 }, + { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_L8, _mesa_texstore_a8 }, + { MESA_FORMAT_L16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_I8, _mesa_texstore_a8 }, + { MESA_FORMAT_I16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, + { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, + { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr }, + { MESA_FORMAT_R8, _mesa_texstore_a8 }, + { MESA_FORMAT_RG88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_R16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 }, + { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 }, + { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 }, + { MESA_FORMAT_Z16, _mesa_texstore_z16 }, + { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 }, + { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 }, + { MESA_FORMAT_Z32, _mesa_texstore_z32 }, + { MESA_FORMAT_S8, _mesa_texstore_s8 }, + { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 }, + { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 }, + { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 }, + { MESA_FORMAT_SL8, _mesa_texstore_sl8 }, + { MESA_FORMAT_SLA8, _mesa_texstore_sla8 }, + { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 }, + { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 }, + { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 }, + + { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 }, + { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 }, + { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 }, + { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 }, + { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 }, + { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 }, + + { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 }, + + { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 }, + { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 }, + { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 }, + + { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, + { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, + + { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 } +}; + + +static GLboolean +_mesa_texstore_null(TEXSTORE_PARAMS) +{ + (void) ctx; (void) dims; + (void) baseInternalFormat; + (void) dstFormat; + (void) dstAddr; + (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; + (void) dstRowStride; (void) dstImageOffsets; + (void) srcWidth; (void) srcHeight; (void) srcDepth; + (void) srcFormat; (void) srcType; + (void) srcAddr; + (void) srcPacking; + + /* should never happen */ + _mesa_problem(NULL, "_mesa_texstore_null() is called"); + return GL_FALSE; +} + + +/** + * Return the StoreTexImageFunc pointer to store an image in the given format. + */ +static StoreTexImageFunc +_mesa_get_texstore_func(gl_format format) +{ +#ifdef DEBUG + GLuint i; + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + ASSERT(texstore_funcs[i].Name == i); + } +#endif + ASSERT(texstore_funcs[format].Name == format); + + if (texstore_funcs[format].Store) + return texstore_funcs[format].Store; + else + return _mesa_texstore_null; +} + + +/** + * Store user data into texture memory. + * Called via glTex[Sub]Image1/2/3D() + */ +GLboolean +_mesa_texstore(TEXSTORE_PARAMS) +{ + StoreTexImageFunc storeImage; + GLboolean success; + + storeImage = _mesa_get_texstore_func(dstFormat); + + success = storeImage(ctx, dims, baseInternalFormat, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + return success; +} + + +/** + * Check if an unpack PBO is active prior to fetching a texture image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + return pixels; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * Check if an unpack PBO is active prior to fetching a compressed texture + * image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(packing->BufferObj)) { + /* not using a PBO - return pointer unchanged */ + return pixels; + } + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + packing->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, packing->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * This function must be called after either of the validate_pbo_*_teximage() + * functions. It unmaps the PBO buffer if it was mapped earlier. + */ +void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** Return texture size in bytes */ +static GLuint +texture_size(const struct gl_texture_image *texImage) +{ + GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width, + texImage->Height, texImage->Depth); + return sz; +} + + +/** Return row stride in bytes */ +static GLuint +texture_row_stride(const struct gl_texture_image *texImage) +{ + GLuint stride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); + return stride; +} + + + +/** + * This is the software fallback for Driver.TexImage1D() + * and Driver.CopyTexImage1D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexImage1D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/** + * This is the software fallback for Driver.TexImage2D() + * and Driver.CopyTexImage2D(). + * + * This function is oriented toward storing images in main memory, rather + * than VRAM. Device driver's can easily plug in their own replacement. + */ +void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexImage2D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexImage3D() + * and Driver.CopyTexImage3D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, "glTexImage3D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + + +/* + * This is the software fallback for Driver.TexSubImage1D() + * and Driver.CopyTexSubImage1D(). + */ +void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexSubImage1D"); + if (!pixels) + return; + + { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, 0, 0, /* offsets */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexSubImage2D() + * and Driver.CopyTexSubImage2D(). + */ +void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexSubImage2D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, 0, + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * This is the software fallback for Driver.TexSubImage3D(). + * and Driver.CopyTexSubImage3D(). + */ +void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, + "glTexSubImage3D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, zoffset, + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * Fallback for Driver.CompressedTexImage1D() + */ +void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexImage2D() + */ +void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + (void) width; (void) height; (void) border; + + /* This is pretty simple, basically just do a memcpy without worrying + * about the usual image unpacking or image transfer operations. + */ + ASSERT(texObj); + ASSERT(texImage); + ASSERT(texImage->Width > 0); + ASSERT(texImage->Height > 0); + ASSERT(texImage->Depth == 1); + ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */ + + /* allocate storage */ + texImage->Data = _mesa_alloc_texmemory(imageSize); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexImage2D"); + if (!data) + return; + + /* copy the data */ + memcpy(texImage->Data, data, imageSize); + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + + +/* + * Fallback for Driver.CompressedTexImage3D() + */ +void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) height; (void) depth; + (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexSubImage1D() + */ +void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 1D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) width; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + +/** + * Fallback for Driver.CompressedTexSubImage2D() + */ +void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLint bytesPerRow, destRowStride, srcRowStride; + GLint i, rows; + GLubyte *dest; + const GLubyte *src; + const gl_format texFormat = texImage->TexFormat; + const GLint destWidth = texImage->Width; + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + + (void) level; + (void) format; + + /* these should have been caught sooner */ + ASSERT((width % bw) == 0 || width == 2 || width == 1); + ASSERT((height % bh) == 0 || height == 2 || height == 1); + ASSERT((xoffset % bw) == 0); + ASSERT((yoffset % bh) == 0); + + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexSubImage2D"); + if (!data) + return; + + srcRowStride = _mesa_format_row_stride(texFormat, width); + src = (const GLubyte *) data; + + destRowStride = _mesa_format_row_stride(texFormat, destWidth); + dest = _mesa_compressed_image_address(xoffset, yoffset, 0, + texFormat, destWidth, + (GLubyte *) texImage->Data); + + bytesPerRow = srcRowStride; /* bytes per row of blocks */ + rows = height / bh; /* rows in blocks */ + + /* copy rows of blocks */ + for (i = 0; i < rows; i++) { + memcpy(dest, src, bytesPerRow); + dest += destRowStride; + src += srcRowStride; + } + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + +/** + * Fallback for Driver.CompressedTexSubImage3D() + */ +void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 3D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) yoffset; (void) zoffset; + (void) width; (void) height; (void) depth; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h index 3211086dd..8640a23a7 100644 --- a/mesalib/src/mesa/main/texstore.h +++ b/mesalib/src/mesa/main/texstore.h @@ -1,218 +1,218 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texstore.h - * Texture image storage routines. - * - * \author Brian Paul - */ - - -#ifndef TEXSTORE_H -#define TEXSTORE_H - - -#include "mtypes.h" -#include "formats.h" - - -/** - * This macro defines the (many) parameters to the texstore functions. - * \param dims either 1 or 2 or 3 - * \param baseInternalFormat user-specified base internal format - * \param dstFormat destination Mesa texture format - * \param dstAddr destination image address - * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels - * \param dstRowStride destination image row stride, in bytes - * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels - * \param srcWidth/Height/Depth source image size, in pixels - * \param srcFormat incoming image format - * \param srcType incoming image data type - * \param srcAddr source image address - * \param srcPacking source image packing parameters - */ -#define TEXSTORE_PARAMS \ - GLcontext *ctx, GLuint dims, \ - GLenum baseInternalFormat, \ - gl_format dstFormat, \ - GLvoid *dstAddr, \ - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ - GLint dstRowStride, const GLuint *dstImageOffsets, \ - GLint srcWidth, GLint srcHeight, GLint srcDepth, \ - GLenum srcFormat, GLenum srcType, \ - const GLvoid *srcAddr, \ - const struct gl_pixelstore_attrib *srcPacking - - -extern GLboolean -_mesa_texstore(TEXSTORE_PARAMS); - - -extern GLchan * -_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking); - - -extern void -_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_texsubimage1d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern const GLvoid * -_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName); - -extern const GLvoid * -_mesa_validate_pbo_compressed_teximage(GLcontext *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName); - -extern void -_mesa_unmap_teximage_pbo(GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texstore.h + * Texture image storage routines. + * + * \author Brian Paul + */ + + +#ifndef TEXSTORE_H +#define TEXSTORE_H + + +#include "mtypes.h" +#include "formats.h" + + +/** + * This macro defines the (many) parameters to the texstore functions. + * \param dims either 1 or 2 or 3 + * \param baseInternalFormat user-specified base internal format + * \param dstFormat destination Mesa texture format + * \param dstAddr destination image address + * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels + * \param dstRowStride destination image row stride, in bytes + * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels + * \param srcWidth/Height/Depth source image size, in pixels + * \param srcFormat incoming image format + * \param srcType incoming image data type + * \param srcAddr source image address + * \param srcPacking source image packing parameters + */ +#define TEXSTORE_PARAMS \ + struct gl_context *ctx, GLuint dims, \ + GLenum baseInternalFormat, \ + gl_format dstFormat, \ + GLvoid *dstAddr, \ + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ + GLint dstRowStride, const GLuint *dstImageOffsets, \ + GLint srcWidth, GLint srcHeight, GLint srcDepth, \ + GLenum srcFormat, GLenum srcType, \ + const GLvoid *srcAddr, \ + const struct gl_pixelstore_attrib *srcPacking + + +extern GLboolean +_mesa_texstore(TEXSTORE_PARAMS); + + +extern GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking); + + +extern void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName); + +extern const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName); + +extern void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + + +#endif diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index 5c8c1fd22..6368f9325 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -1,944 +1,944 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. - */ - - -/* - * Vertex transform feedback support. - * - * Authors: - * Brian Paul - */ - - -#include "buffers.h" -#include "bufferobj.h" -#include "context.h" -#include "hash.h" -#include "transformfeedback.h" -#include "shaderapi.h" -#include "shaderobj.h" -#include "main/dispatch.h" - -#include "program/prog_parameter.h" -//#include "program/shader_api.h" - - -#if FEATURE_EXT_transform_feedback - - -/** - * Do reference counting of transform feedback buffers. - */ -static void -reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, - struct gl_transform_feedback_object *obj) -{ - if (*ptr == obj) - return; - - if (*ptr) { - /* Unreference the old object */ - struct gl_transform_feedback_object *oldObj = *ptr; - - ASSERT(oldObj->RefCount > 0); - oldObj->RefCount--; - - if (oldObj->RefCount == 0) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) - ctx->Driver.DeleteTransformFeedback(ctx, oldObj); - } - - *ptr = NULL; - } - ASSERT(!*ptr); - - if (obj) { - /* reference new object */ - if (obj->RefCount == 0) { - _mesa_problem(NULL, "referencing deleted transform feedback object"); - *ptr = NULL; - } - else { - obj->RefCount++; - *ptr = obj; - } - } -} - - -/** - * Check if the given primitive mode (as in glBegin(mode)) is compatible - * with the current transform feedback mode (if it's enabled). - * This is to be called from glBegin(), glDrawArrays(), glDrawElements(), etc. - * - * \return GL_TRUE if the mode is OK, GL_FALSE otherwise. - */ -GLboolean -_mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode) -{ - if (ctx->TransformFeedback.CurrentObject->Active) { - switch (mode) { - case GL_POINTS: - return ctx->TransformFeedback.Mode == GL_POINTS; - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - return ctx->TransformFeedback.Mode == GL_LINES; - default: - return ctx->TransformFeedback.Mode == GL_TRIANGLES; - } - } - return GL_TRUE; -} - - -/** - * Check that all the buffer objects currently bound for transform - * feedback actually exist. Raise a GL_INVALID_OPERATION error if - * any buffers are missing. - * \return GL_TRUE for success, GL_FALSE if error - */ -GLboolean -_mesa_validate_transform_feedback_buffers(GLcontext *ctx) -{ - /* XXX to do */ - return GL_TRUE; -} - - - -/** - * Per-context init for transform feedback. - */ -void -_mesa_init_transform_feedback(GLcontext *ctx) -{ - /* core mesa expects this, even a dummy one, to be available */ - ASSERT(ctx->Driver.NewTransformFeedback); - - ctx->TransformFeedback.DefaultObject = - ctx->Driver.NewTransformFeedback(ctx, 0); - - assert(ctx->TransformFeedback.DefaultObject->RefCount == 1); - - reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, - ctx->TransformFeedback.DefaultObject); - - assert(ctx->TransformFeedback.DefaultObject->RefCount == 2); - - ctx->TransformFeedback.Objects = _mesa_NewHashTable(); - - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - ctx->Shared->NullBufferObj); -} - - - -/** - * Callback for _mesa_HashDeleteAll(). - */ -static void -delete_cb(GLuint key, void *data, void *userData) -{ - GLcontext *ctx = (GLcontext *) userData; - struct gl_transform_feedback_object *obj = - (struct gl_transform_feedback_object *) data; - - ctx->Driver.DeleteTransformFeedback(ctx, obj); -} - - -/** - * Per-context free/clean-up for transform feedback. - */ -void -_mesa_free_transform_feedback(GLcontext *ctx) -{ - /* core mesa expects this, even a dummy one, to be available */ - ASSERT(ctx->Driver.NewTransformFeedback); - - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - NULL); - - /* Delete all feedback objects */ - _mesa_HashDeleteAll(ctx->TransformFeedback.Objects, delete_cb, ctx); - _mesa_DeleteHashTable(ctx->TransformFeedback.Objects); - - /* Delete the default feedback object */ - assert(ctx->Driver.DeleteTransformFeedback); - ctx->Driver.DeleteTransformFeedback(ctx, - ctx->TransformFeedback.DefaultObject); - - ctx->TransformFeedback.CurrentObject = NULL; -} - - -#else /* FEATURE_EXT_transform_feedback */ - -/* forward declarations */ -static struct gl_transform_feedback_object * -new_transform_feedback(GLcontext *ctx, GLuint name); - -static void -delete_transform_feedback(GLcontext *ctx, - struct gl_transform_feedback_object *obj); - -/* dummy per-context init/clean-up for transform feedback */ -void -_mesa_init_transform_feedback(GLcontext *ctx) -{ - ctx->TransformFeedback.DefaultObject = new_transform_feedback(ctx, 0); - ctx->TransformFeedback.CurrentObject = ctx->TransformFeedback.DefaultObject; - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - ctx->Shared->NullBufferObj); -} - -void -_mesa_free_transform_feedback(GLcontext *ctx) -{ - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - NULL); - ctx->TransformFeedback.CurrentObject = NULL; - delete_transform_feedback(ctx, ctx->TransformFeedback.DefaultObject); -} - -#endif /* FEATURE_EXT_transform_feedback */ - - -/** Default fallback for ctx->Driver.NewTransformFeedback() */ -static struct gl_transform_feedback_object * -new_transform_feedback(GLcontext *ctx, GLuint name) -{ - struct gl_transform_feedback_object *obj; - obj = CALLOC_STRUCT(gl_transform_feedback_object); - if (obj) { - obj->Name = name; - obj->RefCount = 1; - } - return obj; -} - -/** Default fallback for ctx->Driver.DeleteTransformFeedback() */ -static void -delete_transform_feedback(GLcontext *ctx, - struct gl_transform_feedback_object *obj) -{ - GLuint i; - - for (i = 0; i < Elements(obj->Buffers); i++) { - _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); - } - - free(obj); -} - - -#if FEATURE_EXT_transform_feedback - - -/** Default fallback for ctx->Driver.BeginTransformFeedback() */ -static void -begin_transform_feedback(GLcontext *ctx, GLenum mode, - struct gl_transform_feedback_object *obj) -{ - /* nop */ -} - -/** Default fallback for ctx->Driver.EndTransformFeedback() */ -static void -end_transform_feedback(GLcontext *ctx, - struct gl_transform_feedback_object *obj) -{ - /* nop */ -} - -/** Default fallback for ctx->Driver.PauseTransformFeedback() */ -static void -pause_transform_feedback(GLcontext *ctx, - struct gl_transform_feedback_object *obj) -{ - /* nop */ -} - -/** Default fallback for ctx->Driver.ResumeTransformFeedback() */ -static void -resume_transform_feedback(GLcontext *ctx, - struct gl_transform_feedback_object *obj) -{ - /* nop */ -} - -/** Default fallback for ctx->Driver.DrawTransformFeedback() */ -static void -draw_transform_feedback(GLcontext *ctx, GLenum mode, - struct gl_transform_feedback_object *obj) -{ - /* XXX to do */ - /* - * Get number of vertices in obj's feedback buffer. - * Call ctx->Exec.DrawArrays(mode, 0, count); - */ -} - - -/** - * Plug in default device driver functions for transform feedback. - * Most drivers will override some/all of these. - */ -void -_mesa_init_transform_feedback_functions(struct dd_function_table *driver) -{ - driver->NewTransformFeedback = new_transform_feedback; - driver->DeleteTransformFeedback = delete_transform_feedback; - driver->BeginTransformFeedback = begin_transform_feedback; - driver->EndTransformFeedback = end_transform_feedback; - driver->PauseTransformFeedback = pause_transform_feedback; - driver->ResumeTransformFeedback = resume_transform_feedback; - driver->DrawTransformFeedback = draw_transform_feedback; -} - - -void -_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) -{ - SET_BeginTransformFeedbackEXT(disp, _mesa_BeginTransformFeedback); - SET_EndTransformFeedbackEXT(disp, _mesa_EndTransformFeedback); - SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange); - SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase); - SET_BindBufferOffsetEXT(disp, _mesa_BindBufferOffsetEXT); - SET_TransformFeedbackVaryingsEXT(disp, _mesa_TransformFeedbackVaryings); - SET_GetTransformFeedbackVaryingEXT(disp, _mesa_GetTransformFeedbackVarying); -} - - -/** - ** Begin API functions - **/ - - -void GLAPIENTRY -_mesa_BeginTransformFeedback(GLenum mode) -{ - struct gl_transform_feedback_object *obj; - GET_CURRENT_CONTEXT(ctx); - - obj = ctx->TransformFeedback.CurrentObject; - - switch (mode) { - case GL_POINTS: - case GL_LINES: - case GL_TRIANGLES: - /* legal */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBeginTransformFeedback(mode)"); - return; - } - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBeginTransformFeedback(already active)"); - return; - } - - obj->Active = GL_TRUE; - ctx->TransformFeedback.Mode = mode; - - assert(ctx->Driver.BeginTransformFeedback); - ctx->Driver.BeginTransformFeedback(ctx, mode, obj); -} - - -void GLAPIENTRY -_mesa_EndTransformFeedback(void) -{ - struct gl_transform_feedback_object *obj; - GET_CURRENT_CONTEXT(ctx); - - obj = ctx->TransformFeedback.CurrentObject; - - if (!obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEndTransformFeedback(not active)"); - return; - } - - ctx->TransformFeedback.CurrentObject->Active = GL_FALSE; - - assert(ctx->Driver.EndTransformFeedback); - ctx->Driver.EndTransformFeedback(ctx, obj); -} - - -/** - * Helper used by BindBufferRange() and BindBufferBase(). - */ -static void -bind_buffer_range(GLcontext *ctx, GLuint index, - struct gl_buffer_object *bufObj, - GLintptr offset, GLsizeiptr size) -{ - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - - /* The general binding point */ - _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - bufObj); - - /* The per-attribute binding point */ - _mesa_reference_buffer_object(ctx, - &obj->Buffers[index], - bufObj); - - obj->BufferNames[index] = bufObj->Name; - - obj->Offset[index] = offset; - obj->Size[index] = size; -} - - -/** - * Specify a buffer object to receive vertex shader results. Plus, - * specify the starting offset to place the results, and max size. - */ -void GLAPIENTRY -_mesa_BindBufferRange(GLenum target, GLuint index, - GLuint buffer, GLintptr offset, GLsizeiptr size) -{ - struct gl_transform_feedback_object *obj; - struct gl_buffer_object *bufObj; - GET_CURRENT_CONTEXT(ctx); - - if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)"); - return; - } - - obj = ctx->TransformFeedback.CurrentObject; - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(transform feedback active)"); - return; - } - - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index); - return; - } - - if ((size <= 0) || (size & 0x3)) { - /* must be positive and multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) size); - return; - } - - if (offset & 0x3) { - /* must be multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glBindBufferRange(offset=%d)", (int) offset); - return; - } - - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(invalid buffer=%u)", buffer); - return; - } - - if (offset + size >= bufObj->Size) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glBindBufferRange(offset + size %d > buffer size %d)", - (int) (offset + size), (int) (bufObj->Size)); - return; - } - - bind_buffer_range(ctx, index, bufObj, offset, size); -} - - -/** - * Specify a buffer object to receive vertex shader results. - * As above, but start at offset = 0. - */ -void GLAPIENTRY -_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) -{ - struct gl_transform_feedback_object *obj; - struct gl_buffer_object *bufObj; - GLsizeiptr size; - GET_CURRENT_CONTEXT(ctx); - - if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)"); - return; - } - - obj = ctx->TransformFeedback.CurrentObject; - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(transform feedback active)"); - return; - } - - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); - return; - } - - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferBase(invalid buffer=%u)", buffer); - return; - } - - /* default size is the buffer size rounded down to nearest - * multiple of four. - */ - size = bufObj->Size & ~0x3; - - bind_buffer_range(ctx, index, bufObj, 0, size); -} - - -/** - * Specify a buffer object to receive vertex shader results, plus the - * offset in the buffer to start placing results. - * This function is part of GL_EXT_transform_feedback, but not GL3. - */ -void GLAPIENTRY -_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, - GLintptr offset) -{ - struct gl_transform_feedback_object *obj; - struct gl_buffer_object *bufObj; - GET_CURRENT_CONTEXT(ctx); - GLsizeiptr size; - - if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferOffsetEXT(target)"); - return; - } - - obj = ctx->TransformFeedback.CurrentObject; - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferRange(transform feedback active)"); - return; - } - - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glBindBufferOffsetEXT(index=%d)", index); - return; - } - - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!bufObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindBufferOffsetEXT(invalid buffer=%u)", buffer); - return; - } - - /* default size is the buffer size rounded down to nearest - * multiple of four. - */ - size = (bufObj->Size - offset) & ~0x3; - - bind_buffer_range(ctx, index, bufObj, offset, size); -} - - -/** - * This function specifies the vertex shader outputs to be written - * to the feedback buffer(s), and in what order. - */ -void GLAPIENTRY -_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, - const GLchar **varyings, GLenum bufferMode) -{ - struct gl_shader_program *shProg; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - - switch (bufferMode) { - case GL_INTERLEAVED_ATTRIBS: - break; - case GL_SEPARATE_ATTRIBS: - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glTransformFeedbackVaryings(bufferMode)"); - return; - } - - if (count < 0 || count > ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTransformFeedbackVaryings(count=%d)", count); - return; - } - - shProg = _mesa_lookup_shader_program(ctx, program); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTransformFeedbackVaryings(program=%u)", program); - return; - } - - /* free existing varyings, if any */ - for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { - free(shProg->TransformFeedback.VaryingNames[i]); - } - free(shProg->TransformFeedback.VaryingNames); - - /* allocate new memory for varying names */ - shProg->TransformFeedback.VaryingNames = - (GLchar **) malloc(count * sizeof(GLchar *)); - - if (!shProg->TransformFeedback.VaryingNames) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()"); - return; - } - - /* Save the new names and the count */ - for (i = 0; i < (GLuint) count; i++) { - shProg->TransformFeedback.VaryingNames[i] = _mesa_strdup(varyings[i]); - } - shProg->TransformFeedback.NumVarying = count; - - shProg->TransformFeedback.BufferMode = bufferMode; - - /* The varyings won't be used until shader link time */ -} - - -/** - * Get info about the vertex shader's outputs which are to be written - * to the feedback buffer(s). - */ -void GLAPIENTRY -_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, - GLsizei bufSize, GLsizei *length, - GLsizei *size, GLenum *type, GLchar *name) -{ - const struct gl_shader_program *shProg; - const GLchar *varyingName; - GLint v; - GET_CURRENT_CONTEXT(ctx); - - shProg = _mesa_lookup_shader_program(ctx, program); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetTransformFeedbackVaryings(program=%u)", program); - return; - } - - if (index >= shProg->TransformFeedback.NumVarying) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetTransformFeedbackVaryings(index=%u)", index); - return; - } - - varyingName = shProg->TransformFeedback.VaryingNames[index]; - - v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName); - if (v >= 0) { - struct gl_program_parameter *param = &shProg->Varying->Parameters[v]; - - /* return the varying's name and length */ - _mesa_copy_string(name, bufSize, length, varyingName); - - /* return the datatype and value's size (in datatype units) */ - if (type) - *type = param->DataType; - if (size) - *size = param->Size; - } - else { - name[0] = 0; - if (length) - *length = 0; - if (type) - *type = 0; - if (size) - *size = 0; - } -} - - - -static struct gl_transform_feedback_object * -lookup_transform_feedback_object(GLcontext *ctx, GLuint name) -{ - if (name == 0) { - return ctx->TransformFeedback.DefaultObject; - } - else - return (struct gl_transform_feedback_object *) - _mesa_HashLookup(ctx->TransformFeedback.Objects, name); -} - - -/** - * Create new transform feedback objects. Transform feedback objects - * encapsulate the state related to transform feedback to allow quickly - * switching state (and drawing the results, below). - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) -{ - GLuint first; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)"); - return; - } - - if (!names) - return; - - /* we don't need contiguous IDs, but this might be faster */ - first = _mesa_HashFindFreeKeyBlock(ctx->TransformFeedback.Objects, n); - if (first) { - GLsizei i; - for (i = 0; i < n; i++) { - struct gl_transform_feedback_object *obj - = ctx->Driver.NewTransformFeedback(ctx, first + i); - if (!obj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); - return; - } - names[i] = first + i; - _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj); - } - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); - } -} - - -/** - * Is the given ID a transform feedback object? - * Part of GL_ARB_transform_feedback2. - */ -GLboolean GLAPIENTRY -_mesa_IsTransformFeedback(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (name && lookup_transform_feedback_object(ctx, name)) - return GL_TRUE; - else - return GL_FALSE; -} - - -/** - * Bind the given transform feedback object. - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_BindTransformFeedback(GLenum target, GLuint name) -{ - struct gl_transform_feedback_object *obj; - GET_CURRENT_CONTEXT(ctx); - - if (target != GL_TRANSFORM_FEEDBACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindTransformFeedback(target)"); - return; - } - - if (ctx->TransformFeedback.CurrentObject->Active && - !ctx->TransformFeedback.CurrentObject->Paused) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindTransformFeedback(transform is active, or not paused)"); - return; - } - - obj = lookup_transform_feedback_object(ctx, name); - if (!obj) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindTransformFeedback(name=%u)", name); - return; - } - - reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, - obj); -} - - -/** - * Delete the given transform feedback objects. - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteTransformFeedbacks(n < 0)"); - return; - } - - if (!names) - return; - - for (i = 0; i < n; i++) { - if (names[i] > 0) { - struct gl_transform_feedback_object *obj - = lookup_transform_feedback_object(ctx, names[i]); - if (obj) { - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDeleteTransformFeedbacks(object %u is active)", - names[i]); - return; - } - _mesa_HashRemove(ctx->TransformFeedback.Objects, names[i]); - /* unref, but object may not be deleted until later */ - reference_transform_feedback_object(&obj, NULL); - } - } - } -} - - -/** - * Pause transform feedback. - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_PauseTransformFeedback(void) -{ - struct gl_transform_feedback_object *obj; - GET_CURRENT_CONTEXT(ctx); - - obj = ctx->TransformFeedback.CurrentObject; - - if (!obj->Active || obj->Paused) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPauseTransformFeedback(feedback not active or already paused)"); - return; - } - - obj->Paused = GL_TRUE; - - assert(ctx->Driver.PauseTransformFeedback); - ctx->Driver.PauseTransformFeedback(ctx, obj); -} - - -/** - * Resume transform feedback. - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_ResumeTransformFeedback(void) -{ - struct gl_transform_feedback_object *obj; - GET_CURRENT_CONTEXT(ctx); - - obj = ctx->TransformFeedback.CurrentObject; - - if (!obj->Active || !obj->Paused) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPauseTransformFeedback(feedback not active or not paused)"); - return; - } - - obj->Paused = GL_FALSE; - - assert(ctx->Driver.ResumeTransformFeedback); - ctx->Driver.ResumeTransformFeedback(ctx, obj); -} - - -/** - * Draw the vertex data in a transform feedback object. - * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc. - * \param name the transform feedback object - * The number of vertices comes from the transform feedback object. - * User still has to setup of the vertex attribute info with - * glVertexPointer, glColorPointer, etc. - * Part of GL_ARB_transform_feedback2. - */ -void GLAPIENTRY -_mesa_DrawTransformFeedback(GLenum mode, GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_transform_feedback_object *obj = - lookup_transform_feedback_object(ctx, name); - - if (mode > GL_POLYGON) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glDrawTransformFeedback(mode=0x%x)", mode); - return; - } - if (!obj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glDrawTransformFeedback(name = %u)", name); - return; - } - - /* XXX check if EndTransformFeedback has never been called while - * the object was bound - */ - - assert(ctx->Driver.DrawTransformFeedback); - ctx->Driver.DrawTransformFeedback(ctx, mode, obj); -} - - -/* -XXX misc to do: - -glGet*() for - -GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED -GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE -GL_TRANSFORM_FEEDBACK_BINDING -*/ - - -#endif /* FEATURE_EXT_transform_feedback */ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +/* + * Vertex transform feedback support. + * + * Authors: + * Brian Paul + */ + + +#include "buffers.h" +#include "bufferobj.h" +#include "context.h" +#include "hash.h" +#include "transformfeedback.h" +#include "shaderapi.h" +#include "shaderobj.h" +#include "main/dispatch.h" + +#include "program/prog_parameter.h" +//#include "program/shader_api.h" + + +#if FEATURE_EXT_transform_feedback + + +/** + * Do reference counting of transform feedback buffers. + */ +static void +reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, + struct gl_transform_feedback_object *obj) +{ + if (*ptr == obj) + return; + + if (*ptr) { + /* Unreference the old object */ + struct gl_transform_feedback_object *oldObj = *ptr; + + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; + + if (oldObj->RefCount == 0) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) + ctx->Driver.DeleteTransformFeedback(ctx, oldObj); + } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (obj) { + /* reference new object */ + if (obj->RefCount == 0) { + _mesa_problem(NULL, "referencing deleted transform feedback object"); + *ptr = NULL; + } + else { + obj->RefCount++; + *ptr = obj; + } + } +} + + +/** + * Check if the given primitive mode (as in glBegin(mode)) is compatible + * with the current transform feedback mode (if it's enabled). + * This is to be called from glBegin(), glDrawArrays(), glDrawElements(), etc. + * + * \return GL_TRUE if the mode is OK, GL_FALSE otherwise. + */ +GLboolean +_mesa_validate_primitive_mode(struct gl_context *ctx, GLenum mode) +{ + if (ctx->TransformFeedback.CurrentObject->Active) { + switch (mode) { + case GL_POINTS: + return ctx->TransformFeedback.Mode == GL_POINTS; + case GL_LINES: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + return ctx->TransformFeedback.Mode == GL_LINES; + default: + return ctx->TransformFeedback.Mode == GL_TRIANGLES; + } + } + return GL_TRUE; +} + + +/** + * Check that all the buffer objects currently bound for transform + * feedback actually exist. Raise a GL_INVALID_OPERATION error if + * any buffers are missing. + * \return GL_TRUE for success, GL_FALSE if error + */ +GLboolean +_mesa_validate_transform_feedback_buffers(struct gl_context *ctx) +{ + /* XXX to do */ + return GL_TRUE; +} + + + +/** + * Per-context init for transform feedback. + */ +void +_mesa_init_transform_feedback(struct gl_context *ctx) +{ + /* core mesa expects this, even a dummy one, to be available */ + ASSERT(ctx->Driver.NewTransformFeedback); + + ctx->TransformFeedback.DefaultObject = + ctx->Driver.NewTransformFeedback(ctx, 0); + + assert(ctx->TransformFeedback.DefaultObject->RefCount == 1); + + reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, + ctx->TransformFeedback.DefaultObject); + + assert(ctx->TransformFeedback.DefaultObject->RefCount == 2); + + ctx->TransformFeedback.Objects = _mesa_NewHashTable(); + + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + ctx->Shared->NullBufferObj); +} + + + +/** + * Callback for _mesa_HashDeleteAll(). + */ +static void +delete_cb(GLuint key, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_transform_feedback_object *obj = + (struct gl_transform_feedback_object *) data; + + ctx->Driver.DeleteTransformFeedback(ctx, obj); +} + + +/** + * Per-context free/clean-up for transform feedback. + */ +void +_mesa_free_transform_feedback(struct gl_context *ctx) +{ + /* core mesa expects this, even a dummy one, to be available */ + ASSERT(ctx->Driver.NewTransformFeedback); + + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + NULL); + + /* Delete all feedback objects */ + _mesa_HashDeleteAll(ctx->TransformFeedback.Objects, delete_cb, ctx); + _mesa_DeleteHashTable(ctx->TransformFeedback.Objects); + + /* Delete the default feedback object */ + assert(ctx->Driver.DeleteTransformFeedback); + ctx->Driver.DeleteTransformFeedback(ctx, + ctx->TransformFeedback.DefaultObject); + + ctx->TransformFeedback.CurrentObject = NULL; +} + + +#else /* FEATURE_EXT_transform_feedback */ + +/* forward declarations */ +static struct gl_transform_feedback_object * +new_transform_feedback(struct gl_context *ctx, GLuint name); + +static void +delete_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + +/* dummy per-context init/clean-up for transform feedback */ +void +_mesa_init_transform_feedback(struct gl_context *ctx) +{ + ctx->TransformFeedback.DefaultObject = new_transform_feedback(ctx, 0); + ctx->TransformFeedback.CurrentObject = ctx->TransformFeedback.DefaultObject; + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + ctx->Shared->NullBufferObj); +} + +void +_mesa_free_transform_feedback(struct gl_context *ctx) +{ + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + NULL); + ctx->TransformFeedback.CurrentObject = NULL; + delete_transform_feedback(ctx, ctx->TransformFeedback.DefaultObject); +} + +#endif /* FEATURE_EXT_transform_feedback */ + + +/** Default fallback for ctx->Driver.NewTransformFeedback() */ +static struct gl_transform_feedback_object * +new_transform_feedback(struct gl_context *ctx, GLuint name) +{ + struct gl_transform_feedback_object *obj; + obj = CALLOC_STRUCT(gl_transform_feedback_object); + if (obj) { + obj->Name = name; + obj->RefCount = 1; + } + return obj; +} + +/** Default fallback for ctx->Driver.DeleteTransformFeedback() */ +static void +delete_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj) +{ + GLuint i; + + for (i = 0; i < Elements(obj->Buffers); i++) { + _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); + } + + free(obj); +} + + +#if FEATURE_EXT_transform_feedback + + +/** Default fallback for ctx->Driver.BeginTransformFeedback() */ +static void +begin_transform_feedback(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.EndTransformFeedback() */ +static void +end_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.PauseTransformFeedback() */ +static void +pause_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.ResumeTransformFeedback() */ +static void +resume_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.DrawTransformFeedback() */ +static void +draw_transform_feedback(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* XXX to do */ + /* + * Get number of vertices in obj's feedback buffer. + * Call ctx->Exec.DrawArrays(mode, 0, count); + */ +} + + +/** + * Plug in default device driver functions for transform feedback. + * Most drivers will override some/all of these. + */ +void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver) +{ + driver->NewTransformFeedback = new_transform_feedback; + driver->DeleteTransformFeedback = delete_transform_feedback; + driver->BeginTransformFeedback = begin_transform_feedback; + driver->EndTransformFeedback = end_transform_feedback; + driver->PauseTransformFeedback = pause_transform_feedback; + driver->ResumeTransformFeedback = resume_transform_feedback; + driver->DrawTransformFeedback = draw_transform_feedback; +} + + +void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) +{ + SET_BeginTransformFeedbackEXT(disp, _mesa_BeginTransformFeedback); + SET_EndTransformFeedbackEXT(disp, _mesa_EndTransformFeedback); + SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange); + SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase); + SET_BindBufferOffsetEXT(disp, _mesa_BindBufferOffsetEXT); + SET_TransformFeedbackVaryingsEXT(disp, _mesa_TransformFeedbackVaryings); + SET_GetTransformFeedbackVaryingEXT(disp, _mesa_GetTransformFeedbackVarying); +} + + +/** + ** Begin API functions + **/ + + +void GLAPIENTRY +_mesa_BeginTransformFeedback(GLenum mode) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + switch (mode) { + case GL_POINTS: + case GL_LINES: + case GL_TRIANGLES: + /* legal */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBeginTransformFeedback(mode)"); + return; + } + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginTransformFeedback(already active)"); + return; + } + + obj->Active = GL_TRUE; + ctx->TransformFeedback.Mode = mode; + + assert(ctx->Driver.BeginTransformFeedback); + ctx->Driver.BeginTransformFeedback(ctx, mode, obj); +} + + +void GLAPIENTRY +_mesa_EndTransformFeedback(void) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndTransformFeedback(not active)"); + return; + } + + ctx->TransformFeedback.CurrentObject->Active = GL_FALSE; + + assert(ctx->Driver.EndTransformFeedback); + ctx->Driver.EndTransformFeedback(ctx, obj); +} + + +/** + * Helper used by BindBufferRange() and BindBufferBase(). + */ +static void +bind_buffer_range(struct gl_context *ctx, GLuint index, + struct gl_buffer_object *bufObj, + GLintptr offset, GLsizeiptr size) +{ + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + /* The general binding point */ + _mesa_reference_buffer_object(ctx, + &ctx->TransformFeedback.CurrentBuffer, + bufObj); + + /* The per-attribute binding point */ + _mesa_reference_buffer_object(ctx, + &obj->Buffers[index], + bufObj); + + obj->BufferNames[index] = bufObj->Name; + + obj->Offset[index] = offset; + obj->Size[index] = size; +} + + +/** + * Specify a buffer object to receive vertex shader results. Plus, + * specify the starting offset to place the results, and max size. + */ +void GLAPIENTRY +_mesa_BindBufferRange(GLenum target, GLuint index, + GLuint buffer, GLintptr offset, GLsizeiptr size) +{ + struct gl_transform_feedback_object *obj; + struct gl_buffer_object *bufObj; + GET_CURRENT_CONTEXT(ctx); + + if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)"); + return; + } + + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferRange(transform feedback active)"); + return; + } + + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index); + return; + } + + if ((size <= 0) || (size & 0x3)) { + /* must be positive and multiple of four */ + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) size); + return; + } + + if (offset & 0x3) { + /* must be multiple of four */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBufferRange(offset=%d)", (int) offset); + return; + } + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferRange(invalid buffer=%u)", buffer); + return; + } + + if (offset + size >= bufObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBufferRange(offset + size %d > buffer size %d)", + (int) (offset + size), (int) (bufObj->Size)); + return; + } + + bind_buffer_range(ctx, index, bufObj, offset, size); +} + + +/** + * Specify a buffer object to receive vertex shader results. + * As above, but start at offset = 0. + */ +void GLAPIENTRY +_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) +{ + struct gl_transform_feedback_object *obj; + struct gl_buffer_object *bufObj; + GLsizeiptr size; + GET_CURRENT_CONTEXT(ctx); + + if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)"); + return; + } + + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferRange(transform feedback active)"); + return; + } + + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferBase(index=%d)", index); + return; + } + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferBase(invalid buffer=%u)", buffer); + return; + } + + /* default size is the buffer size rounded down to nearest + * multiple of four. + */ + size = bufObj->Size & ~0x3; + + bind_buffer_range(ctx, index, bufObj, 0, size); +} + + +/** + * Specify a buffer object to receive vertex shader results, plus the + * offset in the buffer to start placing results. + * This function is part of GL_EXT_transform_feedback, but not GL3. + */ +void GLAPIENTRY +_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, + GLintptr offset) +{ + struct gl_transform_feedback_object *obj; + struct gl_buffer_object *bufObj; + GET_CURRENT_CONTEXT(ctx); + GLsizeiptr size; + + if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferOffsetEXT(target)"); + return; + } + + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferRange(transform feedback active)"); + return; + } + + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glBindBufferOffsetEXT(index=%d)", index); + return; + } + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindBufferOffsetEXT(invalid buffer=%u)", buffer); + return; + } + + /* default size is the buffer size rounded down to nearest + * multiple of four. + */ + size = (bufObj->Size - offset) & ~0x3; + + bind_buffer_range(ctx, index, bufObj, offset, size); +} + + +/** + * This function specifies the vertex shader outputs to be written + * to the feedback buffer(s), and in what order. + */ +void GLAPIENTRY +_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, + const GLchar **varyings, GLenum bufferMode) +{ + struct gl_shader_program *shProg; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + + switch (bufferMode) { + case GL_INTERLEAVED_ATTRIBS: + break; + case GL_SEPARATE_ATTRIBS: + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glTransformFeedbackVaryings(bufferMode)"); + return; + } + + if (count < 0 || count > ctx->Const.MaxTransformFeedbackSeparateAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTransformFeedbackVaryings(count=%d)", count); + return; + } + + shProg = _mesa_lookup_shader_program(ctx, program); + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTransformFeedbackVaryings(program=%u)", program); + return; + } + + /* free existing varyings, if any */ + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + free(shProg->TransformFeedback.VaryingNames[i]); + } + free(shProg->TransformFeedback.VaryingNames); + + /* allocate new memory for varying names */ + shProg->TransformFeedback.VaryingNames = + (GLchar **) malloc(count * sizeof(GLchar *)); + + if (!shProg->TransformFeedback.VaryingNames) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()"); + return; + } + + /* Save the new names and the count */ + for (i = 0; i < (GLuint) count; i++) { + shProg->TransformFeedback.VaryingNames[i] = _mesa_strdup(varyings[i]); + } + shProg->TransformFeedback.NumVarying = count; + + shProg->TransformFeedback.BufferMode = bufferMode; + + /* The varyings won't be used until shader link time */ +} + + +/** + * Get info about the vertex shader's outputs which are to be written + * to the feedback buffer(s). + */ +void GLAPIENTRY +_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, + GLsizei bufSize, GLsizei *length, + GLsizei *size, GLenum *type, GLchar *name) +{ + const struct gl_shader_program *shProg; + const GLchar *varyingName; + GLint v; + GET_CURRENT_CONTEXT(ctx); + + shProg = _mesa_lookup_shader_program(ctx, program); + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetTransformFeedbackVaryings(program=%u)", program); + return; + } + + if (index >= shProg->TransformFeedback.NumVarying) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetTransformFeedbackVaryings(index=%u)", index); + return; + } + + varyingName = shProg->TransformFeedback.VaryingNames[index]; + + v = _mesa_lookup_parameter_index(shProg->Varying, -1, varyingName); + if (v >= 0) { + struct gl_program_parameter *param = &shProg->Varying->Parameters[v]; + + /* return the varying's name and length */ + _mesa_copy_string(name, bufSize, length, varyingName); + + /* return the datatype and value's size (in datatype units) */ + if (type) + *type = param->DataType; + if (size) + *size = param->Size; + } + else { + name[0] = 0; + if (length) + *length = 0; + if (type) + *type = 0; + if (size) + *size = 0; + } +} + + + +static struct gl_transform_feedback_object * +lookup_transform_feedback_object(struct gl_context *ctx, GLuint name) +{ + if (name == 0) { + return ctx->TransformFeedback.DefaultObject; + } + else + return (struct gl_transform_feedback_object *) + _mesa_HashLookup(ctx->TransformFeedback.Objects, name); +} + + +/** + * Create new transform feedback objects. Transform feedback objects + * encapsulate the state related to transform feedback to allow quickly + * switching state (and drawing the results, below). + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) +{ + GLuint first; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)"); + return; + } + + if (!names) + return; + + /* we don't need contiguous IDs, but this might be faster */ + first = _mesa_HashFindFreeKeyBlock(ctx->TransformFeedback.Objects, n); + if (first) { + GLsizei i; + for (i = 0; i < n; i++) { + struct gl_transform_feedback_object *obj + = ctx->Driver.NewTransformFeedback(ctx, first + i); + if (!obj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + return; + } + names[i] = first + i; + _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj); + } + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + } +} + + +/** + * Is the given ID a transform feedback object? + * Part of GL_ARB_transform_feedback2. + */ +GLboolean GLAPIENTRY +_mesa_IsTransformFeedback(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (name && lookup_transform_feedback_object(ctx, name)) + return GL_TRUE; + else + return GL_FALSE; +} + + +/** + * Bind the given transform feedback object. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_BindTransformFeedback(GLenum target, GLuint name) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + if (target != GL_TRANSFORM_FEEDBACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindTransformFeedback(target)"); + return; + } + + if (ctx->TransformFeedback.CurrentObject->Active && + !ctx->TransformFeedback.CurrentObject->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindTransformFeedback(transform is active, or not paused)"); + return; + } + + obj = lookup_transform_feedback_object(ctx, name); + if (!obj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindTransformFeedback(name=%u)", name); + return; + } + + reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, + obj); +} + + +/** + * Delete the given transform feedback objects. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteTransformFeedbacks(n < 0)"); + return; + } + + if (!names) + return; + + for (i = 0; i < n; i++) { + if (names[i] > 0) { + struct gl_transform_feedback_object *obj + = lookup_transform_feedback_object(ctx, names[i]); + if (obj) { + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDeleteTransformFeedbacks(object %u is active)", + names[i]); + return; + } + _mesa_HashRemove(ctx->TransformFeedback.Objects, names[i]); + /* unref, but object may not be deleted until later */ + reference_transform_feedback_object(&obj, NULL); + } + } + } +} + + +/** + * Pause transform feedback. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_PauseTransformFeedback(void) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active || obj->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPauseTransformFeedback(feedback not active or already paused)"); + return; + } + + obj->Paused = GL_TRUE; + + assert(ctx->Driver.PauseTransformFeedback); + ctx->Driver.PauseTransformFeedback(ctx, obj); +} + + +/** + * Resume transform feedback. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_ResumeTransformFeedback(void) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active || !obj->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPauseTransformFeedback(feedback not active or not paused)"); + return; + } + + obj->Paused = GL_FALSE; + + assert(ctx->Driver.ResumeTransformFeedback); + ctx->Driver.ResumeTransformFeedback(ctx, obj); +} + + +/** + * Draw the vertex data in a transform feedback object. + * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc. + * \param name the transform feedback object + * The number of vertices comes from the transform feedback object. + * User still has to setup of the vertex attribute info with + * glVertexPointer, glColorPointer, etc. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_DrawTransformFeedback(GLenum mode, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_transform_feedback_object *obj = + lookup_transform_feedback_object(ctx, name); + + if (mode > GL_POLYGON) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDrawTransformFeedback(mode=0x%x)", mode); + return; + } + if (!obj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawTransformFeedback(name = %u)", name); + return; + } + + /* XXX check if EndTransformFeedback has never been called while + * the object was bound + */ + + assert(ctx->Driver.DrawTransformFeedback); + ctx->Driver.DrawTransformFeedback(ctx, mode, obj); +} + + +/* +XXX misc to do: + +glGet*() for + +GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED +GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE +GL_TRANSFORM_FEEDBACK_BINDING +*/ + + +#endif /* FEATURE_EXT_transform_feedback */ diff --git a/mesalib/src/mesa/main/transformfeedback.h b/mesalib/src/mesa/main/transformfeedback.h index 4d38522d6..add8d22d6 100644 --- a/mesalib/src/mesa/main/transformfeedback.h +++ b/mesalib/src/mesa/main/transformfeedback.h @@ -1,132 +1,137 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. - */ - - -#ifndef TRANSFORM_FEEDBACK_H -#define TRANSFORM_FEEDBACK_H - -#include "main/mtypes.h" - - -extern void -_mesa_init_transform_feedback(GLcontext *ctx); - -extern void -_mesa_free_transform_feedback(GLcontext *ctx); - -#if FEATURE_EXT_transform_feedback - -extern GLboolean -_mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode); - -extern GLboolean -_mesa_validate_transform_feedback_buffers(GLcontext *ctx); - - -extern void -_mesa_init_transform_feedback_functions(struct dd_function_table *driver); - -extern void -_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp); - - -/*** GL_EXT_transform_feedback ***/ - -extern void GLAPIENTRY -_mesa_BeginTransformFeedback(GLenum mode); - -extern void GLAPIENTRY -_mesa_EndTransformFeedback(void); - -extern void GLAPIENTRY -_mesa_BindBufferRange(GLenum target, GLuint index, - GLuint buffer, GLintptr offset, GLsizeiptr size); - -extern void GLAPIENTRY -_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer); - -extern void GLAPIENTRY -_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, - GLintptr offset); - -extern void GLAPIENTRY -_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, - const GLchar **varyings, GLenum bufferMode); - -extern void GLAPIENTRY -_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, - GLsizei bufSize, GLsizei *length, - GLsizei *size, GLenum *type, GLchar *name); - - - -/*** GL_ARB_transform_feedback2 ***/ - -extern void GLAPIENTRY -_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); - -extern GLboolean GLAPIENTRY -_mesa_IsTransformFeedback(GLuint name); - -extern void GLAPIENTRY -_mesa_BindTransformFeedback(GLenum target, GLuint name); - -extern void GLAPIENTRY -_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names); - -extern void GLAPIENTRY -_mesa_PauseTransformFeedback(void); - -extern void GLAPIENTRY -_mesa_ResumeTransformFeedback(void); - -extern void GLAPIENTRY -_mesa_DrawTransformFeedback(GLenum mode, GLuint name); - -#else /* FEATURE_EXT_transform_feedback */ - -static INLINE GLboolean -_mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode) -{ - return GL_TRUE; -} - -static INLINE GLboolean -_mesa_validate_transform_feedback_buffers(GLcontext *ctx) -{ - return GL_TRUE; -} - -static INLINE void -_mesa_init_transform_feedback_functions(struct dd_function_table *driver) -{ -} - -static INLINE void -_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_EXT_transform_feedback */ - -#endif /* TRANSFORM_FEEDBACK_H */ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +#ifndef TRANSFORM_FEEDBACK_H +#define TRANSFORM_FEEDBACK_H + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; +struct dd_function_table; +struct gl_context; + +extern void +_mesa_init_transform_feedback(struct gl_context *ctx); + +extern void +_mesa_free_transform_feedback(struct gl_context *ctx); + +#if FEATURE_EXT_transform_feedback + +extern GLboolean +_mesa_validate_primitive_mode(struct gl_context *ctx, GLenum mode); + +extern GLboolean +_mesa_validate_transform_feedback_buffers(struct gl_context *ctx); + + +extern void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver); + +extern void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp); + + +/*** GL_EXT_transform_feedback ***/ + +extern void GLAPIENTRY +_mesa_BeginTransformFeedback(GLenum mode); + +extern void GLAPIENTRY +_mesa_EndTransformFeedback(void); + +extern void GLAPIENTRY +_mesa_BindBufferRange(GLenum target, GLuint index, + GLuint buffer, GLintptr offset, GLsizeiptr size); + +extern void GLAPIENTRY +_mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer); + +extern void GLAPIENTRY +_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, + GLintptr offset); + +extern void GLAPIENTRY +_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, + const GLchar **varyings, GLenum bufferMode); + +extern void GLAPIENTRY +_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, + GLsizei bufSize, GLsizei *length, + GLsizei *size, GLenum *type, GLchar *name); + + + +/*** GL_ARB_transform_feedback2 ***/ + +extern void GLAPIENTRY +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); + +extern GLboolean GLAPIENTRY +_mesa_IsTransformFeedback(GLuint name); + +extern void GLAPIENTRY +_mesa_BindTransformFeedback(GLenum target, GLuint name); + +extern void GLAPIENTRY +_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names); + +extern void GLAPIENTRY +_mesa_PauseTransformFeedback(void); + +extern void GLAPIENTRY +_mesa_ResumeTransformFeedback(void); + +extern void GLAPIENTRY +_mesa_DrawTransformFeedback(GLenum mode, GLuint name); + +#else /* FEATURE_EXT_transform_feedback */ + +static INLINE GLboolean +_mesa_validate_primitive_mode(struct gl_context *ctx, GLenum mode) +{ + return GL_TRUE; +} + +static INLINE GLboolean +_mesa_validate_transform_feedback_buffers(struct gl_context *ctx) +{ + return GL_TRUE; +} + +static INLINE void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver) +{ +} + +static INLINE void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_EXT_transform_feedback */ + +#endif /* TRANSFORM_FEEDBACK_H */ diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index a5d7da51f..a6fdabea7 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -1,1382 +1,1662 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file uniforms.c - * Functions related to GLSL uniform variables. - * \author Brian Paul - */ - -/** - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "main/uniforms.h" -#include "program/prog_parameter.h" -#include "program/prog_statevars.h" -#include "program/prog_uniform.h" - - - -static GLenum -base_uniform_type(GLenum type) -{ - switch (type) { -#if 0 /* not needed, for now */ - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - return GL_BOOL; -#endif - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: - return GL_FLOAT; - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_VEC2: - case GL_UNSIGNED_INT_VEC3: - case GL_UNSIGNED_INT_VEC4: - return GL_UNSIGNED_INT; - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: - return GL_INT; - default: - _mesa_problem(NULL, "Invalid type in base_uniform_type()"); - return GL_FLOAT; - } -} - - -static GLboolean -is_boolean_type(GLenum type) -{ - switch (type) { - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -static GLboolean -is_sampler_type(GLenum type) -{ - switch (type) { - case GL_SAMPLER_1D: - case GL_SAMPLER_2D: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_2D_RECT_ARB: - case GL_SAMPLER_2D_RECT_SHADOW_ARB: - case GL_SAMPLER_1D_ARRAY_EXT: - case GL_SAMPLER_2D_ARRAY_EXT: - case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -static struct gl_program_parameter * -get_uniform_parameter(const struct gl_shader_program *shProg, GLuint index) -{ - const struct gl_program *prog = NULL; - GLint progPos; - - progPos = shProg->Uniforms->Uniforms[index].VertPos; - if (progPos >= 0) { - prog = &shProg->VertexProgram->Base; - } - else { - progPos = shProg->Uniforms->Uniforms[index].FragPos; - if (progPos >= 0) { - prog = &shProg->FragmentProgram->Base; - } else { - progPos = shProg->Uniforms->Uniforms[index].GeomPos; - if (progPos >= 0) { - prog = &shProg->GeometryProgram->Base; - } - } - } - - if (!prog || progPos < 0) - return NULL; /* should never happen */ - - return &prog->Parameters->Parameters[progPos]; -} - - -/** - * Called by glGetActiveUniform(). - */ -static void -_mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLchar *nameOut) -{ - const struct gl_shader_program *shProg; - const struct gl_program *prog = NULL; - const struct gl_program_parameter *param; - GLint progPos; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); - if (!shProg) - return; - - if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); - return; - } - - progPos = shProg->Uniforms->Uniforms[index].VertPos; - if (progPos >= 0) { - prog = &shProg->VertexProgram->Base; - } - else { - progPos = shProg->Uniforms->Uniforms[index].FragPos; - if (progPos >= 0) { - prog = &shProg->FragmentProgram->Base; - } else { - progPos = shProg->Uniforms->Uniforms[index].GeomPos; - if (progPos >= 0) { - prog = &shProg->GeometryProgram->Base; - } - } - } - - if (!prog || progPos < 0) - return; /* should never happen */ - - ASSERT(progPos < prog->Parameters->NumParameters); - param = &prog->Parameters->Parameters[progPos]; - - if (nameOut) { - _mesa_copy_string(nameOut, maxLength, length, param->Name); - } - - if (size) { - GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - if ((GLint) param->Size > typeSize) { - /* This is an array. - * Array elements are placed on vector[4] boundaries so they're - * a multiple of four floats. We round typeSize up to next multiple - * of four to get the right size below. - */ - typeSize = (typeSize + 3) & ~3; - } - /* Note that the returned size is in units of the , not bytes */ - *size = param->Size / typeSize; - } - - if (type) { - *type = param->DataType; - } -} - - - -static void -get_matrix_dims(GLenum type, GLint *rows, GLint *cols) -{ - switch (type) { - case GL_FLOAT_MAT2: - *rows = *cols = 2; - break; - case GL_FLOAT_MAT2x3: - *rows = 3; - *cols = 2; - break; - case GL_FLOAT_MAT2x4: - *rows = 4; - *cols = 2; - break; - case GL_FLOAT_MAT3: - *rows = 3; - *cols = 3; - break; - case GL_FLOAT_MAT3x2: - *rows = 2; - *cols = 3; - break; - case GL_FLOAT_MAT3x4: - *rows = 4; - *cols = 3; - break; - case GL_FLOAT_MAT4: - *rows = 4; - *cols = 4; - break; - case GL_FLOAT_MAT4x2: - *rows = 2; - *cols = 4; - break; - case GL_FLOAT_MAT4x3: - *rows = 3; - *cols = 4; - break; - default: - *rows = *cols = 0; - } -} - - -/** - * Determine the number of rows and columns occupied by a uniform - * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4), - * the number of rows = 1 and cols = number of elements in the vector. - */ -static void -get_uniform_rows_cols(const struct gl_program_parameter *p, - GLint *rows, GLint *cols) -{ - get_matrix_dims(p->DataType, rows, cols); - if (*rows == 0 && *cols == 0) { - /* not a matrix type, probably a float or vector */ - if (p->Size <= 4) { - *rows = 1; - *cols = p->Size; - } - else { - *rows = p->Size / 4 + 1; - if (p->Size % 4 == 0) - *cols = 4; - else - *cols = p->Size % 4; - } - } -} - - -/** - * Helper for get_uniform[fi]v() functions. - * Given a shader program name and uniform location, return a pointer - * to the shader program and return the program parameter position. - */ -static void -lookup_uniform_parameter(GLcontext *ctx, GLuint program, GLint location, - struct gl_program **progOut, GLint *paramPosOut) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program_err(ctx, program, "glGetUniform[if]v"); - struct gl_program *prog = NULL; - GLint progPos = -1; - - /* if shProg is NULL, we'll have already recorded an error */ - - if (shProg) { - if (!shProg->Uniforms || - location < 0 || - location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(location)"); - } - else { - /* OK, find the gl_program and program parameter location */ - progPos = shProg->Uniforms->Uniforms[location].VertPos; - if (progPos >= 0) { - prog = &shProg->VertexProgram->Base; - } - else { - progPos = shProg->Uniforms->Uniforms[location].FragPos; - if (progPos >= 0) { - prog = &shProg->FragmentProgram->Base; - } else { - progPos = shProg->Uniforms->Uniforms[location].GeomPos; - if (progPos >= 0) { - prog = &shProg->GeometryProgram->Base; - } - } - } - } - } - - *progOut = prog; - *paramPosOut = progPos; -} - - -/** - * GLGL uniform arrays and structs require special handling. - * - * The GL_ARB_shader_objects spec says that if you use - * glGetUniformLocation to get the location of an array, you CANNOT - * access other elements of the array by adding an offset to the - * returned location. For example, you must call - * glGetUniformLocation("foo[16]") if you want to set the 16th element - * of the array with glUniform(). - * - * HOWEVER, some other OpenGL drivers allow accessing array elements - * by adding an offset to the returned array location. And some apps - * seem to depend on that behaviour. - * - * Mesa's gl_uniform_list doesn't directly support this since each - * entry in the list describes one uniform variable, not one uniform - * element. We could insert dummy entries in the list for each array - * element after [0] but that causes complications elsewhere. - * - * We solve this problem by encoding two values in the location that's - * returned by glGetUniformLocation(): - * a) index into gl_uniform_list::Uniforms[] for the uniform - * b) an array/field offset (0 for simple types) - * - * These two values are encoded in the high and low halves of a GLint. - * By putting the uniform number in the high part and the offset in the - * low part, we can support the unofficial ability to index into arrays - * by adding offsets to the location value. - */ -static void -merge_location_offset(GLint *location, GLint offset) -{ - *location = (*location << 16) | offset; -} - - -/** - * Separate the uniform location and parameter offset. See above. - */ -static void -split_location_offset(GLint *location, GLint *offset) -{ - *offset = *location & 0xffff; - *location = *location >> 16; -} - - - -/** - * Called via glGetUniformfv(). - */ -static void -_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location, - GLfloat *params) -{ - struct gl_program *prog; - GLint paramPos; - GLint offset; - - split_location_offset(&location, &offset); - - lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos); - - if (prog) { - const struct gl_program_parameter *p = - &prog->Parameters->Parameters[paramPos]; - GLint rows, cols, i, j, k; - - get_uniform_rows_cols(p, &rows, &cols); - - k = 0; - for (i = 0; i < rows; i++) { - for (j = 0; j < cols; j++ ) { - params[k++] = prog->Parameters->ParameterValues[paramPos+i][j]; - } - } - } -} - - -/** - * Called via glGetUniformiv(). - * \sa _mesa_get_uniformfv, only difference is a cast. - */ -static void -_mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location, - GLint *params) -{ - struct gl_program *prog; - GLint paramPos; - GLint offset; - - split_location_offset(&location, &offset); - - lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos); - - if (prog) { - const struct gl_program_parameter *p = - &prog->Parameters->Parameters[paramPos]; - GLint rows, cols, i, j, k; - - get_uniform_rows_cols(p, &rows, &cols); - - k = 0; - for (i = 0; i < rows; i++) { - for (j = 0; j < cols; j++ ) { - params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j]; - } - } - } -} - - -/** - * Called via glGetUniformLocation(). - * - * The return value will encode two values, the uniform location and an - * offset (used for arrays, structs). - */ -GLint -_mesa_get_uniform_location(GLcontext *ctx, struct gl_shader_program *shProg, - const GLchar *name) -{ - GLint offset = 0, location = -1; - - if (shProg->LinkStatus == GL_FALSE) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)"); - return -1; - } - - /* XXX we should return -1 if the uniform was declared, but not - * actually used. - */ - - /* XXX we need to be able to parse uniform names for structs and arrays - * such as: - * mymatrix[1] - * mystruct.field1 - */ - - { - /* handle 1-dimension arrays here... */ - char *c = strchr(name, '['); - if (c) { - /* truncate name at [ */ - const GLint len = c - name; - GLchar *newName = malloc(len + 1); - if (!newName) - return -1; /* out of mem */ - memcpy(newName, name, len); - newName[len] = 0; - - location = _mesa_lookup_uniform(shProg->Uniforms, newName); - if (location >= 0) { - const GLint element = atoi(c + 1); - if (element > 0) { - /* get type of the uniform array element */ - struct gl_program_parameter *p; - p = get_uniform_parameter(shProg, location); - if (p) { - GLint rows, cols; - get_matrix_dims(p->DataType, &rows, &cols); - if (rows < 1) - rows = 1; - offset = element * rows; - } - } - } - - free(newName); - } - } - - if (location < 0) { - location = _mesa_lookup_uniform(shProg->Uniforms, name); - } - - if (location >= 0) { - merge_location_offset(&location, offset); - } - - return location; -} - - - -/** - * Update the vertex/fragment program's TexturesUsed array. - * - * This needs to be called after glUniform(set sampler var) is called. - * A call to glUniform(samplerVar, value) causes a sampler to point to a - * particular texture unit. We know the sampler's texture target - * (1D/2D/3D/etc) from compile time but the sampler's texture unit is - * set by glUniform() calls. - * - * So, scan the program->SamplerUnits[] and program->SamplerTargets[] - * information to update the prog->TexturesUsed[] values. - * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, - * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. - * We'll use that info for state validation before rendering. - */ -void -_mesa_update_shader_textures_used(struct gl_program *prog) -{ - GLuint s; - - memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); - - for (s = 0; s < MAX_SAMPLERS; s++) { - if (prog->SamplersUsed & (1 << s)) { - GLuint unit = prog->SamplerUnits[s]; - GLuint tgt = prog->SamplerTargets[s]; - assert(unit < MAX_TEXTURE_IMAGE_UNITS); - assert(tgt < NUM_TEXTURE_TARGETS); - prog->TexturesUsed[unit] |= (1 << tgt); - } - } -} - - -/** - * Check if the type given by userType is allowed to set a uniform of the - * target type. Generally, equivalence is required, but setting Boolean - * uniforms can be done with glUniformiv or glUniformfv. - */ -static GLboolean -compatible_types(GLenum userType, GLenum targetType) -{ - if (userType == targetType) - return GL_TRUE; - - if (targetType == GL_BOOL && (userType == GL_FLOAT || - userType == GL_UNSIGNED_INT || - userType == GL_INT)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC2 && (userType == GL_FLOAT_VEC2 || - userType == GL_UNSIGNED_INT_VEC2 || - userType == GL_INT_VEC2)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC3 && (userType == GL_FLOAT_VEC3 || - userType == GL_UNSIGNED_INT_VEC3 || - userType == GL_INT_VEC3)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC4 && (userType == GL_FLOAT_VEC4 || - userType == GL_UNSIGNED_INT_VEC4 || - userType == GL_INT_VEC4)) - return GL_TRUE; - - if (is_sampler_type(targetType) && userType == GL_INT) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Set the value of a program's uniform variable. - * \param program the program whose uniform to update - * \param index the index of the program parameter for the uniform - * \param offset additional parameter slot offset (for arrays) - * \param type the incoming datatype of 'values' - * \param count the number of uniforms to set - * \param elems number of elements per uniform (1, 2, 3 or 4) - * \param values the new values, of datatype 'type' - */ -static void -set_program_uniform(GLcontext *ctx, struct gl_program *program, - GLint index, GLint offset, - GLenum type, GLsizei count, GLint elems, - const void *values) -{ - const struct gl_program_parameter *param = - &program->Parameters->Parameters[index]; - - assert(offset >= 0); - assert(elems >= 1); - assert(elems <= 4); - - if (!compatible_types(type, param->DataType)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); - return; - } - - if (index + offset > (GLint) program->Parameters->Size) { - /* out of bounds! */ - return; - } - - if (param->Type == PROGRAM_SAMPLER) { - /* This controls which texture unit which is used by a sampler */ - GLboolean changed = GL_FALSE; - GLint i; - - /* this should have been caught by the compatible_types() check */ - ASSERT(type == GL_INT); - - /* loop over number of samplers to change */ - for (i = 0; i < count; i++) { - GLuint sampler = - (GLuint) program->Parameters->ParameterValues[index + offset + i][0]; - GLuint texUnit = ((GLuint *) values)[i]; - - /* check that the sampler (tex unit index) is legal */ - if (texUnit >= ctx->Const.MaxTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glUniform1(invalid sampler/tex unit index for '%s')", - param->Name); - return; - } - - /* This maps a sampler to a texture unit: */ - if (sampler < MAX_SAMPLERS) { -#if 0 - printf("Set program %p sampler %d '%s' to unit %u\n", - program, sampler, param->Name, texUnit); -#endif - if (program->SamplerUnits[sampler] != texUnit) { - program->SamplerUnits[sampler] = texUnit; - changed = GL_TRUE; - } - } - } - - if (changed) { - /* When a sampler's value changes it usually requires rewriting - * a GPU program's TEX instructions since there may not be a - * sampler->texture lookup table. We signal this with the - * ProgramStringNotify() callback. - */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); - _mesa_update_shader_textures_used(program); - /* Do we need to care about the return value here? - * This should not be the first time the driver was notified of - * this program. - */ - (void) ctx->Driver.ProgramStringNotify(ctx, program->Target, program); - } - } - else { - /* ordinary uniform variable */ - const GLboolean isUniformBool = is_boolean_type(param->DataType); - const GLenum basicType = base_uniform_type(type); - const GLint slots = (param->Size + 3) / 4; - const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - GLsizei k, i; - - if ((GLint) param->Size > typeSize) { - /* an array */ - /* we'll ignore extra data below */ - } - else { - /* non-array: count must be at most one; count == 0 is handled by the loop below */ - if (count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniform(uniform '%s' is not an array)", - param->Name); - return; - } - } - - /* loop over number of array elements */ - for (k = 0; k < count; k++) { - GLfloat *uniformVal; - - if (offset + k >= slots) { - /* Extra array data is ignored */ - break; - } - - /* uniformVal (the destination) is always float[4] */ - uniformVal = program->Parameters->ParameterValues[index + offset + k]; - - if (basicType == GL_INT) { - /* convert user's ints to floats */ - const GLint *iValues = ((const GLint *) values) + k * elems; - for (i = 0; i < elems; i++) { - uniformVal[i] = (GLfloat) iValues[i]; - } - } - else if (basicType == GL_UNSIGNED_INT) { - /* convert user's uints to floats */ - const GLuint *iValues = ((const GLuint *) values) + k * elems; - for (i = 0; i < elems; i++) { - uniformVal[i] = (GLfloat) iValues[i]; - } - } - else { - const GLfloat *fValues = ((const GLfloat *) values) + k * elems; - assert(basicType == GL_FLOAT); - for (i = 0; i < elems; i++) { - uniformVal[i] = fValues[i]; - } - } - - /* if the uniform is bool-valued, convert to 1.0 or 0.0 */ - if (isUniformBool) { - for (i = 0; i < elems; i++) { - uniformVal[i] = uniformVal[i] ? 1.0f : 0.0f; - } - } - } - } -} - - -/** - * Called via glUniform*() functions. - */ -void -_mesa_uniform(GLcontext *ctx, struct gl_shader_program *shProg, - GLint location, GLsizei count, - const GLvoid *values, GLenum type) -{ - struct gl_uniform *uniform; - GLint elems, offset; - - if (!shProg || !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(program not linked)"); - return; - } - - if (location == -1) - return; /* The standard specifies this as a no-op */ - - if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location=%d)", - location); - return; - } - - split_location_offset(&location, &offset); - - if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location=%d)", location); - return; - } - - if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(count < 0)"); - return; - } - - elems = _mesa_sizeof_glsl_type(type); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - uniform = &shProg->Uniforms->Uniforms[location]; - - if (ctx->Shader.Flags & GLSL_UNIFORMS) { - const GLenum basicType = base_uniform_type(type); - GLint i; - printf("Mesa: set program %u uniform %s (loc %d) to: ", - shProg->Name, uniform->Name, location); - if (basicType == GL_INT) { - const GLint *v = (const GLint *) values; - for (i = 0; i < count * elems; i++) { - printf("%d ", v[i]); - } - } - else if (basicType == GL_UNSIGNED_INT) { - const GLuint *v = (const GLuint *) values; - for (i = 0; i < count * elems; i++) { - printf("%u ", v[i]); - } - } - else { - const GLfloat *v = (const GLfloat *) values; - assert(basicType == GL_FLOAT); - for (i = 0; i < count * elems; i++) { - printf("%g ", v[i]); - } - } - printf("\n"); - } - - /* A uniform var may be used by both a vertex shader and a fragment - * shader. We may need to update one or both shader's uniform here: - */ - if (shProg->VertexProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->VertPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->VertexProgram->Base, - index, offset, type, count, elems, values); - } - } - - if (shProg->FragmentProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->FragPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->FragmentProgram->Base, - index, offset, type, count, elems, values); - } - } - - if (shProg->GeometryProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->GeomPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->GeometryProgram->Base, - index, offset, type, count, elems, values); - } - } - - uniform->Initialized = GL_TRUE; -} - - -/** - * Set a matrix-valued program parameter. - */ -static void -set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, - GLuint index, GLuint offset, - GLuint count, GLuint rows, GLuint cols, - GLboolean transpose, const GLfloat *values) -{ - GLuint mat, row, col; - GLuint src = 0; - const struct gl_program_parameter * param = &program->Parameters->Parameters[index]; - const GLuint slots = (param->Size + 3) / 4; - const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - GLint nr, nc; - - /* check that the number of rows, columns is correct */ - get_matrix_dims(param->DataType, &nr, &nc); - if (rows != nr || cols != nc) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(matrix size mismatch)"); - return; - } - - if ((GLint) param->Size <= typeSize) { - /* non-array: count must be at most one; count == 0 is handled by the loop below */ - if (count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(uniform is not an array)"); - return; - } - } - - /* - * Note: the _columns_ of a matrix are stored in program registers, not - * the rows. So, the loops below look a little funny. - * XXX could optimize this a bit... - */ - - /* loop over matrices */ - for (mat = 0; mat < count; mat++) { - - /* each matrix: */ - for (col = 0; col < cols; col++) { - GLfloat *v; - if (offset >= slots) { - /* Ignore writes beyond the end of (the used part of) an array */ - return; - } - v = program->Parameters->ParameterValues[index + offset]; - for (row = 0; row < rows; row++) { - if (transpose) { - v[row] = values[src + row * cols + col]; - } - else { - v[row] = values[src + col * rows + row]; - } - } - - offset++; - } - - src += rows * cols; /* next matrix */ - } -} - - -/** - * Called by glUniformMatrix*() functions. - * Note: cols=2, rows=4 ==> array[2] of vec4 - */ -void -_mesa_uniform_matrix(GLcontext *ctx, struct gl_shader_program *shProg, - GLint cols, GLint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values) -{ - struct gl_uniform *uniform; - GLint offset; - - if (!shProg || !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(program not linked)"); - return; - } - - if (location == -1) - return; /* The standard specifies this as a no-op */ - - if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformMatrix(location)"); - return; - } - - split_location_offset(&location, &offset); - - if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(location)"); - return; - } - if (values == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - uniform = &shProg->Uniforms->Uniforms[location]; - - if (shProg->VertexProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->VertPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - if (shProg->FragmentProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->FragPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - if (shProg->GeometryProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->GeomPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - uniform->Initialized = GL_TRUE; -} - - -void GLAPIENTRY -_mesa_Uniform1fARB(GLint location, GLfloat v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, - GLfloat v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1iARB(GLint location, GLint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC4); -} - - -/** OpenGL 3.0 GLuint-valued functions **/ -void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC4); -} - - - -void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 2, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 3, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 4, 4, location, count, transpose, value); -} - - -/** - * Non-square UniformMatrix are OpenGL 2.1 - */ -void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 2, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 3, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 2, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 4, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 3, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram, - 4, 3, location, count, transpose, value); -} - - -void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_uniformfv(ctx, program, location, params); -} - - -void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_uniformiv(ctx, program, location, params); -} - - -GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) -{ - struct gl_shader_program *shProg; - - GET_CURRENT_CONTEXT(ctx); - - shProg = _mesa_lookup_shader_program_err(ctx, programObj, - "glGetUniformLocation"); - if (!shProg) - return -1; - - return _mesa_get_uniform_location(ctx, shProg, name); -} - - -void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_active_uniform(ctx, program, index, maxLength, length, size, - type, name); -} - - -/** - * Plug in shader uniform-related functions into API dispatch table. - */ -void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - SET_Uniform1fARB(exec, _mesa_Uniform1fARB); - SET_Uniform2fARB(exec, _mesa_Uniform2fARB); - SET_Uniform3fARB(exec, _mesa_Uniform3fARB); - SET_Uniform4fARB(exec, _mesa_Uniform4fARB); - SET_Uniform1iARB(exec, _mesa_Uniform1iARB); - SET_Uniform2iARB(exec, _mesa_Uniform2iARB); - SET_Uniform3iARB(exec, _mesa_Uniform3iARB); - SET_Uniform4iARB(exec, _mesa_Uniform4iARB); - SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB); - SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB); - SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB); - SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB); - SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB); - SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB); - SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB); - SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB); - SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB); - - SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB); - SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB); - SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB); - SET_GetUniformivARB(exec, _mesa_GetUniformivARB); - - /* OpenGL 2.1 */ - SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); - - /* OpenGL 3.0 */ - /* XXX finish dispatch */ - (void) _mesa_Uniform1ui; - (void) _mesa_Uniform2ui; - (void) _mesa_Uniform3ui; - (void) _mesa_Uniform4ui; - (void) _mesa_Uniform1uiv; - (void) _mesa_Uniform2uiv; - (void) _mesa_Uniform3uiv; - (void) _mesa_Uniform4uiv; -#endif /* FEATURE_GL */ -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file uniforms.c + * Functions related to GLSL uniform variables. + * \author Brian Paul + */ + +/** + * XXX things to do: + * 1. Check that the right error code is generated for all _mesa_error() calls. + * 2. Insert FLUSH_VERTICES calls in various places + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "main/uniforms.h" +#include "program/prog_parameter.h" +#include "program/prog_statevars.h" +#include "program/prog_uniform.h" +#include "program/prog_instruction.h" + + +static GLenum +base_uniform_type(GLenum type) +{ + switch (type) { +#if 0 /* not needed, for now */ + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + return GL_BOOL; +#endif + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + return GL_FLOAT; + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + return GL_UNSIGNED_INT; + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + return GL_INT; + default: + _mesa_problem(NULL, "Invalid type in base_uniform_type()"); + return GL_FLOAT; + } +} + +static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { + {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, + {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, + {"diff", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_ClipPlane_elements[] = { + {NULL, {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW} +}; + +static struct gl_builtin_uniform_element gl_Point_elements[] = { + {"size", {STATE_POINT_SIZE}, SWIZZLE_XXXX}, + {"sizeMin", {STATE_POINT_SIZE}, SWIZZLE_YYYY}, + {"sizeMax", {STATE_POINT_SIZE}, SWIZZLE_ZZZZ}, + {"fadeThresholdSize", {STATE_POINT_SIZE}, SWIZZLE_WWWW}, + {"distanceConstantAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX}, + {"distanceLinearAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY}, + {"distanceQuadraticAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { + {"emission", {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, + {"ambient", {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"shininess", {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX}, +}; + +static struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { + {"emission", {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, + {"ambient", {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"shininess", {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX}, +}; + +static struct gl_builtin_uniform_element gl_LightSource_elements[] = { + {"ambient", {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, + {"position", {STATE_LIGHT, 0, STATE_POSITION}, SWIZZLE_XYZW}, + {"halfVector", {STATE_LIGHT, 0, STATE_HALF_VECTOR}, SWIZZLE_XYZW}, + {"spotDirection", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, + MAKE_SWIZZLE4(SWIZZLE_X, + SWIZZLE_Y, + SWIZZLE_Z, + SWIZZLE_Z)}, + {"spotCosCutoff", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW}, + {"spotCutoff", {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX}, + {"spotExponent", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW}, + {"constantAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX}, + {"linearAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY}, + {"quadraticAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ}, +}; + +static struct gl_builtin_uniform_element gl_LightModel_elements[] = { + {"ambient", {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_FrontLightModelProduct_elements[] = { + {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_BackLightModelProduct_elements[] = { + {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_FrontLightProduct_elements[] = { + {"ambient", {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHTPROD, 0, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHTPROD, 0, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_BackLightProduct_elements[] = { + {"ambient", {STATE_LIGHTPROD, 0, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, + {"diffuse", {STATE_LIGHTPROD, 0, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, + {"specular", {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_TextureEnvColor_elements[] = { + {NULL, {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneS_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_S}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneT_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_T}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneR_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_R}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_EyePlaneQ_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_Q}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneS_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_S}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneT_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_T}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneR_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_R}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_ObjectPlaneQ_elements[] = { + {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW}, +}; + +static struct gl_builtin_uniform_element gl_Fog_elements[] = { + {"color", {STATE_FOG_COLOR}, SWIZZLE_XYZW}, + {"density", {STATE_FOG_PARAMS}, SWIZZLE_XXXX}, + {"start", {STATE_FOG_PARAMS}, SWIZZLE_YYYY}, + {"end", {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ}, + {"scale", {STATE_FOG_PARAMS}, SWIZZLE_WWWW}, +}; + +static struct gl_builtin_uniform_element gl_NormalScale_elements[] = { + {NULL, {STATE_NORMAL_SCALE}, SWIZZLE_XXXX}, +}; + +#define MATRIX(name, statevar, modifier) \ + static struct gl_builtin_uniform_element name ## _elements[] = { \ + { NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 1, 1, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 2, 2, modifier}, SWIZZLE_XYZW }, \ + { NULL, { statevar, 0, 3, 3, modifier}, SWIZZLE_XYZW }, \ + } + +MATRIX(gl_ModelViewMatrix, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ModelViewMatrixInverse, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ModelViewMatrixTranspose, + STATE_MODELVIEW_MATRIX, 0); +MATRIX(gl_ModelViewMatrixInverseTranspose, + STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_ProjectionMatrix, + STATE_PROJECTION_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ProjectionMatrixInverse, + STATE_PROJECTION_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ProjectionMatrixTranspose, + STATE_PROJECTION_MATRIX, 0); +MATRIX(gl_ProjectionMatrixInverseTranspose, + STATE_PROJECTION_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_ModelViewProjectionMatrix, + STATE_MVP_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_ModelViewProjectionMatrixInverse, + STATE_MVP_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_ModelViewProjectionMatrixTranspose, + STATE_MVP_MATRIX, 0); +MATRIX(gl_ModelViewProjectionMatrixInverseTranspose, + STATE_MVP_MATRIX, STATE_MATRIX_INVERSE); + +MATRIX(gl_TextureMatrix, + STATE_TEXTURE_MATRIX, STATE_MATRIX_TRANSPOSE); +MATRIX(gl_TextureMatrixInverse, + STATE_TEXTURE_MATRIX, STATE_MATRIX_INVTRANS); +MATRIX(gl_TextureMatrixTranspose, + STATE_TEXTURE_MATRIX, 0); +MATRIX(gl_TextureMatrixInverseTranspose, + STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE); + +static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { + { NULL, { STATE_MODELVIEW_MATRIX, 0, 0, 0, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, + { NULL, { STATE_MODELVIEW_MATRIX, 0, 1, 1, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, + { NULL, { STATE_MODELVIEW_MATRIX, 0, 2, 2, STATE_MATRIX_INVERSE}, + SWIZZLE_XYZW }, +}; + +#undef MATRIX + +#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} + +const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { + STATEVAR(gl_DepthRange), + STATEVAR(gl_ClipPlane), + STATEVAR(gl_Point), + STATEVAR(gl_FrontMaterial), + STATEVAR(gl_BackMaterial), + STATEVAR(gl_LightSource), + STATEVAR(gl_LightModel), + STATEVAR(gl_FrontLightModelProduct), + STATEVAR(gl_BackLightModelProduct), + STATEVAR(gl_FrontLightProduct), + STATEVAR(gl_BackLightProduct), + STATEVAR(gl_TextureEnvColor), + STATEVAR(gl_EyePlaneS), + STATEVAR(gl_EyePlaneT), + STATEVAR(gl_EyePlaneR), + STATEVAR(gl_EyePlaneQ), + STATEVAR(gl_ObjectPlaneS), + STATEVAR(gl_ObjectPlaneT), + STATEVAR(gl_ObjectPlaneR), + STATEVAR(gl_ObjectPlaneQ), + STATEVAR(gl_Fog), + + STATEVAR(gl_ModelViewMatrix), + STATEVAR(gl_ModelViewMatrixInverse), + STATEVAR(gl_ModelViewMatrixTranspose), + STATEVAR(gl_ModelViewMatrixInverseTranspose), + + STATEVAR(gl_ProjectionMatrix), + STATEVAR(gl_ProjectionMatrixInverse), + STATEVAR(gl_ProjectionMatrixTranspose), + STATEVAR(gl_ProjectionMatrixInverseTranspose), + + STATEVAR(gl_ModelViewProjectionMatrix), + STATEVAR(gl_ModelViewProjectionMatrixInverse), + STATEVAR(gl_ModelViewProjectionMatrixTranspose), + STATEVAR(gl_ModelViewProjectionMatrixInverseTranspose), + + STATEVAR(gl_TextureMatrix), + STATEVAR(gl_TextureMatrixInverse), + STATEVAR(gl_TextureMatrixTranspose), + STATEVAR(gl_TextureMatrixInverseTranspose), + + STATEVAR(gl_NormalMatrix), + STATEVAR(gl_NormalScale), + + {NULL, NULL, 0} +}; + +static GLboolean +is_boolean_type(GLenum type) +{ + switch (type) { + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +static GLboolean +is_sampler_type(GLenum type) +{ + switch (type) { + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + case GL_SAMPLER_1D_ARRAY_EXT: + case GL_SAMPLER_2D_ARRAY_EXT: + case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +static struct gl_program_parameter * +get_uniform_parameter(const struct gl_shader_program *shProg, GLuint index) +{ + const struct gl_program *prog = NULL; + GLint progPos; + + progPos = shProg->Uniforms->Uniforms[index].VertPos; + if (progPos >= 0) { + prog = &shProg->VertexProgram->Base; + } + else { + progPos = shProg->Uniforms->Uniforms[index].FragPos; + if (progPos >= 0) { + prog = &shProg->FragmentProgram->Base; + } else { + progPos = shProg->Uniforms->Uniforms[index].GeomPos; + if (progPos >= 0) { + prog = &shProg->GeometryProgram->Base; + } + } + } + + if (!prog || progPos < 0) + return NULL; /* should never happen */ + + return &prog->Parameters->Parameters[progPos]; +} + + +/** + * Called by glGetActiveUniform(). + */ +static void +_mesa_get_active_uniform(struct gl_context *ctx, GLuint program, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, + GLenum *type, GLchar *nameOut) +{ + const struct gl_shader_program *shProg; + const struct gl_program *prog = NULL; + const struct gl_program_parameter *param; + GLint progPos; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); + if (!shProg) + return; + + if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); + return; + } + + progPos = shProg->Uniforms->Uniforms[index].VertPos; + if (progPos >= 0) { + prog = &shProg->VertexProgram->Base; + } + else { + progPos = shProg->Uniforms->Uniforms[index].FragPos; + if (progPos >= 0) { + prog = &shProg->FragmentProgram->Base; + } else { + progPos = shProg->Uniforms->Uniforms[index].GeomPos; + if (progPos >= 0) { + prog = &shProg->GeometryProgram->Base; + } + } + } + + if (!prog || progPos < 0) + return; /* should never happen */ + + ASSERT(progPos < prog->Parameters->NumParameters); + param = &prog->Parameters->Parameters[progPos]; + + if (nameOut) { + _mesa_copy_string(nameOut, maxLength, length, param->Name); + } + + if (size) { + GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + if ((GLint) param->Size > typeSize) { + /* This is an array. + * Array elements are placed on vector[4] boundaries so they're + * a multiple of four floats. We round typeSize up to next multiple + * of four to get the right size below. + */ + typeSize = (typeSize + 3) & ~3; + } + /* Note that the returned size is in units of the , not bytes */ + *size = param->Size / typeSize; + } + + if (type) { + *type = param->DataType; + } +} + + + +static void +get_matrix_dims(GLenum type, GLint *rows, GLint *cols) +{ + switch (type) { + case GL_FLOAT_MAT2: + *rows = *cols = 2; + break; + case GL_FLOAT_MAT2x3: + *rows = 3; + *cols = 2; + break; + case GL_FLOAT_MAT2x4: + *rows = 4; + *cols = 2; + break; + case GL_FLOAT_MAT3: + *rows = 3; + *cols = 3; + break; + case GL_FLOAT_MAT3x2: + *rows = 2; + *cols = 3; + break; + case GL_FLOAT_MAT3x4: + *rows = 4; + *cols = 3; + break; + case GL_FLOAT_MAT4: + *rows = 4; + *cols = 4; + break; + case GL_FLOAT_MAT4x2: + *rows = 2; + *cols = 4; + break; + case GL_FLOAT_MAT4x3: + *rows = 3; + *cols = 4; + break; + default: + *rows = *cols = 0; + } +} + + +/** + * Determine the number of rows and columns occupied by a uniform + * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4), + * the number of rows = 1 and cols = number of elements in the vector. + */ +static void +get_uniform_rows_cols(const struct gl_program_parameter *p, + GLint *rows, GLint *cols) +{ + get_matrix_dims(p->DataType, rows, cols); + if (*rows == 0 && *cols == 0) { + /* not a matrix type, probably a float or vector */ + if (p->Size <= 4) { + *rows = 1; + *cols = p->Size; + } + else { + *rows = p->Size / 4 + 1; + if (p->Size % 4 == 0) + *cols = 4; + else + *cols = p->Size % 4; + } + } +} + + +/** + * Helper for get_uniform[fi]v() functions. + * Given a shader program name and uniform location, return a pointer + * to the shader program and return the program parameter position. + */ +static void +lookup_uniform_parameter(struct gl_context *ctx, GLuint program, GLint location, + struct gl_program **progOut, GLint *paramPosOut) +{ + struct gl_shader_program *shProg + = _mesa_lookup_shader_program_err(ctx, program, "glGetUniform[if]v"); + struct gl_program *prog = NULL; + GLint progPos = -1; + + /* if shProg is NULL, we'll have already recorded an error */ + + if (shProg) { + if (!shProg->Uniforms || + location < 0 || + location >= (GLint) shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(location)"); + } + else { + /* OK, find the gl_program and program parameter location */ + progPos = shProg->Uniforms->Uniforms[location].VertPos; + if (progPos >= 0) { + prog = &shProg->VertexProgram->Base; + } + else { + progPos = shProg->Uniforms->Uniforms[location].FragPos; + if (progPos >= 0) { + prog = &shProg->FragmentProgram->Base; + } else { + progPos = shProg->Uniforms->Uniforms[location].GeomPos; + if (progPos >= 0) { + prog = &shProg->GeometryProgram->Base; + } + } + } + } + } + + *progOut = prog; + *paramPosOut = progPos; +} + + +/** + * GLGL uniform arrays and structs require special handling. + * + * The GL_ARB_shader_objects spec says that if you use + * glGetUniformLocation to get the location of an array, you CANNOT + * access other elements of the array by adding an offset to the + * returned location. For example, you must call + * glGetUniformLocation("foo[16]") if you want to set the 16th element + * of the array with glUniform(). + * + * HOWEVER, some other OpenGL drivers allow accessing array elements + * by adding an offset to the returned array location. And some apps + * seem to depend on that behaviour. + * + * Mesa's gl_uniform_list doesn't directly support this since each + * entry in the list describes one uniform variable, not one uniform + * element. We could insert dummy entries in the list for each array + * element after [0] but that causes complications elsewhere. + * + * We solve this problem by encoding two values in the location that's + * returned by glGetUniformLocation(): + * a) index into gl_uniform_list::Uniforms[] for the uniform + * b) an array/field offset (0 for simple types) + * + * These two values are encoded in the high and low halves of a GLint. + * By putting the uniform number in the high part and the offset in the + * low part, we can support the unofficial ability to index into arrays + * by adding offsets to the location value. + */ +static void +merge_location_offset(GLint *location, GLint offset) +{ + *location = (*location << 16) | offset; +} + + +/** + * Separate the uniform location and parameter offset. See above. + */ +static void +split_location_offset(GLint *location, GLint *offset) +{ + *offset = *location & 0xffff; + *location = *location >> 16; +} + + + +/** + * Called via glGetUniformfv(). + */ +static void +_mesa_get_uniformfv(struct gl_context *ctx, GLuint program, GLint location, + GLfloat *params) +{ + struct gl_program *prog; + GLint paramPos; + GLint offset; + + split_location_offset(&location, &offset); + + lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos); + + if (prog) { + const struct gl_program_parameter *p = + &prog->Parameters->Parameters[paramPos]; + GLint rows, cols, i, j, k; + + get_uniform_rows_cols(p, &rows, &cols); + + k = 0; + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++ ) { + params[k++] = prog->Parameters->ParameterValues[paramPos+i][j]; + } + } + } +} + + +/** + * Called via glGetUniformiv(). + * \sa _mesa_get_uniformfv, only difference is a cast. + */ +static void +_mesa_get_uniformiv(struct gl_context *ctx, GLuint program, GLint location, + GLint *params) +{ + struct gl_program *prog; + GLint paramPos; + GLint offset; + + split_location_offset(&location, &offset); + + lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos); + + if (prog) { + const struct gl_program_parameter *p = + &prog->Parameters->Parameters[paramPos]; + GLint rows, cols, i, j, k; + + get_uniform_rows_cols(p, &rows, &cols); + + k = 0; + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++ ) { + params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j]; + } + } + } +} + + +/** + * Called via glGetUniformuiv(). + * New in GL_EXT_gpu_shader4, OpenGL 3.0 + * \sa _mesa_get_uniformfv, only difference is a cast. + */ +static void +_mesa_get_uniformuiv(struct gl_context *ctx, GLuint program, GLint location, + GLuint *params) +{ + struct gl_program *prog; + GLint paramPos; + GLint offset; + + split_location_offset(&location, &offset); + + lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos); + + if (prog) { + const struct gl_program_parameter *p = + &prog->Parameters->Parameters[paramPos]; + GLint rows, cols, i, j, k; + + get_uniform_rows_cols(p, &rows, &cols); + + k = 0; + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++ ) { + params[k++] = (GLuint) prog->Parameters->ParameterValues[paramPos+i][j]; + } + } + } +} + + +/** + * Called via glGetUniformLocation(). + * + * The return value will encode two values, the uniform location and an + * offset (used for arrays, structs). + */ +GLint +_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, + const GLchar *name) +{ + GLint offset = 0, location = -1; + + if (shProg->LinkStatus == GL_FALSE) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)"); + return -1; + } + + /* XXX we should return -1 if the uniform was declared, but not + * actually used. + */ + + /* XXX we need to be able to parse uniform names for structs and arrays + * such as: + * mymatrix[1] + * mystruct.field1 + */ + + { + /* handle 1-dimension arrays here... */ + char *c = strchr(name, '['); + if (c) { + /* truncate name at [ */ + const GLint len = c - name; + GLchar *newName = malloc(len + 1); + if (!newName) + return -1; /* out of mem */ + memcpy(newName, name, len); + newName[len] = 0; + + location = _mesa_lookup_uniform(shProg->Uniforms, newName); + if (location >= 0) { + const GLint element = atoi(c + 1); + if (element > 0) { + /* get type of the uniform array element */ + struct gl_program_parameter *p; + p = get_uniform_parameter(shProg, location); + if (p) { + GLint rows, cols; + get_matrix_dims(p->DataType, &rows, &cols); + if (rows < 1) + rows = 1; + offset = element * rows; + } + } + } + + free(newName); + } + } + + if (location < 0) { + location = _mesa_lookup_uniform(shProg->Uniforms, name); + } + + if (location >= 0) { + merge_location_offset(&location, offset); + } + + return location; +} + + + +/** + * Update the vertex/fragment program's TexturesUsed array. + * + * This needs to be called after glUniform(set sampler var) is called. + * A call to glUniform(samplerVar, value) causes a sampler to point to a + * particular texture unit. We know the sampler's texture target + * (1D/2D/3D/etc) from compile time but the sampler's texture unit is + * set by glUniform() calls. + * + * So, scan the program->SamplerUnits[] and program->SamplerTargets[] + * information to update the prog->TexturesUsed[] values. + * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, + * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. + * We'll use that info for state validation before rendering. + */ +void +_mesa_update_shader_textures_used(struct gl_program *prog) +{ + GLuint s; + + memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); + + for (s = 0; s < MAX_SAMPLERS; s++) { + if (prog->SamplersUsed & (1 << s)) { + GLuint unit = prog->SamplerUnits[s]; + GLuint tgt = prog->SamplerTargets[s]; + assert(unit < MAX_TEXTURE_IMAGE_UNITS); + assert(tgt < NUM_TEXTURE_TARGETS); + prog->TexturesUsed[unit] |= (1 << tgt); + } + } +} + + +/** + * Check if the type given by userType is allowed to set a uniform of the + * target type. Generally, equivalence is required, but setting Boolean + * uniforms can be done with glUniformiv or glUniformfv. + */ +static GLboolean +compatible_types(GLenum userType, GLenum targetType) +{ + if (userType == targetType) + return GL_TRUE; + + if (targetType == GL_BOOL && (userType == GL_FLOAT || + userType == GL_UNSIGNED_INT || + userType == GL_INT)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC2 && (userType == GL_FLOAT_VEC2 || + userType == GL_UNSIGNED_INT_VEC2 || + userType == GL_INT_VEC2)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC3 && (userType == GL_FLOAT_VEC3 || + userType == GL_UNSIGNED_INT_VEC3 || + userType == GL_INT_VEC3)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC4 && (userType == GL_FLOAT_VEC4 || + userType == GL_UNSIGNED_INT_VEC4 || + userType == GL_INT_VEC4)) + return GL_TRUE; + + if (is_sampler_type(targetType) && userType == GL_INT) + return GL_TRUE; + + return GL_FALSE; +} + + +/** + * Set the value of a program's uniform variable. + * \param program the program whose uniform to update + * \param index the index of the program parameter for the uniform + * \param offset additional parameter slot offset (for arrays) + * \param type the incoming datatype of 'values' + * \param count the number of uniforms to set + * \param elems number of elements per uniform (1, 2, 3 or 4) + * \param values the new values, of datatype 'type' + */ +static void +set_program_uniform(struct gl_context *ctx, struct gl_program *program, + GLint index, GLint offset, + GLenum type, GLsizei count, GLint elems, + const void *values) +{ + const struct gl_program_parameter *param = + &program->Parameters->Parameters[index]; + + assert(offset >= 0); + assert(elems >= 1); + assert(elems <= 4); + + if (!compatible_types(type, param->DataType)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); + return; + } + + if (index + offset > (GLint) program->Parameters->Size) { + /* out of bounds! */ + return; + } + + if (param->Type == PROGRAM_SAMPLER) { + /* This controls which texture unit which is used by a sampler */ + GLboolean changed = GL_FALSE; + GLint i; + + /* this should have been caught by the compatible_types() check */ + ASSERT(type == GL_INT); + + /* loop over number of samplers to change */ + for (i = 0; i < count; i++) { + GLuint sampler = + (GLuint) program->Parameters->ParameterValues[index + offset + i][0]; + GLuint texUnit = ((GLuint *) values)[i]; + + /* check that the sampler (tex unit index) is legal */ + if (texUnit >= ctx->Const.MaxTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glUniform1(invalid sampler/tex unit index for '%s')", + param->Name); + return; + } + + /* This maps a sampler to a texture unit: */ + if (sampler < MAX_SAMPLERS) { +#if 0 + printf("Set program %p sampler %d '%s' to unit %u\n", + program, sampler, param->Name, texUnit); +#endif + if (program->SamplerUnits[sampler] != texUnit) { + program->SamplerUnits[sampler] = texUnit; + changed = GL_TRUE; + } + } + } + + if (changed) { + /* When a sampler's value changes it usually requires rewriting + * a GPU program's TEX instructions since there may not be a + * sampler->texture lookup table. We signal this with the + * ProgramStringNotify() callback. + */ + FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); + _mesa_update_shader_textures_used(program); + /* Do we need to care about the return value here? + * This should not be the first time the driver was notified of + * this program. + */ + (void) ctx->Driver.ProgramStringNotify(ctx, program->Target, program); + } + } + else { + /* ordinary uniform variable */ + const GLboolean isUniformBool = is_boolean_type(param->DataType); + const GLenum basicType = base_uniform_type(type); + const GLint slots = (param->Size + 3) / 4; + const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + GLsizei k, i; + + if ((GLint) param->Size > typeSize) { + /* an array */ + /* we'll ignore extra data below */ + } + else { + /* non-array: count must be at most one; count == 0 is handled by the loop below */ + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniform(uniform '%s' is not an array)", + param->Name); + return; + } + } + + /* loop over number of array elements */ + for (k = 0; k < count; k++) { + GLfloat *uniformVal; + + if (offset + k >= slots) { + /* Extra array data is ignored */ + break; + } + + /* uniformVal (the destination) is always float[4] */ + uniformVal = program->Parameters->ParameterValues[index + offset + k]; + + if (basicType == GL_INT) { + /* convert user's ints to floats */ + const GLint *iValues = ((const GLint *) values) + k * elems; + for (i = 0; i < elems; i++) { + uniformVal[i] = (GLfloat) iValues[i]; + } + } + else if (basicType == GL_UNSIGNED_INT) { + /* convert user's uints to floats */ + const GLuint *iValues = ((const GLuint *) values) + k * elems; + for (i = 0; i < elems; i++) { + uniformVal[i] = (GLfloat) iValues[i]; + } + } + else { + const GLfloat *fValues = ((const GLfloat *) values) + k * elems; + assert(basicType == GL_FLOAT); + for (i = 0; i < elems; i++) { + uniformVal[i] = fValues[i]; + } + } + + /* if the uniform is bool-valued, convert to 1.0 or 0.0 */ + if (isUniformBool) { + for (i = 0; i < elems; i++) { + uniformVal[i] = uniformVal[i] ? 1.0f : 0.0f; + } + } + } + } +} + + +/** + * Called via glUniform*() functions. + */ +void +_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint location, GLsizei count, + const GLvoid *values, GLenum type) +{ + struct gl_uniform *uniform; + GLint elems, offset; + + if (!shProg || !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(program not linked)"); + return; + } + + if (location == -1) + return; /* The standard specifies this as a no-op */ + + if (location < -1) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location=%d)", + location); + return; + } + + split_location_offset(&location, &offset); + + if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location=%d)", location); + return; + } + + if (count < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(count < 0)"); + return; + } + + elems = _mesa_sizeof_glsl_type(type); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + uniform = &shProg->Uniforms->Uniforms[location]; + + if (ctx->Shader.Flags & GLSL_UNIFORMS) { + const GLenum basicType = base_uniform_type(type); + GLint i; + printf("Mesa: set program %u uniform %s (loc %d) to: ", + shProg->Name, uniform->Name, location); + if (basicType == GL_INT) { + const GLint *v = (const GLint *) values; + for (i = 0; i < count * elems; i++) { + printf("%d ", v[i]); + } + } + else if (basicType == GL_UNSIGNED_INT) { + const GLuint *v = (const GLuint *) values; + for (i = 0; i < count * elems; i++) { + printf("%u ", v[i]); + } + } + else { + const GLfloat *v = (const GLfloat *) values; + assert(basicType == GL_FLOAT); + for (i = 0; i < count * elems; i++) { + printf("%g ", v[i]); + } + } + printf("\n"); + } + + /* A uniform var may be used by both a vertex shader and a fragment + * shader. We may need to update one or both shader's uniform here: + */ + if (shProg->VertexProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->VertPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->VertexProgram->Base, + index, offset, type, count, elems, values); + } + } + + if (shProg->FragmentProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->FragPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->FragmentProgram->Base, + index, offset, type, count, elems, values); + } + } + + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->GeometryProgram->Base, + index, offset, type, count, elems, values); + } + } + + uniform->Initialized = GL_TRUE; +} + + +/** + * Set a matrix-valued program parameter. + */ +static void +set_program_uniform_matrix(struct gl_context *ctx, struct gl_program *program, + GLuint index, GLuint offset, + GLuint count, GLuint rows, GLuint cols, + GLboolean transpose, const GLfloat *values) +{ + GLuint mat, row, col; + GLuint src = 0; + const struct gl_program_parameter * param = &program->Parameters->Parameters[index]; + const GLuint slots = (param->Size + 3) / 4; + const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + GLint nr, nc; + + /* check that the number of rows, columns is correct */ + get_matrix_dims(param->DataType, &nr, &nc); + if (rows != nr || cols != nc) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(matrix size mismatch)"); + return; + } + + if ((GLint) param->Size <= typeSize) { + /* non-array: count must be at most one; count == 0 is handled by the loop below */ + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(uniform is not an array)"); + return; + } + } + + /* + * Note: the _columns_ of a matrix are stored in program registers, not + * the rows. So, the loops below look a little funny. + * XXX could optimize this a bit... + */ + + /* loop over matrices */ + for (mat = 0; mat < count; mat++) { + + /* each matrix: */ + for (col = 0; col < cols; col++) { + GLfloat *v; + if (offset >= slots) { + /* Ignore writes beyond the end of (the used part of) an array */ + return; + } + v = program->Parameters->ParameterValues[index + offset]; + for (row = 0; row < rows; row++) { + if (transpose) { + v[row] = values[src + row * cols + col]; + } + else { + v[row] = values[src + col * rows + row]; + } + } + + offset++; + } + + src += rows * cols; /* next matrix */ + } +} + + +/** + * Called by glUniformMatrix*() functions. + * Note: cols=2, rows=4 ==> array[2] of vec4 + */ +void +_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint cols, GLint rows, + GLint location, GLsizei count, + GLboolean transpose, const GLfloat *values) +{ + struct gl_uniform *uniform; + GLint offset; + + if (!shProg || !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(program not linked)"); + return; + } + + if (location == -1) + return; /* The standard specifies this as a no-op */ + + if (location < -1) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformMatrix(location)"); + return; + } + + split_location_offset(&location, &offset); + + if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(location)"); + return; + } + if (values == NULL) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + uniform = &shProg->Uniforms->Uniforms[location]; + + if (shProg->VertexProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->VertPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + if (shProg->FragmentProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->FragPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + uniform->Initialized = GL_TRUE; +} + + +void GLAPIENTRY +_mesa_Uniform1fARB(GLint location, GLfloat v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT); +} + +void GLAPIENTRY +_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, + GLfloat v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1iARB(GLint location, GLint v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT); +} + +void GLAPIENTRY +_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT); +} + +void GLAPIENTRY +_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT); +} + +void GLAPIENTRY +_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4); +} + + +/** OpenGL 3.0 GLuint-valued functions **/ +void GLAPIENTRY +_mesa_Uniform1ui(GLint location, GLuint v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); +} + +void GLAPIENTRY +_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT); +} + +void GLAPIENTRY +_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); +} + + + +void GLAPIENTRY +_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 3, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 4, location, count, transpose, value); +} + + +/** + * Non-square UniformMatrix are OpenGL 2.1 + */ +void GLAPIENTRY +_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 3, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 4, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 4, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 3, location, count, transpose, value); +} + + +void GLAPIENTRY +_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_get_uniformfv(ctx, program, location, params); +} + + +void GLAPIENTRY +_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_get_uniformiv(ctx, program, location, params); +} + + +/* GL3 */ +void GLAPIENTRY +_mesa_GetUniformuiv(GLhandleARB program, GLint location, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_get_uniformuiv(ctx, program, location, params); +} + + + +GLint GLAPIENTRY +_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) +{ + struct gl_shader_program *shProg; + + GET_CURRENT_CONTEXT(ctx); + + shProg = _mesa_lookup_shader_program_err(ctx, programObj, + "glGetUniformLocation"); + if (!shProg) + return -1; + + return _mesa_get_uniform_location(ctx, shProg, name); +} + + +void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, + GLsizei maxLength, GLsizei * length, GLint * size, + GLenum * type, GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_get_active_uniform(ctx, program, index, maxLength, length, size, + type, name); +} + + +/** + * Plug in shader uniform-related functions into API dispatch table. + */ +void +_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) +{ +#if FEATURE_GL + SET_Uniform1fARB(exec, _mesa_Uniform1fARB); + SET_Uniform2fARB(exec, _mesa_Uniform2fARB); + SET_Uniform3fARB(exec, _mesa_Uniform3fARB); + SET_Uniform4fARB(exec, _mesa_Uniform4fARB); + SET_Uniform1iARB(exec, _mesa_Uniform1iARB); + SET_Uniform2iARB(exec, _mesa_Uniform2iARB); + SET_Uniform3iARB(exec, _mesa_Uniform3iARB); + SET_Uniform4iARB(exec, _mesa_Uniform4iARB); + SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB); + SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB); + SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB); + SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB); + SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB); + SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB); + SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB); + SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB); + SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB); + SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB); + SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB); + + SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB); + SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB); + SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB); + SET_GetUniformivARB(exec, _mesa_GetUniformivARB); + + /* OpenGL 2.1 */ + SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); + + /* OpenGL 3.0 */ + /* XXX finish dispatch */ + SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); + SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); + SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); + SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); + SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); + SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); + SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); + SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); + SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); + + +#endif /* FEATURE_GL */ +} diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index f823c6144..3a85144fa 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -1,175 +1,193 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. - */ - - -#ifndef UNIFORMS_H -#define UNIFORMS_H - -#include "glheader.h" - -struct gl_program; -struct _glapi_table; - -extern void GLAPIENTRY -_mesa_Uniform1fARB(GLint, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform1iARB(GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform2iARB(GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0); - -extern void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); - -extern void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); - -extern void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); - -extern void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); - - -extern void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - - -extern void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, - GLint *, GLenum *, GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); - -extern GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); - -GLint -_mesa_get_uniform_location(GLcontext *ctx, struct gl_shader_program *shProg, - const GLchar *name); - -void -_mesa_uniform(GLcontext *ctx, struct gl_shader_program *shader_program, - GLint location, GLsizei count, - const GLvoid *values, GLenum type); - -void -_mesa_uniform_matrix(GLcontext *ctx, struct gl_shader_program *shProg, - GLint cols, GLint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values); - -extern void -_mesa_update_shader_textures_used(struct gl_program *prog); - - -extern void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); - -#endif /* UNIFORMS_H */ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +#ifndef UNIFORMS_H +#define UNIFORMS_H + +#include "glheader.h" +#include "program/prog_parameter.h" + +struct gl_program; +struct _glapi_table; + +extern void GLAPIENTRY +_mesa_Uniform1fARB(GLint, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform1iARB(GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform2iARB(GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform1ui(GLint location, GLuint v0); + +extern void GLAPIENTRY +_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); + +extern void GLAPIENTRY +_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); + +extern void GLAPIENTRY +_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + +extern void GLAPIENTRY +_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); + + +extern void GLAPIENTRY +_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + + +extern void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, + GLint *, GLenum *, GLcharARB *); + +extern void GLAPIENTRY +_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); + +extern void GLAPIENTRY +_mesa_GetUniformuiv(GLhandleARB program, GLint location, GLuint *params); + +extern GLint GLAPIENTRY +_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); + +GLint +_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, + const GLchar *name); + +void +_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, + GLint location, GLsizei count, + const GLvoid *values, GLenum type); + +void +_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint cols, GLint rows, + GLint location, GLsizei count, + GLboolean transpose, const GLfloat *values); + +extern void +_mesa_update_shader_textures_used(struct gl_program *prog); + + +extern void +_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); + +struct gl_builtin_uniform_element { + const char *field; + int tokens[STATE_LENGTH]; + int swizzle; +}; + +struct gl_builtin_uniform_desc { + const char *name; + struct gl_builtin_uniform_element *elements; + unsigned int num_elements; +}; + +extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; + +#endif /* UNIFORMS_H */ diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index d19de7ff6..92367a842 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -1,1442 +1,1172 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "enable.h" -#include "enums.h" -#include "hash.h" -#include "macros.h" -#include "mtypes.h" -#include "varray.h" -#include "arrayobj.h" -#include "main/dispatch.h" - - -/** - * Set the fields of a vertex array. - * Also do an error check for GL_ARB_vertex_array_object: check that - * all arrays reside in VBOs when using a vertex array object. - * - * \param array the array to update - * \param dirtyBit which bit to set in ctx->Array.NewState for this array - * \param elementSize size of each array element, in bytes - * \param size components per element (1, 2, 3 or 4) - * \param type datatype of each component (GL_FLOAT, GL_INT, etc) - * \param format either GL_RGBA or GL_BGRA - * \param stride stride between elements, in elements - * \param normalized are integer types converted to floats in [-1, 1]? - * \param ptr the address (or offset inside VBO) of the array data - */ -static void -update_array(GLcontext *ctx, struct gl_client_array *array, - GLbitfield dirtyBit, GLsizei elementSize, - GLint size, GLenum type, GLenum format, - GLsizei stride, GLboolean normalized, const GLvoid *ptr) -{ - ASSERT(format == GL_RGBA || format == GL_BGRA); - - if (ctx->Array.ArrayObj->VBOonly && - ctx->Array.ArrayBufferObj->Name == 0) { - /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. - * Generate GL_INVALID_OPERATION if that's not true. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glVertex/Normal/EtcPointer(non-VBO array)"); - return; - } - - array->Size = size; - array->Type = type; - array->Format = format; - array->Stride = stride; - array->StrideB = stride ? stride : elementSize; - array->Normalized = normalized; - array->Ptr = (const GLubyte *) ptr; - array->_ElementSize = elementSize; - - _mesa_reference_buffer_object(ctx, &array->BufferObj, - ctx->Array.ArrayBufferObj); - - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= dirtyBit; -} - - -void GLAPIENTRY -_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (size < 2 || size > 4) { - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); - return; - } - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size, - _mesa_lookup_enum_by_nr( type ), stride); - - /* always need to check that is legal */ - switch (type) { - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_INT: - elementSize = size * sizeof(GLint); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = size * sizeof(GLhalfARB); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = size * sizeof(GLfixed); - break; -#endif -#if FEATURE_vertex_array_byte - case GL_BYTE: - elementSize = size * sizeof(GLbyte); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, - elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) -{ - GLsizei elementSize; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n", - _mesa_lookup_enum_by_nr( type ), stride); - - switch (type) { - case GL_BYTE: - elementSize = 3 * sizeof(GLbyte); - break; - case GL_SHORT: - elementSize = 3 * sizeof(GLshort); - break; - case GL_INT: - elementSize = 3 * sizeof(GLint); - break; - case GL_FLOAT: - elementSize = 3 * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = 3 * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = 3 * sizeof(GLhalfARB); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = 3 * sizeof(GLfixed); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, - elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr); -} - - -void GLAPIENTRY -_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GLenum format; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (size < 3 || size > 4) { - if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(size)"); - return; - } - } - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size, - _mesa_lookup_enum_by_nr( type ), stride); - - if (size == GL_BGRA) { - if (type != GL_UNSIGNED_BYTE) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); - return; - } - format = GL_BGRA; - size = 4; - } - else { - format = GL_RGBA; - } - - switch (type) { - case GL_BYTE: - elementSize = size * sizeof(GLbyte); - break; - case GL_UNSIGNED_BYTE: - elementSize = size * sizeof(GLubyte); - break; - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_UNSIGNED_SHORT: - elementSize = size * sizeof(GLushort); - break; - case GL_INT: - elementSize = size * sizeof(GLint); - break; - case GL_UNSIGNED_INT: - elementSize = size * sizeof(GLuint); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = size * sizeof(GLhalfARB); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = size * sizeof(GLfixed); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, - elementSize, size, type, format, stride, GL_TRUE, ptr); -} - - -void GLAPIENTRY -_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLint elementSize; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" ); - return; - } - - switch (type) { - case GL_FLOAT: - elementSize = sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = sizeof(GLhalfARB); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, - elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); - return; - } - - switch (type) { - case GL_UNSIGNED_BYTE: - elementSize = sizeof(GLubyte); - break; - case GL_SHORT: - elementSize = sizeof(GLshort); - break; - case GL_INT: - elementSize = sizeof(GLint); - break; - case GL_FLOAT: - elementSize = sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = sizeof(GLdouble); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, - elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GLenum format; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (size != 3 && size != 4) { - if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)"); - return; - } - } - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n", - size, _mesa_lookup_enum_by_nr( type ), stride); - - if (size == GL_BGRA) { - if (type != GL_UNSIGNED_BYTE) { - _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); - return; - } - format = GL_BGRA; - size = 4; - } - else { - format = GL_RGBA; - } - - switch (type) { - case GL_BYTE: - elementSize = size * sizeof(GLbyte); - break; - case GL_UNSIGNED_BYTE: - elementSize = size * sizeof(GLubyte); - break; - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_UNSIGNED_SHORT: - elementSize = size * sizeof(GLushort); - break; - case GL_INT: - elementSize = size * sizeof(GLint); - break; - case GL_UNSIGNED_INT: - elementSize = size * sizeof(GLuint); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = size * sizeof(GLhalfARB); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, - elementSize, size, type, format, stride, GL_TRUE, ptr); -} - - -void GLAPIENTRY -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GLint elementSize; - GET_CURRENT_CONTEXT(ctx); - const GLuint unit = ctx->Array.ActiveTexture; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (size < 1 || size > 4) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); - return; - } - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) - _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n", - unit, size, _mesa_lookup_enum_by_nr( type ), stride); - - /* always need to check that is legal */ - switch (type) { - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_INT: - elementSize = size * sizeof(GLint); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = size * sizeof(GLhalfARB); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = size * sizeof(GLfixed); - break; -#endif -#if FEATURE_vertex_array_byte - case GL_BYTE: - elementSize = size * sizeof(GLbyte); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - ASSERT(unit < Elements(ctx->Array.ArrayObj->TexCoord)); - - update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit], - _NEW_ARRAY_TEXCOORD(unit), - elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, - sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA, - stride, GL_FALSE, ptr); -} - - -void GLAPIENTRY -_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPointSizePointer(stride)" ); - return; - } - - switch (type) { - case GL_FLOAT: - elementSize = sizeof(GLfloat); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = sizeof(GLfixed); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPointSizePointer(type)" ); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, - elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); -} - - -#if FEATURE_NV_vertex_program -/** - * Set a vertex attribute array. - * Note that these arrays DO alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - * The generic attribute slots at #16 and above are not touched. - */ -void GLAPIENTRY -_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - GLboolean normalized = GL_FALSE; - GLsizei elementSize; - GLenum format; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); - return; - } - - if (size < 1 || size > 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)"); - return; - } - - if (stride < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)"); - return; - } - - if (type == GL_UNSIGNED_BYTE && size != 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); - return; - } - - if (size == GL_BGRA) { - if (type != GL_UNSIGNED_BYTE) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glVertexAttribPointerNV(GL_BGRA/type)"); - return; - } - - format = GL_BGRA; - size = 4; - normalized = GL_TRUE; - } - else { - format = GL_RGBA; - } - - /* check for valid 'type' and compute StrideB right away */ - switch (type) { - case GL_UNSIGNED_BYTE: - normalized = GL_TRUE; - elementSize = size * sizeof(GLubyte); - break; - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], - _NEW_ARRAY_ATTRIB(index), - elementSize, size, type, format, stride, normalized, ptr); -} -#endif - - -#if FEATURE_ARB_vertex_program -/** - * Set a generic vertex attribute array. - * Note that these arrays DO NOT alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - */ -void GLAPIENTRY -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, - GLsizei stride, const GLvoid *ptr) -{ - GLsizei elementSize; - GLenum format; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); - return; - } - - if (size < 1 || size > 4) { - if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); - return; - } - } - - if (stride < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)"); - return; - } - - if (size == GL_BGRA) { - if (type != GL_UNSIGNED_BYTE) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glVertexAttribPointerARB(GL_BGRA/type)"); - return; - } - if (normalized != GL_TRUE) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glVertexAttribPointerARB(GL_BGRA/normalized)"); - return; - } - - format = GL_BGRA; - size = 4; - } - else { - format = GL_RGBA; - } - - /* check for valid 'type' and compute StrideB right away */ - /* NOTE: more types are supported here than in the NV extension */ - switch (type) { - case GL_BYTE: - elementSize = size * sizeof(GLbyte); - break; - case GL_UNSIGNED_BYTE: - elementSize = size * sizeof(GLubyte); - break; - case GL_SHORT: - elementSize = size * sizeof(GLshort); - break; - case GL_UNSIGNED_SHORT: - elementSize = size * sizeof(GLushort); - break; - case GL_INT: - elementSize = size * sizeof(GLint); - break; - case GL_UNSIGNED_INT: - elementSize = size * sizeof(GLuint); - break; - case GL_FLOAT: - elementSize = size * sizeof(GLfloat); - break; - case GL_DOUBLE: - elementSize = size * sizeof(GLdouble); - break; - case GL_HALF_FLOAT: - elementSize = size * sizeof(GLhalfARB); - break; -#if FEATURE_fixedpt - case GL_FIXED: - elementSize = size * sizeof(GLfixed); - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); - return; - } - - update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], - _NEW_ARRAY_ATTRIB(index), - elementSize, size, type, format, stride, normalized, ptr); -} -#endif - - -/** - * New in GL3: - * Set an integer-valued vertex attribute array. - * Note that these arrays DO NOT alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - */ -void GLAPIENTRY -_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, - GLboolean normalized, - GLsizei stride, const GLvoid *ptr) -{ - /* NOTE: until we have integer-valued vertex attributes, just - * route this through the regular glVertexAttribPointer() function. - */ - _mesa_VertexAttribPointerARB(index, size, type, normalized, stride, ptr); -} - - - -void GLAPIENTRY -_mesa_EnableVertexAttribArrayARB(GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glEnableVertexAttribArrayARB(index)"); - return; - } - - ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE; - ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index); - ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); -} - - -void GLAPIENTRY -_mesa_DisableVertexAttribArrayARB(GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glEnableVertexAttribArrayARB(index)"); - return; - } - - ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE; - ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index); - ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); -} - - -/** - * Return info for a vertex attribute array (no alias with legacy - * vertex attributes (pos, normal, color, etc)). This function does - * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query. - */ -static GLuint -get_vertex_array_attrib(GLcontext *ctx, GLuint index, GLenum pname, - const char *caller) -{ - const struct gl_client_array *array; - - if (index >= MAX_VERTEX_GENERIC_ATTRIBS) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index); - return 0; - } - - ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - array = &ctx->Array.ArrayObj->VertexAttrib[index]; - - switch (pname) { - case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: - return array->Enabled; - case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: - return array->Size; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: - return array->Stride; - case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: - return array->Type; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: - return array->Normalized; - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: - return array->BufferObj->Name; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname); - return 0; - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribfv(index==0)"); - } - else { - const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; - FLUSH_CURRENT(ctx, 0); - COPY_4V(params, v); - } - } - else { - params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribfv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribdv(index==0)"); - } - else { - const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; - FLUSH_CURRENT(ctx, 0); - params[0] = (GLdouble) v[0]; - params[1] = (GLdouble) v[1]; - params[2] = (GLdouble) v[2]; - params[3] = (GLdouble) v[3]; - } - } - else { - params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribdv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribiv(index==0)"); - } - else { - const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; - FLUSH_CURRENT(ctx, 0); - /* XXX should floats in[0,1] be scaled to full int range? */ - params[0] = (GLint) v[0]; - params[1] = (GLint) v[1]; - params[2] = (GLint) v[2]; - params[3] = (GLint) v[3]; - } - } - else { - params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribiv"); - } -} - - -/** GL 3.0 */ -void GLAPIENTRY -_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribIiv(index==0)"); - } - else { - const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; - FLUSH_CURRENT(ctx, 0); - /* XXX we don't have true integer-valued vertex attribs yet */ - params[0] = (GLint) v[0]; - params[1] = (GLint) v[1]; - params[2] = (GLint) v[2]; - params[3] = (GLint) v[3]; - } - } - else { - params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribIiv"); - } -} - - -/** GL 3.0 */ -void GLAPIENTRY -_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribIuiv(index==0)"); - } - else { - const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; - FLUSH_CURRENT(ctx, 0); - /* XXX we don't have true integer-valued vertex attribs yet */ - params[0] = (GLuint) v[0]; - params[1] = (GLuint) v[1]; - params[2] = (GLuint) v[2]; - params[3] = (GLuint) v[3]; - } - } - else { - params[0] = get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribIuiv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)"); - return; - } - - if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)"); - return; - } - - ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr; -} - - -void GLAPIENTRY -_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - (void) count; - _mesa_VertexPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_NormalPointer(type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_ColorPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - (void) count; - _mesa_IndexPointer(type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - (void) count; - _mesa_TexCoordPointer(size, type, stride, ptr); -} - - -void GLAPIENTRY -_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - (void) count; - _mesa_EdgeFlagPointer(stride, ptr); -} - - -void GLAPIENTRY -_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) -{ - GET_CURRENT_CONTEXT(ctx); - GLboolean tflag, cflag, nflag; /* enable/disable flags */ - GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ - GLenum ctype = 0; /* color type */ - GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ - const GLint toffset = 0; /* always zero */ - GLint defstride; /* default stride */ - GLint c, f; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - f = sizeof(GLfloat); - c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); - - if (stride < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); - return; - } - - switch (format) { - case GL_V2F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 0; ccomps = 0; vcomps = 2; - voffset = 0; - defstride = 2*f; - break; - case GL_V3F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 0; ccomps = 0; vcomps = 3; - voffset = 0; - defstride = 3*f; - break; - case GL_C4UB_V2F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 4; vcomps = 2; - ctype = GL_UNSIGNED_BYTE; - coffset = 0; - voffset = c; - defstride = c + 2*f; - break; - case GL_C4UB_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 4; vcomps = 3; - ctype = GL_UNSIGNED_BYTE; - coffset = 0; - voffset = c; - defstride = c + 3*f; - break; - case GL_C3F_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 0; ccomps = 3; vcomps = 3; - ctype = GL_FLOAT; - coffset = 0; - voffset = 3*f; - defstride = 6*f; - break; - case GL_N3F_V3F: - tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; - tcomps = 0; ccomps = 0; vcomps = 3; - noffset = 0; - voffset = 3*f; - defstride = 6*f; - break; - case GL_C4F_N3F_V3F: - tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 0; ccomps = 4; vcomps = 3; - ctype = GL_FLOAT; - coffset = 0; - noffset = 4*f; - voffset = 7*f; - defstride = 10*f; - break; - case GL_T2F_V3F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 2; ccomps = 0; vcomps = 3; - voffset = 2*f; - defstride = 5*f; - break; - case GL_T4F_V4F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; - tcomps = 4; ccomps = 0; vcomps = 4; - voffset = 4*f; - defstride = 8*f; - break; - case GL_T2F_C4UB_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 2; ccomps = 4; vcomps = 3; - ctype = GL_UNSIGNED_BYTE; - coffset = 2*f; - voffset = c+2*f; - defstride = c+5*f; - break; - case GL_T2F_C3F_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; - tcomps = 2; ccomps = 3; vcomps = 3; - ctype = GL_FLOAT; - coffset = 2*f; - voffset = 5*f; - defstride = 8*f; - break; - case GL_T2F_N3F_V3F: - tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; - tcomps = 2; ccomps = 0; vcomps = 3; - noffset = 2*f; - voffset = 5*f; - defstride = 8*f; - break; - case GL_T2F_C4F_N3F_V3F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 2; ccomps = 4; vcomps = 3; - ctype = GL_FLOAT; - coffset = 2*f; - noffset = 6*f; - voffset = 9*f; - defstride = 12*f; - break; - case GL_T4F_C4F_N3F_V4F: - tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; - tcomps = 4; ccomps = 4; vcomps = 4; - ctype = GL_FLOAT; - coffset = 4*f; - noffset = 8*f; - voffset = 11*f; - defstride = 15*f; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); - return; - } - - if (stride==0) { - stride = defstride; - } - - _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); - _mesa_DisableClientState( GL_INDEX_ARRAY ); - /* XXX also disable secondary color and generic arrays? */ - - /* Texcoords */ - if (tflag) { - _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); - _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, - (GLubyte *) pointer + toffset ); - } - else { - _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); - } - - /* Color */ - if (cflag) { - _mesa_EnableClientState( GL_COLOR_ARRAY ); - _mesa_ColorPointer( ccomps, ctype, stride, - (GLubyte *) pointer + coffset ); - } - else { - _mesa_DisableClientState( GL_COLOR_ARRAY ); - } - - - /* Normals */ - if (nflag) { - _mesa_EnableClientState( GL_NORMAL_ARRAY ); - _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); - } - else { - _mesa_DisableClientState( GL_NORMAL_ARRAY ); - } - - /* Vertices */ - _mesa_EnableClientState( GL_VERTEX_ARRAY ); - _mesa_VertexPointer( vcomps, GL_FLOAT, stride, - (GLubyte *) pointer + voffset ); -} - - -void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); - - if (first < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); - return; - } - if (count <= 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); - return; - } - if (ctx->Array.LockCount != 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); - return; - } - - ctx->Array.LockFirst = first; - ctx->Array.LockCount = count; - - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= _NEW_ARRAY_ALL; -} - - -void GLAPIENTRY -_mesa_UnlockArraysEXT( void ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glUnlockArrays\n"); - - if (ctx->Array.LockCount == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); - return; - } - - ctx->Array.LockFirst = 0; - ctx->Array.LockCount = 0; - ctx->NewState |= _NEW_ARRAY; - ctx->Array.NewState |= _NEW_ARRAY_ALL; -} - - -/* GL_EXT_multi_draw_arrays */ -/* Somebody forgot to spec the first and count parameters as const! */ -void GLAPIENTRY -_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); - } - } -} - - -/* GL_IBM_multimode_draw_arrays */ -void GLAPIENTRY -_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, - const GLsizei * count, - GLsizei primcount, GLint modestride ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for ( i = 0 ; i < primcount ; i++ ) { - if ( count[i] > 0 ) { - GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); - } - } -} - - -/* GL_IBM_multimode_draw_arrays */ -void GLAPIENTRY -_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, - GLenum type, const GLvoid * const * indices, - GLsizei primcount, GLint modestride ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - /* XXX not sure about ARB_vertex_buffer_object handling here */ - - for ( i = 0 ; i < primcount ; i++ ) { - if ( count[i] > 0 ) { - GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); - } - } -} - - -/** - * GL 3.1 glPrimitiveRestartIndex(). - */ -void GLAPIENTRY -_mesa_PrimitiveRestartIndex(GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndex()"); - return; - } - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - ctx->Array.RestartIndex = index; -} - - -/** - * Copy one client vertex array to another. - */ -void -_mesa_copy_client_array(GLcontext *ctx, - struct gl_client_array *dst, - struct gl_client_array *src) -{ - dst->Size = src->Size; - dst->Type = src->Type; - dst->Format = src->Format; - dst->Stride = src->Stride; - dst->StrideB = src->StrideB; - dst->Ptr = src->Ptr; - dst->Enabled = src->Enabled; - dst->Normalized = src->Normalized; - dst->_ElementSize = src->_ElementSize; - _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); - dst->_MaxElement = src->_MaxElement; -} - - - -/** - * Print vertex array's fields. - */ -static void -print_array(const char *name, GLint index, const struct gl_client_array *array) -{ - if (index >= 0) - printf(" %s[%d]: ", name, index); - else - printf(" %s: ", name); - printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu), MaxElem=%u\n", - array->Ptr, array->Type, array->Size, - array->_ElementSize, array->StrideB, - array->BufferObj->Name, (unsigned long) array->BufferObj->Size, - array->_MaxElement); -} - - -/** - * Print current vertex object/array info. For debug. - */ -void -_mesa_print_arrays(GLcontext *ctx) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i; - - _mesa_update_array_object_max_element(ctx, arrayObj); - - printf("Array Object %u\n", arrayObj->Name); - if (arrayObj->Vertex.Enabled) - print_array("Vertex", -1, &arrayObj->Vertex); - if (arrayObj->Normal.Enabled) - print_array("Normal", -1, &arrayObj->Normal); - if (arrayObj->Color.Enabled) - print_array("Color", -1, &arrayObj->Color); - for (i = 0; i < Elements(arrayObj->TexCoord); i++) - if (arrayObj->TexCoord[i].Enabled) - print_array("TexCoord", i, &arrayObj->TexCoord[i]); - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) - if (arrayObj->VertexAttrib[i].Enabled) - print_array("Attrib", i, &arrayObj->VertexAttrib[i]); - printf(" _MaxElement = %u\n", arrayObj->_MaxElement); -} - - -/** - * Initialize vertex array state for given context. - */ -void -_mesa_init_varray(GLcontext *ctx) -{ - ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); - _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, - ctx->Array.DefaultArrayObj); - ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ - - ctx->Array.Objects = _mesa_NewHashTable(); -} - - -/** - * Callback for deleting an array object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_arrayobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_array_object *arrayObj = (struct gl_array_object *) data; - GLcontext *ctx = (GLcontext *) userData; - _mesa_delete_array_object(ctx, arrayObj); -} - - -/** - * Free vertex array state for given context. - */ -void -_mesa_free_varray_data(GLcontext *ctx) -{ - _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx); - _mesa_DeleteHashTable(ctx->Array.Objects); -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "glheader.h" +#include "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "enable.h" +#include "enums.h" +#include "hash.h" +#include "image.h" +#include "macros.h" +#include "mtypes.h" +#include "varray.h" +#include "arrayobj.h" +#include "main/dispatch.h" + + +/** Used to do error checking for GL_EXT_vertex_array_bgra */ +#define BGRA_OR_4 5 + + +/** Used to indicate which GL datatypes are accepted by each of the + * glVertex/Color/Attrib/EtcPointer() functions. + */ +#define BOOL_BIT 0x1 +#define BYTE_BIT 0x2 +#define UNSIGNED_BYTE_BIT 0x4 +#define SHORT_BIT 0x8 +#define UNSIGNED_SHORT_BIT 0x10 +#define INT_BIT 0x20 +#define UNSIGNED_INT_BIT 0x40 +#define HALF_BIT 0x80 +#define FLOAT_BIT 0x100 +#define DOUBLE_BIT 0x200 +#define FIXED_BIT 0x400 + + + +/** Convert GL datatype enum into a _BIT value seen above */ +static GLbitfield +type_to_bit(const struct gl_context *ctx, GLenum type) +{ + switch (type) { + case GL_BOOL: + return BOOL_BIT; + case GL_BYTE: + return BYTE_BIT; + case GL_UNSIGNED_BYTE: + return UNSIGNED_BYTE_BIT; + case GL_SHORT: + return SHORT_BIT; + case GL_UNSIGNED_SHORT: + return UNSIGNED_SHORT_BIT; + case GL_INT: + return INT_BIT; + case GL_UNSIGNED_INT: + return UNSIGNED_INT_BIT; + case GL_HALF_FLOAT: + if (ctx->Extensions.ARB_half_float_vertex) + return HALF_BIT; + else + return 0x0; + case GL_FLOAT: + return FLOAT_BIT; + case GL_DOUBLE: + return DOUBLE_BIT; + case GL_FIXED: + return FIXED_BIT; + default: + return 0; + } +} + + +/** + * Do error checking and update state for glVertex/Color/TexCoord/...Pointer + * functions. + * + * \param func name of calling function used for error reporting + * \param array the array to update + * \param dirtyBit which bit to set in ctx->Array.NewState for this array + * \param legalTypes bitmask of *_BIT above indicating legal datatypes + * \param sizeMin min allowable size value + * \param sizeMax max allowable size value (may also be BGRA_OR_4) + * \param size components per element (1, 2, 3 or 4) + * \param type datatype of each component (GL_FLOAT, GL_INT, etc) + * \param stride stride between elements, in elements + * \param normalized are integer types converted to floats in [-1, 1]? + * \param integer integer-valued values (will not be normalized to [-1,1]) + * \param ptr the address (or offset inside VBO) of the array data + */ +static void +update_array(struct gl_context *ctx, + const char *func, + struct gl_client_array *array, + GLbitfield dirtyBit, GLbitfield legalTypesMask, + GLint sizeMin, GLint sizeMax, + GLint size, GLenum type, GLsizei stride, + GLboolean normalized, GLboolean integer, + const GLvoid *ptr) +{ + GLbitfield typeBit; + GLsizei elementSize; + GLenum format = GL_RGBA; + + if (ctx->API != API_OPENGLES && ctx->API != API_OPENGLES2) { + /* fixed point arrays / data is only allowed with OpenGL ES 1.x/2.0 */ + legalTypesMask &= ~FIXED_BIT; + } + + typeBit = type_to_bit(ctx, type); + if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", + func, _mesa_lookup_enum_by_nr(type)); + return; + } + + /* Do size parameter checking. + * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and + * must be handled specially. + */ + if (ctx->Extensions.EXT_vertex_array_bgra && + sizeMax == BGRA_OR_4 && + size == GL_BGRA) { + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func); + return; + } + format = GL_BGRA; + size = 4; + } + else if (size < sizeMin || size > sizeMax || size > 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); + return; + } + + ASSERT(size <= 4); + + if (stride < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); + return; + } + + if (ctx->Array.ArrayObj->VBOonly && + ctx->Array.ArrayBufferObj->Name == 0) { + /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. + * Generate GL_INVALID_OPERATION if that's not true. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func); + return; + } + + elementSize = _mesa_sizeof_type(type) * size; + + array->Size = size; + array->Type = type; + array->Format = format; + array->Stride = stride; + array->StrideB = stride ? stride : elementSize; + array->Normalized = normalized; + array->Ptr = (const GLubyte *) ptr; + array->_ElementSize = elementSize; + + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Array.ArrayBufferObj); + + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= dirtyBit; +} + + +void GLAPIENTRY +_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GLbitfield legalTypes = (SHORT_BIT | INT_BIT | FLOAT_BIT | + DOUBLE_BIT | HALF_BIT | FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->API == API_OPENGLES) + legalTypes |= BYTE_BIT; + + update_array(ctx, "glVertexPointer", + &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, + legalTypes, 2, 4, + size, type, stride, GL_FALSE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) +{ + const GLbitfield legalTypes = (BYTE_BIT | SHORT_BIT | INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glNormalPointer", + &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, + legalTypes, 3, 3, + 3, type, stride, GL_TRUE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | + SHORT_BIT | UNSIGNED_SHORT_BIT | + INT_BIT | UNSIGNED_INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glColorPointer", + &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, + legalTypes, 3, BGRA_OR_4, + size, type, stride, GL_TRUE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glFogCoordPointer", + &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, + legalTypes, 1, 1, + 1, type, stride, GL_FALSE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | INT_BIT | + FLOAT_BIT | DOUBLE_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glIndexPointer", + &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, + legalTypes, 1, 1, + 1, type, stride, GL_FALSE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | + SHORT_BIT | UNSIGNED_SHORT_BIT | + INT_BIT | UNSIGNED_INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glSecondaryColorPointer", + &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, + legalTypes, 3, BGRA_OR_4, + size, type, stride, GL_TRUE, GL_FALSE, ptr); +} + + +void GLAPIENTRY +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GLbitfield legalTypes = (SHORT_BIT | INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + const GLuint unit = ctx->Array.ActiveTexture; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->API == API_OPENGLES) + legalTypes |= BYTE_BIT; + + ASSERT(unit < Elements(ctx->Array.ArrayObj->TexCoord)); + + update_array(ctx, "glTexCoordPointer", + &ctx->Array.ArrayObj->TexCoord[unit], + _NEW_ARRAY_TEXCOORD(unit), + legalTypes, 1, 4, + size, type, stride, GL_FALSE, GL_FALSE, + ptr); +} + + +void GLAPIENTRY +_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = UNSIGNED_BYTE_BIT; + /* see table 2.4 edits in GL_EXT_gpu_shader4 spec: */ + const GLboolean integer = GL_TRUE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + update_array(ctx, "glEdgeFlagPointer", + &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, + legalTypes, 1, 1, + 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr); +} + + +void GLAPIENTRY +_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (FLOAT_BIT | FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->API != API_OPENGLES) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPointSizePointer(ES 1.x only)"); + return; + } + + update_array(ctx, "glPointSizePointer", + &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, + legalTypes, 1, 1, + 1, type, stride, GL_FALSE, GL_FALSE, ptr); +} + + +#if FEATURE_NV_vertex_program +/** + * Set a vertex attribute array. + * Note that these arrays DO alias the conventional GL vertex arrays + * (position, normal, color, fog, texcoord, etc). + * The generic attribute slots at #16 and above are not touched. + */ +void GLAPIENTRY +_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | + FLOAT_BIT | DOUBLE_BIT); + GLboolean normalized = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); + return; + } + + if (type == GL_UNSIGNED_BYTE && size != 4) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); + return; + } + + update_array(ctx, "glVertexAttribPointerNV", + &ctx->Array.ArrayObj->VertexAttrib[index], + _NEW_ARRAY_ATTRIB(index), + legalTypes, 1, BGRA_OR_4, + size, type, stride, normalized, GL_FALSE, ptr); +} +#endif + + +#if FEATURE_ARB_vertex_program +/** + * Set a generic vertex attribute array. + * Note that these arrays DO NOT alias the conventional GL vertex arrays + * (position, normal, color, fog, texcoord, etc). + */ +void GLAPIENTRY +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, + GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | + SHORT_BIT | UNSIGNED_SHORT_BIT | + INT_BIT | UNSIGNED_INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + FIXED_BIT); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); + return; + } + + update_array(ctx, "glVertexAttribPointer", + &ctx->Array.ArrayObj->VertexAttrib[index], + _NEW_ARRAY_ATTRIB(index), + legalTypes, 1, BGRA_OR_4, + size, type, stride, normalized, GL_FALSE, ptr); +} +#endif + + +/** + * GL_EXT_gpu_shader4 / GL 3.0. + * Set an integer-valued vertex attribute array. + * Note that these arrays DO NOT alias the conventional GL vertex arrays + * (position, normal, color, fog, texcoord, etc). + */ +void GLAPIENTRY +_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | + SHORT_BIT | UNSIGNED_SHORT_BIT | + INT_BIT | UNSIGNED_INT_BIT); + const GLboolean normalized = GL_FALSE; + const GLboolean integer = GL_TRUE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)"); + return; + } + + update_array(ctx, "glVertexAttribIPointer", + &ctx->Array.ArrayObj->VertexAttrib[index], + _NEW_ARRAY_ATTRIB(index), + legalTypes, 1, 4, + size, type, stride, normalized, integer, ptr); +} + + + +void GLAPIENTRY +_mesa_EnableVertexAttribArrayARB(GLuint index) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glEnableVertexAttribArrayARB(index)"); + return; + } + + ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE; + ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index); + ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); +} + + +void GLAPIENTRY +_mesa_DisableVertexAttribArrayARB(GLuint index) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glEnableVertexAttribArrayARB(index)"); + return; + } + + ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE; + ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index); + ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index); +} + + +/** + * Return info for a vertex attribute array (no alias with legacy + * vertex attributes (pos, normal, color, etc)). This function does + * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query. + */ +static GLuint +get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, + const char *caller) +{ + const struct gl_client_array *array; + + if (index >= MAX_VERTEX_GENERIC_ATTRIBS) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index); + return 0; + } + + ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); + + array = &ctx->Array.ArrayObj->VertexAttrib[index]; + + switch (pname) { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: + return array->Enabled; + case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: + return array->Size; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: + return array->Stride; + case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: + return array->Type; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: + return array->Normalized; + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: + return array->BufferObj->Name; + case GL_VERTEX_ATTRIB_ARRAY_INTEGER: + if (ctx->Extensions.EXT_gpu_shader4) { + return array->Integer; + } + /* fall-through */ + default: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname); + return 0; + } +} + + +void GLAPIENTRY +_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribfv(index==0)"); + } + else { + const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; + FLUSH_CURRENT(ctx, 0); + COPY_4V(params, v); + } + } + else { + params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname, + "glGetVertexAttribfv"); + } +} + + +void GLAPIENTRY +_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribdv(index==0)"); + } + else { + const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; + FLUSH_CURRENT(ctx, 0); + params[0] = (GLdouble) v[0]; + params[1] = (GLdouble) v[1]; + params[2] = (GLdouble) v[2]; + params[3] = (GLdouble) v[3]; + } + } + else { + params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname, + "glGetVertexAttribdv"); + } +} + + +void GLAPIENTRY +_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribiv(index==0)"); + } + else { + const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; + FLUSH_CURRENT(ctx, 0); + /* XXX should floats in[0,1] be scaled to full int range? */ + params[0] = (GLint) v[0]; + params[1] = (GLint) v[1]; + params[2] = (GLint) v[2]; + params[3] = (GLint) v[3]; + } + } + else { + params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, + "glGetVertexAttribiv"); + } +} + + +/** GL 3.0 */ +void GLAPIENTRY +_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribIiv(index==0)"); + } + else { + const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; + FLUSH_CURRENT(ctx, 0); + /* XXX we don't have true integer-valued vertex attribs yet */ + params[0] = (GLint) v[0]; + params[1] = (GLint) v[1]; + params[2] = (GLint) v[2]; + params[3] = (GLint) v[3]; + } + } + else { + params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, + "glGetVertexAttribIiv"); + } +} + + +/** GL 3.0 */ +void GLAPIENTRY +_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + if (index == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetVertexAttribIuiv(index==0)"); + } + else { + const GLfloat *v = ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]; + FLUSH_CURRENT(ctx, 0); + /* XXX we don't have true integer-valued vertex attribs yet */ + params[0] = (GLuint) v[0]; + params[1] = (GLuint) v[1]; + params[2] = (GLuint) v[2]; + params[3] = (GLuint) v[3]; + } + } + else { + params[0] = get_vertex_array_attrib(ctx, index, pname, + "glGetVertexAttribIuiv"); + } +} + + +void GLAPIENTRY +_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)"); + return; + } + + if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)"); + return; + } + + ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib)); + + *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr; +} + + +void GLAPIENTRY +_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + (void) count; + _mesa_VertexPointer(size, type, stride, ptr); +} + + +void GLAPIENTRY +_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + (void) count; + _mesa_NormalPointer(type, stride, ptr); +} + + +void GLAPIENTRY +_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + (void) count; + _mesa_ColorPointer(size, type, stride, ptr); +} + + +void GLAPIENTRY +_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + (void) count; + _mesa_IndexPointer(type, stride, ptr); +} + + +void GLAPIENTRY +_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + (void) count; + _mesa_TexCoordPointer(size, type, stride, ptr); +} + + +void GLAPIENTRY +_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) +{ + (void) count; + _mesa_EdgeFlagPointer(stride, ptr); +} + + +void GLAPIENTRY +_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) +{ + GET_CURRENT_CONTEXT(ctx); + GLboolean tflag, cflag, nflag; /* enable/disable flags */ + GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ + GLenum ctype = 0; /* color type */ + GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ + const GLint toffset = 0; /* always zero */ + GLint defstride; /* default stride */ + GLint c, f; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + f = sizeof(GLfloat); + c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); + + if (stride < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); + return; + } + + switch (format) { + case GL_V2F: + tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; + tcomps = 0; ccomps = 0; vcomps = 2; + voffset = 0; + defstride = 2*f; + break; + case GL_V3F: + tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; + tcomps = 0; ccomps = 0; vcomps = 3; + voffset = 0; + defstride = 3*f; + break; + case GL_C4UB_V2F: + tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; + tcomps = 0; ccomps = 4; vcomps = 2; + ctype = GL_UNSIGNED_BYTE; + coffset = 0; + voffset = c; + defstride = c + 2*f; + break; + case GL_C4UB_V3F: + tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; + tcomps = 0; ccomps = 4; vcomps = 3; + ctype = GL_UNSIGNED_BYTE; + coffset = 0; + voffset = c; + defstride = c + 3*f; + break; + case GL_C3F_V3F: + tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; + tcomps = 0; ccomps = 3; vcomps = 3; + ctype = GL_FLOAT; + coffset = 0; + voffset = 3*f; + defstride = 6*f; + break; + case GL_N3F_V3F: + tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; + tcomps = 0; ccomps = 0; vcomps = 3; + noffset = 0; + voffset = 3*f; + defstride = 6*f; + break; + case GL_C4F_N3F_V3F: + tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; + tcomps = 0; ccomps = 4; vcomps = 3; + ctype = GL_FLOAT; + coffset = 0; + noffset = 4*f; + voffset = 7*f; + defstride = 10*f; + break; + case GL_T2F_V3F: + tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; + tcomps = 2; ccomps = 0; vcomps = 3; + voffset = 2*f; + defstride = 5*f; + break; + case GL_T4F_V4F: + tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; + tcomps = 4; ccomps = 0; vcomps = 4; + voffset = 4*f; + defstride = 8*f; + break; + case GL_T2F_C4UB_V3F: + tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; + tcomps = 2; ccomps = 4; vcomps = 3; + ctype = GL_UNSIGNED_BYTE; + coffset = 2*f; + voffset = c+2*f; + defstride = c+5*f; + break; + case GL_T2F_C3F_V3F: + tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; + tcomps = 2; ccomps = 3; vcomps = 3; + ctype = GL_FLOAT; + coffset = 2*f; + voffset = 5*f; + defstride = 8*f; + break; + case GL_T2F_N3F_V3F: + tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; + tcomps = 2; ccomps = 0; vcomps = 3; + noffset = 2*f; + voffset = 5*f; + defstride = 8*f; + break; + case GL_T2F_C4F_N3F_V3F: + tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; + tcomps = 2; ccomps = 4; vcomps = 3; + ctype = GL_FLOAT; + coffset = 2*f; + noffset = 6*f; + voffset = 9*f; + defstride = 12*f; + break; + case GL_T4F_C4F_N3F_V4F: + tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; + tcomps = 4; ccomps = 4; vcomps = 4; + ctype = GL_FLOAT; + coffset = 4*f; + noffset = 8*f; + voffset = 11*f; + defstride = 15*f; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); + return; + } + + if (stride==0) { + stride = defstride; + } + + _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); + _mesa_DisableClientState( GL_INDEX_ARRAY ); + /* XXX also disable secondary color and generic arrays? */ + + /* Texcoords */ + if (tflag) { + _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); + _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, + (GLubyte *) pointer + toffset ); + } + else { + _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); + } + + /* Color */ + if (cflag) { + _mesa_EnableClientState( GL_COLOR_ARRAY ); + _mesa_ColorPointer( ccomps, ctype, stride, + (GLubyte *) pointer + coffset ); + } + else { + _mesa_DisableClientState( GL_COLOR_ARRAY ); + } + + + /* Normals */ + if (nflag) { + _mesa_EnableClientState( GL_NORMAL_ARRAY ); + _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); + } + else { + _mesa_DisableClientState( GL_NORMAL_ARRAY ); + } + + /* Vertices */ + _mesa_EnableClientState( GL_VERTEX_ARRAY ); + _mesa_VertexPointer( vcomps, GL_FLOAT, stride, + (GLubyte *) pointer + voffset ); +} + + +void GLAPIENTRY +_mesa_LockArraysEXT(GLint first, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); + + if (first < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); + return; + } + if (count <= 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); + return; + } + if (ctx->Array.LockCount != 0) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); + return; + } + + ctx->Array.LockFirst = first; + ctx->Array.LockCount = count; + + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= _NEW_ARRAY_ALL; +} + + +void GLAPIENTRY +_mesa_UnlockArraysEXT( void ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glUnlockArrays\n"); + + if (ctx->Array.LockCount == 0) { + _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); + return; + } + + ctx->Array.LockFirst = 0; + ctx->Array.LockCount = 0; + ctx->NewState |= _NEW_ARRAY; + ctx->Array.NewState |= _NEW_ARRAY_ALL; +} + + +/* GL_EXT_multi_draw_arrays */ +void GLAPIENTRY +_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); + } + } +} + + +/* GL_IBM_multimode_draw_arrays */ +void GLAPIENTRY +_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, + const GLsizei * count, + GLsizei primcount, GLint modestride ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + for ( i = 0 ; i < primcount ; i++ ) { + if ( count[i] > 0 ) { + GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); + CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); + } + } +} + + +/* GL_IBM_multimode_draw_arrays */ +void GLAPIENTRY +_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, + GLenum type, const GLvoid * const * indices, + GLsizei primcount, GLint modestride ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + /* XXX not sure about ARB_vertex_buffer_object handling here */ + + for ( i = 0 ; i < primcount ; i++ ) { + if ( count[i] > 0 ) { + GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); + CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); + } + } +} + + +/** + * GL_NV_primitive_restart and GL 3.1 + */ +void GLAPIENTRY +_mesa_PrimitiveRestartIndex(GLuint index) +{ + GET_CURRENT_CONTEXT(ctx); + + if (!ctx->Extensions.NV_primitive_restart && + ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndexNV()"); + return; + } + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + + ctx->Array.RestartIndex = index; +} + + +/** + * Copy one client vertex array to another. + */ +void +_mesa_copy_client_array(struct gl_context *ctx, + struct gl_client_array *dst, + struct gl_client_array *src) +{ + dst->Size = src->Size; + dst->Type = src->Type; + dst->Format = src->Format; + dst->Stride = src->Stride; + dst->StrideB = src->StrideB; + dst->Ptr = src->Ptr; + dst->Enabled = src->Enabled; + dst->Normalized = src->Normalized; + dst->Integer = src->Integer; + dst->_ElementSize = src->_ElementSize; + _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); + dst->_MaxElement = src->_MaxElement; +} + + + +/** + * Print vertex array's fields. + */ +static void +print_array(const char *name, GLint index, const struct gl_client_array *array) +{ + if (index >= 0) + printf(" %s[%d]: ", name, index); + else + printf(" %s: ", name); + printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu), MaxElem=%u\n", + array->Ptr, array->Type, array->Size, + array->_ElementSize, array->StrideB, + array->BufferObj->Name, (unsigned long) array->BufferObj->Size, + array->_MaxElement); +} + + +/** + * Print current vertex object/array info. For debug. + */ +void +_mesa_print_arrays(struct gl_context *ctx) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint i; + + _mesa_update_array_object_max_element(ctx, arrayObj); + + printf("Array Object %u\n", arrayObj->Name); + if (arrayObj->Vertex.Enabled) + print_array("Vertex", -1, &arrayObj->Vertex); + if (arrayObj->Normal.Enabled) + print_array("Normal", -1, &arrayObj->Normal); + if (arrayObj->Color.Enabled) + print_array("Color", -1, &arrayObj->Color); + for (i = 0; i < Elements(arrayObj->TexCoord); i++) + if (arrayObj->TexCoord[i].Enabled) + print_array("TexCoord", i, &arrayObj->TexCoord[i]); + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) + if (arrayObj->VertexAttrib[i].Enabled) + print_array("Attrib", i, &arrayObj->VertexAttrib[i]); + printf(" _MaxElement = %u\n", arrayObj->_MaxElement); +} + + +/** + * Initialize vertex array state for given context. + */ +void +_mesa_init_varray(struct gl_context *ctx) +{ + ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); + _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, + ctx->Array.DefaultArrayObj); + ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ + + ctx->Array.Objects = _mesa_NewHashTable(); +} + + +/** + * Callback for deleting an array object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_arrayobj_cb(GLuint id, void *data, void *userData) +{ + struct gl_array_object *arrayObj = (struct gl_array_object *) data; + struct gl_context *ctx = (struct gl_context *) userData; + _mesa_delete_array_object(ctx, arrayObj); +} + + +/** + * Free vertex array state for given context. + */ +void +_mesa_free_varray_data(struct gl_context *ctx) +{ + _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx); + _mesa_DeleteHashTable(ctx->Array.Objects); +} diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h index c7c3e3ec7..5e25c4e2f 100644 --- a/mesalib/src/mesa/main/varray.h +++ b/mesalib/src/mesa/main/varray.h @@ -1,241 +1,244 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VARRAY_H -#define VARRAY_H - - -#include "mtypes.h" - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - - -extern void GLAPIENTRY -_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); - - -extern void GLAPIENTRY -_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *pointer); - - -extern void GLAPIENTRY -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, - const GLvoid *pointer); - -void GLAPIENTRY -_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, - GLboolean normalized, - GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EnableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_DisableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); - - -extern void GLAPIENTRY -_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); - - -extern void GLAPIENTRY -_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount ); - -extern void GLAPIENTRY -_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount ); - -extern void GLAPIENTRY -_mesa_MultiDrawElementsBaseVertex( GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount, - const GLint *basevertex); - -extern void GLAPIENTRY -_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, - const GLsizei * count, - GLsizei primcount, GLint modestride ); - - -extern void GLAPIENTRY -_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, - GLenum type, const GLvoid * const * indices, - GLsizei primcount, GLint modestride ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - - -extern void GLAPIENTRY -_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices); - -extern void GLAPIENTRY -_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, - GLenum type, const GLvoid *indices); - -extern void GLAPIENTRY -_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex); - -extern void GLAPIENTRY -_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, - GLint basevertex); - -extern void GLAPIENTRY -_mesa_PrimitiveRestartIndex(GLuint index); - - -extern void -_mesa_copy_client_array(GLcontext *ctx, - struct gl_client_array *dst, - struct gl_client_array *src); - - -extern void -_mesa_print_arrays(GLcontext *ctx); - -extern void -_mesa_init_varray( GLcontext * ctx ); - -extern void -_mesa_free_varray_data(GLcontext *ctx); - -#else - -/** No-op */ -#define _mesa_init_varray( c ) ((void)0) -#define _mesa_free_varray_data( c ) ((void)0) - -#endif - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef VARRAY_H +#define VARRAY_H + + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_client_array; +struct gl_context; + +#if _HAVE_FULL_GL + +extern void GLAPIENTRY +_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); + +extern void GLAPIENTRY +_mesa_UnlockArraysEXT( void ); + +extern void GLAPIENTRY +_mesa_LockArraysEXT(GLint first, GLsizei count); + + +extern void GLAPIENTRY +_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); + + +extern void GLAPIENTRY +_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); + + +extern void GLAPIENTRY +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, + const GLvoid *pointer); + +void GLAPIENTRY +_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EnableVertexAttribArrayARB(GLuint index); + + +extern void GLAPIENTRY +_mesa_DisableVertexAttribArrayARB(GLuint index); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); + + +extern void GLAPIENTRY +_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); + + +extern void GLAPIENTRY +_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount ); + +extern void GLAPIENTRY +_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount ); + +extern void GLAPIENTRY +_mesa_MultiDrawElementsBaseVertex( GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount, + const GLint *basevertex); + +extern void GLAPIENTRY +_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, + const GLsizei * count, + GLsizei primcount, GLint modestride ); + + +extern void GLAPIENTRY +_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, + GLenum type, const GLvoid * const * indices, + GLsizei primcount, GLint modestride ); + +extern void GLAPIENTRY +_mesa_LockArraysEXT(GLint first, GLsizei count); + +extern void GLAPIENTRY +_mesa_UnlockArraysEXT( void ); + + +extern void GLAPIENTRY +_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); + +extern void GLAPIENTRY +_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices); + +extern void GLAPIENTRY +_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, + GLenum type, const GLvoid *indices); + +extern void GLAPIENTRY +_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex); + +extern void GLAPIENTRY +_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, + GLint basevertex); + +extern void GLAPIENTRY +_mesa_PrimitiveRestartIndex(GLuint index); + + +extern void +_mesa_copy_client_array(struct gl_context *ctx, + struct gl_client_array *dst, + struct gl_client_array *src); + + +extern void +_mesa_print_arrays(struct gl_context *ctx); + +extern void +_mesa_init_varray( struct gl_context * ctx ); + +extern void +_mesa_free_varray_data(struct gl_context *ctx); + +#else + +/** No-op */ +#define _mesa_init_varray( c ) ((void)0) +#define _mesa_free_varray_data( c ) ((void)0) + +#endif + +#endif diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 5997ca00f..99dc8b350 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -1,284 +1,284 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "context.h" -#include "version.h" - - - -/** - * Examine enabled GL extensions to determine GL version. - * Return major and minor version numbers. - */ -static void -compute_version(GLcontext *ctx) -{ - GLuint major, minor; - static const int max = 100; - - const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample && - ctx->Extensions.ARB_multitexture && - ctx->Extensions.ARB_texture_border_clamp && - ctx->Extensions.ARB_texture_compression && - ctx->Extensions.ARB_texture_cube_map && - ctx->Extensions.EXT_texture_env_add && - ctx->Extensions.ARB_texture_env_combine && - ctx->Extensions.ARB_texture_env_dot3); - const GLboolean ver_1_4 = (ver_1_3 && - ctx->Extensions.ARB_depth_texture && - ctx->Extensions.ARB_shadow && - ctx->Extensions.ARB_texture_env_crossbar && - ctx->Extensions.ARB_texture_mirrored_repeat && - ctx->Extensions.ARB_window_pos && - ctx->Extensions.EXT_blend_color && - ctx->Extensions.EXT_blend_func_separate && - ctx->Extensions.EXT_blend_minmax && - ctx->Extensions.EXT_blend_subtract && - ctx->Extensions.EXT_fog_coord && - ctx->Extensions.EXT_multi_draw_arrays && - ctx->Extensions.EXT_point_parameters && - ctx->Extensions.EXT_secondary_color && - ctx->Extensions.EXT_stencil_wrap && - ctx->Extensions.EXT_texture_lod_bias && - ctx->Extensions.SGIS_generate_mipmap); - const GLboolean ver_1_5 = (ver_1_4 && - ctx->Extensions.ARB_occlusion_query && - ctx->Extensions.ARB_vertex_buffer_object && - ctx->Extensions.EXT_shadow_funcs); - const GLboolean ver_2_0 = (ver_1_5 && - ctx->Extensions.ARB_draw_buffers && - ctx->Extensions.ARB_point_sprite && - ctx->Extensions.ARB_shader_objects && - ctx->Extensions.ARB_vertex_shader && - ctx->Extensions.ARB_fragment_shader && - ctx->Extensions.ARB_texture_non_power_of_two && - ctx->Extensions.EXT_blend_equation_separate && - - /* Technically, 2.0 requires the functionality - * of the EXT version. Enable 2.0 if either - * extension is available, and assume that a - * driver that only exposes the ATI extension - * will fallback to software when necessary. - */ - (ctx->Extensions.EXT_stencil_two_side - || ctx->Extensions.ATI_separate_stencil)); - const GLboolean ver_2_1 = (ver_2_0 && - ctx->Const.GLSLVersion >= 120 && - ctx->Extensions.EXT_pixel_buffer_object && - ctx->Extensions.EXT_texture_sRGB); - const GLboolean ver_3_0 = (ver_2_1 && - ctx->Extensions.ARB_half_float_pixel && - ctx->Extensions.ARB_map_buffer_range && - ctx->Extensions.ARB_texture_float && - ctx->Extensions.ARB_texture_rg && - ctx->Extensions.APPLE_vertex_array_object && - ctx->Extensions.EXT_draw_buffers2 && - ctx->Extensions.EXT_framebuffer_blit && - ctx->Extensions.EXT_framebuffer_multisample && - ctx->Extensions.EXT_framebuffer_object && - ctx->Extensions.EXT_framebuffer_sRGB && - ctx->Extensions.EXT_packed_depth_stencil && - ctx->Extensions.EXT_packed_float && - ctx->Extensions.EXT_texture_array && - ctx->Extensions.EXT_texture_compression_rgtc && - ctx->Extensions.EXT_texture_integer && - ctx->Extensions.EXT_texture_shared_exponent && - ctx->Extensions.EXT_transform_feedback && - ctx->Extensions.NV_conditional_render); - const GLboolean ver_3_1 = (ver_3_0 && - ctx->Extensions.ARB_copy_buffer && - ctx->Extensions.ARB_draw_instanced && - ctx->Extensions.ARB_texture_buffer_object && - ctx->Extensions.ARB_uniform_buffer_object && - ctx->Extensions.NV_primitive_restart && - ctx->Extensions.NV_texture_rectangle && - ctx->Const.MaxVertexTextureImageUnits >= 16); - const GLboolean ver_3_2 = (ver_3_1 && - ctx->Extensions.ARB_depth_clamp && - ctx->Extensions.ARB_draw_elements_base_vertex && - ctx->Extensions.ARB_fragment_coord_conventions && - ctx->Extensions.ARB_geometry_shader4 && - ctx->Extensions.EXT_provoking_vertex && - ctx->Extensions.ARB_seamless_cube_map && - ctx->Extensions.ARB_sync && - ctx->Extensions.ARB_texture_multisample && - ctx->Extensions.EXT_vertex_array_bgra); - const GLboolean ver_3_3 = (ver_3_2 && - ctx->Extensions.ARB_blend_func_extended && - ctx->Extensions.ARB_explicit_attrib_location && - ctx->Extensions.ARB_instanced_arrays && - ctx->Extensions.ARB_occlusion_query2 && - ctx->Extensions.ARB_sampler_objects && - ctx->Extensions.ARB_texture_rgb10_a2ui && - ctx->Extensions.ARB_timer_query && - ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && - ctx->Extensions.EXT_texture_swizzle); - - if (ver_3_3) { - major = 3; - minor = 3; - } - else if (ver_3_2) { - major = 3; - minor = 2; - } - else if (ver_3_1) { - major = 3; - minor = 1; - } - else if (ver_3_0) { - major = 3; - minor = 0; - } - else if (ver_2_1) { - major = 2; - minor = 1; - } - else if (ver_2_0) { - major = 2; - minor = 0; - } - else if (ver_1_5) { - major = 1; - minor = 5; - } - else if (ver_1_4) { - major = 1; - minor = 4; - } - else if (ver_1_3) { - major = 1; - minor = 3; - } - else { - major = 1; - minor = 2; - } - - ctx->VersionMajor = major; - ctx->VersionMinor = minor; - ctx->VersionString = (char *) malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "%u.%u Mesa " MESA_VERSION_STRING, - ctx->VersionMajor, ctx->VersionMinor); - } -} - -static void -compute_version_es1(GLcontext *ctx) -{ - static const int max = 100; - - /* OpenGL ES 1.0 is derived from OpenGL 1.3 */ - const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample && - ctx->Extensions.ARB_multitexture && - ctx->Extensions.ARB_texture_compression && - ctx->Extensions.EXT_texture_env_add && - ctx->Extensions.ARB_texture_env_combine && - ctx->Extensions.ARB_texture_env_dot3); - /* OpenGL ES 1.1 is derived from OpenGL 1.5 */ - const GLboolean ver_1_1 = (ver_1_0 && - ctx->Extensions.EXT_point_parameters && - ctx->Extensions.SGIS_generate_mipmap && - ctx->Extensions.ARB_vertex_buffer_object); - - if (ver_1_1) { - ctx->VersionMajor = 1; - ctx->VersionMinor = 1; - } else if (ver_1_0) { - ctx->VersionMajor = 1; - ctx->VersionMinor = 0; - } else { - _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support."); - } - - ctx->VersionString = (char *) malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING, - ctx->VersionMinor); - } -} - -static void -compute_version_es2(GLcontext *ctx) -{ - static const int max = 100; - - /* OpenGL ES 2.0 is derived from OpenGL 2.0 */ - const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample && - ctx->Extensions.ARB_multitexture && - ctx->Extensions.ARB_texture_compression && - ctx->Extensions.ARB_texture_cube_map && - ctx->Extensions.ARB_texture_mirrored_repeat && - ctx->Extensions.EXT_blend_color && - ctx->Extensions.EXT_blend_func_separate && - ctx->Extensions.EXT_blend_minmax && - ctx->Extensions.EXT_blend_subtract && - ctx->Extensions.EXT_stencil_wrap && - ctx->Extensions.ARB_vertex_buffer_object && - ctx->Extensions.ARB_shader_objects && - ctx->Extensions.ARB_vertex_shader && - ctx->Extensions.ARB_fragment_shader && - ctx->Extensions.ARB_texture_non_power_of_two && - ctx->Extensions.EXT_blend_equation_separate); - if (ver_2_0) { - ctx->VersionMajor = 2; - ctx->VersionMinor = 0; - } else { - _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support."); - } - - ctx->VersionString = (char *) malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING); - } -} - -/** - * Set the context's VersionMajor, VersionMinor, VersionString fields. - * This should only be called once as part of context initialization - * or to perform version check for GLX_ARB_create_context_profile. - */ -void -_mesa_compute_version(GLcontext *ctx) -{ - if (ctx->VersionMajor) - return; - - switch (ctx->API) { - case API_OPENGL: - compute_version(ctx); - break; - case API_OPENGLES: - compute_version_es1(ctx); - break; - case API_OPENGLES2: - compute_version_es2(ctx); - break; - } - -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "context.h" +#include "version.h" + + + +/** + * Examine enabled GL extensions to determine GL version. + * Return major and minor version numbers. + */ +static void +compute_version(struct gl_context *ctx) +{ + GLuint major, minor; + static const int max = 100; + + const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_border_clamp && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.ARB_texture_cube_map && + ctx->Extensions.EXT_texture_env_add && + ctx->Extensions.ARB_texture_env_combine && + ctx->Extensions.ARB_texture_env_dot3); + const GLboolean ver_1_4 = (ver_1_3 && + ctx->Extensions.ARB_depth_texture && + ctx->Extensions.ARB_shadow && + ctx->Extensions.ARB_texture_env_crossbar && + ctx->Extensions.ARB_texture_mirrored_repeat && + ctx->Extensions.ARB_window_pos && + ctx->Extensions.EXT_blend_color && + ctx->Extensions.EXT_blend_func_separate && + ctx->Extensions.EXT_blend_minmax && + ctx->Extensions.EXT_blend_subtract && + ctx->Extensions.EXT_fog_coord && + ctx->Extensions.EXT_multi_draw_arrays && + ctx->Extensions.EXT_point_parameters && + ctx->Extensions.EXT_secondary_color && + ctx->Extensions.EXT_stencil_wrap && + ctx->Extensions.EXT_texture_lod_bias && + ctx->Extensions.SGIS_generate_mipmap); + const GLboolean ver_1_5 = (ver_1_4 && + ctx->Extensions.ARB_occlusion_query && + ctx->Extensions.ARB_vertex_buffer_object && + ctx->Extensions.EXT_shadow_funcs); + const GLboolean ver_2_0 = (ver_1_5 && + ctx->Extensions.ARB_draw_buffers && + ctx->Extensions.ARB_point_sprite && + ctx->Extensions.ARB_shader_objects && + ctx->Extensions.ARB_vertex_shader && + ctx->Extensions.ARB_fragment_shader && + ctx->Extensions.ARB_texture_non_power_of_two && + ctx->Extensions.EXT_blend_equation_separate && + + /* Technically, 2.0 requires the functionality + * of the EXT version. Enable 2.0 if either + * extension is available, and assume that a + * driver that only exposes the ATI extension + * will fallback to software when necessary. + */ + (ctx->Extensions.EXT_stencil_two_side + || ctx->Extensions.ATI_separate_stencil)); + const GLboolean ver_2_1 = (ver_2_0 && + ctx->Const.GLSLVersion >= 120 && + ctx->Extensions.EXT_pixel_buffer_object && + ctx->Extensions.EXT_texture_sRGB); + const GLboolean ver_3_0 = (ver_2_1 && + ctx->Extensions.ARB_half_float_pixel && + ctx->Extensions.ARB_map_buffer_range && + ctx->Extensions.ARB_texture_float && + ctx->Extensions.ARB_texture_rg && + ctx->Extensions.ARB_texture_compression_rgtc && + ctx->Extensions.APPLE_vertex_array_object && + ctx->Extensions.EXT_draw_buffers2 && + ctx->Extensions.EXT_framebuffer_blit && + ctx->Extensions.EXT_framebuffer_multisample && + ctx->Extensions.EXT_framebuffer_object && + ctx->Extensions.EXT_framebuffer_sRGB && + ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.EXT_packed_float && + ctx->Extensions.EXT_texture_array && + ctx->Extensions.EXT_texture_integer && + ctx->Extensions.EXT_texture_shared_exponent && + ctx->Extensions.EXT_transform_feedback && + ctx->Extensions.NV_conditional_render); + const GLboolean ver_3_1 = (ver_3_0 && + ctx->Extensions.ARB_copy_buffer && + ctx->Extensions.ARB_draw_instanced && + ctx->Extensions.ARB_texture_buffer_object && + ctx->Extensions.ARB_uniform_buffer_object && + ctx->Extensions.NV_primitive_restart && + ctx->Extensions.NV_texture_rectangle && + ctx->Const.MaxVertexTextureImageUnits >= 16); + const GLboolean ver_3_2 = (ver_3_1 && + ctx->Extensions.ARB_depth_clamp && + ctx->Extensions.ARB_draw_elements_base_vertex && + ctx->Extensions.ARB_fragment_coord_conventions && + ctx->Extensions.ARB_geometry_shader4 && + ctx->Extensions.EXT_provoking_vertex && + ctx->Extensions.ARB_seamless_cube_map && + ctx->Extensions.ARB_sync && + ctx->Extensions.ARB_texture_multisample && + ctx->Extensions.EXT_vertex_array_bgra); + const GLboolean ver_3_3 = (ver_3_2 && + ctx->Extensions.ARB_blend_func_extended && + ctx->Extensions.ARB_explicit_attrib_location && + ctx->Extensions.ARB_instanced_arrays && + ctx->Extensions.ARB_occlusion_query2 && + ctx->Extensions.ARB_sampler_objects && + ctx->Extensions.ARB_texture_rgb10_a2ui && + ctx->Extensions.ARB_timer_query && + ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && + ctx->Extensions.EXT_texture_swizzle); + + if (ver_3_3) { + major = 3; + minor = 3; + } + else if (ver_3_2) { + major = 3; + minor = 2; + } + else if (ver_3_1) { + major = 3; + minor = 1; + } + else if (ver_3_0) { + major = 3; + minor = 0; + } + else if (ver_2_1) { + major = 2; + minor = 1; + } + else if (ver_2_0) { + major = 2; + minor = 0; + } + else if (ver_1_5) { + major = 1; + minor = 5; + } + else if (ver_1_4) { + major = 1; + minor = 4; + } + else if (ver_1_3) { + major = 1; + minor = 3; + } + else { + major = 1; + minor = 2; + } + + ctx->VersionMajor = major; + ctx->VersionMinor = minor; + ctx->VersionString = (char *) malloc(max); + if (ctx->VersionString) { + _mesa_snprintf(ctx->VersionString, max, + "%u.%u Mesa " MESA_VERSION_STRING, + ctx->VersionMajor, ctx->VersionMinor); + } +} + +static void +compute_version_es1(struct gl_context *ctx) +{ + static const int max = 100; + + /* OpenGL ES 1.0 is derived from OpenGL 1.3 */ + const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.EXT_texture_env_add && + ctx->Extensions.ARB_texture_env_combine && + ctx->Extensions.ARB_texture_env_dot3); + /* OpenGL ES 1.1 is derived from OpenGL 1.5 */ + const GLboolean ver_1_1 = (ver_1_0 && + ctx->Extensions.EXT_point_parameters && + ctx->Extensions.SGIS_generate_mipmap && + ctx->Extensions.ARB_vertex_buffer_object); + + if (ver_1_1) { + ctx->VersionMajor = 1; + ctx->VersionMinor = 1; + } else if (ver_1_0) { + ctx->VersionMajor = 1; + ctx->VersionMinor = 0; + } else { + _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support."); + } + + ctx->VersionString = (char *) malloc(max); + if (ctx->VersionString) { + _mesa_snprintf(ctx->VersionString, max, + "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING, + ctx->VersionMinor); + } +} + +static void +compute_version_es2(struct gl_context *ctx) +{ + static const int max = 100; + + /* OpenGL ES 2.0 is derived from OpenGL 2.0 */ + const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.ARB_texture_cube_map && + ctx->Extensions.ARB_texture_mirrored_repeat && + ctx->Extensions.EXT_blend_color && + ctx->Extensions.EXT_blend_func_separate && + ctx->Extensions.EXT_blend_minmax && + ctx->Extensions.EXT_blend_subtract && + ctx->Extensions.EXT_stencil_wrap && + ctx->Extensions.ARB_vertex_buffer_object && + ctx->Extensions.ARB_shader_objects && + ctx->Extensions.ARB_vertex_shader && + ctx->Extensions.ARB_fragment_shader && + ctx->Extensions.ARB_texture_non_power_of_two && + ctx->Extensions.EXT_blend_equation_separate); + if (ver_2_0) { + ctx->VersionMajor = 2; + ctx->VersionMinor = 0; + } else { + _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support."); + } + + ctx->VersionString = (char *) malloc(max); + if (ctx->VersionString) { + _mesa_snprintf(ctx->VersionString, max, + "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING); + } +} + +/** + * Set the context's VersionMajor, VersionMinor, VersionString fields. + * This should only be called once as part of context initialization + * or to perform version check for GLX_ARB_create_context_profile. + */ +void +_mesa_compute_version(struct gl_context *ctx) +{ + if (ctx->VersionMajor) + return; + + switch (ctx->API) { + case API_OPENGL: + compute_version(ctx); + break; + case API_OPENGLES: + compute_version_es1(ctx); + break; + case API_OPENGLES2: + compute_version_es2(ctx); + break; + } + +} diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h index 1289ca985..0dff499ef 100644 --- a/mesalib/src/mesa/main/version.h +++ b/mesalib/src/mesa/main/version.h @@ -1,60 +1,60 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VERSION_H -#define VERSION_H - - -#include "mtypes.h" - - -/* Mesa version */ -#define MESA_MAJOR 7 -#define MESA_MINOR 9 -#define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.9" - -/* To make version comparison easy */ -#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define MESA_VERSION_CODE MESA_VERSION(MESA_MAJOR, MESA_MINOR, MESA_PATCH) - - -/* OpenGL API version */ -#define OPENGL_MAJOR 2 -#define OPENGL_MINOR 1 -#define OPENGL_PATCH 0 -#define OPENGL_VERSION_STRING "2.1" - -/* To make version comparison easy */ -#define OPENGL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define OPENGL_VERSION_CODE OPENGL_VERSION(OPENGL_MAJOR, OPENGL_MINOR, OPENGL_PATCH) - - -extern void -_mesa_compute_version(GLcontext *ctx); - - -#endif /* VERSION_H */ +/* + * Mesa 3-D graphics library + * Version: 7.10 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef VERSION_H +#define VERSION_H + + +struct gl_context; + + +/* Mesa version */ +#define MESA_MAJOR 7 +#define MESA_MINOR 10 +#define MESA_PATCH 0 +#define MESA_VERSION_STRING "7.10-devel" + +/* To make version comparison easy */ +#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#define MESA_VERSION_CODE MESA_VERSION(MESA_MAJOR, MESA_MINOR, MESA_PATCH) + + +/* OpenGL API version */ +#define OPENGL_MAJOR 2 +#define OPENGL_MINOR 1 +#define OPENGL_PATCH 0 +#define OPENGL_VERSION_STRING "2.1" + +/* To make version comparison easy */ +#define OPENGL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#define OPENGL_VERSION_CODE OPENGL_VERSION(OPENGL_MAJOR, OPENGL_MINOR, OPENGL_PATCH) + + +extern void +_mesa_compute_version(struct gl_context *ctx); + + +#endif /* VERSION_H */ diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c index 309308c98..1b4e6c339 100644 --- a/mesalib/src/mesa/main/viewport.c +++ b/mesalib/src/mesa/main/viewport.c @@ -1,180 +1,180 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file viewport.c - * glViewport and glDepthRange functions. - */ - - -#include "context.h" -#include "macros.h" -#include "viewport.h" - - -/** - * Set the viewport. - * \sa Called via glViewport() or display list execution. - * - * Flushes the vertices and calls _mesa_set_viewport() with the given - * parameters. - */ -void GLAPIENTRY -_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_set_viewport(ctx, x, y, width, height); -} - - -/** - * Set new viewport parameters and update derived state (the _WindowMap - * matrix). Usually called from _mesa_Viewport(). - * - * \param ctx GL context. - * \param x, y coordinates of the lower left corner of the viewport rectangle. - * \param width width of the viewport rectangle. - * \param height height of the viewport rectangle. - */ -void -_mesa_set_viewport(GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glViewport(%d, %d, %d, %d)", x, y, width, height); - return; - } - - /* clamp width and height to the implementation dependent range */ - width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); - height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); - - ctx->Viewport.X = x; - ctx->Viewport.Width = width; - ctx->Viewport.Y = y; - ctx->Viewport.Height = height; - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on - * the WindowMap matrix being up to date in the driver's Viewport - * and DepthRange functions. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - ctx->DrawBuffer->_DepthMaxF); -#endif - - if (ctx->Driver.Viewport) { - /* Many drivers will use this call to check for window size changes - * and reallocate the z/stencil/accum/etc buffers if needed. - */ - ctx->Driver.Viewport(ctx, x, y, width, height); - } -} - - -/** - * Called by glDepthRange - * - * \param nearval specifies the Z buffer value which should correspond to - * the near clip plane - * \param farval specifies the Z buffer value which should correspond to - * the far clip plane - */ -void GLAPIENTRY -_mesa_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - - if (ctx->Viewport.Near == nearval && - ctx->Viewport.Far == farval) - return; - - ctx->Viewport.Near = (GLfloat) CLAMP(nearval, 0.0, 1.0); - ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0); - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on - * the WindowMap matrix being up to date in the driver's Viewport - * and DepthRange functions. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - ctx->DrawBuffer->_DepthMaxF); -#endif - - if (ctx->Driver.DepthRange) { - ctx->Driver.DepthRange(ctx, nearval, farval); - } -} - - - -/** - * Initialize the context viewport attribute group. - * \param ctx the GL context. - */ -void _mesa_init_viewport(GLcontext *ctx) -{ - GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ - - /* Viewport group */ - ctx->Viewport.X = 0; - ctx->Viewport.Y = 0; - ctx->Viewport.Width = 0; - ctx->Viewport.Height = 0; - ctx->Viewport.Near = 0.0; - ctx->Viewport.Far = 1.0; - _math_matrix_ctr(&ctx->Viewport._WindowMap); - - _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0, - 0.0F, 1.0F, depthMax); -} - - -/** - * Free the context viewport attribute group data. - * \param ctx the GL context. - */ -void _mesa_free_viewport_data(GLcontext *ctx) -{ - _math_matrix_dtr(&ctx->Viewport._WindowMap); -} - +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file viewport.c + * glViewport and glDepthRange functions. + */ + + +#include "context.h" +#include "macros.h" +#include "viewport.h" + + +/** + * Set the viewport. + * \sa Called via glViewport() or display list execution. + * + * Flushes the vertices and calls _mesa_set_viewport() with the given + * parameters. + */ +void GLAPIENTRY +_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_set_viewport(ctx, x, y, width, height); +} + + +/** + * Set new viewport parameters and update derived state (the _WindowMap + * matrix). Usually called from _mesa_Viewport(). + * + * \param ctx GL context. + * \param x, y coordinates of the lower left corner of the viewport rectangle. + * \param width width of the viewport rectangle. + * \param height height of the viewport rectangle. + */ +void +_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, + GLsizei width, GLsizei height) +{ + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); + + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glViewport(%d, %d, %d, %d)", x, y, width, height); + return; + } + + /* clamp width and height to the implementation dependent range */ + width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); + height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); + + ctx->Viewport.X = x; + ctx->Viewport.Width = width; + ctx->Viewport.Y = y; + ctx->Viewport.Height = height; + ctx->NewState |= _NEW_VIEWPORT; + +#if 1 + /* XXX remove this someday. Currently the DRI drivers rely on + * the WindowMap matrix being up to date in the driver's Viewport + * and DepthRange functions. + */ + _math_matrix_viewport(&ctx->Viewport._WindowMap, + ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + ctx->Viewport.Near, ctx->Viewport.Far, + ctx->DrawBuffer->_DepthMaxF); +#endif + + if (ctx->Driver.Viewport) { + /* Many drivers will use this call to check for window size changes + * and reallocate the z/stencil/accum/etc buffers if needed. + */ + ctx->Driver.Viewport(ctx, x, y, width, height); + } +} + + +/** + * Called by glDepthRange + * + * \param nearval specifies the Z buffer value which should correspond to + * the near clip plane + * \param farval specifies the Z buffer value which should correspond to + * the far clip plane + */ +void GLAPIENTRY +_mesa_DepthRange(GLclampd nearval, GLclampd farval) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); + + if (ctx->Viewport.Near == nearval && + ctx->Viewport.Far == farval) + return; + + ctx->Viewport.Near = (GLfloat) CLAMP(nearval, 0.0, 1.0); + ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0); + ctx->NewState |= _NEW_VIEWPORT; + +#if 1 + /* XXX remove this someday. Currently the DRI drivers rely on + * the WindowMap matrix being up to date in the driver's Viewport + * and DepthRange functions. + */ + _math_matrix_viewport(&ctx->Viewport._WindowMap, + ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + ctx->Viewport.Near, ctx->Viewport.Far, + ctx->DrawBuffer->_DepthMaxF); +#endif + + if (ctx->Driver.DepthRange) { + ctx->Driver.DepthRange(ctx, nearval, farval); + } +} + + + +/** + * Initialize the context viewport attribute group. + * \param ctx the GL context. + */ +void _mesa_init_viewport(struct gl_context *ctx) +{ + GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ + + /* Viewport group */ + ctx->Viewport.X = 0; + ctx->Viewport.Y = 0; + ctx->Viewport.Width = 0; + ctx->Viewport.Height = 0; + ctx->Viewport.Near = 0.0; + ctx->Viewport.Far = 1.0; + _math_matrix_ctr(&ctx->Viewport._WindowMap); + + _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0, + 0.0F, 1.0F, depthMax); +} + + +/** + * Free the context viewport attribute group data. + * \param ctx the GL context. + */ +void _mesa_free_viewport_data(struct gl_context *ctx) +{ + _math_matrix_dtr(&ctx->Viewport._WindowMap); +} + diff --git a/mesalib/src/mesa/main/viewport.h b/mesalib/src/mesa/main/viewport.h index ec054a7c5..757c28116 100644 --- a/mesalib/src/mesa/main/viewport.h +++ b/mesalib/src/mesa/main/viewport.h @@ -1,54 +1,55 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef VIEWPORT_H -#define VIEWPORT_H - -#include "glheader.h" -#include "mtypes.h" - -extern void GLAPIENTRY -_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); - - -extern void -_mesa_set_viewport(GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height); - - -extern void GLAPIENTRY -_mesa_DepthRange(GLclampd nearval, GLclampd farval); - - -extern void -_mesa_init_viewport(GLcontext *ctx); - - -extern void -_mesa_free_viewport_data(GLcontext *ctx); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef VIEWPORT_H +#define VIEWPORT_H + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); + + +extern void +_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, + GLsizei width, GLsizei height); + + +extern void GLAPIENTRY +_mesa_DepthRange(GLclampd nearval, GLclampd farval); + + +extern void +_mesa_init_viewport(struct gl_context *ctx); + + +extern void +_mesa_free_viewport_data(struct gl_context *ctx); + + +#endif diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c index ca352e88e..6fec7f09b 100644 --- a/mesalib/src/mesa/main/vtxfmt.c +++ b/mesalib/src/mesa/main/vtxfmt.c @@ -1,203 +1,171 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - * Gareth Hughes - */ - -#include "glheader.h" -#include "api_arrayelt.h" -#include "context.h" -#include "imports.h" -#include "mtypes.h" -#include "vtxfmt.h" -#include "eval.h" -#include "dlist.h" - - -#if FEATURE_beginend - - -/* The neutral vertex format. This wraps all tnl module functions, - * verifying that the currently-installed module is valid and then - * installing the function pointers in a lazy fashion. It records the - * function pointers that have been swapped out, which allows a fast - * restoration of the neutral module in almost all cases -- a typical - * app might only require 4-6 functions to be modified from the neutral - * baseline, and only restoring these is certainly preferable to doing - * the entire module's 60 or so function pointers. - */ - -#define PRE_LOOPBACK( FUNC ) \ -{ \ - GET_CURRENT_CONTEXT(ctx); \ - struct gl_tnl_module * const tnl = &(ctx->TnlModule); \ - const int tmp_offset = _gloffset_ ## FUNC ; \ - \ - ASSERT( tnl->Current ); \ - ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \ - ASSERT( tmp_offset >= 0 ); \ - \ - if (tnl->SwapCount == 0) \ - ctx->Driver.BeginVertices( ctx ); \ - \ - /* Save the swapped function's dispatch entry so it can be */ \ - /* restored later. */ \ - tnl->Swapped[tnl->SwapCount].location = & (((_glapi_proc *)ctx->Exec)[tmp_offset]); \ - tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC); \ - tnl->SwapCount++; \ - \ - if ( 0 ) \ - _mesa_debug(ctx, " swapping gl" #FUNC"...\n" ); \ - \ - /* Install the tnl function pointer. */ \ - SET_ ## FUNC(ctx->Exec, tnl->Current->FUNC); \ -} - -#define TAG(x) neutral_##x -#include "vtxfmt_tmp.h" - - -/** - * Use the per-vertex functions found in to initialze the given - * API dispatch table. - */ -static void -install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) -{ - _mesa_install_arrayelt_vtxfmt(tab, vfmt); - - SET_Color3f(tab, vfmt->Color3f); - SET_Color3fv(tab, vfmt->Color3fv); - SET_Color4f(tab, vfmt->Color4f); - SET_Color4fv(tab, vfmt->Color4fv); - SET_EdgeFlag(tab, vfmt->EdgeFlag); - - _mesa_install_eval_vtxfmt(tab, vfmt); - - SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); - SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); - SET_Indexf(tab, vfmt->Indexf); - SET_Indexfv(tab, vfmt->Indexfv); - SET_Materialfv(tab, vfmt->Materialfv); - SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB); - SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB); - SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB); - SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB); - SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB); - SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB); - SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB); - SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB); - SET_Normal3f(tab, vfmt->Normal3f); - SET_Normal3fv(tab, vfmt->Normal3fv); - SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); - SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT); - SET_TexCoord1f(tab, vfmt->TexCoord1f); - SET_TexCoord1fv(tab, vfmt->TexCoord1fv); - SET_TexCoord2f(tab, vfmt->TexCoord2f); - SET_TexCoord2fv(tab, vfmt->TexCoord2fv); - SET_TexCoord3f(tab, vfmt->TexCoord3f); - SET_TexCoord3fv(tab, vfmt->TexCoord3fv); - SET_TexCoord4f(tab, vfmt->TexCoord4f); - SET_TexCoord4fv(tab, vfmt->TexCoord4fv); - SET_Vertex2f(tab, vfmt->Vertex2f); - SET_Vertex2fv(tab, vfmt->Vertex2fv); - SET_Vertex3f(tab, vfmt->Vertex3f); - SET_Vertex3fv(tab, vfmt->Vertex3fv); - SET_Vertex4f(tab, vfmt->Vertex4f); - SET_Vertex4fv(tab, vfmt->Vertex4fv); - - _mesa_install_dlist_vtxfmt(tab, vfmt); - - SET_Begin(tab, vfmt->Begin); - SET_End(tab, vfmt->End); - SET_Rectf(tab, vfmt->Rectf); - SET_DrawArrays(tab, vfmt->DrawArrays); - SET_DrawElements(tab, vfmt->DrawElements); - SET_DrawRangeElements(tab, vfmt->DrawRangeElements); - SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT); - SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); - SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); - SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); - SET_DrawArraysInstanced(tab, vfmt->DrawArraysInstanced); - SET_DrawElementsInstanced(tab, vfmt->DrawElementsInstanced); - - /* GL_NV_vertex_program */ - SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); - SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); - SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); - SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); - SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); - SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); - SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); - SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); -#if FEATURE_ARB_vertex_program - SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); - SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); - SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); - SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB); - SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB); - SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB); - SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB); - SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); -#endif -} - - -void _mesa_init_exec_vtxfmt( GLcontext *ctx ) -{ - install_vtxfmt( ctx->Exec, &neutral_vtxfmt ); - ctx->TnlModule.SwapCount = 0; -} - - -void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) -{ - ctx->TnlModule.Current = vfmt; - _mesa_restore_exec_vtxfmt( ctx ); -} - - -void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) -{ - install_vtxfmt( ctx->Save, vfmt ); -} - - -void _mesa_restore_exec_vtxfmt( GLcontext *ctx ) -{ - struct gl_tnl_module *tnl = &(ctx->TnlModule); - GLuint i; - - /* Restore the neutral tnl module wrapper. - */ - for ( i = 0 ; i < tnl->SwapCount ; i++ ) { - *(tnl->Swapped[i].location) = tnl->Swapped[i].function; - } - - tnl->SwapCount = 0; -} - - -#endif /* FEATURE_beginend */ +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Keith Whitwell + * Gareth Hughes + */ + +#include "glheader.h" +#include "api_arrayelt.h" +#include "context.h" +#include "imports.h" +#include "mtypes.h" +#include "vtxfmt.h" +#include "eval.h" +#include "dlist.h" +#include "main/dispatch.h" + + +#if FEATURE_beginend + +/** + * Use the per-vertex functions found in to initialoze the given + * API dispatch table. + */ +static void +install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) +{ + _mesa_install_arrayelt_vtxfmt(tab, vfmt); + + SET_Color3f(tab, vfmt->Color3f); + SET_Color3fv(tab, vfmt->Color3fv); + SET_Color4f(tab, vfmt->Color4f); + SET_Color4fv(tab, vfmt->Color4fv); + SET_EdgeFlag(tab, vfmt->EdgeFlag); + + _mesa_install_eval_vtxfmt(tab, vfmt); + + SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); + SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); + SET_Indexf(tab, vfmt->Indexf); + SET_Indexfv(tab, vfmt->Indexfv); + SET_Materialfv(tab, vfmt->Materialfv); + SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB); + SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB); + SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB); + SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB); + SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB); + SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB); + SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB); + SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB); + SET_Normal3f(tab, vfmt->Normal3f); + SET_Normal3fv(tab, vfmt->Normal3fv); + SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); + SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT); + SET_TexCoord1f(tab, vfmt->TexCoord1f); + SET_TexCoord1fv(tab, vfmt->TexCoord1fv); + SET_TexCoord2f(tab, vfmt->TexCoord2f); + SET_TexCoord2fv(tab, vfmt->TexCoord2fv); + SET_TexCoord3f(tab, vfmt->TexCoord3f); + SET_TexCoord3fv(tab, vfmt->TexCoord3fv); + SET_TexCoord4f(tab, vfmt->TexCoord4f); + SET_TexCoord4fv(tab, vfmt->TexCoord4fv); + SET_Vertex2f(tab, vfmt->Vertex2f); + SET_Vertex2fv(tab, vfmt->Vertex2fv); + SET_Vertex3f(tab, vfmt->Vertex3f); + SET_Vertex3fv(tab, vfmt->Vertex3fv); + SET_Vertex4f(tab, vfmt->Vertex4f); + SET_Vertex4fv(tab, vfmt->Vertex4fv); + + _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ + + SET_Begin(tab, vfmt->Begin); + SET_End(tab, vfmt->End); + SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV); + + SET_Rectf(tab, vfmt->Rectf); + + SET_DrawArrays(tab, vfmt->DrawArrays); + SET_DrawElements(tab, vfmt->DrawElements); + SET_DrawRangeElements(tab, vfmt->DrawRangeElements); + SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT); + SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); + SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); + SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); + SET_DrawArraysInstancedARB(tab, vfmt->DrawArraysInstanced); + SET_DrawElementsInstancedARB(tab, vfmt->DrawElementsInstanced); + + /* GL_NV_vertex_program */ + SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); + SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); + SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); + SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV); + SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV); + SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); + SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); + SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); +#if FEATURE_ARB_vertex_program + SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); + SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); + SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); + SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB); + SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB); + SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB); + SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB); + SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); +#endif + + /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ + SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); + SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); + SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); + SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); + SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); + SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); + SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); + + SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); + SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); + SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); + SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); + SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); + SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); + SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); +} + + +/** + * Install per-vertex functions into the API dispatch table for execution. + */ +void +_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) +{ + if (ctx->API == API_OPENGL) + install_vtxfmt( ctx->Exec, vfmt ); +} + + +/** + * Install per-vertex functions into the API dispatch table for display + * list compilation. + */ +void +_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt) +{ + if (ctx->API == API_OPENGL) + install_vtxfmt( ctx->Save, vfmt ); +} + + +#endif /* FEATURE_beginend */ diff --git a/mesalib/src/mesa/main/vtxfmt.h b/mesalib/src/mesa/main/vtxfmt.h index aad38b87c..235198747 100644 --- a/mesalib/src/mesa/main/vtxfmt.h +++ b/mesalib/src/mesa/main/vtxfmt.h @@ -1,72 +1,58 @@ -/** - * \file vtxfmt.h - * - * \author Keith Whitwell - * \author Gareth Hughes - */ - -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _VTXFMT_H_ -#define _VTXFMT_H_ - -#include "compiler.h" -#include "mtypes.h" - -#if FEATURE_beginend - -extern void _mesa_init_exec_vtxfmt( GLcontext *ctx ); - -extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ); -extern void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ); - -extern void _mesa_restore_exec_vtxfmt( GLcontext *ctx ); - -#else /* FEATURE_beginend */ - -static INLINE void -_mesa_init_exec_vtxfmt( GLcontext *ctx ) -{ -} - -static INLINE void -_mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) -{ -} - -static INLINE void -_mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) -{ -} - -static INLINE void -_mesa_restore_exec_vtxfmt( GLcontext *ctx ) -{ -} - -#endif /* FEATURE_beginend */ - -#endif /* _VTXFMT_H_ */ +/** + * \file vtxfmt.h + * + * \author Keith Whitwell + * \author Gareth Hughes + */ + +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _VTXFMT_H_ +#define _VTXFMT_H_ + +#include "compiler.h" +#include "mtypes.h" + +#if FEATURE_beginend + +extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); +extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); + +#else /* FEATURE_beginend */ + +static INLINE void +_mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ) +{ +} + +static INLINE void +_mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ) +{ +} + +#endif /* FEATURE_beginend */ + +#endif /* _VTXFMT_H_ */ diff --git a/mesalib/src/mesa/main/vtxfmt_tmp.h b/mesalib/src/mesa/main/vtxfmt_tmp.h deleted file mode 100644 index 9ec6ea49a..000000000 --- a/mesalib/src/mesa/main/vtxfmt_tmp.h +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes - */ - -#ifndef PRE_LOOPBACK -#define PRE_LOOPBACK( FUNC ) -#endif - -#include "main/dispatch.h" - -static void GLAPIENTRY TAG(ArrayElement)( GLint i ) -{ - PRE_LOOPBACK( ArrayElement ); - CALL_ArrayElement(GET_DISPATCH(), ( i )); -} - -static void GLAPIENTRY TAG(Color3f)( GLfloat r, GLfloat g, GLfloat b ) -{ - PRE_LOOPBACK( Color3f ); - CALL_Color3f(GET_DISPATCH(), ( r, g, b )); -} - -static void GLAPIENTRY TAG(Color3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Color3fv ); - CALL_Color3fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(Color4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) -{ - PRE_LOOPBACK( Color4f ); - CALL_Color4f(GET_DISPATCH(), ( r, g, b, a )); -} - -static void GLAPIENTRY TAG(Color4fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Color4fv ); - CALL_Color4fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(EdgeFlag)( GLboolean e ) -{ - PRE_LOOPBACK( EdgeFlag ); - CALL_EdgeFlag(GET_DISPATCH(), ( e )); -} - -static void GLAPIENTRY TAG(EvalCoord1f)( GLfloat s ) -{ - PRE_LOOPBACK( EvalCoord1f ); - CALL_EvalCoord1f(GET_DISPATCH(), ( s )); -} - -static void GLAPIENTRY TAG(EvalCoord1fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( EvalCoord1fv ); - CALL_EvalCoord1fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(EvalCoord2f)( GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( EvalCoord2f ); - CALL_EvalCoord2f(GET_DISPATCH(), ( s, t )); -} - -static void GLAPIENTRY TAG(EvalCoord2fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( EvalCoord2fv ); - CALL_EvalCoord2fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(EvalPoint1)( GLint i ) -{ - PRE_LOOPBACK( EvalPoint1 ); - CALL_EvalPoint1(GET_DISPATCH(), ( i )); -} - -static void GLAPIENTRY TAG(EvalPoint2)( GLint i, GLint j ) -{ - PRE_LOOPBACK( EvalPoint2 ); - CALL_EvalPoint2(GET_DISPATCH(), ( i, j )); -} - -static void GLAPIENTRY TAG(FogCoordfEXT)( GLfloat f ) -{ - PRE_LOOPBACK( FogCoordfEXT ); - CALL_FogCoordfEXT(GET_DISPATCH(), ( f )); -} - -static void GLAPIENTRY TAG(FogCoordfvEXT)( const GLfloat *v ) -{ - PRE_LOOPBACK( FogCoordfvEXT ); - CALL_FogCoordfvEXT(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(Indexf)( GLfloat f ) -{ - PRE_LOOPBACK( Indexf ); - CALL_Indexf(GET_DISPATCH(), ( f )); -} - -static void GLAPIENTRY TAG(Indexfv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Indexfv ); - CALL_Indexfv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(Materialfv)( GLenum face, GLenum pname, const GLfloat *v ) -{ - PRE_LOOPBACK( Materialfv ); - CALL_Materialfv(GET_DISPATCH(), ( face, pname, v )); -} - -static void GLAPIENTRY TAG(MultiTexCoord1fARB)( GLenum target, GLfloat a ) -{ - PRE_LOOPBACK( MultiTexCoord1fARB ); - CALL_MultiTexCoord1fARB(GET_DISPATCH(), ( target, a )); -} - -static void GLAPIENTRY TAG(MultiTexCoord1fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord1fvARB ); - CALL_MultiTexCoord1fvARB(GET_DISPATCH(), ( target, tc )); -} - -static void GLAPIENTRY TAG(MultiTexCoord2fARB)( GLenum target, GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( MultiTexCoord2fARB ); - CALL_MultiTexCoord2fARB(GET_DISPATCH(), ( target, s, t )); -} - -static void GLAPIENTRY TAG(MultiTexCoord2fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord2fvARB ); - CALL_MultiTexCoord2fvARB(GET_DISPATCH(), ( target, tc )); -} - -static void GLAPIENTRY TAG(MultiTexCoord3fARB)( GLenum target, GLfloat s, - GLfloat t, GLfloat r ) -{ - PRE_LOOPBACK( MultiTexCoord3fARB ); - CALL_MultiTexCoord3fARB(GET_DISPATCH(), ( target, s, t, r )); -} - -static void GLAPIENTRY TAG(MultiTexCoord3fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord3fvARB ); - CALL_MultiTexCoord3fvARB(GET_DISPATCH(), ( target, tc )); -} - -static void GLAPIENTRY TAG(MultiTexCoord4fARB)( GLenum target, GLfloat s, - GLfloat t, GLfloat r, GLfloat q ) -{ - PRE_LOOPBACK( MultiTexCoord4fARB ); - CALL_MultiTexCoord4fARB(GET_DISPATCH(), ( target, s, t, r, q )); -} - -static void GLAPIENTRY TAG(MultiTexCoord4fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord4fvARB ); - CALL_MultiTexCoord4fvARB(GET_DISPATCH(), ( target, tc )); -} - -static void GLAPIENTRY TAG(Normal3f)( GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( Normal3f ); - CALL_Normal3f(GET_DISPATCH(), ( x, y, z )); -} - -static void GLAPIENTRY TAG(Normal3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Normal3fv ); - CALL_Normal3fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(SecondaryColor3fEXT)( GLfloat r, GLfloat g, GLfloat b ) -{ - PRE_LOOPBACK( SecondaryColor3fEXT ); - CALL_SecondaryColor3fEXT(GET_DISPATCH(), ( r, g, b )); -} - -static void GLAPIENTRY TAG(SecondaryColor3fvEXT)( const GLfloat *v ) -{ - PRE_LOOPBACK( SecondaryColor3fvEXT ); - CALL_SecondaryColor3fvEXT(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(TexCoord1f)( GLfloat s ) -{ - PRE_LOOPBACK( TexCoord1f ); - CALL_TexCoord1f(GET_DISPATCH(), ( s )); -} - -static void GLAPIENTRY TAG(TexCoord1fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord1fv ); - CALL_TexCoord1fv(GET_DISPATCH(), ( tc )); -} - -static void GLAPIENTRY TAG(TexCoord2f)( GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( TexCoord2f ); - CALL_TexCoord2f(GET_DISPATCH(), ( s, t )); -} - -static void GLAPIENTRY TAG(TexCoord2fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord2fv ); - CALL_TexCoord2fv(GET_DISPATCH(), ( tc )); -} - -static void GLAPIENTRY TAG(TexCoord3f)( GLfloat s, GLfloat t, GLfloat r ) -{ - PRE_LOOPBACK( TexCoord3f ); - CALL_TexCoord3f(GET_DISPATCH(), ( s, t, r )); -} - -static void GLAPIENTRY TAG(TexCoord3fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord3fv ); - CALL_TexCoord3fv(GET_DISPATCH(), ( tc )); -} - -static void GLAPIENTRY TAG(TexCoord4f)( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) -{ - PRE_LOOPBACK( TexCoord4f ); - CALL_TexCoord4f(GET_DISPATCH(), ( s, t, r, q )); -} - -static void GLAPIENTRY TAG(TexCoord4fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord4fv ); - CALL_TexCoord4fv(GET_DISPATCH(), ( tc )); -} - -static void GLAPIENTRY TAG(Vertex2f)( GLfloat x, GLfloat y ) -{ - PRE_LOOPBACK( Vertex2f ); - CALL_Vertex2f(GET_DISPATCH(), ( x, y )); -} - -static void GLAPIENTRY TAG(Vertex2fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex2fv ); - CALL_Vertex2fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(Vertex3f)( GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( Vertex3f ); - CALL_Vertex3f(GET_DISPATCH(), ( x, y, z )); -} - -static void GLAPIENTRY TAG(Vertex3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex3fv ); - CALL_Vertex3fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(Vertex4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - PRE_LOOPBACK( Vertex4f ); - CALL_Vertex4f(GET_DISPATCH(), ( x, y, z, w )); -} - -static void GLAPIENTRY TAG(Vertex4fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex4fv ); - CALL_Vertex4fv(GET_DISPATCH(), ( v )); -} - -static void GLAPIENTRY TAG(CallList)( GLuint i ) -{ - PRE_LOOPBACK( CallList ); - CALL_CallList(GET_DISPATCH(), ( i )); -} - -static void GLAPIENTRY TAG(CallLists)( GLsizei sz, GLenum type, const GLvoid *v ) -{ - PRE_LOOPBACK( CallLists ); - CALL_CallLists(GET_DISPATCH(), ( sz, type, v )); -} - -static void GLAPIENTRY TAG(Begin)( GLenum mode ) -{ - PRE_LOOPBACK( Begin ); - CALL_Begin(GET_DISPATCH(), ( mode )); -} - -static void GLAPIENTRY TAG(End)( void ) -{ - PRE_LOOPBACK( End ); - CALL_End(GET_DISPATCH(), ()); -} - -static void GLAPIENTRY TAG(Rectf)( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - PRE_LOOPBACK( Rectf ); - CALL_Rectf(GET_DISPATCH(), ( x1, y1, x2, y2 )); -} - -static void GLAPIENTRY TAG(DrawArrays)( GLenum mode, GLint start, GLsizei count ) -{ - PRE_LOOPBACK( DrawArrays ); - CALL_DrawArrays(GET_DISPATCH(), ( mode, start, count )); -} - -static void GLAPIENTRY TAG(DrawElements)( GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices ) -{ - PRE_LOOPBACK( DrawElements ); - CALL_DrawElements(GET_DISPATCH(), ( mode, count, type, indices )); -} - -static void GLAPIENTRY TAG(MultiDrawElementsEXT)( GLenum mode, - const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount) -{ - PRE_LOOPBACK( MultiDrawElementsEXT ); - CALL_MultiDrawElementsEXT(GET_DISPATCH(), ( mode, count, type, indices, - primcount )); -} - -static void GLAPIENTRY TAG(DrawRangeElements)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, const GLvoid *indices ) -{ - PRE_LOOPBACK( DrawRangeElements ); - CALL_DrawRangeElements(GET_DISPATCH(), ( mode, start, end, count, type, indices )); -} - -static void GLAPIENTRY TAG(DrawElementsBaseVertex)( GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex) -{ - PRE_LOOPBACK( DrawElementsBaseVertex ); - CALL_DrawElementsBaseVertex(GET_DISPATCH(), ( mode, count, type, - indices, basevertex )); -} - -static void GLAPIENTRY TAG(DrawRangeElementsBaseVertex)( GLenum mode, - GLuint start, - GLuint end, - GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex) -{ - PRE_LOOPBACK( DrawRangeElementsBaseVertex ); - CALL_DrawRangeElementsBaseVertex(GET_DISPATCH(), ( mode, start, end, - count, type, indices, - basevertex )); -} - -static void GLAPIENTRY TAG(MultiDrawElementsBaseVertex)( GLenum mode, - const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex) -{ - PRE_LOOPBACK( MultiDrawElementsBaseVertex ); - CALL_MultiDrawElementsBaseVertex(GET_DISPATCH(), ( mode, count, type, - indices, - primcount, basevertex )); -} - -static void GLAPIENTRY -TAG(DrawArraysInstanced)(GLenum mode, GLint first, - GLsizei count, GLsizei primcount) -{ - PRE_LOOPBACK( DrawArraysInstanced ); - CALL_DrawArraysInstanced(GET_DISPATCH(), (mode, first, count, primcount)); -} - -static void GLAPIENTRY -TAG(DrawElementsInstanced)(GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices, - GLsizei primcount) -{ - PRE_LOOPBACK( DrawElementsInstanced ); - CALL_DrawElementsInstanced(GET_DISPATCH(), - (mode, count, type, indices, primcount)); -} - - -static void GLAPIENTRY TAG(EvalMesh1)( GLenum mode, GLint i1, GLint i2 ) -{ - PRE_LOOPBACK( EvalMesh1 ); - CALL_EvalMesh1(GET_DISPATCH(), ( mode, i1, i2 )); -} - -static void GLAPIENTRY TAG(EvalMesh2)( GLenum mode, GLint i1, GLint i2, - GLint j1, GLint j2 ) -{ - PRE_LOOPBACK( EvalMesh2 ); - CALL_EvalMesh2(GET_DISPATCH(), ( mode, i1, i2, j1, j2 )); -} - -static void GLAPIENTRY TAG(VertexAttrib1fNV)( GLuint index, GLfloat x ) -{ - PRE_LOOPBACK( VertexAttrib1fNV ); - CALL_VertexAttrib1fNV(GET_DISPATCH(), ( index, x )); -} - -static void GLAPIENTRY TAG(VertexAttrib1fvNV)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib1fvNV ); - CALL_VertexAttrib1fvNV(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ) -{ - PRE_LOOPBACK( VertexAttrib2fNV ); - CALL_VertexAttrib2fNV(GET_DISPATCH(), ( index, x, y )); -} - -static void GLAPIENTRY TAG(VertexAttrib2fvNV)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib2fvNV ); - CALL_VertexAttrib2fvNV(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( VertexAttrib3fNV ); - CALL_VertexAttrib3fNV(GET_DISPATCH(), ( index, x, y, z )); -} - -static void GLAPIENTRY TAG(VertexAttrib3fvNV)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib3fvNV ); - CALL_VertexAttrib3fvNV(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - PRE_LOOPBACK( VertexAttrib4fNV ); - CALL_VertexAttrib4fNV(GET_DISPATCH(), ( index, x, y, z, w )); -} - -static void GLAPIENTRY TAG(VertexAttrib4fvNV)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib4fvNV ); - CALL_VertexAttrib4fvNV(GET_DISPATCH(), ( index, v )); -} - - -static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x ) -{ - PRE_LOOPBACK( VertexAttrib1fARB ); - CALL_VertexAttrib1fARB(GET_DISPATCH(), ( index, x )); -} - -static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib1fvARB ); - CALL_VertexAttrib1fvARB(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ) -{ - PRE_LOOPBACK( VertexAttrib2fARB ); - CALL_VertexAttrib2fARB(GET_DISPATCH(), ( index, x, y )); -} - -static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib2fvARB ); - CALL_VertexAttrib2fvARB(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( VertexAttrib3fARB ); - CALL_VertexAttrib3fARB(GET_DISPATCH(), ( index, x, y, z )); -} - -static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib3fvARB ); - CALL_VertexAttrib3fvARB(GET_DISPATCH(), ( index, v )); -} - -static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - PRE_LOOPBACK( VertexAttrib4fARB ); - CALL_VertexAttrib4fARB(GET_DISPATCH(), ( index, x, y, z, w )); -} - -static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib4fvARB ); - CALL_VertexAttrib4fvARB(GET_DISPATCH(), ( index, v )); -} - - -static GLvertexformat TAG(vtxfmt) = { - TAG(ArrayElement), - TAG(Color3f), - TAG(Color3fv), - TAG(Color4f), - TAG(Color4fv), - TAG(EdgeFlag), - TAG(EvalCoord1f), - TAG(EvalCoord1fv), - TAG(EvalCoord2f), - TAG(EvalCoord2fv), - TAG(EvalPoint1), - TAG(EvalPoint2), - TAG(FogCoordfEXT), - TAG(FogCoordfvEXT), - TAG(Indexf), - TAG(Indexfv), - TAG(Materialfv), - TAG(MultiTexCoord1fARB), - TAG(MultiTexCoord1fvARB), - TAG(MultiTexCoord2fARB), - TAG(MultiTexCoord2fvARB), - TAG(MultiTexCoord3fARB), - TAG(MultiTexCoord3fvARB), - TAG(MultiTexCoord4fARB), - TAG(MultiTexCoord4fvARB), - TAG(Normal3f), - TAG(Normal3fv), - TAG(SecondaryColor3fEXT), - TAG(SecondaryColor3fvEXT), - TAG(TexCoord1f), - TAG(TexCoord1fv), - TAG(TexCoord2f), - TAG(TexCoord2fv), - TAG(TexCoord3f), - TAG(TexCoord3fv), - TAG(TexCoord4f), - TAG(TexCoord4fv), - TAG(Vertex2f), - TAG(Vertex2fv), - TAG(Vertex3f), - TAG(Vertex3fv), - TAG(Vertex4f), - TAG(Vertex4fv), - TAG(CallList), - TAG(CallLists), - TAG(Begin), - TAG(End), - TAG(VertexAttrib1fNV), - TAG(VertexAttrib1fvNV), - TAG(VertexAttrib2fNV), - TAG(VertexAttrib2fvNV), - TAG(VertexAttrib3fNV), - TAG(VertexAttrib3fvNV), - TAG(VertexAttrib4fNV), - TAG(VertexAttrib4fvNV), - TAG(VertexAttrib1fARB), - TAG(VertexAttrib1fvARB), - TAG(VertexAttrib2fARB), - TAG(VertexAttrib2fvARB), - TAG(VertexAttrib3fARB), - TAG(VertexAttrib3fvARB), - TAG(VertexAttrib4fARB), - TAG(VertexAttrib4fvARB), - TAG(Rectf), - TAG(DrawArrays), - TAG(DrawElements), - TAG(DrawRangeElements), - TAG(MultiDrawElementsEXT), - TAG(DrawElementsBaseVertex), - TAG(DrawRangeElementsBaseVertex), - TAG(MultiDrawElementsBaseVertex), - TAG(DrawArraysInstanced), - TAG(DrawElementsInstanced), - TAG(EvalMesh1), - TAG(EvalMesh2) -}; - -#undef TAG -#undef PRE_LOOPBACK -- cgit v1.2.3